< prev index next >

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

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

*** 54,84 **** float apply(int i, float a); } abstract FloatVector uOp(FUnOp f); ! abstract FloatVector uOp(Mask<Float> m, FUnOp f); // Binary operator interface FBinOp { float apply(int i, float a, float b); } abstract FloatVector bOp(Vector<Float> v, FBinOp f); ! abstract FloatVector bOp(Vector<Float> v, Mask<Float> m, FBinOp f); // Trinary operator interface FTriOp { float apply(int i, float a, float b, float c); } abstract FloatVector tOp(Vector<Float> v1, Vector<Float> v2, FTriOp f); ! abstract FloatVector tOp(Vector<Float> v1, Vector<Float> v2, Mask<Float> m, FTriOp f); // Reduction operator abstract float rOp(float v, FBinOp f); --- 54,84 ---- float apply(int i, float a); } abstract FloatVector uOp(FUnOp f); ! abstract FloatVector uOp(VectorMask<Float> m, FUnOp f); // Binary operator interface FBinOp { float apply(int i, float a, float b); } abstract FloatVector bOp(Vector<Float> v, FBinOp f); ! abstract FloatVector bOp(Vector<Float> v, VectorMask<Float> m, FBinOp f); // Trinary operator interface FTriOp { float apply(int i, float a, float b, float c); } abstract FloatVector tOp(Vector<Float> v1, Vector<Float> v2, FTriOp f); ! abstract FloatVector tOp(Vector<Float> v1, Vector<Float> v2, VectorMask<Float> m, FTriOp f); // Reduction operator abstract float rOp(float v, FBinOp f);
*** 86,106 **** interface FBinTest { boolean apply(int i, float a, float b); } ! abstract Mask<Float> bTest(Vector<Float> v, FBinTest f); // Foreach interface FUnCon { void apply(int i, float a); } abstract void forEach(FUnCon f); ! abstract void forEach(Mask<Float> 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, float a, float b); } ! abstract VectorMask<Float> bTest(Vector<Float> v, FBinTest f); // Foreach interface FUnCon { void apply(int i, float a); } abstract void forEach(FUnCon f); ! abstract void forEach(VectorMask<Float> 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 FloatVector zero(Species<Float> species) { return VectorIntrinsics.broadcastCoerced((Class<FloatVector>) species.boxType(), float.class, species.length(), Float.floatToIntBits(0.0f), species, ((bits, s) -> ((FloatSpecies)s).op(i -> Float.intBitsToFloat((int)bits)))); } --- 109,119 ---- * @param species species of desired vector * @return a zero vector of given species */ @ForceInline @SuppressWarnings("unchecked") ! public static FloatVector zero(VectorSpecies<Float> species) { return VectorIntrinsics.broadcastCoerced((Class<FloatVector>) species.boxType(), float.class, species.length(), Float.floatToIntBits(0.0f), species, ((bits, s) -> ((FloatSpecies)s).op(i -> Float.intBitsToFloat((int)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<Float>, 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<Float>, 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 FloatVector fromByteArray(Species<Float> species, byte[] a, int ix) { Objects.requireNonNull(a); ix = VectorIntrinsics.checkIndex(ix, a.length, species.bitSize() / Byte.SIZE); return VectorIntrinsics.load((Class<FloatVector>) species.boxType(), float.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 FloatVector fromByteArray(VectorSpecies<Float> species, byte[] a, int ix) { Objects.requireNonNull(a); ix = VectorIntrinsics.checkIndex(ix, a.length, species.bitSize() / Byte.SIZE); return VectorIntrinsics.load((Class<FloatVector>) species.boxType(), float.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<Float>, 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<Float>, 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 FloatVector fromByteArray(Species<Float> species, byte[] a, int ix, Mask<Float> 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 FloatVector fromByteArray(VectorSpecies<Float> species, byte[] a, int ix, VectorMask<Float> 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 FloatVector fromArray(Species<Float> species, float[] a, int i){ Objects.requireNonNull(a); i = VectorIntrinsics.checkIndex(i, a.length, species.length()); return VectorIntrinsics.load((Class<FloatVector>) species.boxType(), float.class, species.length(), a, (((long) i) << ARRAY_SHIFT) + Unsafe.ARRAY_FLOAT_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 FloatVector fromArray(VectorSpecies<Float> species, float[] a, int i){ Objects.requireNonNull(a); i = VectorIntrinsics.checkIndex(i, a.length, species.length()); return VectorIntrinsics.load((Class<FloatVector>) species.boxType(), float.class, species.length(), a, (((long) i) << ARRAY_SHIFT) + Unsafe.ARRAY_FLOAT_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 FloatVector fromArray(Species<Float> species, float[] a, int i, Mask<Float> 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 FloatVector fromArray(VectorSpecies<Float> species, float[] a, int i, VectorMask<Float> m) { return zero(species).blend(fromArray(species, a, i), m); } /** * Loads a vector from an array using indexes obtained from an index
*** 254,264 **** * or for any vector lane index {@code N} the result of * {@code i + indexMap[j + N]} is {@code < 0} or {@code >= a.length} */ @ForceInline @SuppressWarnings("unchecked") ! public static FloatVector fromArray(Species<Float> species, float[] a, int i, int[] indexMap, int j) { Objects.requireNonNull(a); Objects.requireNonNull(indexMap); // Index vector: vix[0:n] = k -> i + indexMap[j + k] --- 254,264 ---- * or for any vector lane index {@code N} the result of * {@code i + indexMap[j + N]} is {@code < 0} or {@code >= a.length} */ @ForceInline @SuppressWarnings("unchecked") ! public static FloatVector fromArray(VectorSpecies<Float> species, float[] a, int i, int[] indexMap, int j) { Objects.requireNonNull(a); Objects.requireNonNull(indexMap); // Index vector: vix[0:n] = k -> i + indexMap[j + k]
*** 267,277 **** vix = VectorIntrinsics.checkIndex(vix, a.length); return VectorIntrinsics.loadWithMap((Class<FloatVector>) species.boxType(), float.class, species.length(), IntVector.species(species.indexShape()).boxType(), a, Unsafe.ARRAY_FLOAT_BASE_OFFSET, vix, a, i, indexMap, j, species, ! (float[] c, int idx, int[] iMap, int idy, Species<Float> s) -> ((FloatSpecies)s).op(n -> c[idx + iMap[idy+n]])); } /** * Loads a vector from an array using indexes obtained from an index --- 267,277 ---- vix = VectorIntrinsics.checkIndex(vix, a.length); return VectorIntrinsics.loadWithMap((Class<FloatVector>) species.boxType(), float.class, species.length(), IntVector.species(species.indexShape()).boxType(), a, Unsafe.ARRAY_FLOAT_BASE_OFFSET, vix, a, i, indexMap, j, species, ! (float[] c, int idx, int[] iMap, int idy, VectorSpecies<Float> s) -> ((FloatSpecies)s).op(n -> c[idx + iMap[idy+n]])); } /** * Loads a vector from an array using indexes obtained from an index
*** 297,307 **** * {@code N} is set the result of {@code i + indexMap[j + N]} is * {@code < 0} or {@code >= a.length} */ @ForceInline @SuppressWarnings("unchecked") ! public static FloatVector fromArray(Species<Float> species, float[] a, int i, Mask<Float> m, int[] indexMap, int j) { // @@@ This can result in out of bounds errors for unset mask lanes return zero(species).blend(fromArray(species, a, i, indexMap, j), m); } --- 297,307 ---- * {@code N} is set the result of {@code i + indexMap[j + N]} is * {@code < 0} or {@code >= a.length} */ @ForceInline @SuppressWarnings("unchecked") ! public static FloatVector fromArray(VectorSpecies<Float> species, float[] a, int i, VectorMask<Float> m, int[] indexMap, int j) { // @@@ This can result in out of bounds errors for unset mask lanes return zero(species).blend(fromArray(species, a, i, indexMap, j), m); }
*** 312,322 **** * 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<Float>, ByteBuffer, int, Mask)} method} as follows: * <pre>{@code * return this.fromByteBuffer(b, i, this.maskAllTrue()) * }</pre> * * @param species species of desired vector --- 312,322 ---- * 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<Float>, ByteBuffer, int, VectorMask)} method} as follows: * <pre>{@code * return this.fromByteBuffer(b, i, this.maskAllTrue()) * }</pre> * * @param species species of desired vector
*** 329,339 **** * {@code this.length() * this.elementSize() / Byte.SIZE} bytes * remaining in the byte buffer from the given offset */ @ForceInline @SuppressWarnings("unchecked") ! public static FloatVector fromByteBuffer(Species<Float> 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<FloatVector>) species.boxType(), float.class, species.length(), --- 329,339 ---- * {@code this.length() * this.elementSize() / Byte.SIZE} bytes * remaining in the byte buffer from the given offset */ @ForceInline @SuppressWarnings("unchecked") ! public static FloatVector fromByteBuffer(VectorSpecies<Float> 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<FloatVector>) species.boxType(), float.class, species.length(),
*** 381,391 **** * 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 FloatVector fromByteBuffer(Species<Float> species, ByteBuffer bb, int ix, Mask<Float> m) { return zero(species).blend(fromByteBuffer(species, bb, ix), m); } /** * Returns a vector where all lane elements are set to the primitive --- 381,391 ---- * 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 FloatVector fromByteBuffer(VectorSpecies<Float> species, ByteBuffer bb, int ix, VectorMask<Float> m) { return zero(species).blend(fromByteBuffer(species, bb, ix), m); } /** * Returns a vector where all lane elements are set to the primitive
*** 396,406 **** * @return a vector of vector where all lane elements are set to * the primitive value {@code e} */ @ForceInline @SuppressWarnings("unchecked") ! public static FloatVector broadcast(Species<Float> s, float e) { return VectorIntrinsics.broadcastCoerced( (Class<FloatVector>) s.boxType(), float.class, s.length(), Float.floatToIntBits(e), s, ((bits, sp) -> ((FloatSpecies)sp).op(i -> Float.intBitsToFloat((int)bits)))); } --- 396,406 ---- * @return a vector of vector where all lane elements are set to * the primitive value {@code e} */ @ForceInline @SuppressWarnings("unchecked") ! public static FloatVector broadcast(VectorSpecies<Float> s, float e) { return VectorIntrinsics.broadcastCoerced( (Class<FloatVector>) s.boxType(), float.class, s.length(), Float.floatToIntBits(e), s, ((bits, sp) -> ((FloatSpecies)sp).op(i -> Float.intBitsToFloat((int)bits)))); }
*** 419,429 **** * value * @throws IndexOutOfBoundsException if {@code es.length < this.length()} */ @ForceInline @SuppressWarnings("unchecked") ! public static FloatVector scalars(Species<Float> s, float... es) { Objects.requireNonNull(es); int ix = VectorIntrinsics.checkIndex(0, es.length, s.length()); return VectorIntrinsics.load((Class<FloatVector>) s.boxType(), float.class, s.length(), es, Unsafe.ARRAY_FLOAT_BASE_OFFSET, es, ix, s, --- 419,429 ---- * value * @throws IndexOutOfBoundsException if {@code es.length < this.length()} */ @ForceInline @SuppressWarnings("unchecked") ! public static FloatVector scalars(VectorSpecies<Float> s, float... es) { Objects.requireNonNull(es); int ix = VectorIntrinsics.checkIndex(0, es.length, s.length()); return VectorIntrinsics.load((Class<FloatVector>) s.boxType(), float.class, s.length(), es, Unsafe.ARRAY_FLOAT_BASE_OFFSET, es, ix, s,
*** 439,449 **** * @param e the value * @return a vector where the first lane element is set to the primitive * value {@code e} */ @ForceInline ! public static final FloatVector single(Species<Float> s, float e) { return zero(s).with(0, e); } /** * Returns a vector where each lane element is set to a randomly --- 439,449 ---- * @param e the value * @return a vector where the first lane element is set to the primitive * value {@code e} */ @ForceInline ! public static final FloatVector single(VectorSpecies<Float> s, float e) { return zero(s).with(0, e); } /** * Returns a vector where each lane element is set to a randomly
*** 454,692 **** * * @param s species of the desired vector * @return a vector where each lane elements is set to a randomly * generated primitive value */ ! public static FloatVector random(Species<Float> s) { ThreadLocalRandom r = ThreadLocalRandom.current(); return ((FloatSpecies)s).op(i -> r.nextFloat()); } - /** - * 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<Float> maskFromValues(Species<Float> species, boolean... bits) { - if (species.boxType() == FloatMaxVector.class) - return new FloatMaxVector.FloatMaxMask(bits); - switch (species.bitSize()) { - case 64: return new Float64Vector.Float64Mask(bits); - case 128: return new Float128Vector.Float128Mask(bits); - case 256: return new Float256Vector.Float256Mask(bits); - case 512: return new Float512Vector.Float512Mask(bits); - default: throw new IllegalArgumentException(Integer.toString(species.bitSize())); - } - } - - // @@@ This is a bad implementation -- makes lambdas capturing -- fix this - static Mask<Float> trueMask(Species<Float> species) { - if (species.boxType() == FloatMaxVector.class) - return FloatMaxVector.FloatMaxMask.TRUE_MASK; - switch (species.bitSize()) { - case 64: return Float64Vector.Float64Mask.TRUE_MASK; - case 128: return Float128Vector.Float128Mask.TRUE_MASK; - case 256: return Float256Vector.Float256Mask.TRUE_MASK; - case 512: return Float512Vector.Float512Mask.TRUE_MASK; - default: throw new IllegalArgumentException(Integer.toString(species.bitSize())); - } - } - - static Mask<Float> falseMask(Species<Float> species) { - if (species.boxType() == FloatMaxVector.class) - return FloatMaxVector.FloatMaxMask.FALSE_MASK; - switch (species.bitSize()) { - case 64: return Float64Vector.Float64Mask.FALSE_MASK; - case 128: return Float128Vector.Float128Mask.FALSE_MASK; - case 256: return Float256Vector.Float256Mask.FALSE_MASK; - case 512: return Float512Vector.Float512Mask.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<Float> maskFromArray(Species<Float> species, boolean[] bits, int ix) { - Objects.requireNonNull(bits); - ix = VectorIntrinsics.checkIndex(ix, bits.length, species.length()); - return VectorIntrinsics.load((Class<Mask<Float>>) species.maskType(), int.class, species.length(), - bits, (((long) ix) << ARRAY_SHIFT) + Unsafe.ARRAY_BOOLEAN_BASE_OFFSET, - bits, ix, species, - (c, idx, s) -> (Mask<Float>) ((FloatSpecies)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<Float> maskAllTrue(Species<Float> species) { - return VectorIntrinsics.broadcastCoerced((Class<Mask<Float>>) species.maskType(), int.class, species.length(), - (int)-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<Float> maskAllFalse(Species<Float> species) { - return VectorIntrinsics.broadcastCoerced((Class<Mask<Float>>) species.maskType(), int.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<Float> shuffle(Species<Float> species, IntUnaryOperator f) { - if (species.boxType() == FloatMaxVector.class) - return new FloatMaxVector.FloatMaxShuffle(f); - switch (species.bitSize()) { - case 64: return new Float64Vector.Float64Shuffle(f); - case 128: return new Float128Vector.Float128Shuffle(f); - case 256: return new Float256Vector.Float256Shuffle(f); - case 512: return new Float512Vector.Float512Shuffle(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<Float> shuffleIota(Species<Float> species) { - if (species.boxType() == FloatMaxVector.class) - return new FloatMaxVector.FloatMaxShuffle(AbstractShuffle.IDENTITY); - switch (species.bitSize()) { - case 64: return new Float64Vector.Float64Shuffle(AbstractShuffle.IDENTITY); - case 128: return new Float128Vector.Float128Shuffle(AbstractShuffle.IDENTITY); - case 256: return new Float256Vector.Float256Shuffle(AbstractShuffle.IDENTITY); - case 512: return new Float512Vector.Float512Shuffle(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<Float> shuffleFromValues(Species<Float> species, int... ixs) { - if (species.boxType() == FloatMaxVector.class) - return new FloatMaxVector.FloatMaxShuffle(ixs); - switch (species.bitSize()) { - case 64: return new Float64Vector.Float64Shuffle(ixs); - case 128: return new Float128Vector.Float128Shuffle(ixs); - case 256: return new Float256Vector.Float256Shuffle(ixs); - case 512: return new Float512Vector.Float512Shuffle(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<Float> shuffleFromArray(Species<Float> species, int[] ixs, int i) { - if (species.boxType() == FloatMaxVector.class) - return new FloatMaxVector.FloatMaxShuffle(ixs, i); - switch (species.bitSize()) { - case 64: return new Float64Vector.Float64Shuffle(ixs, i); - case 128: return new Float128Vector.Float128Shuffle(ixs, i); - case 256: return new Float256Vector.Float256Shuffle(ixs, i); - case 512: return new Float512Vector.Float512Shuffle(ixs, i); - default: throw new IllegalArgumentException(Integer.toString(species.bitSize())); - } - } - // Ops @Override public abstract FloatVector add(Vector<Float> v); --- 454,468 ---- * * @param s species of the desired vector * @return a vector where each lane elements is set to a randomly * generated primitive value */ ! public static FloatVector random(VectorSpecies<Float> s) { ThreadLocalRandom r = ThreadLocalRandom.current(); return ((FloatSpecies)s).op(i -> r.nextFloat()); } // Ops @Override public abstract FloatVector add(Vector<Float> v);
*** 701,711 **** * scalar */ public abstract FloatVector add(float s); @Override ! public abstract FloatVector add(Vector<Float> v, Mask<Float> m); /** * Adds this vector to broadcast of an input scalar, * selecting lane elements controlled by a mask. * <p> --- 477,487 ---- * scalar */ public abstract FloatVector add(float s); @Override ! public abstract FloatVector add(Vector<Float> v, VectorMask<Float> m); /** * Adds this vector to broadcast of an input scalar, * selecting lane elements controlled by a mask. * <p>
*** 715,725 **** * @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 FloatVector add(float s, Mask<Float> m); @Override public abstract FloatVector sub(Vector<Float> v); /** --- 491,501 ---- * @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 FloatVector add(float s, VectorMask<Float> m); @Override public abstract FloatVector sub(Vector<Float> v); /**
*** 733,743 **** * scalar from this vector */ public abstract FloatVector sub(float s); @Override ! public abstract FloatVector sub(Vector<Float> v, Mask<Float> m); /** * Subtracts the broadcast of an input scalar from this vector, selecting * lane elements controlled by a mask. * <p> --- 509,519 ---- * scalar from this vector */ public abstract FloatVector sub(float s); @Override ! public abstract FloatVector sub(Vector<Float> v, VectorMask<Float> m); /** * Subtracts the broadcast of an input scalar from this vector, selecting * lane elements controlled by a mask. * <p>
*** 747,757 **** * @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 FloatVector sub(float s, Mask<Float> m); @Override public abstract FloatVector mul(Vector<Float> v); /** --- 523,533 ---- * @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 FloatVector sub(float s, VectorMask<Float> m); @Override public abstract FloatVector mul(Vector<Float> v); /**
*** 765,775 **** * input scalar */ public abstract FloatVector mul(float s); @Override ! public abstract FloatVector mul(Vector<Float> v, Mask<Float> m); /** * Multiplies this vector with the broadcast of an input scalar, selecting * lane elements controlled by a mask. * <p> --- 541,551 ---- * input scalar */ public abstract FloatVector mul(float s); @Override ! public abstract FloatVector mul(Vector<Float> v, VectorMask<Float> m); /** * Multiplies this vector with the broadcast of an input scalar, selecting * lane elements controlled by a mask. * <p>
*** 779,807 **** * @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 FloatVector mul(float s, Mask<Float> m); @Override public abstract FloatVector neg(); @Override ! public abstract FloatVector neg(Mask<Float> m); @Override public abstract FloatVector abs(); @Override ! public abstract FloatVector abs(Mask<Float> m); @Override public abstract FloatVector min(Vector<Float> v); @Override ! public abstract FloatVector min(Vector<Float> v, Mask<Float> m); /** * Returns the minimum of this vector and the broadcast of an input scalar. * <p> * This is a vector binary operation where the operation --- 555,583 ---- * @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 FloatVector mul(float s, VectorMask<Float> m); @Override public abstract FloatVector neg(); @Override ! public abstract FloatVector neg(VectorMask<Float> m); @Override public abstract FloatVector abs(); @Override ! public abstract FloatVector abs(VectorMask<Float> m); @Override public abstract FloatVector min(Vector<Float> v); @Override ! public abstract FloatVector min(Vector<Float> v, VectorMask<Float> m); /** * Returns the minimum of this vector and the broadcast of an input scalar. * <p> * This is a vector binary operation where the operation
*** 814,824 **** @Override public abstract FloatVector max(Vector<Float> v); @Override ! public abstract FloatVector max(Vector<Float> v, Mask<Float> m); /** * Returns the maximum of this vector and the broadcast of an input scalar. * <p> * This is a vector binary operation where the operation --- 590,600 ---- @Override public abstract FloatVector max(Vector<Float> v); @Override ! public abstract FloatVector max(Vector<Float> v, VectorMask<Float> m); /** * Returns the maximum of this vector and the broadcast of an input scalar. * <p> * This is a vector binary operation where the operation
*** 828,838 **** * @return the maximum of this vector and the broadcast of an input scalar */ public abstract FloatVector max(float s); @Override ! public abstract Mask<Float> equal(Vector<Float> 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 --- 604,614 ---- * @return the maximum of this vector and the broadcast of an input scalar */ public abstract FloatVector max(float s); @Override ! public abstract VectorMask<Float> equal(Vector<Float> 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
*** 840,853 **** * * @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<Float> equal(float s); @Override ! public abstract Mask<Float> notEqual(Vector<Float> 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 --- 616,629 ---- * * @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<Float> equal(float s); @Override ! public abstract VectorMask<Float> notEqual(Vector<Float> 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
*** 855,868 **** * * @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<Float> notEqual(float s); @Override ! public abstract Mask<Float> lessThan(Vector<Float> 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 --- 631,644 ---- * * @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<Float> notEqual(float s); @Override ! public abstract VectorMask<Float> lessThan(Vector<Float> 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
*** 870,883 **** * * @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<Float> lessThan(float s); @Override ! public abstract Mask<Float> lessThanEq(Vector<Float> 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 --- 646,659 ---- * * @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<Float> lessThan(float s); @Override ! public abstract VectorMask<Float> lessThanEq(Vector<Float> 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
*** 885,898 **** * * @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<Float> lessThanEq(float s); @Override ! public abstract Mask<Float> greaterThan(Vector<Float> 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 --- 661,674 ---- * * @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<Float> lessThanEq(float s); @Override ! public abstract VectorMask<Float> greaterThan(Vector<Float> 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
*** 900,913 **** * * @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<Float> greaterThan(float s); @Override ! public abstract Mask<Float> greaterThanEq(Vector<Float> v); /** * Tests if this vector is greater than or equal to the broadcast of an * input scalar. * <p> --- 676,689 ---- * * @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<Float> greaterThan(float s); @Override ! public abstract VectorMask<Float> greaterThanEq(Vector<Float> v); /** * Tests if this vector is greater than or equal to the broadcast of an * input scalar. * <p>
*** 916,929 **** * * @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<Float> greaterThanEq(float s); @Override ! public abstract FloatVector blend(Vector<Float> v, Mask<Float> m); /** * Blends the lane elements of this vector with those of the broadcast of an * input scalar, selecting lanes controlled by a mask. * <p> --- 692,705 ---- * * @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<Float> greaterThanEq(float s); @Override ! public abstract FloatVector blend(Vector<Float> v, VectorMask<Float> m); /** * Blends the lane elements of this vector with those of the broadcast of an * input scalar, selecting lanes controlled by a mask. * <p>
*** 936,956 **** * @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 FloatVector blend(float s, Mask<Float> m); @Override public abstract FloatVector rearrange(Vector<Float> v, ! Shuffle<Float> s, Mask<Float> m); @Override ! public abstract FloatVector rearrange(Shuffle<Float> m); @Override ! public abstract FloatVector reshape(Species<Float> s); @Override public abstract FloatVector rotateEL(int i); @Override --- 712,732 ---- * @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 FloatVector blend(float s, VectorMask<Float> m); @Override public abstract FloatVector rearrange(Vector<Float> v, ! VectorShuffle<Float> s, VectorMask<Float> m); @Override ! public abstract FloatVector rearrange(VectorShuffle<Float> m); @Override ! public abstract FloatVector reshape(VectorSpecies<Float> s); @Override public abstract FloatVector rotateEL(int i); @Override
*** 994,1004 **** * * @param v the input vector * @param m the mask controlling lane selection * @return the result of dividing this vector by the input vector */ ! public abstract FloatVector div(Vector<Float> v, Mask<Float> m); /** * Divides this vector by the broadcast of an input scalar, selecting lane * elements controlled by a mask. * <p> --- 770,780 ---- * * @param v the input vector * @param m the mask controlling lane selection * @return the result of dividing this vector by the input vector */ ! public abstract FloatVector div(Vector<Float> v, VectorMask<Float> m); /** * Divides this vector by the broadcast of an input scalar, selecting lane * elements controlled by a mask. * <p>
*** 1008,1018 **** * @param s the input scalar * @param m the mask controlling lane selection * @return the result of dividing this vector by the broadcast of an input * scalar */ ! public abstract FloatVector div(float s, Mask<Float> m); /** * Calculates the square root of this vector. * <p> * This is a vector unary operation where the {@link Math#sqrt} operation --- 784,794 ---- * @param s the input scalar * @param m the mask controlling lane selection * @return the result of dividing this vector by the broadcast of an input * scalar */ ! public abstract FloatVector div(float s, VectorMask<Float> m); /** * Calculates the square root of this vector. * <p> * This is a vector unary operation where the {@link Math#sqrt} operation
*** 1030,1040 **** * is applied to lane elements. * * @param m the mask controlling lane selection * @return the square root of this vector */ ! public FloatVector sqrt(Mask<Float> m) { return uOp(m, (i, a) -> (float) Math.sqrt((double) a)); } /** * Calculates the trigonometric tangent of this vector. --- 806,816 ---- * is applied to lane elements. * * @param m the mask controlling lane selection * @return the square root of this vector */ ! public FloatVector sqrt(VectorMask<Float> m) { return uOp(m, (i, a) -> (float) Math.sqrt((double) a)); } /** * Calculates the trigonometric tangent of this vector.
*** 1061,1071 **** * described in {@link FloatVector#tan} * * @param m the mask controlling lane selection * @return the tangent of this vector */ ! public FloatVector tan(Mask<Float> m) { return uOp(m, (i, a) -> (float) Math.tan((double) a)); } /** * Calculates the hyperbolic tangent of this vector. --- 837,847 ---- * described in {@link FloatVector#tan} * * @param m the mask controlling lane selection * @return the tangent of this vector */ ! public FloatVector tan(VectorMask<Float> m) { return uOp(m, (i, a) -> (float) Math.tan((double) a)); } /** * Calculates the hyperbolic tangent of this vector.
*** 1092,1102 **** * described in {@link FloatVector#tanh} * * @param m the mask controlling lane selection * @return the hyperbolic tangent of this vector */ ! public FloatVector tanh(Mask<Float> m) { return uOp(m, (i, a) -> (float) Math.tanh((double) a)); } /** * Calculates the trigonometric sine of this vector. --- 868,878 ---- * described in {@link FloatVector#tanh} * * @param m the mask controlling lane selection * @return the hyperbolic tangent of this vector */ ! public FloatVector tanh(VectorMask<Float> m) { return uOp(m, (i, a) -> (float) Math.tanh((double) a)); } /** * Calculates the trigonometric sine of this vector.
*** 1123,1133 **** * described in {@link FloatVector#sin} * * @param m the mask controlling lane selection * @return the sine of this vector */ ! public FloatVector sin(Mask<Float> m) { return uOp(m, (i, a) -> (float) Math.sin((double) a)); } /** * Calculates the hyperbolic sine of this vector. --- 899,909 ---- * described in {@link FloatVector#sin} * * @param m the mask controlling lane selection * @return the sine of this vector */ ! public FloatVector sin(VectorMask<Float> m) { return uOp(m, (i, a) -> (float) Math.sin((double) a)); } /** * Calculates the hyperbolic sine of this vector.
*** 1154,1164 **** * described in {@link FloatVector#sinh} * * @param m the mask controlling lane selection * @return the hyperbolic sine of this vector */ ! public FloatVector sinh(Mask<Float> m) { return uOp(m, (i, a) -> (float) Math.sinh((double) a)); } /** * Calculates the trigonometric cosine of this vector. --- 930,940 ---- * described in {@link FloatVector#sinh} * * @param m the mask controlling lane selection * @return the hyperbolic sine of this vector */ ! public FloatVector sinh(VectorMask<Float> m) { return uOp(m, (i, a) -> (float) Math.sinh((double) a)); } /** * Calculates the trigonometric cosine of this vector.
*** 1185,1195 **** * described in {@link FloatVector#cos} * * @param m the mask controlling lane selection * @return the cosine of this vector */ ! public FloatVector cos(Mask<Float> m) { return uOp(m, (i, a) -> (float) Math.cos((double) a)); } /** * Calculates the hyperbolic cosine of this vector. --- 961,971 ---- * described in {@link FloatVector#cos} * * @param m the mask controlling lane selection * @return the cosine of this vector */ ! public FloatVector cos(VectorMask<Float> m) { return uOp(m, (i, a) -> (float) Math.cos((double) a)); } /** * Calculates the hyperbolic cosine of this vector.
*** 1216,1226 **** * described in {@link FloatVector#cosh} * * @param m the mask controlling lane selection * @return the hyperbolic cosine of this vector */ ! public FloatVector cosh(Mask<Float> m) { return uOp(m, (i, a) -> (float) Math.cosh((double) a)); } /** * Calculates the arc sine of this vector. --- 992,1002 ---- * described in {@link FloatVector#cosh} * * @param m the mask controlling lane selection * @return the hyperbolic cosine of this vector */ ! public FloatVector cosh(VectorMask<Float> m) { return uOp(m, (i, a) -> (float) Math.cosh((double) a)); } /** * Calculates the arc sine of this vector.
*** 1247,1257 **** * described in {@link FloatVector#asin} * * @param m the mask controlling lane selection * @return the arc sine of this vector */ ! public FloatVector asin(Mask<Float> m) { return uOp(m, (i, a) -> (float) Math.asin((double) a)); } /** * Calculates the arc cosine of this vector. --- 1023,1033 ---- * described in {@link FloatVector#asin} * * @param m the mask controlling lane selection * @return the arc sine of this vector */ ! public FloatVector asin(VectorMask<Float> m) { return uOp(m, (i, a) -> (float) Math.asin((double) a)); } /** * Calculates the arc cosine of this vector.
*** 1278,1288 **** * described in {@link FloatVector#acos} * * @param m the mask controlling lane selection * @return the arc cosine of this vector */ ! public FloatVector acos(Mask<Float> m) { return uOp(m, (i, a) -> (float) Math.acos((double) a)); } /** * Calculates the arc tangent of this vector. --- 1054,1064 ---- * described in {@link FloatVector#acos} * * @param m the mask controlling lane selection * @return the arc cosine of this vector */ ! public FloatVector acos(VectorMask<Float> m) { return uOp(m, (i, a) -> (float) Math.acos((double) a)); } /** * Calculates the arc tangent of this vector.
*** 1309,1319 **** * described in {@link FloatVector#atan} * * @param m the mask controlling lane selection * @return the arc tangent of this vector */ ! public FloatVector atan(Mask<Float> m) { return uOp(m, (i, a) -> (float) Math.atan((double) a)); } /** * Calculates the arc tangent of this vector divided by an input vector. --- 1085,1095 ---- * described in {@link FloatVector#atan} * * @param m the mask controlling lane selection * @return the arc tangent of this vector */ ! public FloatVector atan(VectorMask<Float> m) { return uOp(m, (i, a) -> (float) Math.atan((double) a)); } /** * Calculates the arc tangent of this vector divided by an input vector.
*** 1359,1369 **** * * @param v the input vector * @param m the mask controlling lane selection * @return the arc tangent of this vector divided by the input vector */ ! public FloatVector atan2(Vector<Float> v, Mask<Float> m) { return bOp(v, m, (i, a, b) -> (float) Math.atan2((double) a, (double) b)); } /** * Calculates the arc tangent of this vector divided by the broadcast of an --- 1135,1145 ---- * * @param v the input vector * @param m the mask controlling lane selection * @return the arc tangent of this vector divided by the input vector */ ! public FloatVector atan2(Vector<Float> v, VectorMask<Float> m) { return bOp(v, m, (i, a, b) -> (float) Math.atan2((double) a, (double) b)); } /** * Calculates the arc tangent of this vector divided by the broadcast of an
*** 1374,1384 **** * * @param s the input scalar * @param m the mask controlling lane selection * @return the arc tangent of this vector over the input vector */ ! public abstract FloatVector atan2(float s, Mask<Float> m); /** * Calculates the cube root of this vector. * <p> * This is a vector unary operation with same semantic definition as --- 1150,1160 ---- * * @param s the input scalar * @param m the mask controlling lane selection * @return the arc tangent of this vector over the input vector */ ! public abstract FloatVector atan2(float s, VectorMask<Float> m); /** * Calculates the cube root of this vector. * <p> * This is a vector unary operation with same semantic definition as
*** 1403,1413 **** * described in {@link FloatVector#cbrt} * * @param m the mask controlling lane selection * @return the cube root of this vector */ ! public FloatVector cbrt(Mask<Float> m) { return uOp(m, (i, a) -> (float) Math.cbrt((double) a)); } /** * Calculates the natural logarithm of this vector. --- 1179,1189 ---- * described in {@link FloatVector#cbrt} * * @param m the mask controlling lane selection * @return the cube root of this vector */ ! public FloatVector cbrt(VectorMask<Float> m) { return uOp(m, (i, a) -> (float) Math.cbrt((double) a)); } /** * Calculates the natural logarithm of this vector.
*** 1434,1444 **** * described in {@link FloatVector#log} * * @param m the mask controlling lane selection * @return the natural logarithm of this vector */ ! public FloatVector log(Mask<Float> m) { return uOp(m, (i, a) -> (float) Math.log((double) a)); } /** * Calculates the base 10 logarithm of this vector. --- 1210,1220 ---- * described in {@link FloatVector#log} * * @param m the mask controlling lane selection * @return the natural logarithm of this vector */ ! public FloatVector log(VectorMask<Float> m) { return uOp(m, (i, a) -> (float) Math.log((double) a)); } /** * Calculates the base 10 logarithm of this vector.
*** 1465,1475 **** * described in {@link FloatVector#log10} * * @param m the mask controlling lane selection * @return the base 10 logarithm of this vector */ ! public FloatVector log10(Mask<Float> m) { return uOp(m, (i, a) -> (float) Math.log10((double) a)); } /** * Calculates the natural logarithm of the sum of this vector and the --- 1241,1251 ---- * described in {@link FloatVector#log10} * * @param m the mask controlling lane selection * @return the base 10 logarithm of this vector */ ! public FloatVector log10(VectorMask<Float> m) { return uOp(m, (i, a) -> (float) Math.log10((double) a)); } /** * Calculates the natural logarithm of the sum of this vector and the
*** 1499,1509 **** * * @param m the mask controlling lane selection * @return the natural logarithm of the sum of this vector and the broadcast * of {@code 1} */ ! public FloatVector log1p(Mask<Float> m) { return uOp(m, (i, a) -> (float) Math.log1p((double) a)); } /** * Calculates this vector raised to the power of an input vector. --- 1275,1285 ---- * * @param m the mask controlling lane selection * @return the natural logarithm of the sum of this vector and the broadcast * of {@code 1} */ ! public FloatVector log1p(VectorMask<Float> m) { return uOp(m, (i, a) -> (float) Math.log1p((double) a)); } /** * Calculates this vector raised to the power of an input vector.
*** 1550,1560 **** * * @param v the input vector * @param m the mask controlling lane selection * @return this vector raised to the power of an input vector */ ! public FloatVector pow(Vector<Float> v, Mask<Float> m) { return bOp(v, m, (i, a, b) -> (float) Math.pow((double) a, (double) b)); } /** * Calculates this vector raised to the power of the broadcast of an input --- 1326,1336 ---- * * @param v the input vector * @param m the mask controlling lane selection * @return this vector raised to the power of an input vector */ ! public FloatVector pow(Vector<Float> v, VectorMask<Float> m) { return bOp(v, m, (i, a, b) -> (float) Math.pow((double) a, (double) b)); } /** * Calculates this vector raised to the power of the broadcast of an input
*** 1566,1576 **** * @param s the input scalar * @param m the mask controlling lane selection * @return this vector raised to the power of the broadcast of an input * scalar. */ ! public abstract FloatVector pow(float s, Mask<Float> m); /** * Calculates the broadcast of Euler's number {@code e} raised to the power * of this vector. * <p> --- 1342,1352 ---- * @param s the input scalar * @param m the mask controlling lane selection * @return this vector raised to the power of the broadcast of an input * scalar. */ ! public abstract FloatVector pow(float s, VectorMask<Float> m); /** * Calculates the broadcast of Euler's number {@code e} raised to the power * of this vector. * <p>
*** 1598,1608 **** * * @param m the mask controlling lane selection * @return the broadcast of Euler's number {@code e} raised to the power of * this vector */ ! public FloatVector exp(Mask<Float> m) { return uOp(m, (i, a) -> (float) Math.exp((double) a)); } /** * Calculates the broadcast of Euler's number {@code e} raised to the power --- 1374,1384 ---- * * @param m the mask controlling lane selection * @return the broadcast of Euler's number {@code e} raised to the power of * this vector */ ! public FloatVector exp(VectorMask<Float> m) { return uOp(m, (i, a) -> (float) Math.exp((double) a)); } /** * Calculates the broadcast of Euler's number {@code e} raised to the power
*** 1643,1653 **** * * @param m the mask controlling lane selection * @return the broadcast of Euler's number {@code e} raised to the power of * this vector minus the broadcast of {@code -1} */ ! public FloatVector expm1(Mask<Float> m) { return uOp(m, (i, a) -> (float) Math.expm1((double) a)); } /** * Calculates the product of this vector and a first input vector summed --- 1419,1429 ---- * * @param m the mask controlling lane selection * @return the broadcast of Euler's number {@code e} raised to the power of * this vector minus the broadcast of {@code -1} */ ! public FloatVector expm1(VectorMask<Float> m) { return uOp(m, (i, a) -> (float) Math.expm1((double) a)); } /** * Calculates the product of this vector and a first input vector summed
*** 1702,1712 **** * @param v2 the second input vector * @param m the mask controlling lane selection * @return the product of this vector and the first input vector summed with * the second input vector */ ! public FloatVector fma(Vector<Float> v1, Vector<Float> v2, Mask<Float> m) { return tOp(v1, v2, m, (i, a, b, c) -> Math.fma(a, b, c)); } /** * Calculates the product of this vector and the broadcast of a first input --- 1478,1488 ---- * @param v2 the second input vector * @param m the mask controlling lane selection * @return the product of this vector and the first input vector summed with * the second input vector */ ! public FloatVector fma(Vector<Float> v1, Vector<Float> v2, VectorMask<Float> m) { return tOp(v1, v2, m, (i, a, b, c) -> Math.fma(a, b, c)); } /** * Calculates the product of this vector and the broadcast of a first input
*** 1724,1734 **** * @param s2 the second input scalar * @param m the mask controlling lane selection * @return the product of this vector and the broadcast of a first input * scalar summed with the broadcast of a second input scalar */ ! public abstract FloatVector fma(float s1, float s2, Mask<Float> m); /** * Calculates square root of the sum of the squares of this vector and an * input vector. * More specifically as if the following (ignoring any differences in --- 1500,1510 ---- * @param s2 the second input scalar * @param m the mask controlling lane selection * @return the product of this vector and the broadcast of a first input * scalar summed with the broadcast of a second input scalar */ ! public abstract FloatVector fma(float s1, float s2, VectorMask<Float> m); /** * Calculates square root of the sum of the squares of this vector and an * input vector. * More specifically as if the following (ignoring any differences in
*** 1791,1801 **** * @param v the input vector * @param m the mask controlling lane selection * @return square root of the sum of the squares of this vector and an input * vector */ ! public FloatVector hypot(Vector<Float> v, Mask<Float> m) { return bOp(v, m, (i, a, b) -> (float) Math.hypot((double) a, (double) b)); } /** * Calculates square root of the sum of the squares of this vector and the --- 1567,1577 ---- * @param v the input vector * @param m the mask controlling lane selection * @return square root of the sum of the squares of this vector and an input * vector */ ! public FloatVector hypot(Vector<Float> v, VectorMask<Float> m) { return bOp(v, m, (i, a, b) -> (float) Math.hypot((double) a, (double) b)); } /** * Calculates square root of the sum of the squares of this vector and the
*** 1813,1836 **** * @param s the input scalar * @param m the mask controlling lane selection * @return square root of the sum of the squares of this vector and the * broadcast of an input scalar */ ! public abstract FloatVector hypot(float s, Mask<Float> m); @Override public abstract void intoByteArray(byte[] a, int ix); @Override ! public abstract void intoByteArray(byte[] a, int ix, Mask<Float> m); @Override public abstract void intoByteBuffer(ByteBuffer bb, int ix); @Override ! public abstract void intoByteBuffer(ByteBuffer bb, int ix, Mask<Float> m); // Type specific horizontal reductions /** * Adds all lane elements of this vector. --- 1589,1612 ---- * @param s the input scalar * @param m the mask controlling lane selection * @return square root of the sum of the squares of this vector and the * broadcast of an input scalar */ ! public abstract FloatVector hypot(float s, VectorMask<Float> m); @Override public abstract void intoByteArray(byte[] a, int ix); @Override ! public abstract void intoByteArray(byte[] a, int ix, VectorMask<Float> m); @Override public abstract void intoByteBuffer(ByteBuffer bb, int ix); @Override ! public abstract void intoByteBuffer(ByteBuffer bb, int ix, VectorMask<Float> m); // Type specific horizontal reductions /** * Adds all lane elements of this vector.
*** 1870,1880 **** * For this reason, the output of this method may vary on the same input values. * * @param m the mask controlling lane selection * @return the addition of the selected lane elements of this vector */ ! public abstract float addAll(Mask<Float> m); /** * Multiplies all lane elements of this vector. * <p> * This is a vector reduction operation where the --- 1646,1656 ---- * For this reason, the output of this method may vary on the same input values. * * @param m the mask controlling lane selection * @return the addition of the selected lane elements of this vector */ ! public abstract float addAll(VectorMask<Float> m); /** * Multiplies all lane elements of this vector. * <p> * This is a vector reduction operation where the
*** 1910,1920 **** * For this reason, the output of this method may vary on the same input values. * * @param m the mask controlling lane selection * @return the multiplication of all the lane elements of this vector */ ! public abstract float mulAll(Mask<Float> m); /** * Returns the minimum lane element of this vector. * <p> * This is an associative vector reduction operation where the operation --- 1686,1696 ---- * For this reason, the output of this method may vary on the same input values. * * @param m the mask controlling lane selection * @return the multiplication of all the lane elements of this vector */ ! public abstract float mulAll(VectorMask<Float> m); /** * Returns the minimum lane element of this vector. * <p> * This is an associative vector reduction operation where the operation
*** 1936,1946 **** * {@link Float#POSITIVE_INFINITY}. * * @param m the mask controlling lane selection * @return the minimum lane element of this vector */ ! public abstract float minAll(Mask<Float> m); /** * Returns the maximum lane element of this vector. * <p> * This is an associative vector reduction operation where the operation --- 1712,1722 ---- * {@link Float#POSITIVE_INFINITY}. * * @param m the mask controlling lane selection * @return the minimum lane element of this vector */ ! public abstract float minAll(VectorMask<Float> m); /** * Returns the maximum lane element of this vector. * <p> * This is an associative vector reduction operation where the operation
*** 1962,1972 **** * {@link Float#NEGATIVE_INFINITY}. * * @param m the mask controlling lane selection * @return the maximum lane element of this vector */ ! public abstract float maxAll(Mask<Float> m); // Type specific accessors /** --- 1738,1748 ---- * {@link Float#NEGATIVE_INFINITY}. * * @param m the mask controlling lane selection * @return the maximum lane element of this vector */ ! public abstract float maxAll(VectorMask<Float> m); // Type specific accessors /**
*** 2045,2055 **** * @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(float[] a, int i, Mask<Float> m); /** * Stores this vector into an array using indexes obtained from an index * map. * <p> --- 1821,1831 ---- * @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(float[] a, int i, VectorMask<Float> m); /** * Stores this vector into an array using indexes obtained from an index * map. * <p>
*** 2090,2156 **** * {@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 abstract void intoArray(float[] a, int i, Mask<Float> m, int[] indexMap, int j); // Species @Override ! public abstract Species<Float> species(); /** ! * Class representing {@link FloatVector}'s of the same {@link Vector.Shape Shape}. */ ! static final class FloatSpecies extends Vector.AbstractSpecies<Float> { final Function<float[], FloatVector> vectorFactory; - final Function<boolean[], Vector.Mask<Float>> maskFactory; ! private FloatSpecies(Vector.Shape shape, Class<?> boxType, Class<?> maskType, Function<float[], FloatVector> vectorFactory, ! Function<boolean[], Vector.Mask<Float>> maskFactory) { ! super(shape, float.class, Float.SIZE, boxType, maskType); this.vectorFactory = vectorFactory; - this.maskFactory = maskFactory; } interface FOp { float apply(int i); } - interface FOpm { - boolean apply(int i); - } - FloatVector op(FOp f) { float[] res = new float[length()]; for (int i = 0; i < length(); i++) { res[i] = f.apply(i); } return vectorFactory.apply(res); } ! FloatVector op(Vector.Mask<Float> o, FOp f) { float[] res = new float[length()]; boolean[] mbits = ((AbstractMask<Float>)o).getBits(); for (int i = 0; i < length(); i++) { if (mbits[i]) { res[i] = f.apply(i); } } return vectorFactory.apply(res); } - - Vector.Mask<Float> 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 float}. * <p> --- 1866,1921 ---- * {@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 abstract void intoArray(float[] a, int i, VectorMask<Float> m, int[] indexMap, int j); // Species @Override ! public abstract VectorSpecies<Float> species(); /** ! * Class representing {@link FloatVector}'s of the same {@link VectorShape VectorShape}. */ ! static final class FloatSpecies extends AbstractSpecies<Float> { final Function<float[], FloatVector> vectorFactory; ! private FloatSpecies(VectorShape shape, Class<?> boxType, Class<?> maskType, Function<float[], FloatVector> vectorFactory, ! Function<boolean[], VectorMask<Float>> maskFactory, ! Function<IntUnaryOperator, VectorShuffle<Float>> shuffleFromArrayFactory, ! fShuffleFromArray<Float> shuffleFromOpFactory) { ! super(shape, float.class, Float.SIZE, boxType, maskType, maskFactory, ! shuffleFromArrayFactory, shuffleFromOpFactory); this.vectorFactory = vectorFactory; } interface FOp { float apply(int i); } FloatVector op(FOp f) { float[] res = new float[length()]; for (int i = 0; i < length(); i++) { res[i] = f.apply(i); } return vectorFactory.apply(res); } ! FloatVector op(VectorMask<Float> o, FOp f) { float[] res = new float[length()]; boolean[] mbits = ((AbstractMask<Float>)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 float}. * <p>
*** 2160,2180 **** * shuffles created from such species will be shape compatible. * * @return the preferred species for an element type of {@code float} */ private static FloatSpecies preferredSpecies() { ! return (FloatSpecies) Species.ofPreferred(float.class); } /** * Finds a species for an element type of {@code float} and shape. * * @param s the shape * @return a species for an element type of {@code float} and shape * @throws IllegalArgumentException if no such species exists for the shape */ ! static FloatSpecies species(Vector.Shape s) { Objects.requireNonNull(s); switch (s) { case S_64_BIT: return (FloatSpecies) SPECIES_64; case S_128_BIT: return (FloatSpecies) SPECIES_128; case S_256_BIT: return (FloatSpecies) SPECIES_256; --- 1925,1945 ---- * shuffles created from such species will be shape compatible. * * @return the preferred species for an element type of {@code float} */ private static FloatSpecies preferredSpecies() { ! return (FloatSpecies) VectorSpecies.ofPreferred(float.class); } /** * Finds a species for an element type of {@code float} and shape. * * @param s the shape * @return a species for an element type of {@code float} and shape * @throws IllegalArgumentException if no such species exists for the shape */ ! static FloatSpecies species(VectorShape s) { Objects.requireNonNull(s); switch (s) { case S_64_BIT: return (FloatSpecies) SPECIES_64; case S_128_BIT: return (FloatSpecies) SPECIES_128; case S_256_BIT: return (FloatSpecies) SPECIES_256;
*** 2182,2212 **** case S_Max_BIT: return (FloatSpecies) SPECIES_MAX; default: throw new IllegalArgumentException("Bad shape: " + s); } } ! /** Species representing {@link FloatVector}s of {@link Vector.Shape#S_64_BIT Shape.S_64_BIT}. */ ! public static final Species<Float> SPECIES_64 = new FloatSpecies(Shape.S_64_BIT, Float64Vector.class, Float64Vector.Float64Mask.class, ! Float64Vector::new, Float64Vector.Float64Mask::new); ! ! /** Species representing {@link FloatVector}s of {@link Vector.Shape#S_128_BIT Shape.S_128_BIT}. */ ! public static final Species<Float> SPECIES_128 = new FloatSpecies(Shape.S_128_BIT, Float128Vector.class, Float128Vector.Float128Mask.class, ! Float128Vector::new, Float128Vector.Float128Mask::new); ! ! /** Species representing {@link FloatVector}s of {@link Vector.Shape#S_256_BIT Shape.S_256_BIT}. */ ! public static final Species<Float> SPECIES_256 = new FloatSpecies(Shape.S_256_BIT, Float256Vector.class, Float256Vector.Float256Mask.class, ! Float256Vector::new, Float256Vector.Float256Mask::new); ! ! /** Species representing {@link FloatVector}s of {@link Vector.Shape#S_512_BIT Shape.S_512_BIT}. */ ! public static final Species<Float> SPECIES_512 = new FloatSpecies(Shape.S_512_BIT, Float512Vector.class, Float512Vector.Float512Mask.class, ! Float512Vector::new, Float512Vector.Float512Mask::new); ! ! /** Species representing {@link FloatVector}s of {@link Vector.Shape#S_Max_BIT Shape.S_Max_BIT}. */ ! public static final Species<Float> SPECIES_MAX = new FloatSpecies(Shape.S_Max_BIT, FloatMaxVector.class, FloatMaxVector.FloatMaxMask.class, ! FloatMaxVector::new, FloatMaxVector.FloatMaxMask::new); /** * Preferred species for {@link FloatVector}s. * A preferred species is a species of maximal bit size for the platform. */ ! public static final Species<Float> SPECIES_PREFERRED = (Species<Float>) preferredSpecies(); } --- 1947,1982 ---- case S_Max_BIT: return (FloatSpecies) SPECIES_MAX; default: throw new IllegalArgumentException("Bad shape: " + s); } } ! /** Species representing {@link FloatVector}s of {@link VectorShape#S_64_BIT VectorShape.S_64_BIT}. */ ! public static final VectorSpecies<Float> SPECIES_64 = new FloatSpecies(VectorShape.S_64_BIT, Float64Vector.class, Float64Vector.Float64Mask.class, ! Float64Vector::new, Float64Vector.Float64Mask::new, ! Float64Vector.Float64Shuffle::new, Float64Vector.Float64Shuffle::new); ! ! /** Species representing {@link FloatVector}s of {@link VectorShape#S_128_BIT VectorShape.S_128_BIT}. */ ! public static final VectorSpecies<Float> SPECIES_128 = new FloatSpecies(VectorShape.S_128_BIT, Float128Vector.class, Float128Vector.Float128Mask.class, ! Float128Vector::new, Float128Vector.Float128Mask::new, ! Float128Vector.Float128Shuffle::new, Float128Vector.Float128Shuffle::new); ! ! /** Species representing {@link FloatVector}s of {@link VectorShape#S_256_BIT VectorShape.S_256_BIT}. */ ! public static final VectorSpecies<Float> SPECIES_256 = new FloatSpecies(VectorShape.S_256_BIT, Float256Vector.class, Float256Vector.Float256Mask.class, ! Float256Vector::new, Float256Vector.Float256Mask::new, ! Float256Vector.Float256Shuffle::new, Float256Vector.Float256Shuffle::new); ! ! /** Species representing {@link FloatVector}s of {@link VectorShape#S_512_BIT VectorShape.S_512_BIT}. */ ! public static final VectorSpecies<Float> SPECIES_512 = new FloatSpecies(VectorShape.S_512_BIT, Float512Vector.class, Float512Vector.Float512Mask.class, ! Float512Vector::new, Float512Vector.Float512Mask::new, ! Float512Vector.Float512Shuffle::new, Float512Vector.Float512Shuffle::new); ! ! /** Species representing {@link FloatVector}s of {@link VectorShape#S_Max_BIT VectorShape.S_Max_BIT}. */ ! public static final VectorSpecies<Float> SPECIES_MAX = new FloatSpecies(VectorShape.S_Max_BIT, FloatMaxVector.class, FloatMaxVector.FloatMaxMask.class, ! FloatMaxVector::new, FloatMaxVector.FloatMaxMask::new, ! FloatMaxVector.FloatMaxShuffle::new, FloatMaxVector.FloatMaxShuffle::new); /** * Preferred species for {@link FloatVector}s. * A preferred species is a species of maximal bit size for the platform. */ ! public static final VectorSpecies<Float> SPECIES_PREFERRED = (VectorSpecies<Float>) preferredSpecies(); }
< prev index next >