< prev index next >

src/jdk.incubator.vector/share/classes/jdk/incubator/vector/ShortVector.java

Print this page
rev 54658 : refactored mask and shuffle creation methods, moved classes to top-level

*** 54,84 **** short apply(int i, short a); } abstract ShortVector uOp(FUnOp f); ! abstract ShortVector uOp(Mask<Short> m, FUnOp f); // Binary operator interface FBinOp { short apply(int i, short a, short b); } abstract ShortVector bOp(Vector<Short> v, FBinOp f); ! abstract ShortVector bOp(Vector<Short> v, Mask<Short> m, FBinOp f); // Trinary operator interface FTriOp { short apply(int i, short a, short b, short c); } abstract ShortVector tOp(Vector<Short> v1, Vector<Short> v2, FTriOp f); ! abstract ShortVector tOp(Vector<Short> v1, Vector<Short> v2, Mask<Short> m, FTriOp f); // Reduction operator abstract short rOp(short v, FBinOp f); --- 54,84 ---- short apply(int i, short a); } abstract ShortVector uOp(FUnOp f); ! abstract ShortVector uOp(VectorMask<Short> m, FUnOp f); // Binary operator interface FBinOp { short apply(int i, short a, short b); } abstract ShortVector bOp(Vector<Short> v, FBinOp f); ! abstract ShortVector bOp(Vector<Short> v, VectorMask<Short> m, FBinOp f); // Trinary operator interface FTriOp { short apply(int i, short a, short b, short c); } abstract ShortVector tOp(Vector<Short> v1, Vector<Short> v2, FTriOp f); ! abstract ShortVector tOp(Vector<Short> v1, Vector<Short> v2, VectorMask<Short> m, FTriOp f); // Reduction operator abstract short rOp(short v, FBinOp f);
*** 86,106 **** interface FBinTest { boolean apply(int i, short a, short b); } ! abstract Mask<Short> bTest(Vector<Short> v, FBinTest f); // Foreach interface FUnCon { void apply(int i, short a); } abstract void forEach(FUnCon f); ! abstract void forEach(Mask<Short> m, FUnCon f); // Static factories /** * Returns a vector where all lane elements are set to the default --- 86,106 ---- interface FBinTest { boolean apply(int i, short a, short b); } ! abstract VectorMask<Short> bTest(Vector<Short> v, FBinTest f); // Foreach interface FUnCon { void apply(int i, short a); } abstract void forEach(FUnCon f); ! abstract void forEach(VectorMask<Short> m, FUnCon f); // Static factories /** * Returns a vector where all lane elements are set to the default
*** 109,119 **** * @param species species of desired vector * @return a zero vector of given species */ @ForceInline @SuppressWarnings("unchecked") ! public static ShortVector zero(Species<Short> species) { return VectorIntrinsics.broadcastCoerced((Class<ShortVector>) species.boxType(), short.class, species.length(), 0, species, ((bits, s) -> ((ShortSpecies)s).op(i -> (short)bits))); } --- 109,119 ---- * @param species species of desired vector * @return a zero vector of given species */ @ForceInline @SuppressWarnings("unchecked") ! public static ShortVector zero(VectorSpecies<Short> species) { return VectorIntrinsics.broadcastCoerced((Class<ShortVector>) species.boxType(), short.class, species.length(), 0, species, ((bits, s) -> ((ShortSpecies)s).op(i -> (short)bits))); }
*** 123,133 **** * 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<Short>, ByteBuffer, int, Mask) method} as follows: * <pre>{@code * return this.fromByteBuffer(ByteBuffer.wrap(a), i, this.maskAllTrue()); * }</pre> * * @param species species of desired vector --- 123,133 ---- * 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<Short>, ByteBuffer, int, VectorMask) method} as follows: * <pre>{@code * return this.fromByteBuffer(ByteBuffer.wrap(a), i, this.maskAllTrue()); * }</pre> * * @param species species of desired vector
*** 137,147 **** * @throws IndexOutOfBoundsException if {@code i < 0} or * {@code i > a.length - (this.length() * this.elementSize() / Byte.SIZE)} */ @ForceInline @SuppressWarnings("unchecked") ! public static ShortVector fromByteArray(Species<Short> species, byte[] a, int ix) { Objects.requireNonNull(a); ix = VectorIntrinsics.checkIndex(ix, a.length, species.bitSize() / Byte.SIZE); return VectorIntrinsics.load((Class<ShortVector>) species.boxType(), short.class, species.length(), a, ((long) ix) + Unsafe.ARRAY_BYTE_BASE_OFFSET, a, ix, species, --- 137,147 ---- * @throws IndexOutOfBoundsException if {@code i < 0} or * {@code i > a.length - (this.length() * this.elementSize() / Byte.SIZE)} */ @ForceInline @SuppressWarnings("unchecked") ! public static ShortVector fromByteArray(VectorSpecies<Short> species, byte[] a, int ix) { Objects.requireNonNull(a); ix = VectorIntrinsics.checkIndex(ix, a.length, species.bitSize() / Byte.SIZE); return VectorIntrinsics.load((Class<ShortVector>) species.boxType(), short.class, species.length(), a, ((long) ix) + Unsafe.ARRAY_BYTE_BASE_OFFSET, a, ix, species,
*** 159,169 **** * 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<Short>, ByteBuffer, int, Mask) method} as follows: * <pre>{@code * return this.fromByteBuffer(ByteBuffer.wrap(a), i, m); * }</pre> * * @param species species of desired vector --- 159,169 ---- * 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<Short>, ByteBuffer, int, VectorMask) method} as follows: * <pre>{@code * return this.fromByteBuffer(ByteBuffer.wrap(a), i, m); * }</pre> * * @param species species of desired vector
*** 178,188 **** * 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 ShortVector fromByteArray(Species<Short> species, byte[] a, int ix, Mask<Short> m) { return zero(species).blend(fromByteArray(species, a, ix), m); } /** * Loads a vector from an array starting at offset. --- 178,188 ---- * 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 ShortVector fromByteArray(VectorSpecies<Short> species, byte[] a, int ix, VectorMask<Short> m) { return zero(species).blend(fromByteArray(species, a, ix), m); } /** * Loads a vector from an array starting at offset.
*** 198,208 **** * @throws IndexOutOfBoundsException if {@code i < 0}, or * {@code i > a.length - this.length()} */ @ForceInline @SuppressWarnings("unchecked") ! public static ShortVector fromArray(Species<Short> species, short[] a, int i){ Objects.requireNonNull(a); i = VectorIntrinsics.checkIndex(i, a.length, species.length()); return VectorIntrinsics.load((Class<ShortVector>) species.boxType(), short.class, species.length(), a, (((long) i) << ARRAY_SHIFT) + Unsafe.ARRAY_SHORT_BASE_OFFSET, a, i, species, --- 198,208 ---- * @throws IndexOutOfBoundsException if {@code i < 0}, or * {@code i > a.length - this.length()} */ @ForceInline @SuppressWarnings("unchecked") ! public static ShortVector fromArray(VectorSpecies<Short> species, short[] a, int i){ Objects.requireNonNull(a); i = VectorIntrinsics.checkIndex(i, a.length, species.length()); return VectorIntrinsics.load((Class<ShortVector>) species.boxType(), short.class, species.length(), a, (((long) i) << ARRAY_SHIFT) + Unsafe.ARRAY_SHORT_BASE_OFFSET, a, i, species,
*** 227,237 **** * @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 ShortVector fromArray(Species<Short> species, short[] a, int i, Mask<Short> m) { return zero(species).blend(fromArray(species, a, i), m); } /** * Loads a vector from an array using indexes obtained from an index --- 227,237 ---- * @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 ShortVector fromArray(VectorSpecies<Short> species, short[] a, int i, VectorMask<Short> m) { return zero(species).blend(fromArray(species, a, i), m); } /** * Loads a vector from an array using indexes obtained from an index
*** 252,262 **** * @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 ShortVector fromArray(Species<Short> species, short[] a, int i, int[] indexMap, int j) { return ((ShortSpecies)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. --- 252,262 ---- * @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 ShortVector fromArray(VectorSpecies<Short> species, short[] a, int i, int[] indexMap, int j) { return ((ShortSpecies)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.
*** 279,289 **** * {@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 ShortVector fromArray(Species<Short> species, short[] a, int i, Mask<Short> m, int[] indexMap, int j) { return ((ShortSpecies)species).op(m, n -> a[i + indexMap[j + n]]); } /** * Loads a vector from a {@link ByteBuffer byte buffer} starting at an --- 279,289 ---- * {@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 ShortVector fromArray(VectorSpecies<Short> species, short[] a, int i, VectorMask<Short> m, int[] indexMap, int j) { return ((ShortSpecies)species).op(m, n -> a[i + indexMap[j + n]]); } /** * Loads a vector from a {@link ByteBuffer byte buffer} starting at an
*** 292,302 **** * 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<Short>, ByteBuffer, int, Mask)} method} as follows: * <pre>{@code * return this.fromByteBuffer(b, i, this.maskAllTrue()) * }</pre> * * @param species species of desired vector --- 292,302 ---- * 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<Short>, ByteBuffer, int, VectorMask)} method} as follows: * <pre>{@code * return this.fromByteBuffer(b, i, this.maskAllTrue()) * }</pre> * * @param species species of desired vector
*** 309,319 **** * {@code this.length() * this.elementSize() / Byte.SIZE} bytes * remaining in the byte buffer from the given offset */ @ForceInline @SuppressWarnings("unchecked") ! public static ShortVector fromByteBuffer(Species<Short> 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<ShortVector>) species.boxType(), short.class, species.length(), --- 309,319 ---- * {@code this.length() * this.elementSize() / Byte.SIZE} bytes * remaining in the byte buffer from the given offset */ @ForceInline @SuppressWarnings("unchecked") ! public static ShortVector fromByteBuffer(VectorSpecies<Short> 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<ShortVector>) species.boxType(), short.class, species.length(),
*** 361,371 **** * 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 ShortVector fromByteBuffer(Species<Short> species, ByteBuffer bb, int ix, Mask<Short> m) { return zero(species).blend(fromByteBuffer(species, bb, ix), m); } /** * Returns a vector where all lane elements are set to the primitive --- 361,371 ---- * 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 ShortVector fromByteBuffer(VectorSpecies<Short> species, ByteBuffer bb, int ix, VectorMask<Short> m) { return zero(species).blend(fromByteBuffer(species, bb, ix), m); } /** * Returns a vector where all lane elements are set to the primitive
*** 376,386 **** * @return a vector of vector where all lane elements are set to * the primitive value {@code e} */ @ForceInline @SuppressWarnings("unchecked") ! public static ShortVector broadcast(Species<Short> s, short e) { return VectorIntrinsics.broadcastCoerced( (Class<ShortVector>) s.boxType(), short.class, s.length(), e, s, ((bits, sp) -> ((ShortSpecies)sp).op(i -> (short)bits))); } --- 376,386 ---- * @return a vector of vector where all lane elements are set to * the primitive value {@code e} */ @ForceInline @SuppressWarnings("unchecked") ! public static ShortVector broadcast(VectorSpecies<Short> s, short e) { return VectorIntrinsics.broadcastCoerced( (Class<ShortVector>) s.boxType(), short.class, s.length(), e, s, ((bits, sp) -> ((ShortSpecies)sp).op(i -> (short)bits))); }
*** 399,409 **** * value * @throws IndexOutOfBoundsException if {@code es.length < this.length()} */ @ForceInline @SuppressWarnings("unchecked") ! public static ShortVector scalars(Species<Short> s, short... es) { Objects.requireNonNull(es); int ix = VectorIntrinsics.checkIndex(0, es.length, s.length()); return VectorIntrinsics.load((Class<ShortVector>) s.boxType(), short.class, s.length(), es, Unsafe.ARRAY_SHORT_BASE_OFFSET, es, ix, s, --- 399,409 ---- * value * @throws IndexOutOfBoundsException if {@code es.length < this.length()} */ @ForceInline @SuppressWarnings("unchecked") ! public static ShortVector scalars(VectorSpecies<Short> s, short... es) { Objects.requireNonNull(es); int ix = VectorIntrinsics.checkIndex(0, es.length, s.length()); return VectorIntrinsics.load((Class<ShortVector>) s.boxType(), short.class, s.length(), es, Unsafe.ARRAY_SHORT_BASE_OFFSET, es, ix, s,
*** 419,429 **** * @param e the value * @return a vector where the first lane element is set to the primitive * value {@code e} */ @ForceInline ! public static final ShortVector single(Species<Short> s, short e) { return zero(s).with(0, e); } /** * Returns a vector where each lane element is set to a randomly --- 419,429 ---- * @param e the value * @return a vector where the first lane element is set to the primitive * value {@code e} */ @ForceInline ! public static final ShortVector single(VectorSpecies<Short> s, short e) { return zero(s).with(0, e); } /** * Returns a vector where each lane element is set to a randomly
*** 434,672 **** * * @param s species of the desired vector * @return a vector where each lane elements is set to a randomly * generated primitive value */ ! public static ShortVector random(Species<Short> s) { ThreadLocalRandom r = ThreadLocalRandom.current(); return ((ShortSpecies)s).op(i -> (short) 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<Short> maskFromValues(Species<Short> species, boolean... bits) { - if (species.boxType() == ShortMaxVector.class) - return new ShortMaxVector.ShortMaxMask(bits); - switch (species.bitSize()) { - case 64: return new Short64Vector.Short64Mask(bits); - case 128: return new Short128Vector.Short128Mask(bits); - case 256: return new Short256Vector.Short256Mask(bits); - case 512: return new Short512Vector.Short512Mask(bits); - default: throw new IllegalArgumentException(Integer.toString(species.bitSize())); - } - } - - // @@@ This is a bad implementation -- makes lambdas capturing -- fix this - static Mask<Short> trueMask(Species<Short> species) { - if (species.boxType() == ShortMaxVector.class) - return ShortMaxVector.ShortMaxMask.TRUE_MASK; - switch (species.bitSize()) { - case 64: return Short64Vector.Short64Mask.TRUE_MASK; - case 128: return Short128Vector.Short128Mask.TRUE_MASK; - case 256: return Short256Vector.Short256Mask.TRUE_MASK; - case 512: return Short512Vector.Short512Mask.TRUE_MASK; - default: throw new IllegalArgumentException(Integer.toString(species.bitSize())); - } - } - - static Mask<Short> falseMask(Species<Short> species) { - if (species.boxType() == ShortMaxVector.class) - return ShortMaxVector.ShortMaxMask.FALSE_MASK; - switch (species.bitSize()) { - case 64: return Short64Vector.Short64Mask.FALSE_MASK; - case 128: return Short128Vector.Short128Mask.FALSE_MASK; - case 256: return Short256Vector.Short256Mask.FALSE_MASK; - case 512: return Short512Vector.Short512Mask.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<Short> maskFromArray(Species<Short> species, boolean[] bits, int ix) { - Objects.requireNonNull(bits); - ix = VectorIntrinsics.checkIndex(ix, bits.length, species.length()); - return VectorIntrinsics.load((Class<Mask<Short>>) species.maskType(), short.class, species.length(), - bits, (((long) ix) << ARRAY_SHIFT) + Unsafe.ARRAY_BOOLEAN_BASE_OFFSET, - bits, ix, species, - (c, idx, s) -> (Mask<Short>) ((ShortSpecies)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<Short> maskAllTrue(Species<Short> species) { - return VectorIntrinsics.broadcastCoerced((Class<Mask<Short>>) species.maskType(), short.class, species.length(), - (short)-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<Short> maskAllFalse(Species<Short> species) { - return VectorIntrinsics.broadcastCoerced((Class<Mask<Short>>) species.maskType(), short.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<Short> shuffle(Species<Short> species, IntUnaryOperator f) { - if (species.boxType() == ShortMaxVector.class) - return new ShortMaxVector.ShortMaxShuffle(f); - switch (species.bitSize()) { - case 64: return new Short64Vector.Short64Shuffle(f); - case 128: return new Short128Vector.Short128Shuffle(f); - case 256: return new Short256Vector.Short256Shuffle(f); - case 512: return new Short512Vector.Short512Shuffle(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<Short> shuffleIota(Species<Short> species) { - if (species.boxType() == ShortMaxVector.class) - return new ShortMaxVector.ShortMaxShuffle(AbstractShuffle.IDENTITY); - switch (species.bitSize()) { - case 64: return new Short64Vector.Short64Shuffle(AbstractShuffle.IDENTITY); - case 128: return new Short128Vector.Short128Shuffle(AbstractShuffle.IDENTITY); - case 256: return new Short256Vector.Short256Shuffle(AbstractShuffle.IDENTITY); - case 512: return new Short512Vector.Short512Shuffle(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<Short> shuffleFromValues(Species<Short> species, int... ixs) { - if (species.boxType() == ShortMaxVector.class) - return new ShortMaxVector.ShortMaxShuffle(ixs); - switch (species.bitSize()) { - case 64: return new Short64Vector.Short64Shuffle(ixs); - case 128: return new Short128Vector.Short128Shuffle(ixs); - case 256: return new Short256Vector.Short256Shuffle(ixs); - case 512: return new Short512Vector.Short512Shuffle(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<Short> shuffleFromArray(Species<Short> species, int[] ixs, int i) { - if (species.boxType() == ShortMaxVector.class) - return new ShortMaxVector.ShortMaxShuffle(ixs, i); - switch (species.bitSize()) { - case 64: return new Short64Vector.Short64Shuffle(ixs, i); - case 128: return new Short128Vector.Short128Shuffle(ixs, i); - case 256: return new Short256Vector.Short256Shuffle(ixs, i); - case 512: return new Short512Vector.Short512Shuffle(ixs, i); - default: throw new IllegalArgumentException(Integer.toString(species.bitSize())); - } - } - // Ops @Override public abstract ShortVector add(Vector<Short> v); --- 434,448 ---- * * @param s species of the desired vector * @return a vector where each lane elements is set to a randomly * generated primitive value */ ! public static ShortVector random(VectorSpecies<Short> s) { ThreadLocalRandom r = ThreadLocalRandom.current(); return ((ShortSpecies)s).op(i -> (short) r.nextInt()); } // Ops @Override public abstract ShortVector add(Vector<Short> v);
*** 681,691 **** * scalar */ public abstract ShortVector add(short s); @Override ! public abstract ShortVector add(Vector<Short> v, Mask<Short> m); /** * Adds this vector to broadcast of an input scalar, * selecting lane elements controlled by a mask. * <p> --- 457,467 ---- * scalar */ public abstract ShortVector add(short s); @Override ! public abstract ShortVector add(Vector<Short> v, VectorMask<Short> m); /** * Adds this vector to broadcast of an input scalar, * selecting lane elements controlled by a mask. * <p>
*** 695,705 **** * @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 ShortVector add(short s, Mask<Short> m); @Override public abstract ShortVector sub(Vector<Short> v); /** --- 471,481 ---- * @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 ShortVector add(short s, VectorMask<Short> m); @Override public abstract ShortVector sub(Vector<Short> v); /**
*** 713,723 **** * scalar from this vector */ public abstract ShortVector sub(short s); @Override ! public abstract ShortVector sub(Vector<Short> v, Mask<Short> m); /** * Subtracts the broadcast of an input scalar from this vector, selecting * lane elements controlled by a mask. * <p> --- 489,499 ---- * scalar from this vector */ public abstract ShortVector sub(short s); @Override ! public abstract ShortVector sub(Vector<Short> v, VectorMask<Short> m); /** * Subtracts the broadcast of an input scalar from this vector, selecting * lane elements controlled by a mask. * <p>
*** 727,737 **** * @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 ShortVector sub(short s, Mask<Short> m); @Override public abstract ShortVector mul(Vector<Short> v); /** --- 503,513 ---- * @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 ShortVector sub(short s, VectorMask<Short> m); @Override public abstract ShortVector mul(Vector<Short> v); /**
*** 745,755 **** * input scalar */ public abstract ShortVector mul(short s); @Override ! public abstract ShortVector mul(Vector<Short> v, Mask<Short> m); /** * Multiplies this vector with the broadcast of an input scalar, selecting * lane elements controlled by a mask. * <p> --- 521,531 ---- * input scalar */ public abstract ShortVector mul(short s); @Override ! public abstract ShortVector mul(Vector<Short> v, VectorMask<Short> m); /** * Multiplies this vector with the broadcast of an input scalar, selecting * lane elements controlled by a mask. * <p>
*** 759,787 **** * @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 ShortVector mul(short s, Mask<Short> m); @Override public abstract ShortVector neg(); @Override ! public abstract ShortVector neg(Mask<Short> m); @Override public abstract ShortVector abs(); @Override ! public abstract ShortVector abs(Mask<Short> m); @Override public abstract ShortVector min(Vector<Short> v); @Override ! public abstract ShortVector min(Vector<Short> v, Mask<Short> m); /** * Returns the minimum of this vector and the broadcast of an input scalar. * <p> * This is a vector binary operation where the operation --- 535,563 ---- * @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 ShortVector mul(short s, VectorMask<Short> m); @Override public abstract ShortVector neg(); @Override ! public abstract ShortVector neg(VectorMask<Short> m); @Override public abstract ShortVector abs(); @Override ! public abstract ShortVector abs(VectorMask<Short> m); @Override public abstract ShortVector min(Vector<Short> v); @Override ! public abstract ShortVector min(Vector<Short> v, VectorMask<Short> m); /** * Returns the minimum of this vector and the broadcast of an input scalar. * <p> * This is a vector binary operation where the operation
*** 794,804 **** @Override public abstract ShortVector max(Vector<Short> v); @Override ! public abstract ShortVector max(Vector<Short> v, Mask<Short> m); /** * Returns the maximum of this vector and the broadcast of an input scalar. * <p> * This is a vector binary operation where the operation --- 570,580 ---- @Override public abstract ShortVector max(Vector<Short> v); @Override ! public abstract ShortVector max(Vector<Short> v, VectorMask<Short> m); /** * Returns the maximum of this vector and the broadcast of an input scalar. * <p> * This is a vector binary operation where the operation
*** 808,818 **** * @return the maximum of this vector and the broadcast of an input scalar */ public abstract ShortVector max(short s); @Override ! public abstract Mask<Short> equal(Vector<Short> 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 --- 584,594 ---- * @return the maximum of this vector and the broadcast of an input scalar */ public abstract ShortVector max(short s); @Override ! public abstract VectorMask<Short> equal(Vector<Short> 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
*** 820,833 **** * * @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<Short> equal(short s); @Override ! public abstract Mask<Short> notEqual(Vector<Short> 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 --- 596,609 ---- * * @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<Short> equal(short s); @Override ! public abstract VectorMask<Short> notEqual(Vector<Short> 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
*** 835,848 **** * * @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<Short> notEqual(short s); @Override ! public abstract Mask<Short> lessThan(Vector<Short> 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 --- 611,624 ---- * * @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<Short> notEqual(short s); @Override ! public abstract VectorMask<Short> lessThan(Vector<Short> 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
*** 850,863 **** * * @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<Short> lessThan(short s); @Override ! public abstract Mask<Short> lessThanEq(Vector<Short> 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 --- 626,639 ---- * * @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<Short> lessThan(short s); @Override ! public abstract VectorMask<Short> lessThanEq(Vector<Short> 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
*** 865,878 **** * * @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<Short> lessThanEq(short s); @Override ! public abstract Mask<Short> greaterThan(Vector<Short> 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 --- 641,654 ---- * * @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<Short> lessThanEq(short s); @Override ! public abstract VectorMask<Short> greaterThan(Vector<Short> 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
*** 880,893 **** * * @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<Short> greaterThan(short s); @Override ! public abstract Mask<Short> greaterThanEq(Vector<Short> v); /** * Tests if this vector is greater than or equal to the broadcast of an * input scalar. * <p> --- 656,669 ---- * * @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<Short> greaterThan(short s); @Override ! public abstract VectorMask<Short> greaterThanEq(Vector<Short> v); /** * Tests if this vector is greater than or equal to the broadcast of an * input scalar. * <p>
*** 896,909 **** * * @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<Short> greaterThanEq(short s); @Override ! public abstract ShortVector blend(Vector<Short> v, Mask<Short> m); /** * Blends the lane elements of this vector with those of the broadcast of an * input scalar, selecting lanes controlled by a mask. * <p> --- 672,685 ---- * * @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<Short> greaterThanEq(short s); @Override ! public abstract ShortVector blend(Vector<Short> v, VectorMask<Short> m); /** * Blends the lane elements of this vector with those of the broadcast of an * input scalar, selecting lanes controlled by a mask. * <p>
*** 916,936 **** * @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 ShortVector blend(short s, Mask<Short> m); @Override public abstract ShortVector rearrange(Vector<Short> v, ! Shuffle<Short> s, Mask<Short> m); @Override ! public abstract ShortVector rearrange(Shuffle<Short> m); @Override ! public abstract ShortVector reshape(Species<Short> s); @Override public abstract ShortVector rotateEL(int i); @Override --- 692,712 ---- * @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 ShortVector blend(short s, VectorMask<Short> m); @Override public abstract ShortVector rearrange(Vector<Short> v, ! VectorShuffle<Short> s, VectorMask<Short> m); @Override ! public abstract ShortVector rearrange(VectorShuffle<Short> m); @Override ! public abstract ShortVector reshape(VectorSpecies<Short> s); @Override public abstract ShortVector rotateEL(int i); @Override
*** 976,986 **** * * @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 ShortVector and(Vector<Short> v, Mask<Short> m); /** * Bitwise ANDs this vector with the broadcast of an input scalar, selecting * lane elements controlled by a mask. * <p> --- 752,762 ---- * * @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 ShortVector and(Vector<Short> v, VectorMask<Short> m); /** * Bitwise ANDs this vector with the broadcast of an input scalar, selecting * lane elements controlled by a mask. * <p>
*** 990,1000 **** * @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 ShortVector and(short s, Mask<Short> m); /** * Bitwise ORs this vector with an input vector. * <p> * This is a vector binary operation where the primitive bitwise OR --- 766,776 ---- * @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 ShortVector and(short s, VectorMask<Short> m); /** * Bitwise ORs this vector with an input vector. * <p> * This is a vector binary operation where the primitive bitwise OR
*** 1026,1036 **** * * @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 ShortVector or(Vector<Short> v, Mask<Short> m); /** * Bitwise ORs this vector with the broadcast of an input scalar, selecting * lane elements controlled by a mask. * <p> --- 802,812 ---- * * @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 ShortVector or(Vector<Short> v, VectorMask<Short> m); /** * Bitwise ORs this vector with the broadcast of an input scalar, selecting * lane elements controlled by a mask. * <p>
*** 1040,1050 **** * @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 ShortVector or(short s, Mask<Short> m); /** * Bitwise XORs this vector with an input vector. * <p> * This is a vector binary operation where the primitive bitwise XOR --- 816,826 ---- * @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 ShortVector or(short s, VectorMask<Short> m); /** * Bitwise XORs this vector with an input vector. * <p> * This is a vector binary operation where the primitive bitwise XOR
*** 1076,1086 **** * * @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 ShortVector xor(Vector<Short> v, Mask<Short> m); /** * Bitwise XORs this vector with the broadcast of an input scalar, selecting * lane elements controlled by a mask. * <p> --- 852,862 ---- * * @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 ShortVector xor(Vector<Short> v, VectorMask<Short> m); /** * Bitwise XORs this vector with the broadcast of an input scalar, selecting * lane elements controlled by a mask. * <p>
*** 1090,1100 **** * @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 ShortVector xor(short s, Mask<Short> m); /** * Bitwise NOTs this vector. * <p> * This is a vector unary operation where the primitive bitwise NOT --- 866,876 ---- * @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 ShortVector xor(short s, VectorMask<Short> m); /** * Bitwise NOTs this vector. * <p> * This is a vector unary operation where the primitive bitwise NOT
*** 1111,1121 **** * operation ({@code ~}) is applied to lane elements. * * @param m the mask controlling lane selection * @return the bitwise NOT of this vector */ ! public abstract ShortVector not(Mask<Short> 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 --- 887,897 ---- * operation ({@code ~}) is applied to lane elements. * * @param m the mask controlling lane selection * @return the bitwise NOT of this vector */ ! public abstract ShortVector not(VectorMask<Short> 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
*** 1145,1155 **** * @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 ShortVector shiftL(int s, Mask<Short> m); // logical, or unsigned, shift right /** --- 921,931 ---- * @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 ShortVector shiftL(int s, VectorMask<Short> m); // logical, or unsigned, shift right /**
*** 1184,1194 **** * @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 ShortVector shiftR(int s, Mask<Short> m); /** * Arithmetically right shifts (or signed right shifts) this vector by the * broadcast of an input scalar. --- 960,970 ---- * @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 ShortVector shiftR(int s, VectorMask<Short> m); /** * Arithmetically right shifts (or signed right shifts) this vector by the * broadcast of an input scalar.
*** 1221,1244 **** * @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 ShortVector aShiftR(int s, Mask<Short> m); @Override public abstract void intoByteArray(byte[] a, int ix); @Override ! public abstract void intoByteArray(byte[] a, int ix, Mask<Short> m); @Override public abstract void intoByteBuffer(ByteBuffer bb, int ix); @Override ! public abstract void intoByteBuffer(ByteBuffer bb, int ix, Mask<Short> m); // Type specific horizontal reductions /** * Adds all lane elements of this vector. --- 997,1020 ---- * @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 ShortVector aShiftR(int s, VectorMask<Short> m); @Override public abstract void intoByteArray(byte[] a, int ix); @Override ! public abstract void intoByteArray(byte[] a, int ix, VectorMask<Short> m); @Override public abstract void intoByteBuffer(ByteBuffer bb, int ix); @Override ! public abstract void intoByteBuffer(ByteBuffer bb, int ix, VectorMask<Short> m); // Type specific horizontal reductions /** * Adds all lane elements of this vector.
*** 1260,1270 **** * 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 short addAll(Mask<Short> m); /** * Multiplies all lane elements of this vector. * <p> * This is an associative vector reduction operation where the --- 1036,1046 ---- * 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 short addAll(VectorMask<Short> m); /** * Multiplies all lane elements of this vector. * <p> * This is an associative vector reduction operation where the
*** 1284,1294 **** * 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 short mulAll(Mask<Short> m); /** * Returns the minimum lane element of this vector. * <p> * This is an associative vector reduction operation where the operation --- 1060,1070 ---- * 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 short mulAll(VectorMask<Short> m); /** * Returns the minimum lane element of this vector. * <p> * This is an associative vector reduction operation where the operation
*** 1310,1320 **** * {@link Short#MAX_VALUE}. * * @param m the mask controlling lane selection * @return the minimum lane element of this vector */ ! public abstract short minAll(Mask<Short> m); /** * Returns the maximum lane element of this vector. * <p> * This is an associative vector reduction operation where the operation --- 1086,1096 ---- * {@link Short#MAX_VALUE}. * * @param m the mask controlling lane selection * @return the minimum lane element of this vector */ ! public abstract short minAll(VectorMask<Short> m); /** * Returns the maximum lane element of this vector. * <p> * This is an associative vector reduction operation where the operation
*** 1336,1346 **** * {@link Short#MIN_VALUE}. * * @param m the mask controlling lane selection * @return the maximum lane element of this vector */ ! public abstract short maxAll(Mask<Short> m); /** * Logically ORs all lane elements of this vector. * <p> * This is an associative vector reduction operation where the logical OR --- 1112,1122 ---- * {@link Short#MIN_VALUE}. * * @param m the mask controlling lane selection * @return the maximum lane element of this vector */ ! public abstract short maxAll(VectorMask<Short> m); /** * Logically ORs all lane elements of this vector. * <p> * This is an associative vector reduction operation where the logical OR
*** 1360,1370 **** * 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 short orAll(Mask<Short> m); /** * Logically ANDs all lane elements of this vector. * <p> * This is an associative vector reduction operation where the logical AND --- 1136,1146 ---- * 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 short orAll(VectorMask<Short> m); /** * Logically ANDs all lane elements of this vector. * <p> * This is an associative vector reduction operation where the logical AND
*** 1384,1394 **** * 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 short andAll(Mask<Short> m); /** * Logically XORs all lane elements of this vector. * <p> * This is an associative vector reduction operation where the logical XOR --- 1160,1170 ---- * 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 short andAll(VectorMask<Short> m); /** * Logically XORs all lane elements of this vector. * <p> * This is an associative vector reduction operation where the logical XOR
*** 1408,1418 **** * 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 short xorAll(Mask<Short> m); // Type specific accessors /** * Gets the lane element at lane index {@code i} --- 1184,1194 ---- * 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 short xorAll(VectorMask<Short> m); // Type specific accessors /** * Gets the lane element at lane index {@code i}
*** 1490,1500 **** * @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(short[] a, int i, Mask<Short> m); /** * Stores this vector into an array using indexes obtained from an index * map. * <p> --- 1266,1276 ---- * @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(short[] a, int i, VectorMask<Short> m); /** * Stores this vector into an array using indexes obtained from an index * map. * <p>
*** 1537,1605 **** * {@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(short[] a, int i, Mask<Short> m, int[] indexMap, int j) { forEach(m, (n, e) -> a[i + indexMap[j + n]] = e); } // Species @Override ! public abstract Species<Short> species(); /** ! * Class representing {@link ShortVector}'s of the same {@link Vector.Shape Shape}. */ ! static final class ShortSpecies extends Vector.AbstractSpecies<Short> { final Function<short[], ShortVector> vectorFactory; - final Function<boolean[], Vector.Mask<Short>> maskFactory; ! private ShortSpecies(Vector.Shape shape, Class<?> boxType, Class<?> maskType, Function<short[], ShortVector> vectorFactory, ! Function<boolean[], Vector.Mask<Short>> maskFactory) { ! super(shape, short.class, Short.SIZE, boxType, maskType); this.vectorFactory = vectorFactory; - this.maskFactory = maskFactory; } interface FOp { short apply(int i); } - interface FOpm { - boolean apply(int i); - } - ShortVector op(FOp f) { short[] res = new short[length()]; for (int i = 0; i < length(); i++) { res[i] = f.apply(i); } return vectorFactory.apply(res); } ! ShortVector op(Vector.Mask<Short> o, FOp f) { short[] res = new short[length()]; boolean[] mbits = ((AbstractMask<Short>)o).getBits(); for (int i = 0; i < length(); i++) { if (mbits[i]) { res[i] = f.apply(i); } } return vectorFactory.apply(res); } - - Vector.Mask<Short> 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 short}. * <p> --- 1313,1370 ---- * {@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(short[] a, int i, VectorMask<Short> m, int[] indexMap, int j) { forEach(m, (n, e) -> a[i + indexMap[j + n]] = e); } // Species @Override ! public abstract VectorSpecies<Short> species(); /** ! * Class representing {@link ShortVector}'s of the same {@link VectorShape VectorShape}. */ ! static final class ShortSpecies extends AbstractSpecies<Short> { final Function<short[], ShortVector> vectorFactory; ! private ShortSpecies(VectorShape shape, Class<?> boxType, Class<?> maskType, Function<short[], ShortVector> vectorFactory, ! Function<boolean[], VectorMask<Short>> maskFactory, ! Function<IntUnaryOperator, VectorShuffle<Short>> shuffleFromArrayFactory, ! fShuffleFromArray<Short> shuffleFromOpFactory) { ! super(shape, short.class, Short.SIZE, boxType, maskType, maskFactory, ! shuffleFromArrayFactory, shuffleFromOpFactory); this.vectorFactory = vectorFactory; } interface FOp { short apply(int i); } ShortVector op(FOp f) { short[] res = new short[length()]; for (int i = 0; i < length(); i++) { res[i] = f.apply(i); } return vectorFactory.apply(res); } ! ShortVector op(VectorMask<Short> o, FOp f) { short[] res = new short[length()]; boolean[] mbits = ((AbstractMask<Short>)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 short}. * <p>
*** 1609,1629 **** * shuffles created from such species will be shape compatible. * * @return the preferred species for an element type of {@code short} */ private static ShortSpecies preferredSpecies() { ! return (ShortSpecies) Species.ofPreferred(short.class); } /** * Finds a species for an element type of {@code short} and shape. * * @param s the shape * @return a species for an element type of {@code short} and shape * @throws IllegalArgumentException if no such species exists for the shape */ ! static ShortSpecies species(Vector.Shape s) { Objects.requireNonNull(s); switch (s) { case S_64_BIT: return (ShortSpecies) SPECIES_64; case S_128_BIT: return (ShortSpecies) SPECIES_128; case S_256_BIT: return (ShortSpecies) SPECIES_256; --- 1374,1394 ---- * shuffles created from such species will be shape compatible. * * @return the preferred species for an element type of {@code short} */ private static ShortSpecies preferredSpecies() { ! return (ShortSpecies) VectorSpecies.ofPreferred(short.class); } /** * Finds a species for an element type of {@code short} and shape. * * @param s the shape * @return a species for an element type of {@code short} and shape * @throws IllegalArgumentException if no such species exists for the shape */ ! static ShortSpecies species(VectorShape s) { Objects.requireNonNull(s); switch (s) { case S_64_BIT: return (ShortSpecies) SPECIES_64; case S_128_BIT: return (ShortSpecies) SPECIES_128; case S_256_BIT: return (ShortSpecies) SPECIES_256;
*** 1631,1661 **** case S_Max_BIT: return (ShortSpecies) SPECIES_MAX; default: throw new IllegalArgumentException("Bad shape: " + s); } } ! /** Species representing {@link ShortVector}s of {@link Vector.Shape#S_64_BIT Shape.S_64_BIT}. */ ! public static final Species<Short> SPECIES_64 = new ShortSpecies(Shape.S_64_BIT, Short64Vector.class, Short64Vector.Short64Mask.class, ! Short64Vector::new, Short64Vector.Short64Mask::new); ! ! /** Species representing {@link ShortVector}s of {@link Vector.Shape#S_128_BIT Shape.S_128_BIT}. */ ! public static final Species<Short> SPECIES_128 = new ShortSpecies(Shape.S_128_BIT, Short128Vector.class, Short128Vector.Short128Mask.class, ! Short128Vector::new, Short128Vector.Short128Mask::new); ! ! /** Species representing {@link ShortVector}s of {@link Vector.Shape#S_256_BIT Shape.S_256_BIT}. */ ! public static final Species<Short> SPECIES_256 = new ShortSpecies(Shape.S_256_BIT, Short256Vector.class, Short256Vector.Short256Mask.class, ! Short256Vector::new, Short256Vector.Short256Mask::new); ! ! /** Species representing {@link ShortVector}s of {@link Vector.Shape#S_512_BIT Shape.S_512_BIT}. */ ! public static final Species<Short> SPECIES_512 = new ShortSpecies(Shape.S_512_BIT, Short512Vector.class, Short512Vector.Short512Mask.class, ! Short512Vector::new, Short512Vector.Short512Mask::new); ! ! /** Species representing {@link ShortVector}s of {@link Vector.Shape#S_Max_BIT Shape.S_Max_BIT}. */ ! public static final Species<Short> SPECIES_MAX = new ShortSpecies(Shape.S_Max_BIT, ShortMaxVector.class, ShortMaxVector.ShortMaxMask.class, ! ShortMaxVector::new, ShortMaxVector.ShortMaxMask::new); /** * Preferred species for {@link ShortVector}s. * A preferred species is a species of maximal bit size for the platform. */ ! public static final Species<Short> SPECIES_PREFERRED = (Species<Short>) preferredSpecies(); } --- 1396,1431 ---- case S_Max_BIT: return (ShortSpecies) SPECIES_MAX; default: throw new IllegalArgumentException("Bad shape: " + s); } } ! /** Species representing {@link ShortVector}s of {@link VectorShape#S_64_BIT VectorShape.S_64_BIT}. */ ! public static final VectorSpecies<Short> SPECIES_64 = new ShortSpecies(VectorShape.S_64_BIT, Short64Vector.class, Short64Vector.Short64Mask.class, ! Short64Vector::new, Short64Vector.Short64Mask::new, ! Short64Vector.Short64Shuffle::new, Short64Vector.Short64Shuffle::new); ! ! /** Species representing {@link ShortVector}s of {@link VectorShape#S_128_BIT VectorShape.S_128_BIT}. */ ! public static final VectorSpecies<Short> SPECIES_128 = new ShortSpecies(VectorShape.S_128_BIT, Short128Vector.class, Short128Vector.Short128Mask.class, ! Short128Vector::new, Short128Vector.Short128Mask::new, ! Short128Vector.Short128Shuffle::new, Short128Vector.Short128Shuffle::new); ! ! /** Species representing {@link ShortVector}s of {@link VectorShape#S_256_BIT VectorShape.S_256_BIT}. */ ! public static final VectorSpecies<Short> SPECIES_256 = new ShortSpecies(VectorShape.S_256_BIT, Short256Vector.class, Short256Vector.Short256Mask.class, ! Short256Vector::new, Short256Vector.Short256Mask::new, ! Short256Vector.Short256Shuffle::new, Short256Vector.Short256Shuffle::new); ! ! /** Species representing {@link ShortVector}s of {@link VectorShape#S_512_BIT VectorShape.S_512_BIT}. */ ! public static final VectorSpecies<Short> SPECIES_512 = new ShortSpecies(VectorShape.S_512_BIT, Short512Vector.class, Short512Vector.Short512Mask.class, ! Short512Vector::new, Short512Vector.Short512Mask::new, ! Short512Vector.Short512Shuffle::new, Short512Vector.Short512Shuffle::new); ! ! /** Species representing {@link ShortVector}s of {@link VectorShape#S_Max_BIT VectorShape.S_Max_BIT}. */ ! public static final VectorSpecies<Short> SPECIES_MAX = new ShortSpecies(VectorShape.S_Max_BIT, ShortMaxVector.class, ShortMaxVector.ShortMaxMask.class, ! ShortMaxVector::new, ShortMaxVector.ShortMaxMask::new, ! ShortMaxVector.ShortMaxShuffle::new, ShortMaxVector.ShortMaxShuffle::new); /** * Preferred species for {@link ShortVector}s. * A preferred species is a species of maximal bit size for the platform. */ ! public static final VectorSpecies<Short> SPECIES_PREFERRED = (VectorSpecies<Short>) preferredSpecies(); }
< prev index next >