< prev index next >

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

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

*** 54,84 **** double apply(int i, double a); } abstract DoubleVector uOp(FUnOp f); ! abstract DoubleVector uOp(Mask<Double> m, FUnOp f); // Binary operator interface FBinOp { double apply(int i, double a, double b); } abstract DoubleVector bOp(Vector<Double> v, FBinOp f); ! abstract DoubleVector bOp(Vector<Double> v, Mask<Double> m, FBinOp f); // Trinary operator interface FTriOp { double apply(int i, double a, double b, double c); } abstract DoubleVector tOp(Vector<Double> v1, Vector<Double> v2, FTriOp f); ! abstract DoubleVector tOp(Vector<Double> v1, Vector<Double> v2, Mask<Double> m, FTriOp f); // Reduction operator abstract double rOp(double v, FBinOp f); --- 54,84 ---- double apply(int i, double a); } abstract DoubleVector uOp(FUnOp f); ! abstract DoubleVector uOp(VectorMask<Double> m, FUnOp f); // Binary operator interface FBinOp { double apply(int i, double a, double b); } abstract DoubleVector bOp(Vector<Double> v, FBinOp f); ! abstract DoubleVector bOp(Vector<Double> v, VectorMask<Double> m, FBinOp f); // Trinary operator interface FTriOp { double apply(int i, double a, double b, double c); } abstract DoubleVector tOp(Vector<Double> v1, Vector<Double> v2, FTriOp f); ! abstract DoubleVector tOp(Vector<Double> v1, Vector<Double> v2, VectorMask<Double> m, FTriOp f); // Reduction operator abstract double rOp(double v, FBinOp f);
*** 86,106 **** interface FBinTest { boolean apply(int i, double a, double b); } ! abstract Mask<Double> bTest(Vector<Double> v, FBinTest f); // Foreach interface FUnCon { void apply(int i, double a); } abstract void forEach(FUnCon f); ! abstract void forEach(Mask<Double> 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, double a, double b); } ! abstract VectorMask<Double> bTest(Vector<Double> v, FBinTest f); // Foreach interface FUnCon { void apply(int i, double a); } abstract void forEach(FUnCon f); ! abstract void forEach(VectorMask<Double> 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 DoubleVector zero(Species<Double> species) { return VectorIntrinsics.broadcastCoerced((Class<DoubleVector>) species.boxType(), double.class, species.length(), Double.doubleToLongBits(0.0f), species, ((bits, s) -> ((DoubleSpecies)s).op(i -> Double.longBitsToDouble((long)bits)))); } --- 109,119 ---- * @param species species of desired vector * @return a zero vector of given species */ @ForceInline @SuppressWarnings("unchecked") ! public static DoubleVector zero(VectorSpecies<Double> species) { return VectorIntrinsics.broadcastCoerced((Class<DoubleVector>) species.boxType(), double.class, species.length(), Double.doubleToLongBits(0.0f), species, ((bits, s) -> ((DoubleSpecies)s).op(i -> Double.longBitsToDouble((long)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<Double>, 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<Double>, 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 DoubleVector fromByteArray(Species<Double> species, byte[] a, int ix) { Objects.requireNonNull(a); ix = VectorIntrinsics.checkIndex(ix, a.length, species.bitSize() / Byte.SIZE); return VectorIntrinsics.load((Class<DoubleVector>) species.boxType(), double.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 DoubleVector fromByteArray(VectorSpecies<Double> species, byte[] a, int ix) { Objects.requireNonNull(a); ix = VectorIntrinsics.checkIndex(ix, a.length, species.bitSize() / Byte.SIZE); return VectorIntrinsics.load((Class<DoubleVector>) species.boxType(), double.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<Double>, 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<Double>, 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 DoubleVector fromByteArray(Species<Double> species, byte[] a, int ix, Mask<Double> 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 DoubleVector fromByteArray(VectorSpecies<Double> species, byte[] a, int ix, VectorMask<Double> 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 DoubleVector fromArray(Species<Double> species, double[] a, int i){ Objects.requireNonNull(a); i = VectorIntrinsics.checkIndex(i, a.length, species.length()); return VectorIntrinsics.load((Class<DoubleVector>) species.boxType(), double.class, species.length(), a, (((long) i) << ARRAY_SHIFT) + Unsafe.ARRAY_DOUBLE_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 DoubleVector fromArray(VectorSpecies<Double> species, double[] a, int i){ Objects.requireNonNull(a); i = VectorIntrinsics.checkIndex(i, a.length, species.length()); return VectorIntrinsics.load((Class<DoubleVector>) species.boxType(), double.class, species.length(), a, (((long) i) << ARRAY_SHIFT) + Unsafe.ARRAY_DOUBLE_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 DoubleVector fromArray(Species<Double> species, double[] a, int i, Mask<Double> 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 DoubleVector fromArray(VectorSpecies<Double> species, double[] a, int i, VectorMask<Double> 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 DoubleVector fromArray(Species<Double> species, double[] a, int i, int[] indexMap, int j) { Objects.requireNonNull(a); Objects.requireNonNull(indexMap); if (species.length() == 1) { return DoubleVector.fromArray(species, a, i + indexMap[j]); --- 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 DoubleVector fromArray(VectorSpecies<Double> species, double[] a, int i, int[] indexMap, int j) { Objects.requireNonNull(a); Objects.requireNonNull(indexMap); if (species.length() == 1) { return DoubleVector.fromArray(species, a, i + indexMap[j]);
*** 270,280 **** vix = VectorIntrinsics.checkIndex(vix, a.length); return VectorIntrinsics.loadWithMap((Class<DoubleVector>) species.boxType(), double.class, species.length(), IntVector.species(species.indexShape()).boxType(), a, Unsafe.ARRAY_DOUBLE_BASE_OFFSET, vix, a, i, indexMap, j, species, ! (double[] c, int idx, int[] iMap, int idy, Species<Double> s) -> ((DoubleSpecies)s).op(n -> c[idx + iMap[idy+n]])); } /** * Loads a vector from an array using indexes obtained from an index --- 270,280 ---- vix = VectorIntrinsics.checkIndex(vix, a.length); return VectorIntrinsics.loadWithMap((Class<DoubleVector>) species.boxType(), double.class, species.length(), IntVector.species(species.indexShape()).boxType(), a, Unsafe.ARRAY_DOUBLE_BASE_OFFSET, vix, a, i, indexMap, j, species, ! (double[] c, int idx, int[] iMap, int idy, VectorSpecies<Double> s) -> ((DoubleSpecies)s).op(n -> c[idx + iMap[idy+n]])); } /** * Loads a vector from an array using indexes obtained from an index
*** 300,310 **** * {@code N} is set the result of {@code i + indexMap[j + N]} is * {@code < 0} or {@code >= a.length} */ @ForceInline @SuppressWarnings("unchecked") ! public static DoubleVector fromArray(Species<Double> species, double[] a, int i, Mask<Double> 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); } --- 300,310 ---- * {@code N} is set the result of {@code i + indexMap[j + N]} is * {@code < 0} or {@code >= a.length} */ @ForceInline @SuppressWarnings("unchecked") ! public static DoubleVector fromArray(VectorSpecies<Double> species, double[] a, int i, VectorMask<Double> 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); }
*** 315,325 **** * 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<Double>, ByteBuffer, int, Mask)} method} as follows: * <pre>{@code * return this.fromByteBuffer(b, i, this.maskAllTrue()) * }</pre> * * @param species species of desired vector --- 315,325 ---- * 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<Double>, ByteBuffer, int, VectorMask)} method} as follows: * <pre>{@code * return this.fromByteBuffer(b, i, this.maskAllTrue()) * }</pre> * * @param species species of desired vector
*** 332,342 **** * {@code this.length() * this.elementSize() / Byte.SIZE} bytes * remaining in the byte buffer from the given offset */ @ForceInline @SuppressWarnings("unchecked") ! public static DoubleVector fromByteBuffer(Species<Double> 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<DoubleVector>) species.boxType(), double.class, species.length(), --- 332,342 ---- * {@code this.length() * this.elementSize() / Byte.SIZE} bytes * remaining in the byte buffer from the given offset */ @ForceInline @SuppressWarnings("unchecked") ! public static DoubleVector fromByteBuffer(VectorSpecies<Double> 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<DoubleVector>) species.boxType(), double.class, species.length(),
*** 384,394 **** * 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 DoubleVector fromByteBuffer(Species<Double> species, ByteBuffer bb, int ix, Mask<Double> m) { return zero(species).blend(fromByteBuffer(species, bb, ix), m); } /** * Returns a vector where all lane elements are set to the primitive --- 384,394 ---- * 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 DoubleVector fromByteBuffer(VectorSpecies<Double> species, ByteBuffer bb, int ix, VectorMask<Double> m) { return zero(species).blend(fromByteBuffer(species, bb, ix), m); } /** * Returns a vector where all lane elements are set to the primitive
*** 399,409 **** * @return a vector of vector where all lane elements are set to * the primitive value {@code e} */ @ForceInline @SuppressWarnings("unchecked") ! public static DoubleVector broadcast(Species<Double> s, double e) { return VectorIntrinsics.broadcastCoerced( (Class<DoubleVector>) s.boxType(), double.class, s.length(), Double.doubleToLongBits(e), s, ((bits, sp) -> ((DoubleSpecies)sp).op(i -> Double.longBitsToDouble((long)bits)))); } --- 399,409 ---- * @return a vector of vector where all lane elements are set to * the primitive value {@code e} */ @ForceInline @SuppressWarnings("unchecked") ! public static DoubleVector broadcast(VectorSpecies<Double> s, double e) { return VectorIntrinsics.broadcastCoerced( (Class<DoubleVector>) s.boxType(), double.class, s.length(), Double.doubleToLongBits(e), s, ((bits, sp) -> ((DoubleSpecies)sp).op(i -> Double.longBitsToDouble((long)bits)))); }
*** 422,432 **** * value * @throws IndexOutOfBoundsException if {@code es.length < this.length()} */ @ForceInline @SuppressWarnings("unchecked") ! public static DoubleVector scalars(Species<Double> s, double... es) { Objects.requireNonNull(es); int ix = VectorIntrinsics.checkIndex(0, es.length, s.length()); return VectorIntrinsics.load((Class<DoubleVector>) s.boxType(), double.class, s.length(), es, Unsafe.ARRAY_DOUBLE_BASE_OFFSET, es, ix, s, --- 422,432 ---- * value * @throws IndexOutOfBoundsException if {@code es.length < this.length()} */ @ForceInline @SuppressWarnings("unchecked") ! public static DoubleVector scalars(VectorSpecies<Double> s, double... es) { Objects.requireNonNull(es); int ix = VectorIntrinsics.checkIndex(0, es.length, s.length()); return VectorIntrinsics.load((Class<DoubleVector>) s.boxType(), double.class, s.length(), es, Unsafe.ARRAY_DOUBLE_BASE_OFFSET, es, ix, s,
*** 442,452 **** * @param e the value * @return a vector where the first lane element is set to the primitive * value {@code e} */ @ForceInline ! public static final DoubleVector single(Species<Double> s, double e) { return zero(s).with(0, e); } /** * Returns a vector where each lane element is set to a randomly --- 442,452 ---- * @param e the value * @return a vector where the first lane element is set to the primitive * value {@code e} */ @ForceInline ! public static final DoubleVector single(VectorSpecies<Double> s, double e) { return zero(s).with(0, e); } /** * Returns a vector where each lane element is set to a randomly
*** 457,695 **** * * @param s species of the desired vector * @return a vector where each lane elements is set to a randomly * generated primitive value */ ! public static DoubleVector random(Species<Double> s) { ThreadLocalRandom r = ThreadLocalRandom.current(); return ((DoubleSpecies)s).op(i -> r.nextDouble()); } - /** - * 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<Double> maskFromValues(Species<Double> species, boolean... bits) { - if (species.boxType() == DoubleMaxVector.class) - return new DoubleMaxVector.DoubleMaxMask(bits); - switch (species.bitSize()) { - case 64: return new Double64Vector.Double64Mask(bits); - case 128: return new Double128Vector.Double128Mask(bits); - case 256: return new Double256Vector.Double256Mask(bits); - case 512: return new Double512Vector.Double512Mask(bits); - default: throw new IllegalArgumentException(Integer.toString(species.bitSize())); - } - } - - // @@@ This is a bad implementation -- makes lambdas capturing -- fix this - static Mask<Double> trueMask(Species<Double> species) { - if (species.boxType() == DoubleMaxVector.class) - return DoubleMaxVector.DoubleMaxMask.TRUE_MASK; - switch (species.bitSize()) { - case 64: return Double64Vector.Double64Mask.TRUE_MASK; - case 128: return Double128Vector.Double128Mask.TRUE_MASK; - case 256: return Double256Vector.Double256Mask.TRUE_MASK; - case 512: return Double512Vector.Double512Mask.TRUE_MASK; - default: throw new IllegalArgumentException(Integer.toString(species.bitSize())); - } - } - - static Mask<Double> falseMask(Species<Double> species) { - if (species.boxType() == DoubleMaxVector.class) - return DoubleMaxVector.DoubleMaxMask.FALSE_MASK; - switch (species.bitSize()) { - case 64: return Double64Vector.Double64Mask.FALSE_MASK; - case 128: return Double128Vector.Double128Mask.FALSE_MASK; - case 256: return Double256Vector.Double256Mask.FALSE_MASK; - case 512: return Double512Vector.Double512Mask.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<Double> maskFromArray(Species<Double> species, boolean[] bits, int ix) { - Objects.requireNonNull(bits); - ix = VectorIntrinsics.checkIndex(ix, bits.length, species.length()); - return VectorIntrinsics.load((Class<Mask<Double>>) species.maskType(), long.class, species.length(), - bits, (((long) ix) << ARRAY_SHIFT) + Unsafe.ARRAY_BOOLEAN_BASE_OFFSET, - bits, ix, species, - (c, idx, s) -> (Mask<Double>) ((DoubleSpecies)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<Double> maskAllTrue(Species<Double> species) { - return VectorIntrinsics.broadcastCoerced((Class<Mask<Double>>) species.maskType(), long.class, species.length(), - (long)-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<Double> maskAllFalse(Species<Double> species) { - return VectorIntrinsics.broadcastCoerced((Class<Mask<Double>>) species.maskType(), long.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<Double> shuffle(Species<Double> species, IntUnaryOperator f) { - if (species.boxType() == DoubleMaxVector.class) - return new DoubleMaxVector.DoubleMaxShuffle(f); - switch (species.bitSize()) { - case 64: return new Double64Vector.Double64Shuffle(f); - case 128: return new Double128Vector.Double128Shuffle(f); - case 256: return new Double256Vector.Double256Shuffle(f); - case 512: return new Double512Vector.Double512Shuffle(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<Double> shuffleIota(Species<Double> species) { - if (species.boxType() == DoubleMaxVector.class) - return new DoubleMaxVector.DoubleMaxShuffle(AbstractShuffle.IDENTITY); - switch (species.bitSize()) { - case 64: return new Double64Vector.Double64Shuffle(AbstractShuffle.IDENTITY); - case 128: return new Double128Vector.Double128Shuffle(AbstractShuffle.IDENTITY); - case 256: return new Double256Vector.Double256Shuffle(AbstractShuffle.IDENTITY); - case 512: return new Double512Vector.Double512Shuffle(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<Double> shuffleFromValues(Species<Double> species, int... ixs) { - if (species.boxType() == DoubleMaxVector.class) - return new DoubleMaxVector.DoubleMaxShuffle(ixs); - switch (species.bitSize()) { - case 64: return new Double64Vector.Double64Shuffle(ixs); - case 128: return new Double128Vector.Double128Shuffle(ixs); - case 256: return new Double256Vector.Double256Shuffle(ixs); - case 512: return new Double512Vector.Double512Shuffle(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<Double> shuffleFromArray(Species<Double> species, int[] ixs, int i) { - if (species.boxType() == DoubleMaxVector.class) - return new DoubleMaxVector.DoubleMaxShuffle(ixs, i); - switch (species.bitSize()) { - case 64: return new Double64Vector.Double64Shuffle(ixs, i); - case 128: return new Double128Vector.Double128Shuffle(ixs, i); - case 256: return new Double256Vector.Double256Shuffle(ixs, i); - case 512: return new Double512Vector.Double512Shuffle(ixs, i); - default: throw new IllegalArgumentException(Integer.toString(species.bitSize())); - } - } - // Ops @Override public abstract DoubleVector add(Vector<Double> v); --- 457,471 ---- * * @param s species of the desired vector * @return a vector where each lane elements is set to a randomly * generated primitive value */ ! public static DoubleVector random(VectorSpecies<Double> s) { ThreadLocalRandom r = ThreadLocalRandom.current(); return ((DoubleSpecies)s).op(i -> r.nextDouble()); } // Ops @Override public abstract DoubleVector add(Vector<Double> v);
*** 704,714 **** * scalar */ public abstract DoubleVector add(double s); @Override ! public abstract DoubleVector add(Vector<Double> v, Mask<Double> m); /** * Adds this vector to broadcast of an input scalar, * selecting lane elements controlled by a mask. * <p> --- 480,490 ---- * scalar */ public abstract DoubleVector add(double s); @Override ! public abstract DoubleVector add(Vector<Double> v, VectorMask<Double> m); /** * Adds this vector to broadcast of an input scalar, * selecting lane elements controlled by a mask. * <p>
*** 718,728 **** * @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 DoubleVector add(double s, Mask<Double> m); @Override public abstract DoubleVector sub(Vector<Double> v); /** --- 494,504 ---- * @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 DoubleVector add(double s, VectorMask<Double> m); @Override public abstract DoubleVector sub(Vector<Double> v); /**
*** 736,746 **** * scalar from this vector */ public abstract DoubleVector sub(double s); @Override ! public abstract DoubleVector sub(Vector<Double> v, Mask<Double> m); /** * Subtracts the broadcast of an input scalar from this vector, selecting * lane elements controlled by a mask. * <p> --- 512,522 ---- * scalar from this vector */ public abstract DoubleVector sub(double s); @Override ! public abstract DoubleVector sub(Vector<Double> v, VectorMask<Double> m); /** * Subtracts the broadcast of an input scalar from this vector, selecting * lane elements controlled by a mask. * <p>
*** 750,760 **** * @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 DoubleVector sub(double s, Mask<Double> m); @Override public abstract DoubleVector mul(Vector<Double> v); /** --- 526,536 ---- * @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 DoubleVector sub(double s, VectorMask<Double> m); @Override public abstract DoubleVector mul(Vector<Double> v); /**
*** 768,778 **** * input scalar */ public abstract DoubleVector mul(double s); @Override ! public abstract DoubleVector mul(Vector<Double> v, Mask<Double> m); /** * Multiplies this vector with the broadcast of an input scalar, selecting * lane elements controlled by a mask. * <p> --- 544,554 ---- * input scalar */ public abstract DoubleVector mul(double s); @Override ! public abstract DoubleVector mul(Vector<Double> v, VectorMask<Double> m); /** * Multiplies this vector with the broadcast of an input scalar, selecting * lane elements controlled by a mask. * <p>
*** 782,810 **** * @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 DoubleVector mul(double s, Mask<Double> m); @Override public abstract DoubleVector neg(); @Override ! public abstract DoubleVector neg(Mask<Double> m); @Override public abstract DoubleVector abs(); @Override ! public abstract DoubleVector abs(Mask<Double> m); @Override public abstract DoubleVector min(Vector<Double> v); @Override ! public abstract DoubleVector min(Vector<Double> v, Mask<Double> m); /** * Returns the minimum of this vector and the broadcast of an input scalar. * <p> * This is a vector binary operation where the operation --- 558,586 ---- * @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 DoubleVector mul(double s, VectorMask<Double> m); @Override public abstract DoubleVector neg(); @Override ! public abstract DoubleVector neg(VectorMask<Double> m); @Override public abstract DoubleVector abs(); @Override ! public abstract DoubleVector abs(VectorMask<Double> m); @Override public abstract DoubleVector min(Vector<Double> v); @Override ! public abstract DoubleVector min(Vector<Double> v, VectorMask<Double> m); /** * Returns the minimum of this vector and the broadcast of an input scalar. * <p> * This is a vector binary operation where the operation
*** 817,827 **** @Override public abstract DoubleVector max(Vector<Double> v); @Override ! public abstract DoubleVector max(Vector<Double> v, Mask<Double> m); /** * Returns the maximum of this vector and the broadcast of an input scalar. * <p> * This is a vector binary operation where the operation --- 593,603 ---- @Override public abstract DoubleVector max(Vector<Double> v); @Override ! public abstract DoubleVector max(Vector<Double> v, VectorMask<Double> m); /** * Returns the maximum of this vector and the broadcast of an input scalar. * <p> * This is a vector binary operation where the operation
*** 831,841 **** * @return the maximum of this vector and the broadcast of an input scalar */ public abstract DoubleVector max(double s); @Override ! public abstract Mask<Double> equal(Vector<Double> 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 --- 607,617 ---- * @return the maximum of this vector and the broadcast of an input scalar */ public abstract DoubleVector max(double s); @Override ! public abstract VectorMask<Double> equal(Vector<Double> 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
*** 843,856 **** * * @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<Double> equal(double s); @Override ! public abstract Mask<Double> notEqual(Vector<Double> 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 --- 619,632 ---- * * @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<Double> equal(double s); @Override ! public abstract VectorMask<Double> notEqual(Vector<Double> 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
*** 858,871 **** * * @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<Double> notEqual(double s); @Override ! public abstract Mask<Double> lessThan(Vector<Double> 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 --- 634,647 ---- * * @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<Double> notEqual(double s); @Override ! public abstract VectorMask<Double> lessThan(Vector<Double> 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
*** 873,886 **** * * @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<Double> lessThan(double s); @Override ! public abstract Mask<Double> lessThanEq(Vector<Double> 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 --- 649,662 ---- * * @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<Double> lessThan(double s); @Override ! public abstract VectorMask<Double> lessThanEq(Vector<Double> 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
*** 888,901 **** * * @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<Double> lessThanEq(double s); @Override ! public abstract Mask<Double> greaterThan(Vector<Double> 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 --- 664,677 ---- * * @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<Double> lessThanEq(double s); @Override ! public abstract VectorMask<Double> greaterThan(Vector<Double> 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
*** 903,916 **** * * @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<Double> greaterThan(double s); @Override ! public abstract Mask<Double> greaterThanEq(Vector<Double> v); /** * Tests if this vector is greater than or equal to the broadcast of an * input scalar. * <p> --- 679,692 ---- * * @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<Double> greaterThan(double s); @Override ! public abstract VectorMask<Double> greaterThanEq(Vector<Double> v); /** * Tests if this vector is greater than or equal to the broadcast of an * input scalar. * <p>
*** 919,932 **** * * @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<Double> greaterThanEq(double s); @Override ! public abstract DoubleVector blend(Vector<Double> v, Mask<Double> m); /** * Blends the lane elements of this vector with those of the broadcast of an * input scalar, selecting lanes controlled by a mask. * <p> --- 695,708 ---- * * @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<Double> greaterThanEq(double s); @Override ! public abstract DoubleVector blend(Vector<Double> v, VectorMask<Double> m); /** * Blends the lane elements of this vector with those of the broadcast of an * input scalar, selecting lanes controlled by a mask. * <p>
*** 939,959 **** * @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 DoubleVector blend(double s, Mask<Double> m); @Override public abstract DoubleVector rearrange(Vector<Double> v, ! Shuffle<Double> s, Mask<Double> m); @Override ! public abstract DoubleVector rearrange(Shuffle<Double> m); @Override ! public abstract DoubleVector reshape(Species<Double> s); @Override public abstract DoubleVector rotateEL(int i); @Override --- 715,735 ---- * @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 DoubleVector blend(double s, VectorMask<Double> m); @Override public abstract DoubleVector rearrange(Vector<Double> v, ! VectorShuffle<Double> s, VectorMask<Double> m); @Override ! public abstract DoubleVector rearrange(VectorShuffle<Double> m); @Override ! public abstract DoubleVector reshape(VectorSpecies<Double> s); @Override public abstract DoubleVector rotateEL(int i); @Override
*** 997,1007 **** * * @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 DoubleVector div(Vector<Double> v, Mask<Double> m); /** * Divides this vector by the broadcast of an input scalar, selecting lane * elements controlled by a mask. * <p> --- 773,783 ---- * * @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 DoubleVector div(Vector<Double> v, VectorMask<Double> m); /** * Divides this vector by the broadcast of an input scalar, selecting lane * elements controlled by a mask. * <p>
*** 1011,1021 **** * @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 DoubleVector div(double s, Mask<Double> m); /** * Calculates the square root of this vector. * <p> * This is a vector unary operation where the {@link Math#sqrt} operation --- 787,797 ---- * @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 DoubleVector div(double s, VectorMask<Double> m); /** * Calculates the square root of this vector. * <p> * This is a vector unary operation where the {@link Math#sqrt} operation
*** 1033,1043 **** * is applied to lane elements. * * @param m the mask controlling lane selection * @return the square root of this vector */ ! public DoubleVector sqrt(Mask<Double> m) { return uOp(m, (i, a) -> (double) Math.sqrt((double) a)); } /** * Calculates the trigonometric tangent of this vector. --- 809,819 ---- * is applied to lane elements. * * @param m the mask controlling lane selection * @return the square root of this vector */ ! public DoubleVector sqrt(VectorMask<Double> m) { return uOp(m, (i, a) -> (double) Math.sqrt((double) a)); } /** * Calculates the trigonometric tangent of this vector.
*** 1064,1074 **** * described in {@link DoubleVector#tan} * * @param m the mask controlling lane selection * @return the tangent of this vector */ ! public DoubleVector tan(Mask<Double> m) { return uOp(m, (i, a) -> (double) Math.tan((double) a)); } /** * Calculates the hyperbolic tangent of this vector. --- 840,850 ---- * described in {@link DoubleVector#tan} * * @param m the mask controlling lane selection * @return the tangent of this vector */ ! public DoubleVector tan(VectorMask<Double> m) { return uOp(m, (i, a) -> (double) Math.tan((double) a)); } /** * Calculates the hyperbolic tangent of this vector.
*** 1095,1105 **** * described in {@link DoubleVector#tanh} * * @param m the mask controlling lane selection * @return the hyperbolic tangent of this vector */ ! public DoubleVector tanh(Mask<Double> m) { return uOp(m, (i, a) -> (double) Math.tanh((double) a)); } /** * Calculates the trigonometric sine of this vector. --- 871,881 ---- * described in {@link DoubleVector#tanh} * * @param m the mask controlling lane selection * @return the hyperbolic tangent of this vector */ ! public DoubleVector tanh(VectorMask<Double> m) { return uOp(m, (i, a) -> (double) Math.tanh((double) a)); } /** * Calculates the trigonometric sine of this vector.
*** 1126,1136 **** * described in {@link DoubleVector#sin} * * @param m the mask controlling lane selection * @return the sine of this vector */ ! public DoubleVector sin(Mask<Double> m) { return uOp(m, (i, a) -> (double) Math.sin((double) a)); } /** * Calculates the hyperbolic sine of this vector. --- 902,912 ---- * described in {@link DoubleVector#sin} * * @param m the mask controlling lane selection * @return the sine of this vector */ ! public DoubleVector sin(VectorMask<Double> m) { return uOp(m, (i, a) -> (double) Math.sin((double) a)); } /** * Calculates the hyperbolic sine of this vector.
*** 1157,1167 **** * described in {@link DoubleVector#sinh} * * @param m the mask controlling lane selection * @return the hyperbolic sine of this vector */ ! public DoubleVector sinh(Mask<Double> m) { return uOp(m, (i, a) -> (double) Math.sinh((double) a)); } /** * Calculates the trigonometric cosine of this vector. --- 933,943 ---- * described in {@link DoubleVector#sinh} * * @param m the mask controlling lane selection * @return the hyperbolic sine of this vector */ ! public DoubleVector sinh(VectorMask<Double> m) { return uOp(m, (i, a) -> (double) Math.sinh((double) a)); } /** * Calculates the trigonometric cosine of this vector.
*** 1188,1198 **** * described in {@link DoubleVector#cos} * * @param m the mask controlling lane selection * @return the cosine of this vector */ ! public DoubleVector cos(Mask<Double> m) { return uOp(m, (i, a) -> (double) Math.cos((double) a)); } /** * Calculates the hyperbolic cosine of this vector. --- 964,974 ---- * described in {@link DoubleVector#cos} * * @param m the mask controlling lane selection * @return the cosine of this vector */ ! public DoubleVector cos(VectorMask<Double> m) { return uOp(m, (i, a) -> (double) Math.cos((double) a)); } /** * Calculates the hyperbolic cosine of this vector.
*** 1219,1229 **** * described in {@link DoubleVector#cosh} * * @param m the mask controlling lane selection * @return the hyperbolic cosine of this vector */ ! public DoubleVector cosh(Mask<Double> m) { return uOp(m, (i, a) -> (double) Math.cosh((double) a)); } /** * Calculates the arc sine of this vector. --- 995,1005 ---- * described in {@link DoubleVector#cosh} * * @param m the mask controlling lane selection * @return the hyperbolic cosine of this vector */ ! public DoubleVector cosh(VectorMask<Double> m) { return uOp(m, (i, a) -> (double) Math.cosh((double) a)); } /** * Calculates the arc sine of this vector.
*** 1250,1260 **** * described in {@link DoubleVector#asin} * * @param m the mask controlling lane selection * @return the arc sine of this vector */ ! public DoubleVector asin(Mask<Double> m) { return uOp(m, (i, a) -> (double) Math.asin((double) a)); } /** * Calculates the arc cosine of this vector. --- 1026,1036 ---- * described in {@link DoubleVector#asin} * * @param m the mask controlling lane selection * @return the arc sine of this vector */ ! public DoubleVector asin(VectorMask<Double> m) { return uOp(m, (i, a) -> (double) Math.asin((double) a)); } /** * Calculates the arc cosine of this vector.
*** 1281,1291 **** * described in {@link DoubleVector#acos} * * @param m the mask controlling lane selection * @return the arc cosine of this vector */ ! public DoubleVector acos(Mask<Double> m) { return uOp(m, (i, a) -> (double) Math.acos((double) a)); } /** * Calculates the arc tangent of this vector. --- 1057,1067 ---- * described in {@link DoubleVector#acos} * * @param m the mask controlling lane selection * @return the arc cosine of this vector */ ! public DoubleVector acos(VectorMask<Double> m) { return uOp(m, (i, a) -> (double) Math.acos((double) a)); } /** * Calculates the arc tangent of this vector.
*** 1312,1322 **** * described in {@link DoubleVector#atan} * * @param m the mask controlling lane selection * @return the arc tangent of this vector */ ! public DoubleVector atan(Mask<Double> m) { return uOp(m, (i, a) -> (double) Math.atan((double) a)); } /** * Calculates the arc tangent of this vector divided by an input vector. --- 1088,1098 ---- * described in {@link DoubleVector#atan} * * @param m the mask controlling lane selection * @return the arc tangent of this vector */ ! public DoubleVector atan(VectorMask<Double> m) { return uOp(m, (i, a) -> (double) Math.atan((double) a)); } /** * Calculates the arc tangent of this vector divided by an input vector.
*** 1362,1372 **** * * @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 DoubleVector atan2(Vector<Double> v, Mask<Double> m) { return bOp(v, m, (i, a, b) -> (double) Math.atan2((double) a, (double) b)); } /** * Calculates the arc tangent of this vector divided by the broadcast of an --- 1138,1148 ---- * * @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 DoubleVector atan2(Vector<Double> v, VectorMask<Double> m) { return bOp(v, m, (i, a, b) -> (double) Math.atan2((double) a, (double) b)); } /** * Calculates the arc tangent of this vector divided by the broadcast of an
*** 1377,1387 **** * * @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 DoubleVector atan2(double s, Mask<Double> m); /** * Calculates the cube root of this vector. * <p> * This is a vector unary operation with same semantic definition as --- 1153,1163 ---- * * @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 DoubleVector atan2(double s, VectorMask<Double> m); /** * Calculates the cube root of this vector. * <p> * This is a vector unary operation with same semantic definition as
*** 1406,1416 **** * described in {@link DoubleVector#cbrt} * * @param m the mask controlling lane selection * @return the cube root of this vector */ ! public DoubleVector cbrt(Mask<Double> m) { return uOp(m, (i, a) -> (double) Math.cbrt((double) a)); } /** * Calculates the natural logarithm of this vector. --- 1182,1192 ---- * described in {@link DoubleVector#cbrt} * * @param m the mask controlling lane selection * @return the cube root of this vector */ ! public DoubleVector cbrt(VectorMask<Double> m) { return uOp(m, (i, a) -> (double) Math.cbrt((double) a)); } /** * Calculates the natural logarithm of this vector.
*** 1437,1447 **** * described in {@link DoubleVector#log} * * @param m the mask controlling lane selection * @return the natural logarithm of this vector */ ! public DoubleVector log(Mask<Double> m) { return uOp(m, (i, a) -> (double) Math.log((double) a)); } /** * Calculates the base 10 logarithm of this vector. --- 1213,1223 ---- * described in {@link DoubleVector#log} * * @param m the mask controlling lane selection * @return the natural logarithm of this vector */ ! public DoubleVector log(VectorMask<Double> m) { return uOp(m, (i, a) -> (double) Math.log((double) a)); } /** * Calculates the base 10 logarithm of this vector.
*** 1468,1478 **** * described in {@link DoubleVector#log10} * * @param m the mask controlling lane selection * @return the base 10 logarithm of this vector */ ! public DoubleVector log10(Mask<Double> m) { return uOp(m, (i, a) -> (double) Math.log10((double) a)); } /** * Calculates the natural logarithm of the sum of this vector and the --- 1244,1254 ---- * described in {@link DoubleVector#log10} * * @param m the mask controlling lane selection * @return the base 10 logarithm of this vector */ ! public DoubleVector log10(VectorMask<Double> m) { return uOp(m, (i, a) -> (double) Math.log10((double) a)); } /** * Calculates the natural logarithm of the sum of this vector and the
*** 1502,1512 **** * * @param m the mask controlling lane selection * @return the natural logarithm of the sum of this vector and the broadcast * of {@code 1} */ ! public DoubleVector log1p(Mask<Double> m) { return uOp(m, (i, a) -> (double) Math.log1p((double) a)); } /** * Calculates this vector raised to the power of an input vector. --- 1278,1288 ---- * * @param m the mask controlling lane selection * @return the natural logarithm of the sum of this vector and the broadcast * of {@code 1} */ ! public DoubleVector log1p(VectorMask<Double> m) { return uOp(m, (i, a) -> (double) Math.log1p((double) a)); } /** * Calculates this vector raised to the power of an input vector.
*** 1553,1563 **** * * @param v the input vector * @param m the mask controlling lane selection * @return this vector raised to the power of an input vector */ ! public DoubleVector pow(Vector<Double> v, Mask<Double> m) { return bOp(v, m, (i, a, b) -> (double) Math.pow((double) a, (double) b)); } /** * Calculates this vector raised to the power of the broadcast of an input --- 1329,1339 ---- * * @param v the input vector * @param m the mask controlling lane selection * @return this vector raised to the power of an input vector */ ! public DoubleVector pow(Vector<Double> v, VectorMask<Double> m) { return bOp(v, m, (i, a, b) -> (double) Math.pow((double) a, (double) b)); } /** * Calculates this vector raised to the power of the broadcast of an input
*** 1569,1579 **** * @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 DoubleVector pow(double s, Mask<Double> m); /** * Calculates the broadcast of Euler's number {@code e} raised to the power * of this vector. * <p> --- 1345,1355 ---- * @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 DoubleVector pow(double s, VectorMask<Double> m); /** * Calculates the broadcast of Euler's number {@code e} raised to the power * of this vector. * <p>
*** 1601,1611 **** * * @param m the mask controlling lane selection * @return the broadcast of Euler's number {@code e} raised to the power of * this vector */ ! public DoubleVector exp(Mask<Double> m) { return uOp(m, (i, a) -> (double) Math.exp((double) a)); } /** * Calculates the broadcast of Euler's number {@code e} raised to the power --- 1377,1387 ---- * * @param m the mask controlling lane selection * @return the broadcast of Euler's number {@code e} raised to the power of * this vector */ ! public DoubleVector exp(VectorMask<Double> m) { return uOp(m, (i, a) -> (double) Math.exp((double) a)); } /** * Calculates the broadcast of Euler's number {@code e} raised to the power
*** 1646,1656 **** * * @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 DoubleVector expm1(Mask<Double> m) { return uOp(m, (i, a) -> (double) Math.expm1((double) a)); } /** * Calculates the product of this vector and a first input vector summed --- 1422,1432 ---- * * @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 DoubleVector expm1(VectorMask<Double> m) { return uOp(m, (i, a) -> (double) Math.expm1((double) a)); } /** * Calculates the product of this vector and a first input vector summed
*** 1705,1715 **** * @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 DoubleVector fma(Vector<Double> v1, Vector<Double> v2, Mask<Double> 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 --- 1481,1491 ---- * @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 DoubleVector fma(Vector<Double> v1, Vector<Double> v2, VectorMask<Double> 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
*** 1727,1737 **** * @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 DoubleVector fma(double s1, double s2, Mask<Double> 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 --- 1503,1513 ---- * @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 DoubleVector fma(double s1, double s2, VectorMask<Double> 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
*** 1794,1804 **** * @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 DoubleVector hypot(Vector<Double> v, Mask<Double> m) { return bOp(v, m, (i, a, b) -> (double) Math.hypot((double) a, (double) b)); } /** * Calculates square root of the sum of the squares of this vector and the --- 1570,1580 ---- * @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 DoubleVector hypot(Vector<Double> v, VectorMask<Double> m) { return bOp(v, m, (i, a, b) -> (double) Math.hypot((double) a, (double) b)); } /** * Calculates square root of the sum of the squares of this vector and the
*** 1816,1839 **** * @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 DoubleVector hypot(double s, Mask<Double> m); @Override public abstract void intoByteArray(byte[] a, int ix); @Override ! public abstract void intoByteArray(byte[] a, int ix, Mask<Double> m); @Override public abstract void intoByteBuffer(ByteBuffer bb, int ix); @Override ! public abstract void intoByteBuffer(ByteBuffer bb, int ix, Mask<Double> m); // Type specific horizontal reductions /** * Adds all lane elements of this vector. --- 1592,1615 ---- * @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 DoubleVector hypot(double s, VectorMask<Double> m); @Override public abstract void intoByteArray(byte[] a, int ix); @Override ! public abstract void intoByteArray(byte[] a, int ix, VectorMask<Double> m); @Override public abstract void intoByteBuffer(ByteBuffer bb, int ix); @Override ! public abstract void intoByteBuffer(ByteBuffer bb, int ix, VectorMask<Double> m); // Type specific horizontal reductions /** * Adds all lane elements of this vector.
*** 1873,1883 **** * 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 double addAll(Mask<Double> m); /** * Multiplies all lane elements of this vector. * <p> * This is a vector reduction operation where the --- 1649,1659 ---- * 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 double addAll(VectorMask<Double> m); /** * Multiplies all lane elements of this vector. * <p> * This is a vector reduction operation where the
*** 1913,1923 **** * 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 double mulAll(Mask<Double> m); /** * Returns the minimum lane element of this vector. * <p> * This is an associative vector reduction operation where the operation --- 1689,1699 ---- * 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 double mulAll(VectorMask<Double> m); /** * Returns the minimum lane element of this vector. * <p> * This is an associative vector reduction operation where the operation
*** 1939,1949 **** * {@link Double#POSITIVE_INFINITY}. * * @param m the mask controlling lane selection * @return the minimum lane element of this vector */ ! public abstract double minAll(Mask<Double> m); /** * Returns the maximum lane element of this vector. * <p> * This is an associative vector reduction operation where the operation --- 1715,1725 ---- * {@link Double#POSITIVE_INFINITY}. * * @param m the mask controlling lane selection * @return the minimum lane element of this vector */ ! public abstract double minAll(VectorMask<Double> m); /** * Returns the maximum lane element of this vector. * <p> * This is an associative vector reduction operation where the operation
*** 1965,1975 **** * {@link Double#NEGATIVE_INFINITY}. * * @param m the mask controlling lane selection * @return the maximum lane element of this vector */ ! public abstract double maxAll(Mask<Double> m); // Type specific accessors /** --- 1741,1751 ---- * {@link Double#NEGATIVE_INFINITY}. * * @param m the mask controlling lane selection * @return the maximum lane element of this vector */ ! public abstract double maxAll(VectorMask<Double> m); // Type specific accessors /**
*** 2048,2058 **** * @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(double[] a, int i, Mask<Double> m); /** * Stores this vector into an array using indexes obtained from an index * map. * <p> --- 1824,1834 ---- * @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(double[] a, int i, VectorMask<Double> m); /** * Stores this vector into an array using indexes obtained from an index * map. * <p>
*** 2093,2159 **** * {@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(double[] a, int i, Mask<Double> m, int[] indexMap, int j); // Species @Override ! public abstract Species<Double> species(); /** ! * Class representing {@link DoubleVector}'s of the same {@link Vector.Shape Shape}. */ ! static final class DoubleSpecies extends Vector.AbstractSpecies<Double> { final Function<double[], DoubleVector> vectorFactory; - final Function<boolean[], Vector.Mask<Double>> maskFactory; ! private DoubleSpecies(Vector.Shape shape, Class<?> boxType, Class<?> maskType, Function<double[], DoubleVector> vectorFactory, ! Function<boolean[], Vector.Mask<Double>> maskFactory) { ! super(shape, double.class, Double.SIZE, boxType, maskType); this.vectorFactory = vectorFactory; - this.maskFactory = maskFactory; } interface FOp { double apply(int i); } - interface FOpm { - boolean apply(int i); - } - DoubleVector op(FOp f) { double[] res = new double[length()]; for (int i = 0; i < length(); i++) { res[i] = f.apply(i); } return vectorFactory.apply(res); } ! DoubleVector op(Vector.Mask<Double> o, FOp f) { double[] res = new double[length()]; boolean[] mbits = ((AbstractMask<Double>)o).getBits(); for (int i = 0; i < length(); i++) { if (mbits[i]) { res[i] = f.apply(i); } } return vectorFactory.apply(res); } - - Vector.Mask<Double> 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 double}. * <p> --- 1869,1924 ---- * {@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(double[] a, int i, VectorMask<Double> m, int[] indexMap, int j); // Species @Override ! public abstract VectorSpecies<Double> species(); /** ! * Class representing {@link DoubleVector}'s of the same {@link VectorShape VectorShape}. */ ! static final class DoubleSpecies extends AbstractSpecies<Double> { final Function<double[], DoubleVector> vectorFactory; ! private DoubleSpecies(VectorShape shape, Class<?> boxType, Class<?> maskType, Function<double[], DoubleVector> vectorFactory, ! Function<boolean[], VectorMask<Double>> maskFactory, ! Function<IntUnaryOperator, VectorShuffle<Double>> shuffleFromArrayFactory, ! fShuffleFromArray<Double> shuffleFromOpFactory) { ! super(shape, double.class, Double.SIZE, boxType, maskType, maskFactory, ! shuffleFromArrayFactory, shuffleFromOpFactory); this.vectorFactory = vectorFactory; } interface FOp { double apply(int i); } DoubleVector op(FOp f) { double[] res = new double[length()]; for (int i = 0; i < length(); i++) { res[i] = f.apply(i); } return vectorFactory.apply(res); } ! DoubleVector op(VectorMask<Double> o, FOp f) { double[] res = new double[length()]; boolean[] mbits = ((AbstractMask<Double>)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 double}. * <p>
*** 2163,2183 **** * shuffles created from such species will be shape compatible. * * @return the preferred species for an element type of {@code double} */ private static DoubleSpecies preferredSpecies() { ! return (DoubleSpecies) Species.ofPreferred(double.class); } /** * Finds a species for an element type of {@code double} and shape. * * @param s the shape * @return a species for an element type of {@code double} and shape * @throws IllegalArgumentException if no such species exists for the shape */ ! static DoubleSpecies species(Vector.Shape s) { Objects.requireNonNull(s); switch (s) { case S_64_BIT: return (DoubleSpecies) SPECIES_64; case S_128_BIT: return (DoubleSpecies) SPECIES_128; case S_256_BIT: return (DoubleSpecies) SPECIES_256; --- 1928,1948 ---- * shuffles created from such species will be shape compatible. * * @return the preferred species for an element type of {@code double} */ private static DoubleSpecies preferredSpecies() { ! return (DoubleSpecies) VectorSpecies.ofPreferred(double.class); } /** * Finds a species for an element type of {@code double} and shape. * * @param s the shape * @return a species for an element type of {@code double} and shape * @throws IllegalArgumentException if no such species exists for the shape */ ! static DoubleSpecies species(VectorShape s) { Objects.requireNonNull(s); switch (s) { case S_64_BIT: return (DoubleSpecies) SPECIES_64; case S_128_BIT: return (DoubleSpecies) SPECIES_128; case S_256_BIT: return (DoubleSpecies) SPECIES_256;
*** 2185,2215 **** case S_Max_BIT: return (DoubleSpecies) SPECIES_MAX; default: throw new IllegalArgumentException("Bad shape: " + s); } } ! /** Species representing {@link DoubleVector}s of {@link Vector.Shape#S_64_BIT Shape.S_64_BIT}. */ ! public static final Species<Double> SPECIES_64 = new DoubleSpecies(Shape.S_64_BIT, Double64Vector.class, Double64Vector.Double64Mask.class, ! Double64Vector::new, Double64Vector.Double64Mask::new); ! ! /** Species representing {@link DoubleVector}s of {@link Vector.Shape#S_128_BIT Shape.S_128_BIT}. */ ! public static final Species<Double> SPECIES_128 = new DoubleSpecies(Shape.S_128_BIT, Double128Vector.class, Double128Vector.Double128Mask.class, ! Double128Vector::new, Double128Vector.Double128Mask::new); ! ! /** Species representing {@link DoubleVector}s of {@link Vector.Shape#S_256_BIT Shape.S_256_BIT}. */ ! public static final Species<Double> SPECIES_256 = new DoubleSpecies(Shape.S_256_BIT, Double256Vector.class, Double256Vector.Double256Mask.class, ! Double256Vector::new, Double256Vector.Double256Mask::new); ! ! /** Species representing {@link DoubleVector}s of {@link Vector.Shape#S_512_BIT Shape.S_512_BIT}. */ ! public static final Species<Double> SPECIES_512 = new DoubleSpecies(Shape.S_512_BIT, Double512Vector.class, Double512Vector.Double512Mask.class, ! Double512Vector::new, Double512Vector.Double512Mask::new); ! ! /** Species representing {@link DoubleVector}s of {@link Vector.Shape#S_Max_BIT Shape.S_Max_BIT}. */ ! public static final Species<Double> SPECIES_MAX = new DoubleSpecies(Shape.S_Max_BIT, DoubleMaxVector.class, DoubleMaxVector.DoubleMaxMask.class, ! DoubleMaxVector::new, DoubleMaxVector.DoubleMaxMask::new); /** * Preferred species for {@link DoubleVector}s. * A preferred species is a species of maximal bit size for the platform. */ ! public static final Species<Double> SPECIES_PREFERRED = (Species<Double>) preferredSpecies(); } --- 1950,1985 ---- case S_Max_BIT: return (DoubleSpecies) SPECIES_MAX; default: throw new IllegalArgumentException("Bad shape: " + s); } } ! /** Species representing {@link DoubleVector}s of {@link VectorShape#S_64_BIT VectorShape.S_64_BIT}. */ ! public static final VectorSpecies<Double> SPECIES_64 = new DoubleSpecies(VectorShape.S_64_BIT, Double64Vector.class, Double64Vector.Double64Mask.class, ! Double64Vector::new, Double64Vector.Double64Mask::new, ! Double64Vector.Double64Shuffle::new, Double64Vector.Double64Shuffle::new); ! ! /** Species representing {@link DoubleVector}s of {@link VectorShape#S_128_BIT VectorShape.S_128_BIT}. */ ! public static final VectorSpecies<Double> SPECIES_128 = new DoubleSpecies(VectorShape.S_128_BIT, Double128Vector.class, Double128Vector.Double128Mask.class, ! Double128Vector::new, Double128Vector.Double128Mask::new, ! Double128Vector.Double128Shuffle::new, Double128Vector.Double128Shuffle::new); ! ! /** Species representing {@link DoubleVector}s of {@link VectorShape#S_256_BIT VectorShape.S_256_BIT}. */ ! public static final VectorSpecies<Double> SPECIES_256 = new DoubleSpecies(VectorShape.S_256_BIT, Double256Vector.class, Double256Vector.Double256Mask.class, ! Double256Vector::new, Double256Vector.Double256Mask::new, ! Double256Vector.Double256Shuffle::new, Double256Vector.Double256Shuffle::new); ! ! /** Species representing {@link DoubleVector}s of {@link VectorShape#S_512_BIT VectorShape.S_512_BIT}. */ ! public static final VectorSpecies<Double> SPECIES_512 = new DoubleSpecies(VectorShape.S_512_BIT, Double512Vector.class, Double512Vector.Double512Mask.class, ! Double512Vector::new, Double512Vector.Double512Mask::new, ! Double512Vector.Double512Shuffle::new, Double512Vector.Double512Shuffle::new); ! ! /** Species representing {@link DoubleVector}s of {@link VectorShape#S_Max_BIT VectorShape.S_Max_BIT}. */ ! public static final VectorSpecies<Double> SPECIES_MAX = new DoubleSpecies(VectorShape.S_Max_BIT, DoubleMaxVector.class, DoubleMaxVector.DoubleMaxMask.class, ! DoubleMaxVector::new, DoubleMaxVector.DoubleMaxMask::new, ! DoubleMaxVector.DoubleMaxShuffle::new, DoubleMaxVector.DoubleMaxShuffle::new); /** * Preferred species for {@link DoubleVector}s. * A preferred species is a species of maximal bit size for the platform. */ ! public static final VectorSpecies<Double> SPECIES_PREFERRED = (VectorSpecies<Double>) preferredSpecies(); }
< prev index next >