< prev index next >
src/jdk.incubator.vector/share/classes/jdk/incubator/vector/ByteVector.java
Print this page
rev 54658 : refactored mask and shuffle creation methods, moved classes to top-level
*** 53,83 ****
byte apply(int i, byte a);
}
abstract ByteVector uOp(FUnOp f);
! abstract ByteVector uOp(Mask<Byte> m, FUnOp f);
// Binary operator
interface FBinOp {
byte apply(int i, byte a, byte b);
}
abstract ByteVector bOp(Vector<Byte> v, FBinOp f);
! abstract ByteVector bOp(Vector<Byte> v, Mask<Byte> m, FBinOp f);
// Trinary operator
interface FTriOp {
byte apply(int i, byte a, byte b, byte c);
}
abstract ByteVector tOp(Vector<Byte> v1, Vector<Byte> v2, FTriOp f);
! abstract ByteVector tOp(Vector<Byte> v1, Vector<Byte> v2, Mask<Byte> m, FTriOp f);
// Reduction operator
abstract byte rOp(byte v, FBinOp f);
--- 53,83 ----
byte apply(int i, byte a);
}
abstract ByteVector uOp(FUnOp f);
! abstract ByteVector uOp(VectorMask<Byte> m, FUnOp f);
// Binary operator
interface FBinOp {
byte apply(int i, byte a, byte b);
}
abstract ByteVector bOp(Vector<Byte> v, FBinOp f);
! abstract ByteVector bOp(Vector<Byte> v, VectorMask<Byte> m, FBinOp f);
// Trinary operator
interface FTriOp {
byte apply(int i, byte a, byte b, byte c);
}
abstract ByteVector tOp(Vector<Byte> v1, Vector<Byte> v2, FTriOp f);
! abstract ByteVector tOp(Vector<Byte> v1, Vector<Byte> v2, VectorMask<Byte> m, FTriOp f);
// Reduction operator
abstract byte rOp(byte v, FBinOp f);
*** 85,105 ****
interface FBinTest {
boolean apply(int i, byte a, byte b);
}
! abstract Mask<Byte> bTest(Vector<Byte> v, FBinTest f);
// Foreach
interface FUnCon {
void apply(int i, byte a);
}
abstract void forEach(FUnCon f);
! abstract void forEach(Mask<Byte> m, FUnCon f);
// Static factories
/**
* Returns a vector where all lane elements are set to the default
--- 85,105 ----
interface FBinTest {
boolean apply(int i, byte a, byte b);
}
! abstract VectorMask<Byte> bTest(Vector<Byte> v, FBinTest f);
// Foreach
interface FUnCon {
void apply(int i, byte a);
}
abstract void forEach(FUnCon f);
! abstract void forEach(VectorMask<Byte> m, FUnCon f);
// Static factories
/**
* Returns a vector where all lane elements are set to the default
*** 108,118 ****
* @param species species of desired vector
* @return a zero vector of given species
*/
@ForceInline
@SuppressWarnings("unchecked")
! public static ByteVector zero(Species<Byte> species) {
return VectorIntrinsics.broadcastCoerced((Class<ByteVector>) species.boxType(), byte.class, species.length(),
0, species,
((bits, s) -> ((ByteSpecies)s).op(i -> (byte)bits)));
}
--- 108,118 ----
* @param species species of desired vector
* @return a zero vector of given species
*/
@ForceInline
@SuppressWarnings("unchecked")
! public static ByteVector zero(VectorSpecies<Byte> species) {
return VectorIntrinsics.broadcastCoerced((Class<ByteVector>) species.boxType(), byte.class, species.length(),
0, species,
((bits, s) -> ((ByteSpecies)s).op(i -> (byte)bits)));
}
*** 122,132 ****
* Bytes are composed into primitive lane elements according to the
* native byte order of the underlying platform
* <p>
* This method behaves as if it returns the result of calling the
* byte buffer, offset, and mask accepting
! * {@link #fromByteBuffer(Species<Byte>, ByteBuffer, int, Mask) method} as follows:
* <pre>{@code
* return this.fromByteBuffer(ByteBuffer.wrap(a), i, this.maskAllTrue());
* }</pre>
*
* @param species species of desired vector
--- 122,132 ----
* Bytes are composed into primitive lane elements according to the
* native byte order of the underlying platform
* <p>
* This method behaves as if it returns the result of calling the
* byte buffer, offset, and mask accepting
! * {@link #fromByteBuffer(VectorSpecies<Byte>, ByteBuffer, int, VectorMask) method} as follows:
* <pre>{@code
* return this.fromByteBuffer(ByteBuffer.wrap(a), i, this.maskAllTrue());
* }</pre>
*
* @param species species of desired vector
*** 136,146 ****
* @throws IndexOutOfBoundsException if {@code i < 0} or
* {@code i > a.length - (this.length() * this.elementSize() / Byte.SIZE)}
*/
@ForceInline
@SuppressWarnings("unchecked")
! public static ByteVector fromByteArray(Species<Byte> species, byte[] a, int ix) {
Objects.requireNonNull(a);
ix = VectorIntrinsics.checkIndex(ix, a.length, species.bitSize() / Byte.SIZE);
return VectorIntrinsics.load((Class<ByteVector>) species.boxType(), byte.class, species.length(),
a, ((long) ix) + Unsafe.ARRAY_BYTE_BASE_OFFSET,
a, ix, species,
--- 136,146 ----
* @throws IndexOutOfBoundsException if {@code i < 0} or
* {@code i > a.length - (this.length() * this.elementSize() / Byte.SIZE)}
*/
@ForceInline
@SuppressWarnings("unchecked")
! public static ByteVector fromByteArray(VectorSpecies<Byte> species, byte[] a, int ix) {
Objects.requireNonNull(a);
ix = VectorIntrinsics.checkIndex(ix, a.length, species.bitSize() / Byte.SIZE);
return VectorIntrinsics.load((Class<ByteVector>) species.boxType(), byte.class, species.length(),
a, ((long) ix) + Unsafe.ARRAY_BYTE_BASE_OFFSET,
a, ix, species,
*** 158,168 ****
* Bytes are composed into primitive lane elements according to the
* native byte order of the underlying platform.
* <p>
* This method behaves as if it returns the result of calling the
* byte buffer, offset, and mask accepting
! * {@link #fromByteBuffer(Species<Byte>, ByteBuffer, int, Mask) method} as follows:
* <pre>{@code
* return this.fromByteBuffer(ByteBuffer.wrap(a), i, m);
* }</pre>
*
* @param species species of desired vector
--- 158,168 ----
* Bytes are composed into primitive lane elements according to the
* native byte order of the underlying platform.
* <p>
* This method behaves as if it returns the result of calling the
* byte buffer, offset, and mask accepting
! * {@link #fromByteBuffer(VectorSpecies<Byte>, ByteBuffer, int, VectorMask) method} as follows:
* <pre>{@code
* return this.fromByteBuffer(ByteBuffer.wrap(a), i, m);
* }</pre>
*
* @param species species of desired vector
*** 177,187 ****
* for any vector lane index {@code N} where the mask at lane {@code N}
* is set
* {@code i >= a.length - (N * this.elementSize() / Byte.SIZE)}
*/
@ForceInline
! public static ByteVector fromByteArray(Species<Byte> species, byte[] a, int ix, Mask<Byte> m) {
return zero(species).blend(fromByteArray(species, a, ix), m);
}
/**
* Loads a vector from an array starting at offset.
--- 177,187 ----
* for any vector lane index {@code N} where the mask at lane {@code N}
* is set
* {@code i >= a.length - (N * this.elementSize() / Byte.SIZE)}
*/
@ForceInline
! public static ByteVector fromByteArray(VectorSpecies<Byte> species, byte[] a, int ix, VectorMask<Byte> m) {
return zero(species).blend(fromByteArray(species, a, ix), m);
}
/**
* Loads a vector from an array starting at offset.
*** 197,207 ****
* @throws IndexOutOfBoundsException if {@code i < 0}, or
* {@code i > a.length - this.length()}
*/
@ForceInline
@SuppressWarnings("unchecked")
! public static ByteVector fromArray(Species<Byte> species, byte[] a, int i){
Objects.requireNonNull(a);
i = VectorIntrinsics.checkIndex(i, a.length, species.length());
return VectorIntrinsics.load((Class<ByteVector>) species.boxType(), byte.class, species.length(),
a, (((long) i) << ARRAY_SHIFT) + Unsafe.ARRAY_BYTE_BASE_OFFSET,
a, i, species,
--- 197,207 ----
* @throws IndexOutOfBoundsException if {@code i < 0}, or
* {@code i > a.length - this.length()}
*/
@ForceInline
@SuppressWarnings("unchecked")
! public static ByteVector fromArray(VectorSpecies<Byte> species, byte[] a, int i){
Objects.requireNonNull(a);
i = VectorIntrinsics.checkIndex(i, a.length, species.length());
return VectorIntrinsics.load((Class<ByteVector>) species.boxType(), byte.class, species.length(),
a, (((long) i) << ARRAY_SHIFT) + Unsafe.ARRAY_BYTE_BASE_OFFSET,
a, i, species,
*** 226,236 ****
* @throws IndexOutOfBoundsException if {@code i < 0}, or
* for any vector lane index {@code N} where the mask at lane {@code N}
* is set {@code i > a.length - N}
*/
@ForceInline
! public static ByteVector fromArray(Species<Byte> species, byte[] a, int i, Mask<Byte> m) {
return zero(species).blend(fromArray(species, a, i), m);
}
/**
* Loads a vector from an array using indexes obtained from an index
--- 226,236 ----
* @throws IndexOutOfBoundsException if {@code i < 0}, or
* for any vector lane index {@code N} where the mask at lane {@code N}
* is set {@code i > a.length - N}
*/
@ForceInline
! public static ByteVector fromArray(VectorSpecies<Byte> species, byte[] a, int i, VectorMask<Byte> m) {
return zero(species).blend(fromArray(species, a, i), m);
}
/**
* Loads a vector from an array using indexes obtained from an index
*** 251,261 ****
* @throws IndexOutOfBoundsException if {@code j < 0}, or
* {@code j > indexMap.length - this.length()},
* or for any vector lane index {@code N} the result of
* {@code i + indexMap[j + N]} is {@code < 0} or {@code >= a.length}
*/
! public static ByteVector fromArray(Species<Byte> species, byte[] a, int i, int[] indexMap, int j) {
return ((ByteSpecies)species).op(n -> a[i + indexMap[j + n]]);
}
/**
* Loads a vector from an array using indexes obtained from an index
* map and using a mask.
--- 251,261 ----
* @throws IndexOutOfBoundsException if {@code j < 0}, or
* {@code j > indexMap.length - this.length()},
* or for any vector lane index {@code N} the result of
* {@code i + indexMap[j + N]} is {@code < 0} or {@code >= a.length}
*/
! public static ByteVector fromArray(VectorSpecies<Byte> species, byte[] a, int i, int[] indexMap, int j) {
return ((ByteSpecies)species).op(n -> a[i + indexMap[j + n]]);
}
/**
* Loads a vector from an array using indexes obtained from an index
* map and using a mask.
*** 278,288 ****
* {@code j > indexMap.length - this.length()},
* or for any vector lane index {@code N} where the mask at lane
* {@code N} is set the result of {@code i + indexMap[j + N]} is
* {@code < 0} or {@code >= a.length}
*/
! public static ByteVector fromArray(Species<Byte> species, byte[] a, int i, Mask<Byte> m, int[] indexMap, int j) {
return ((ByteSpecies)species).op(m, n -> a[i + indexMap[j + n]]);
}
/**
* Loads a vector from a {@link ByteBuffer byte buffer} starting at an
--- 278,288 ----
* {@code j > indexMap.length - this.length()},
* or for any vector lane index {@code N} where the mask at lane
* {@code N} is set the result of {@code i + indexMap[j + N]} is
* {@code < 0} or {@code >= a.length}
*/
! public static ByteVector fromArray(VectorSpecies<Byte> species, byte[] a, int i, VectorMask<Byte> m, int[] indexMap, int j) {
return ((ByteSpecies)species).op(m, n -> a[i + indexMap[j + n]]);
}
/**
* Loads a vector from a {@link ByteBuffer byte buffer} starting at an
*** 291,301 ****
* Bytes are composed into primitive lane elements according to the
* native byte order of the underlying platform.
* <p>
* This method behaves as if it returns the result of calling the
* byte buffer, offset, and mask accepting
! * {@link #fromByteBuffer(Species<Byte>, ByteBuffer, int, Mask)} method} as follows:
* <pre>{@code
* return this.fromByteBuffer(b, i, this.maskAllTrue())
* }</pre>
*
* @param species species of desired vector
--- 291,301 ----
* Bytes are composed into primitive lane elements according to the
* native byte order of the underlying platform.
* <p>
* This method behaves as if it returns the result of calling the
* byte buffer, offset, and mask accepting
! * {@link #fromByteBuffer(VectorSpecies<Byte>, ByteBuffer, int, VectorMask)} method} as follows:
* <pre>{@code
* return this.fromByteBuffer(b, i, this.maskAllTrue())
* }</pre>
*
* @param species species of desired vector
*** 308,318 ****
* {@code this.length() * this.elementSize() / Byte.SIZE} bytes
* remaining in the byte buffer from the given offset
*/
@ForceInline
@SuppressWarnings("unchecked")
! public static ByteVector fromByteBuffer(Species<Byte> species, ByteBuffer bb, int ix) {
if (bb.order() != ByteOrder.nativeOrder()) {
throw new IllegalArgumentException();
}
ix = VectorIntrinsics.checkIndex(ix, bb.limit(), species.bitSize() / Byte.SIZE);
return VectorIntrinsics.load((Class<ByteVector>) species.boxType(), byte.class, species.length(),
--- 308,318 ----
* {@code this.length() * this.elementSize() / Byte.SIZE} bytes
* remaining in the byte buffer from the given offset
*/
@ForceInline
@SuppressWarnings("unchecked")
! public static ByteVector fromByteBuffer(VectorSpecies<Byte> species, ByteBuffer bb, int ix) {
if (bb.order() != ByteOrder.nativeOrder()) {
throw new IllegalArgumentException();
}
ix = VectorIntrinsics.checkIndex(ix, bb.limit(), species.bitSize() / Byte.SIZE);
return VectorIntrinsics.load((Class<ByteVector>) species.boxType(), byte.class, species.length(),
*** 360,370 ****
* for any vector lane index {@code N} where the mask at lane {@code N}
* is set
* {@code i >= b.limit() - (N * this.elementSize() / Byte.SIZE)}
*/
@ForceInline
! public static ByteVector fromByteBuffer(Species<Byte> species, ByteBuffer bb, int ix, Mask<Byte> m) {
return zero(species).blend(fromByteBuffer(species, bb, ix), m);
}
/**
* Returns a vector where all lane elements are set to the primitive
--- 360,370 ----
* for any vector lane index {@code N} where the mask at lane {@code N}
* is set
* {@code i >= b.limit() - (N * this.elementSize() / Byte.SIZE)}
*/
@ForceInline
! public static ByteVector fromByteBuffer(VectorSpecies<Byte> species, ByteBuffer bb, int ix, VectorMask<Byte> m) {
return zero(species).blend(fromByteBuffer(species, bb, ix), m);
}
/**
* Returns a vector where all lane elements are set to the primitive
*** 375,385 ****
* @return a vector of vector where all lane elements are set to
* the primitive value {@code e}
*/
@ForceInline
@SuppressWarnings("unchecked")
! public static ByteVector broadcast(Species<Byte> s, byte e) {
return VectorIntrinsics.broadcastCoerced(
(Class<ByteVector>) s.boxType(), byte.class, s.length(),
e, s,
((bits, sp) -> ((ByteSpecies)sp).op(i -> (byte)bits)));
}
--- 375,385 ----
* @return a vector of vector where all lane elements are set to
* the primitive value {@code e}
*/
@ForceInline
@SuppressWarnings("unchecked")
! public static ByteVector broadcast(VectorSpecies<Byte> s, byte e) {
return VectorIntrinsics.broadcastCoerced(
(Class<ByteVector>) s.boxType(), byte.class, s.length(),
e, s,
((bits, sp) -> ((ByteSpecies)sp).op(i -> (byte)bits)));
}
*** 398,408 ****
* value
* @throws IndexOutOfBoundsException if {@code es.length < this.length()}
*/
@ForceInline
@SuppressWarnings("unchecked")
! public static ByteVector scalars(Species<Byte> s, byte... es) {
Objects.requireNonNull(es);
int ix = VectorIntrinsics.checkIndex(0, es.length, s.length());
return VectorIntrinsics.load((Class<ByteVector>) s.boxType(), byte.class, s.length(),
es, Unsafe.ARRAY_BYTE_BASE_OFFSET,
es, ix, s,
--- 398,408 ----
* value
* @throws IndexOutOfBoundsException if {@code es.length < this.length()}
*/
@ForceInline
@SuppressWarnings("unchecked")
! public static ByteVector scalars(VectorSpecies<Byte> s, byte... es) {
Objects.requireNonNull(es);
int ix = VectorIntrinsics.checkIndex(0, es.length, s.length());
return VectorIntrinsics.load((Class<ByteVector>) s.boxType(), byte.class, s.length(),
es, Unsafe.ARRAY_BYTE_BASE_OFFSET,
es, ix, s,
*** 418,428 ****
* @param e the value
* @return a vector where the first lane element is set to the primitive
* value {@code e}
*/
@ForceInline
! public static final ByteVector single(Species<Byte> s, byte e) {
return zero(s).with(0, e);
}
/**
* Returns a vector where each lane element is set to a randomly
--- 418,428 ----
* @param e the value
* @return a vector where the first lane element is set to the primitive
* value {@code e}
*/
@ForceInline
! public static final ByteVector single(VectorSpecies<Byte> s, byte e) {
return zero(s).with(0, e);
}
/**
* Returns a vector where each lane element is set to a randomly
*** 433,671 ****
*
* @param s species of the desired vector
* @return a vector where each lane elements is set to a randomly
* generated primitive value
*/
! public static ByteVector random(Species<Byte> s) {
ThreadLocalRandom r = ThreadLocalRandom.current();
return ((ByteSpecies)s).op(i -> (byte) r.nextInt());
}
- /**
- * Returns a mask where each lane is set or unset according to given
- * {@code boolean} values
- * <p>
- * For each mask lane, where {@code N} is the mask lane index,
- * if the given {@code boolean} value at index {@code N} is {@code true}
- * then the mask lane at index {@code N} is set, otherwise it is unset.
- *
- * @param species mask species
- * @param bits the given {@code boolean} values
- * @return a mask where each lane is set or unset according to the given {@code boolean} value
- * @throws IndexOutOfBoundsException if {@code bits.length < species.length()}
- */
- @ForceInline
- public static Mask<Byte> maskFromValues(Species<Byte> species, boolean... bits) {
- if (species.boxType() == ByteMaxVector.class)
- return new ByteMaxVector.ByteMaxMask(bits);
- switch (species.bitSize()) {
- case 64: return new Byte64Vector.Byte64Mask(bits);
- case 128: return new Byte128Vector.Byte128Mask(bits);
- case 256: return new Byte256Vector.Byte256Mask(bits);
- case 512: return new Byte512Vector.Byte512Mask(bits);
- default: throw new IllegalArgumentException(Integer.toString(species.bitSize()));
- }
- }
-
- // @@@ This is a bad implementation -- makes lambdas capturing -- fix this
- static Mask<Byte> trueMask(Species<Byte> species) {
- if (species.boxType() == ByteMaxVector.class)
- return ByteMaxVector.ByteMaxMask.TRUE_MASK;
- switch (species.bitSize()) {
- case 64: return Byte64Vector.Byte64Mask.TRUE_MASK;
- case 128: return Byte128Vector.Byte128Mask.TRUE_MASK;
- case 256: return Byte256Vector.Byte256Mask.TRUE_MASK;
- case 512: return Byte512Vector.Byte512Mask.TRUE_MASK;
- default: throw new IllegalArgumentException(Integer.toString(species.bitSize()));
- }
- }
-
- static Mask<Byte> falseMask(Species<Byte> species) {
- if (species.boxType() == ByteMaxVector.class)
- return ByteMaxVector.ByteMaxMask.FALSE_MASK;
- switch (species.bitSize()) {
- case 64: return Byte64Vector.Byte64Mask.FALSE_MASK;
- case 128: return Byte128Vector.Byte128Mask.FALSE_MASK;
- case 256: return Byte256Vector.Byte256Mask.FALSE_MASK;
- case 512: return Byte512Vector.Byte512Mask.FALSE_MASK;
- default: throw new IllegalArgumentException(Integer.toString(species.bitSize()));
- }
- }
-
- /**
- * Loads a mask from a {@code boolean} array starting at an offset.
- * <p>
- * For each mask lane, where {@code N} is the mask lane index,
- * if the array element at index {@code ix + N} is {@code true} then the
- * mask lane at index {@code N} is set, otherwise it is unset.
- *
- * @param species mask species
- * @param bits the {@code boolean} array
- * @param ix the offset into the array
- * @return the mask loaded from a {@code boolean} array
- * @throws IndexOutOfBoundsException if {@code ix < 0}, or
- * {@code ix > bits.length - species.length()}
- */
- @ForceInline
- @SuppressWarnings("unchecked")
- public static Mask<Byte> maskFromArray(Species<Byte> species, boolean[] bits, int ix) {
- Objects.requireNonNull(bits);
- ix = VectorIntrinsics.checkIndex(ix, bits.length, species.length());
- return VectorIntrinsics.load((Class<Mask<Byte>>) species.maskType(), byte.class, species.length(),
- bits, (((long) ix) << ARRAY_SHIFT) + Unsafe.ARRAY_BOOLEAN_BASE_OFFSET,
- bits, ix, species,
- (c, idx, s) -> (Mask<Byte>) ((ByteSpecies)s).opm(n -> c[idx + n]));
- }
-
- /**
- * Returns a mask where all lanes are set.
- *
- * @param species mask species
- * @return a mask where all lanes are set
- */
- @ForceInline
- @SuppressWarnings("unchecked")
- public static Mask<Byte> maskAllTrue(Species<Byte> species) {
- return VectorIntrinsics.broadcastCoerced((Class<Mask<Byte>>) species.maskType(), byte.class, species.length(),
- (byte)-1, species,
- ((z, s) -> trueMask(s)));
- }
-
- /**
- * Returns a mask where all lanes are unset.
- *
- * @param species mask species
- * @return a mask where all lanes are unset
- */
- @ForceInline
- @SuppressWarnings("unchecked")
- public static Mask<Byte> maskAllFalse(Species<Byte> species) {
- return VectorIntrinsics.broadcastCoerced((Class<Mask<Byte>>) species.maskType(), byte.class, species.length(),
- 0, species,
- ((z, s) -> falseMask(s)));
- }
-
- /**
- * Returns a shuffle of mapped indexes where each lane element is
- * the result of applying a mapping function to the corresponding lane
- * index.
- * <p>
- * Care should be taken to ensure Shuffle values produced from this
- * method are consumed as constants to ensure optimal generation of
- * code. For example, values held in static final fields or values
- * held in loop constant local variables.
- * <p>
- * This method behaves as if a shuffle is created from an array of
- * mapped indexes as follows:
- * <pre>{@code
- * int[] a = new int[species.length()];
- * for (int i = 0; i < a.length; i++) {
- * a[i] = f.applyAsInt(i);
- * }
- * return this.shuffleFromValues(a);
- * }</pre>
- *
- * @param species shuffle species
- * @param f the lane index mapping function
- * @return a shuffle of mapped indexes
- */
- @ForceInline
- public static Shuffle<Byte> shuffle(Species<Byte> species, IntUnaryOperator f) {
- if (species.boxType() == ByteMaxVector.class)
- return new ByteMaxVector.ByteMaxShuffle(f);
- switch (species.bitSize()) {
- case 64: return new Byte64Vector.Byte64Shuffle(f);
- case 128: return new Byte128Vector.Byte128Shuffle(f);
- case 256: return new Byte256Vector.Byte256Shuffle(f);
- case 512: return new Byte512Vector.Byte512Shuffle(f);
- default: throw new IllegalArgumentException(Integer.toString(species.bitSize()));
- }
- }
-
- /**
- * Returns a shuffle where each lane element is the value of its
- * corresponding lane index.
- * <p>
- * This method behaves as if a shuffle is created from an identity
- * index mapping function as follows:
- * <pre>{@code
- * return this.shuffle(i -> i);
- * }</pre>
- *
- * @param species shuffle species
- * @return a shuffle of lane indexes
- */
- @ForceInline
- public static Shuffle<Byte> shuffleIota(Species<Byte> species) {
- if (species.boxType() == ByteMaxVector.class)
- return new ByteMaxVector.ByteMaxShuffle(AbstractShuffle.IDENTITY);
- switch (species.bitSize()) {
- case 64: return new Byte64Vector.Byte64Shuffle(AbstractShuffle.IDENTITY);
- case 128: return new Byte128Vector.Byte128Shuffle(AbstractShuffle.IDENTITY);
- case 256: return new Byte256Vector.Byte256Shuffle(AbstractShuffle.IDENTITY);
- case 512: return new Byte512Vector.Byte512Shuffle(AbstractShuffle.IDENTITY);
- default: throw new IllegalArgumentException(Integer.toString(species.bitSize()));
- }
- }
-
- /**
- * Returns a shuffle where each lane element is set to a given
- * {@code int} value logically AND'ed by the species length minus one.
- * <p>
- * For each shuffle lane, where {@code N} is the shuffle lane index, the
- * the {@code int} value at index {@code N} logically AND'ed by
- * {@code species.length() - 1} is placed into the resulting shuffle at
- * lane index {@code N}.
- *
- * @param species shuffle species
- * @param ixs the given {@code int} values
- * @return a shuffle where each lane element is set to a given
- * {@code int} value
- * @throws IndexOutOfBoundsException if the number of int values is
- * {@code < species.length()}
- */
- @ForceInline
- public static Shuffle<Byte> shuffleFromValues(Species<Byte> species, int... ixs) {
- if (species.boxType() == ByteMaxVector.class)
- return new ByteMaxVector.ByteMaxShuffle(ixs);
- switch (species.bitSize()) {
- case 64: return new Byte64Vector.Byte64Shuffle(ixs);
- case 128: return new Byte128Vector.Byte128Shuffle(ixs);
- case 256: return new Byte256Vector.Byte256Shuffle(ixs);
- case 512: return new Byte512Vector.Byte512Shuffle(ixs);
- default: throw new IllegalArgumentException(Integer.toString(species.bitSize()));
- }
- }
-
- /**
- * Loads a shuffle from an {@code int} array starting at an offset.
- * <p>
- * For each shuffle lane, where {@code N} is the shuffle lane index, the
- * array element at index {@code i + N} logically AND'ed by
- * {@code species.length() - 1} is placed into the resulting shuffle at lane
- * index {@code N}.
- *
- * @param species shuffle species
- * @param ixs the {@code int} array
- * @param i the offset into the array
- * @return a shuffle loaded from the {@code int} array
- * @throws IndexOutOfBoundsException if {@code i < 0}, or
- * {@code i > a.length - species.length()}
- */
- @ForceInline
- public static Shuffle<Byte> shuffleFromArray(Species<Byte> species, int[] ixs, int i) {
- if (species.boxType() == ByteMaxVector.class)
- return new ByteMaxVector.ByteMaxShuffle(ixs, i);
- switch (species.bitSize()) {
- case 64: return new Byte64Vector.Byte64Shuffle(ixs, i);
- case 128: return new Byte128Vector.Byte128Shuffle(ixs, i);
- case 256: return new Byte256Vector.Byte256Shuffle(ixs, i);
- case 512: return new Byte512Vector.Byte512Shuffle(ixs, i);
- default: throw new IllegalArgumentException(Integer.toString(species.bitSize()));
- }
- }
-
// Ops
@Override
public abstract ByteVector add(Vector<Byte> v);
--- 433,447 ----
*
* @param s species of the desired vector
* @return a vector where each lane elements is set to a randomly
* generated primitive value
*/
! public static ByteVector random(VectorSpecies<Byte> s) {
ThreadLocalRandom r = ThreadLocalRandom.current();
return ((ByteSpecies)s).op(i -> (byte) r.nextInt());
}
// Ops
@Override
public abstract ByteVector add(Vector<Byte> v);
*** 680,690 ****
* scalar
*/
public abstract ByteVector add(byte s);
@Override
! public abstract ByteVector add(Vector<Byte> v, Mask<Byte> m);
/**
* Adds this vector to broadcast of an input scalar,
* selecting lane elements controlled by a mask.
* <p>
--- 456,466 ----
* scalar
*/
public abstract ByteVector add(byte s);
@Override
! public abstract ByteVector add(Vector<Byte> v, VectorMask<Byte> m);
/**
* Adds this vector to broadcast of an input scalar,
* selecting lane elements controlled by a mask.
* <p>
*** 694,704 ****
* @param s the input scalar
* @param m the mask controlling lane selection
* @return the result of adding this vector to the broadcast of an input
* scalar
*/
! public abstract ByteVector add(byte s, Mask<Byte> m);
@Override
public abstract ByteVector sub(Vector<Byte> v);
/**
--- 470,480 ----
* @param s the input scalar
* @param m the mask controlling lane selection
* @return the result of adding this vector to the broadcast of an input
* scalar
*/
! public abstract ByteVector add(byte s, VectorMask<Byte> m);
@Override
public abstract ByteVector sub(Vector<Byte> v);
/**
*** 712,722 ****
* scalar from this vector
*/
public abstract ByteVector sub(byte s);
@Override
! public abstract ByteVector sub(Vector<Byte> v, Mask<Byte> m);
/**
* Subtracts the broadcast of an input scalar from this vector, selecting
* lane elements controlled by a mask.
* <p>
--- 488,498 ----
* scalar from this vector
*/
public abstract ByteVector sub(byte s);
@Override
! public abstract ByteVector sub(Vector<Byte> v, VectorMask<Byte> m);
/**
* Subtracts the broadcast of an input scalar from this vector, selecting
* lane elements controlled by a mask.
* <p>
*** 726,736 ****
* @param s the input scalar
* @param m the mask controlling lane selection
* @return the result of subtracting the broadcast of an input
* scalar from this vector
*/
! public abstract ByteVector sub(byte s, Mask<Byte> m);
@Override
public abstract ByteVector mul(Vector<Byte> v);
/**
--- 502,512 ----
* @param s the input scalar
* @param m the mask controlling lane selection
* @return the result of subtracting the broadcast of an input
* scalar from this vector
*/
! public abstract ByteVector sub(byte s, VectorMask<Byte> m);
@Override
public abstract ByteVector mul(Vector<Byte> v);
/**
*** 744,754 ****
* input scalar
*/
public abstract ByteVector mul(byte s);
@Override
! public abstract ByteVector mul(Vector<Byte> v, Mask<Byte> m);
/**
* Multiplies this vector with the broadcast of an input scalar, selecting
* lane elements controlled by a mask.
* <p>
--- 520,530 ----
* input scalar
*/
public abstract ByteVector mul(byte s);
@Override
! public abstract ByteVector mul(Vector<Byte> v, VectorMask<Byte> m);
/**
* Multiplies this vector with the broadcast of an input scalar, selecting
* lane elements controlled by a mask.
* <p>
*** 758,786 ****
* @param s the input scalar
* @param m the mask controlling lane selection
* @return the result of multiplying this vector with the broadcast of an
* input scalar
*/
! public abstract ByteVector mul(byte s, Mask<Byte> m);
@Override
public abstract ByteVector neg();
@Override
! public abstract ByteVector neg(Mask<Byte> m);
@Override
public abstract ByteVector abs();
@Override
! public abstract ByteVector abs(Mask<Byte> m);
@Override
public abstract ByteVector min(Vector<Byte> v);
@Override
! public abstract ByteVector min(Vector<Byte> v, Mask<Byte> m);
/**
* Returns the minimum of this vector and the broadcast of an input scalar.
* <p>
* This is a vector binary operation where the operation
--- 534,562 ----
* @param s the input scalar
* @param m the mask controlling lane selection
* @return the result of multiplying this vector with the broadcast of an
* input scalar
*/
! public abstract ByteVector mul(byte s, VectorMask<Byte> m);
@Override
public abstract ByteVector neg();
@Override
! public abstract ByteVector neg(VectorMask<Byte> m);
@Override
public abstract ByteVector abs();
@Override
! public abstract ByteVector abs(VectorMask<Byte> m);
@Override
public abstract ByteVector min(Vector<Byte> v);
@Override
! public abstract ByteVector min(Vector<Byte> v, VectorMask<Byte> m);
/**
* Returns the minimum of this vector and the broadcast of an input scalar.
* <p>
* This is a vector binary operation where the operation
*** 793,803 ****
@Override
public abstract ByteVector max(Vector<Byte> v);
@Override
! public abstract ByteVector max(Vector<Byte> v, Mask<Byte> m);
/**
* Returns the maximum of this vector and the broadcast of an input scalar.
* <p>
* This is a vector binary operation where the operation
--- 569,579 ----
@Override
public abstract ByteVector max(Vector<Byte> v);
@Override
! public abstract ByteVector max(Vector<Byte> v, VectorMask<Byte> m);
/**
* Returns the maximum of this vector and the broadcast of an input scalar.
* <p>
* This is a vector binary operation where the operation
*** 807,817 ****
* @return the maximum of this vector and the broadcast of an input scalar
*/
public abstract ByteVector max(byte s);
@Override
! public abstract Mask<Byte> equal(Vector<Byte> v);
/**
* Tests if this vector is equal to the broadcast of an input scalar.
* <p>
* This is a vector binary test operation where the primitive equals
--- 583,593 ----
* @return the maximum of this vector and the broadcast of an input scalar
*/
public abstract ByteVector max(byte s);
@Override
! public abstract VectorMask<Byte> equal(Vector<Byte> v);
/**
* Tests if this vector is equal to the broadcast of an input scalar.
* <p>
* This is a vector binary test operation where the primitive equals
*** 819,832 ****
*
* @param s the input scalar
* @return the result mask of testing if this vector is equal to the
* broadcast of an input scalar
*/
! public abstract Mask<Byte> equal(byte s);
@Override
! public abstract Mask<Byte> notEqual(Vector<Byte> v);
/**
* Tests if this vector is not equal to the broadcast of an input scalar.
* <p>
* This is a vector binary test operation where the primitive not equals
--- 595,608 ----
*
* @param s the input scalar
* @return the result mask of testing if this vector is equal to the
* broadcast of an input scalar
*/
! public abstract VectorMask<Byte> equal(byte s);
@Override
! public abstract VectorMask<Byte> notEqual(Vector<Byte> v);
/**
* Tests if this vector is not equal to the broadcast of an input scalar.
* <p>
* This is a vector binary test operation where the primitive not equals
*** 834,847 ****
*
* @param s the input scalar
* @return the result mask of testing if this vector is not equal to the
* broadcast of an input scalar
*/
! public abstract Mask<Byte> notEqual(byte s);
@Override
! public abstract Mask<Byte> lessThan(Vector<Byte> v);
/**
* Tests if this vector is less than the broadcast of an input scalar.
* <p>
* This is a vector binary test operation where the primitive less than
--- 610,623 ----
*
* @param s the input scalar
* @return the result mask of testing if this vector is not equal to the
* broadcast of an input scalar
*/
! public abstract VectorMask<Byte> notEqual(byte s);
@Override
! public abstract VectorMask<Byte> lessThan(Vector<Byte> v);
/**
* Tests if this vector is less than the broadcast of an input scalar.
* <p>
* This is a vector binary test operation where the primitive less than
*** 849,862 ****
*
* @param s the input scalar
* @return the mask result of testing if this vector is less than the
* broadcast of an input scalar
*/
! public abstract Mask<Byte> lessThan(byte s);
@Override
! public abstract Mask<Byte> lessThanEq(Vector<Byte> v);
/**
* Tests if this vector is less or equal to the broadcast of an input scalar.
* <p>
* This is a vector binary test operation where the primitive less than
--- 625,638 ----
*
* @param s the input scalar
* @return the mask result of testing if this vector is less than the
* broadcast of an input scalar
*/
! public abstract VectorMask<Byte> lessThan(byte s);
@Override
! public abstract VectorMask<Byte> lessThanEq(Vector<Byte> v);
/**
* Tests if this vector is less or equal to the broadcast of an input scalar.
* <p>
* This is a vector binary test operation where the primitive less than
*** 864,877 ****
*
* @param s the input scalar
* @return the mask result of testing if this vector is less than or equal
* to the broadcast of an input scalar
*/
! public abstract Mask<Byte> lessThanEq(byte s);
@Override
! public abstract Mask<Byte> greaterThan(Vector<Byte> v);
/**
* Tests if this vector is greater than the broadcast of an input scalar.
* <p>
* This is a vector binary test operation where the primitive greater than
--- 640,653 ----
*
* @param s the input scalar
* @return the mask result of testing if this vector is less than or equal
* to the broadcast of an input scalar
*/
! public abstract VectorMask<Byte> lessThanEq(byte s);
@Override
! public abstract VectorMask<Byte> greaterThan(Vector<Byte> v);
/**
* Tests if this vector is greater than the broadcast of an input scalar.
* <p>
* This is a vector binary test operation where the primitive greater than
*** 879,892 ****
*
* @param s the input scalar
* @return the mask result of testing if this vector is greater than the
* broadcast of an input scalar
*/
! public abstract Mask<Byte> greaterThan(byte s);
@Override
! public abstract Mask<Byte> greaterThanEq(Vector<Byte> v);
/**
* Tests if this vector is greater than or equal to the broadcast of an
* input scalar.
* <p>
--- 655,668 ----
*
* @param s the input scalar
* @return the mask result of testing if this vector is greater than the
* broadcast of an input scalar
*/
! public abstract VectorMask<Byte> greaterThan(byte s);
@Override
! public abstract VectorMask<Byte> greaterThanEq(Vector<Byte> v);
/**
* Tests if this vector is greater than or equal to the broadcast of an
* input scalar.
* <p>
*** 895,908 ****
*
* @param s the input scalar
* @return the mask result of testing if this vector is greater than or
* equal to the broadcast of an input scalar
*/
! public abstract Mask<Byte> greaterThanEq(byte s);
@Override
! public abstract ByteVector blend(Vector<Byte> v, Mask<Byte> m);
/**
* Blends the lane elements of this vector with those of the broadcast of an
* input scalar, selecting lanes controlled by a mask.
* <p>
--- 671,684 ----
*
* @param s the input scalar
* @return the mask result of testing if this vector is greater than or
* equal to the broadcast of an input scalar
*/
! public abstract VectorMask<Byte> greaterThanEq(byte s);
@Override
! public abstract ByteVector blend(Vector<Byte> v, VectorMask<Byte> m);
/**
* Blends the lane elements of this vector with those of the broadcast of an
* input scalar, selecting lanes controlled by a mask.
* <p>
*** 915,935 ****
* @param s the input scalar
* @param m the mask controlling lane selection
* @return the result of blending the lane elements of this vector with
* those of the broadcast of an input scalar
*/
! public abstract ByteVector blend(byte s, Mask<Byte> m);
@Override
public abstract ByteVector rearrange(Vector<Byte> v,
! Shuffle<Byte> s, Mask<Byte> m);
@Override
! public abstract ByteVector rearrange(Shuffle<Byte> m);
@Override
! public abstract ByteVector reshape(Species<Byte> s);
@Override
public abstract ByteVector rotateEL(int i);
@Override
--- 691,711 ----
* @param s the input scalar
* @param m the mask controlling lane selection
* @return the result of blending the lane elements of this vector with
* those of the broadcast of an input scalar
*/
! public abstract ByteVector blend(byte s, VectorMask<Byte> m);
@Override
public abstract ByteVector rearrange(Vector<Byte> v,
! VectorShuffle<Byte> s, VectorMask<Byte> m);
@Override
! public abstract ByteVector rearrange(VectorShuffle<Byte> m);
@Override
! public abstract ByteVector reshape(VectorSpecies<Byte> s);
@Override
public abstract ByteVector rotateEL(int i);
@Override
*** 975,985 ****
*
* @param v the input vector
* @param m the mask controlling lane selection
* @return the bitwise AND of this vector with the input vector
*/
! public abstract ByteVector and(Vector<Byte> v, Mask<Byte> m);
/**
* Bitwise ANDs this vector with the broadcast of an input scalar, selecting
* lane elements controlled by a mask.
* <p>
--- 751,761 ----
*
* @param v the input vector
* @param m the mask controlling lane selection
* @return the bitwise AND of this vector with the input vector
*/
! public abstract ByteVector and(Vector<Byte> v, VectorMask<Byte> m);
/**
* Bitwise ANDs this vector with the broadcast of an input scalar, selecting
* lane elements controlled by a mask.
* <p>
*** 989,999 ****
* @param s the input scalar
* @param m the mask controlling lane selection
* @return the bitwise AND of this vector with the broadcast of an input
* scalar
*/
! public abstract ByteVector and(byte s, Mask<Byte> m);
/**
* Bitwise ORs this vector with an input vector.
* <p>
* This is a vector binary operation where the primitive bitwise OR
--- 765,775 ----
* @param s the input scalar
* @param m the mask controlling lane selection
* @return the bitwise AND of this vector with the broadcast of an input
* scalar
*/
! public abstract ByteVector and(byte s, VectorMask<Byte> m);
/**
* Bitwise ORs this vector with an input vector.
* <p>
* This is a vector binary operation where the primitive bitwise OR
*** 1025,1035 ****
*
* @param v the input vector
* @param m the mask controlling lane selection
* @return the bitwise OR of this vector with the input vector
*/
! public abstract ByteVector or(Vector<Byte> v, Mask<Byte> m);
/**
* Bitwise ORs this vector with the broadcast of an input scalar, selecting
* lane elements controlled by a mask.
* <p>
--- 801,811 ----
*
* @param v the input vector
* @param m the mask controlling lane selection
* @return the bitwise OR of this vector with the input vector
*/
! public abstract ByteVector or(Vector<Byte> v, VectorMask<Byte> m);
/**
* Bitwise ORs this vector with the broadcast of an input scalar, selecting
* lane elements controlled by a mask.
* <p>
*** 1039,1049 ****
* @param s the input scalar
* @param m the mask controlling lane selection
* @return the bitwise OR of this vector with the broadcast of an input
* scalar
*/
! public abstract ByteVector or(byte s, Mask<Byte> m);
/**
* Bitwise XORs this vector with an input vector.
* <p>
* This is a vector binary operation where the primitive bitwise XOR
--- 815,825 ----
* @param s the input scalar
* @param m the mask controlling lane selection
* @return the bitwise OR of this vector with the broadcast of an input
* scalar
*/
! public abstract ByteVector or(byte s, VectorMask<Byte> m);
/**
* Bitwise XORs this vector with an input vector.
* <p>
* This is a vector binary operation where the primitive bitwise XOR
*** 1075,1085 ****
*
* @param v the input vector
* @param m the mask controlling lane selection
* @return the bitwise XOR of this vector with the input vector
*/
! public abstract ByteVector xor(Vector<Byte> v, Mask<Byte> m);
/**
* Bitwise XORs this vector with the broadcast of an input scalar, selecting
* lane elements controlled by a mask.
* <p>
--- 851,861 ----
*
* @param v the input vector
* @param m the mask controlling lane selection
* @return the bitwise XOR of this vector with the input vector
*/
! public abstract ByteVector xor(Vector<Byte> v, VectorMask<Byte> m);
/**
* Bitwise XORs this vector with the broadcast of an input scalar, selecting
* lane elements controlled by a mask.
* <p>
*** 1089,1099 ****
* @param s the input scalar
* @param m the mask controlling lane selection
* @return the bitwise XOR of this vector with the broadcast of an input
* scalar
*/
! public abstract ByteVector xor(byte s, Mask<Byte> m);
/**
* Bitwise NOTs this vector.
* <p>
* This is a vector unary operation where the primitive bitwise NOT
--- 865,875 ----
* @param s the input scalar
* @param m the mask controlling lane selection
* @return the bitwise XOR of this vector with the broadcast of an input
* scalar
*/
! public abstract ByteVector xor(byte s, VectorMask<Byte> m);
/**
* Bitwise NOTs this vector.
* <p>
* This is a vector unary operation where the primitive bitwise NOT
*** 1110,1120 ****
* operation ({@code ~}) is applied to lane elements.
*
* @param m the mask controlling lane selection
* @return the bitwise NOT of this vector
*/
! public abstract ByteVector not(Mask<Byte> m);
/**
* Logically left shifts this vector by the broadcast of an input scalar.
* <p>
* This is a vector binary operation where the primitive logical left shift
--- 886,896 ----
* operation ({@code ~}) is applied to lane elements.
*
* @param m the mask controlling lane selection
* @return the bitwise NOT of this vector
*/
! public abstract ByteVector not(VectorMask<Byte> m);
/**
* Logically left shifts this vector by the broadcast of an input scalar.
* <p>
* This is a vector binary operation where the primitive logical left shift
*** 1144,1154 ****
* @param s the input scalar; the number of the bits to left shift
* @param m the mask controlling lane selection
* @return the result of logically left shifting left this vector by the
* broadcast of an input scalar
*/
! public abstract ByteVector shiftL(int s, Mask<Byte> m);
// logical, or unsigned, shift right
/**
--- 920,930 ----
* @param s the input scalar; the number of the bits to left shift
* @param m the mask controlling lane selection
* @return the result of logically left shifting left this vector by the
* broadcast of an input scalar
*/
! public abstract ByteVector shiftL(int s, VectorMask<Byte> m);
// logical, or unsigned, shift right
/**
*** 1183,1193 ****
* @param s the input scalar; the number of the bits to right shift
* @param m the mask controlling lane selection
* @return the result of logically right shifting this vector by the
* broadcast of an input scalar
*/
! public abstract ByteVector shiftR(int s, Mask<Byte> m);
/**
* Arithmetically right shifts (or signed right shifts) this vector by the
* broadcast of an input scalar.
--- 959,969 ----
* @param s the input scalar; the number of the bits to right shift
* @param m the mask controlling lane selection
* @return the result of logically right shifting this vector by the
* broadcast of an input scalar
*/
! public abstract ByteVector shiftR(int s, VectorMask<Byte> m);
/**
* Arithmetically right shifts (or signed right shifts) this vector by the
* broadcast of an input scalar.
*** 1220,1243 ****
* @param s the input scalar; the number of the bits to right shift
* @param m the mask controlling lane selection
* @return the result of arithmetically right shifting this vector by the
* broadcast of an input scalar
*/
! public abstract ByteVector aShiftR(int s, Mask<Byte> m);
@Override
public abstract void intoByteArray(byte[] a, int ix);
@Override
! public abstract void intoByteArray(byte[] a, int ix, Mask<Byte> m);
@Override
public abstract void intoByteBuffer(ByteBuffer bb, int ix);
@Override
! public abstract void intoByteBuffer(ByteBuffer bb, int ix, Mask<Byte> m);
// Type specific horizontal reductions
/**
* Adds all lane elements of this vector.
--- 996,1019 ----
* @param s the input scalar; the number of the bits to right shift
* @param m the mask controlling lane selection
* @return the result of arithmetically right shifting this vector by the
* broadcast of an input scalar
*/
! public abstract ByteVector aShiftR(int s, VectorMask<Byte> m);
@Override
public abstract void intoByteArray(byte[] a, int ix);
@Override
! public abstract void intoByteArray(byte[] a, int ix, VectorMask<Byte> m);
@Override
public abstract void intoByteBuffer(ByteBuffer bb, int ix);
@Override
! public abstract void intoByteBuffer(ByteBuffer bb, int ix, VectorMask<Byte> m);
// Type specific horizontal reductions
/**
* Adds all lane elements of this vector.
*** 1259,1269 ****
* and the identity value is {@code 0}.
*
* @param m the mask controlling lane selection
* @return the addition of the selected lane elements of this vector
*/
! public abstract byte addAll(Mask<Byte> m);
/**
* Multiplies all lane elements of this vector.
* <p>
* This is an associative vector reduction operation where the
--- 1035,1045 ----
* and the identity value is {@code 0}.
*
* @param m the mask controlling lane selection
* @return the addition of the selected lane elements of this vector
*/
! public abstract byte addAll(VectorMask<Byte> m);
/**
* Multiplies all lane elements of this vector.
* <p>
* This is an associative vector reduction operation where the
*** 1283,1293 ****
* and the identity value is {@code 1}.
*
* @param m the mask controlling lane selection
* @return the multiplication of all the lane elements of this vector
*/
! public abstract byte mulAll(Mask<Byte> m);
/**
* Returns the minimum lane element of this vector.
* <p>
* This is an associative vector reduction operation where the operation
--- 1059,1069 ----
* and the identity value is {@code 1}.
*
* @param m the mask controlling lane selection
* @return the multiplication of all the lane elements of this vector
*/
! public abstract byte mulAll(VectorMask<Byte> m);
/**
* Returns the minimum lane element of this vector.
* <p>
* This is an associative vector reduction operation where the operation
*** 1309,1319 ****
* {@link Byte#MAX_VALUE}.
*
* @param m the mask controlling lane selection
* @return the minimum lane element of this vector
*/
! public abstract byte minAll(Mask<Byte> m);
/**
* Returns the maximum lane element of this vector.
* <p>
* This is an associative vector reduction operation where the operation
--- 1085,1095 ----
* {@link Byte#MAX_VALUE}.
*
* @param m the mask controlling lane selection
* @return the minimum lane element of this vector
*/
! public abstract byte minAll(VectorMask<Byte> m);
/**
* Returns the maximum lane element of this vector.
* <p>
* This is an associative vector reduction operation where the operation
*** 1335,1345 ****
* {@link Byte#MIN_VALUE}.
*
* @param m the mask controlling lane selection
* @return the maximum lane element of this vector
*/
! public abstract byte maxAll(Mask<Byte> m);
/**
* Logically ORs all lane elements of this vector.
* <p>
* This is an associative vector reduction operation where the logical OR
--- 1111,1121 ----
* {@link Byte#MIN_VALUE}.
*
* @param m the mask controlling lane selection
* @return the maximum lane element of this vector
*/
! public abstract byte maxAll(VectorMask<Byte> m);
/**
* Logically ORs all lane elements of this vector.
* <p>
* This is an associative vector reduction operation where the logical OR
*** 1359,1369 ****
* and the identity value is {@code 0}.
*
* @param m the mask controlling lane selection
* @return the logical OR all the lane elements of this vector
*/
! public abstract byte orAll(Mask<Byte> m);
/**
* Logically ANDs all lane elements of this vector.
* <p>
* This is an associative vector reduction operation where the logical AND
--- 1135,1145 ----
* and the identity value is {@code 0}.
*
* @param m the mask controlling lane selection
* @return the logical OR all the lane elements of this vector
*/
! public abstract byte orAll(VectorMask<Byte> m);
/**
* Logically ANDs all lane elements of this vector.
* <p>
* This is an associative vector reduction operation where the logical AND
*** 1383,1393 ****
* and the identity value is {@code -1}.
*
* @param m the mask controlling lane selection
* @return the logical AND all the lane elements of this vector
*/
! public abstract byte andAll(Mask<Byte> m);
/**
* Logically XORs all lane elements of this vector.
* <p>
* This is an associative vector reduction operation where the logical XOR
--- 1159,1169 ----
* and the identity value is {@code -1}.
*
* @param m the mask controlling lane selection
* @return the logical AND all the lane elements of this vector
*/
! public abstract byte andAll(VectorMask<Byte> m);
/**
* Logically XORs all lane elements of this vector.
* <p>
* This is an associative vector reduction operation where the logical XOR
*** 1407,1417 ****
* and the identity value is {@code 0}.
*
* @param m the mask controlling lane selection
* @return the logical XOR all the lane elements of this vector
*/
! public abstract byte xorAll(Mask<Byte> m);
// Type specific accessors
/**
* Gets the lane element at lane index {@code i}
--- 1183,1193 ----
* and the identity value is {@code 0}.
*
* @param m the mask controlling lane selection
* @return the logical XOR all the lane elements of this vector
*/
! public abstract byte xorAll(VectorMask<Byte> m);
// Type specific accessors
/**
* Gets the lane element at lane index {@code i}
*** 1489,1499 ****
* @param m the mask
* @throws IndexOutOfBoundsException if {@code i < 0}, or
* for any vector lane index {@code N} where the mask at lane {@code N}
* is set {@code i >= a.length - N}
*/
! public abstract void intoArray(byte[] a, int i, Mask<Byte> m);
/**
* Stores this vector into an array using indexes obtained from an index
* map.
* <p>
--- 1265,1275 ----
* @param m the mask
* @throws IndexOutOfBoundsException if {@code i < 0}, or
* for any vector lane index {@code N} where the mask at lane {@code N}
* is set {@code i >= a.length - N}
*/
! public abstract void intoArray(byte[] a, int i, VectorMask<Byte> m);
/**
* Stores this vector into an array using indexes obtained from an index
* map.
* <p>
*** 1536,1604 ****
* {@code j > indexMap.length - this.length()},
* or for any vector lane index {@code N} where the mask at lane
* {@code N} is set the result of {@code i + indexMap[j + N]} is
* {@code < 0} or {@code >= a.length}
*/
! public void intoArray(byte[] a, int i, Mask<Byte> m, int[] indexMap, int j) {
forEach(m, (n, e) -> a[i + indexMap[j + n]] = e);
}
// Species
@Override
! public abstract Species<Byte> species();
/**
! * Class representing {@link ByteVector}'s of the same {@link Vector.Shape Shape}.
*/
! static final class ByteSpecies extends Vector.AbstractSpecies<Byte> {
final Function<byte[], ByteVector> vectorFactory;
- final Function<boolean[], Vector.Mask<Byte>> maskFactory;
! private ByteSpecies(Vector.Shape shape,
Class<?> boxType,
Class<?> maskType,
Function<byte[], ByteVector> vectorFactory,
! Function<boolean[], Vector.Mask<Byte>> maskFactory) {
! super(shape, byte.class, Byte.SIZE, boxType, maskType);
this.vectorFactory = vectorFactory;
- this.maskFactory = maskFactory;
}
interface FOp {
byte apply(int i);
}
- interface FOpm {
- boolean apply(int i);
- }
-
ByteVector op(FOp f) {
byte[] res = new byte[length()];
for (int i = 0; i < length(); i++) {
res[i] = f.apply(i);
}
return vectorFactory.apply(res);
}
! ByteVector op(Vector.Mask<Byte> o, FOp f) {
byte[] res = new byte[length()];
boolean[] mbits = ((AbstractMask<Byte>)o).getBits();
for (int i = 0; i < length(); i++) {
if (mbits[i]) {
res[i] = f.apply(i);
}
}
return vectorFactory.apply(res);
}
-
- Vector.Mask<Byte> opm(IntVector.IntSpecies.FOpm f) {
- boolean[] res = new boolean[length()];
- for (int i = 0; i < length(); i++) {
- res[i] = (boolean)f.apply(i);
- }
- return maskFactory.apply(res);
- }
}
/**
* Finds the preferred species for an element type of {@code byte}.
* <p>
--- 1312,1369 ----
* {@code j > indexMap.length - this.length()},
* or for any vector lane index {@code N} where the mask at lane
* {@code N} is set the result of {@code i + indexMap[j + N]} is
* {@code < 0} or {@code >= a.length}
*/
! public void intoArray(byte[] a, int i, VectorMask<Byte> m, int[] indexMap, int j) {
forEach(m, (n, e) -> a[i + indexMap[j + n]] = e);
}
// Species
@Override
! public abstract VectorSpecies<Byte> species();
/**
! * Class representing {@link ByteVector}'s of the same {@link VectorShape VectorShape}.
*/
! static final class ByteSpecies extends AbstractSpecies<Byte> {
final Function<byte[], ByteVector> vectorFactory;
! private ByteSpecies(VectorShape shape,
Class<?> boxType,
Class<?> maskType,
Function<byte[], ByteVector> vectorFactory,
! Function<boolean[], VectorMask<Byte>> maskFactory,
! Function<IntUnaryOperator, VectorShuffle<Byte>> shuffleFromArrayFactory,
! fShuffleFromArray<Byte> shuffleFromOpFactory) {
! super(shape, byte.class, Byte.SIZE, boxType, maskType, maskFactory,
! shuffleFromArrayFactory, shuffleFromOpFactory);
this.vectorFactory = vectorFactory;
}
interface FOp {
byte apply(int i);
}
ByteVector op(FOp f) {
byte[] res = new byte[length()];
for (int i = 0; i < length(); i++) {
res[i] = f.apply(i);
}
return vectorFactory.apply(res);
}
! ByteVector op(VectorMask<Byte> o, FOp f) {
byte[] res = new byte[length()];
boolean[] mbits = ((AbstractMask<Byte>)o).getBits();
for (int i = 0; i < length(); i++) {
if (mbits[i]) {
res[i] = f.apply(i);
}
}
return vectorFactory.apply(res);
}
}
/**
* Finds the preferred species for an element type of {@code byte}.
* <p>
*** 1608,1628 ****
* shuffles created from such species will be shape compatible.
*
* @return the preferred species for an element type of {@code byte}
*/
private static ByteSpecies preferredSpecies() {
! return (ByteSpecies) Species.ofPreferred(byte.class);
}
/**
* Finds a species for an element type of {@code byte} and shape.
*
* @param s the shape
* @return a species for an element type of {@code byte} and shape
* @throws IllegalArgumentException if no such species exists for the shape
*/
! static ByteSpecies species(Vector.Shape s) {
Objects.requireNonNull(s);
switch (s) {
case S_64_BIT: return (ByteSpecies) SPECIES_64;
case S_128_BIT: return (ByteSpecies) SPECIES_128;
case S_256_BIT: return (ByteSpecies) SPECIES_256;
--- 1373,1393 ----
* shuffles created from such species will be shape compatible.
*
* @return the preferred species for an element type of {@code byte}
*/
private static ByteSpecies preferredSpecies() {
! return (ByteSpecies) VectorSpecies.ofPreferred(byte.class);
}
/**
* Finds a species for an element type of {@code byte} and shape.
*
* @param s the shape
* @return a species for an element type of {@code byte} and shape
* @throws IllegalArgumentException if no such species exists for the shape
*/
! static ByteSpecies species(VectorShape s) {
Objects.requireNonNull(s);
switch (s) {
case S_64_BIT: return (ByteSpecies) SPECIES_64;
case S_128_BIT: return (ByteSpecies) SPECIES_128;
case S_256_BIT: return (ByteSpecies) SPECIES_256;
*** 1630,1660 ****
case S_Max_BIT: return (ByteSpecies) SPECIES_MAX;
default: throw new IllegalArgumentException("Bad shape: " + s);
}
}
! /** Species representing {@link ByteVector}s of {@link Vector.Shape#S_64_BIT Shape.S_64_BIT}. */
! public static final Species<Byte> SPECIES_64 = new ByteSpecies(Shape.S_64_BIT, Byte64Vector.class, Byte64Vector.Byte64Mask.class,
! Byte64Vector::new, Byte64Vector.Byte64Mask::new);
!
! /** Species representing {@link ByteVector}s of {@link Vector.Shape#S_128_BIT Shape.S_128_BIT}. */
! public static final Species<Byte> SPECIES_128 = new ByteSpecies(Shape.S_128_BIT, Byte128Vector.class, Byte128Vector.Byte128Mask.class,
! Byte128Vector::new, Byte128Vector.Byte128Mask::new);
!
! /** Species representing {@link ByteVector}s of {@link Vector.Shape#S_256_BIT Shape.S_256_BIT}. */
! public static final Species<Byte> SPECIES_256 = new ByteSpecies(Shape.S_256_BIT, Byte256Vector.class, Byte256Vector.Byte256Mask.class,
! Byte256Vector::new, Byte256Vector.Byte256Mask::new);
!
! /** Species representing {@link ByteVector}s of {@link Vector.Shape#S_512_BIT Shape.S_512_BIT}. */
! public static final Species<Byte> SPECIES_512 = new ByteSpecies(Shape.S_512_BIT, Byte512Vector.class, Byte512Vector.Byte512Mask.class,
! Byte512Vector::new, Byte512Vector.Byte512Mask::new);
!
! /** Species representing {@link ByteVector}s of {@link Vector.Shape#S_Max_BIT Shape.S_Max_BIT}. */
! public static final Species<Byte> SPECIES_MAX = new ByteSpecies(Shape.S_Max_BIT, ByteMaxVector.class, ByteMaxVector.ByteMaxMask.class,
! ByteMaxVector::new, ByteMaxVector.ByteMaxMask::new);
/**
* Preferred species for {@link ByteVector}s.
* A preferred species is a species of maximal bit size for the platform.
*/
! public static final Species<Byte> SPECIES_PREFERRED = (Species<Byte>) preferredSpecies();
}
--- 1395,1430 ----
case S_Max_BIT: return (ByteSpecies) SPECIES_MAX;
default: throw new IllegalArgumentException("Bad shape: " + s);
}
}
! /** Species representing {@link ByteVector}s of {@link VectorShape#S_64_BIT VectorShape.S_64_BIT}. */
! public static final VectorSpecies<Byte> SPECIES_64 = new ByteSpecies(VectorShape.S_64_BIT, Byte64Vector.class, Byte64Vector.Byte64Mask.class,
! Byte64Vector::new, Byte64Vector.Byte64Mask::new,
! Byte64Vector.Byte64Shuffle::new, Byte64Vector.Byte64Shuffle::new);
!
! /** Species representing {@link ByteVector}s of {@link VectorShape#S_128_BIT VectorShape.S_128_BIT}. */
! public static final VectorSpecies<Byte> SPECIES_128 = new ByteSpecies(VectorShape.S_128_BIT, Byte128Vector.class, Byte128Vector.Byte128Mask.class,
! Byte128Vector::new, Byte128Vector.Byte128Mask::new,
! Byte128Vector.Byte128Shuffle::new, Byte128Vector.Byte128Shuffle::new);
!
! /** Species representing {@link ByteVector}s of {@link VectorShape#S_256_BIT VectorShape.S_256_BIT}. */
! public static final VectorSpecies<Byte> SPECIES_256 = new ByteSpecies(VectorShape.S_256_BIT, Byte256Vector.class, Byte256Vector.Byte256Mask.class,
! Byte256Vector::new, Byte256Vector.Byte256Mask::new,
! Byte256Vector.Byte256Shuffle::new, Byte256Vector.Byte256Shuffle::new);
!
! /** Species representing {@link ByteVector}s of {@link VectorShape#S_512_BIT VectorShape.S_512_BIT}. */
! public static final VectorSpecies<Byte> SPECIES_512 = new ByteSpecies(VectorShape.S_512_BIT, Byte512Vector.class, Byte512Vector.Byte512Mask.class,
! Byte512Vector::new, Byte512Vector.Byte512Mask::new,
! Byte512Vector.Byte512Shuffle::new, Byte512Vector.Byte512Shuffle::new);
!
! /** Species representing {@link ByteVector}s of {@link VectorShape#S_Max_BIT VectorShape.S_Max_BIT}. */
! public static final VectorSpecies<Byte> SPECIES_MAX = new ByteSpecies(VectorShape.S_Max_BIT, ByteMaxVector.class, ByteMaxVector.ByteMaxMask.class,
! ByteMaxVector::new, ByteMaxVector.ByteMaxMask::new,
! ByteMaxVector.ByteMaxShuffle::new, ByteMaxVector.ByteMaxShuffle::new);
/**
* Preferred species for {@link ByteVector}s.
* A preferred species is a species of maximal bit size for the platform.
*/
! public static final VectorSpecies<Byte> SPECIES_PREFERRED = (VectorSpecies<Byte>) preferredSpecies();
}
< prev index next >