< prev index next >

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

Print this page
rev 55237 : javadoc changes

*** 103,113 **** /** * Returns a vector where all lane elements are set to the default * primitive value. * ! * @return a zero vector */ @ForceInline @SuppressWarnings("unchecked") public static DoubleVector zero(DoubleSpecies species) { return species.zero(); --- 103,114 ---- /** * Returns a vector where all lane elements are set to the default * primitive value. * ! * @param species species of desired vector ! * @return a zero vector of given species */ @ForceInline @SuppressWarnings("unchecked") public static DoubleVector zero(DoubleSpecies species) { return species.zero();
*** 124,133 **** --- 125,135 ---- * {@link #fromByteBuffer(DoubleSpecies, ByteBuffer, int, Mask) method} as follows: * <pre>{@code * return this.fromByteBuffer(ByteBuffer.wrap(a), i, this.maskAllTrue()); * }</pre> * + * @param species species of desired vector * @param a the byte array * @param ix the offset into the array * @return a vector loaded from a byte array * @throws IndexOutOfBoundsException if {@code i < 0} or * {@code i > a.length - (this.length() * this.elementSize() / Byte.SIZE)}
*** 159,168 **** --- 161,171 ---- * {@link #fromByteBuffer(DoubleSpecies, ByteBuffer, int, Mask) method} as follows: * <pre>{@code * return this.fromByteBuffer(ByteBuffer.wrap(a), i, m); * }</pre> * + * @param species species of desired vector * @param a the byte array * @param ix the offset into the array * @param m the mask * @return a vector loaded from a byte array * @throws IndexOutOfBoundsException if {@code i < 0} or
*** 183,192 **** --- 186,196 ---- * <p> * For each vector lane, where {@code N} is the vector lane index, the * array element at index {@code i + N} is placed into the * resulting vector at lane index {@code N}. * + * @param species species of desired vector * @param a the array * @param i the offset into the array * @return the vector loaded from an array * @throws IndexOutOfBoundsException if {@code i < 0}, or * {@code i > a.length - this.length()}
*** 210,219 **** --- 214,224 ---- * if the mask lane at index {@code N} is set then the array element at * index {@code i + N} is placed into the resulting vector at lane index * {@code N}, otherwise the default element value is placed into the * resulting vector at lane index {@code N}. * + * @param species species of desired vector * @param a the array * @param i the offset into the array * @param m the mask * @return the vector loaded from an array * @throws IndexOutOfBoundsException if {@code i < 0}, or
*** 231,240 **** --- 236,246 ---- * <p> * For each vector lane, where {@code N} is the vector lane index, the * array element at index {@code i + indexMap[j + N]} is placed into the * resulting vector at lane index {@code N}. * + * @param species species of desired vector * @param a the array * @param i the offset into the array, may be negative if relative * indexes in the index map compensate to produce a value within the * array bounds * @param indexMap the index map
*** 273,286 **** --- 279,294 ---- * For each vector lane, where {@code N} is the vector lane index, * if the mask lane at index {@code N} is set then the array element at * index {@code i + indexMap[j + N]} is placed into the resulting vector * at lane index {@code N}. * + * @param species species of desired vector * @param a the array * @param i the offset into the array, may be negative if relative * indexes in the index map compensate to produce a value within the * array bounds + * @param m the mask * @param indexMap the index map * @param j the offset into the index map * @return the vector loaded from an array * @throws IndexOutOfBoundsException if {@code j < 0}, or * {@code j > indexMap.length - this.length()},
*** 308,317 **** --- 316,326 ---- * {@link #fromByteBuffer(DoubleSpecies, ByteBuffer, int, Mask)} method} as follows: * <pre>{@code * return this.fromByteBuffer(b, i, this.maskAllTrue()) * }</pre> * + * @param species species of desired vector * @param bb the byte buffer * @param ix the offset into the byte buffer * @return a vector loaded from a byte buffer * @throws IndexOutOfBoundsException if the offset is {@code < 0}, * or {@code > b.limit()},
*** 359,370 **** --- 368,381 ---- * es[n] = eb.get(n); * } * Vector<E> r = ((ESpecies<S>)this).fromArray(es, 0, m); * }</pre> * + * @param species species of desired vector * @param bb the byte buffer * @param ix the offset into the byte buffer + * @param m the mask * @return a vector loaded from a byte buffer * @throws IndexOutOfBoundsException if the offset is {@code < 0}, * or {@code > b.limit()}, * for any vector lane index {@code N} where the mask at lane {@code N} * is set
*** 373,382 **** --- 384,406 ---- @ForceInline public static DoubleVector fromByteBuffer(DoubleSpecies species, ByteBuffer bb, int ix, Mask<Double> m) { return zero(species).blend(fromByteBuffer(species, bb, ix), m); } + /** + * 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(DoubleSpecies species, boolean... bits) { if (species.boxType() == DoubleMaxVector.class) return new DoubleMaxVector.DoubleMaxMask(bits); switch (species.bitSize()) {
*** 411,420 **** --- 435,458 ---- 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 i + 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(DoubleSpecies species, boolean[] bits, int ix) { Objects.requireNonNull(bits); ix = VectorIntrinsics.checkIndex(ix, bits.length, species.length());
*** 422,447 **** --- 460,521 ---- 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 a set. + * + * @param species mask species + * @return a mask where all lanes are a set + */ @ForceInline @SuppressWarnings("unchecked") public static Mask<Double> maskAllTrue(DoubleSpecies species) { return VectorIntrinsics.broadcastCoerced((Class<Mask<Double>>) species.maskType(), long.class, species.length(), (long)-1, species, ((z, s) -> trueMask((DoubleSpecies)s))); } + /** + * Returns a mask where all lanes are a unset. + * + * @param species mask species + * @return a mask where all lanes are a unset + */ @ForceInline @SuppressWarnings("unchecked") public static Mask<Double> maskAllFalse(DoubleSpecies species) { return VectorIntrinsics.broadcastCoerced((Class<Mask<Double>>) species.maskType(), long.class, species.length(), 0, species, ((z, s) -> falseMask((DoubleSpecies)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(DoubleSpecies species, IntUnaryOperator f) { if (species.boxType() == DoubleMaxVector.class) return new DoubleMaxVector.DoubleMaxShuffle(f); switch (species.bitSize()) {
*** 451,460 **** --- 525,547 ---- 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(DoubleSpecies species) { if (species.boxType() == DoubleMaxVector.class) return new DoubleMaxVector.DoubleMaxShuffle(AbstractShuffle.IDENTITY); switch (species.bitSize()) {
*** 464,473 **** --- 551,576 ---- 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(DoubleSpecies species, int... ixs) { if (species.boxType() == DoubleMaxVector.class) return new DoubleMaxVector.DoubleMaxShuffle(ixs); switch (species.bitSize()) {
*** 477,486 **** --- 580,604 ---- 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(DoubleSpecies species, int[] ixs, int i) { if (species.boxType() == DoubleMaxVector.class) return new DoubleMaxVector.DoubleMaxShuffle(ixs, i); switch (species.bitSize()) {
*** 1638,1714 **** @Override public abstract void intoByteBuffer(ByteBuffer bb, int ix, Mask<Double> m); // Type specific horizontal reductions - /** * Adds all lane elements of this vector. * <p> ! * This is an associative vector reduction operation where the addition * operation ({@code +}) is applied to lane elements, ! * and the identity value is {@code 0}. * * @return the addition of all the lane elements of this vector */ public abstract double addAll(); /** * Adds all lane elements of this vector, selecting lane elements * controlled by a mask. * <p> ! * This is an associative vector reduction operation where the addition * operation ({@code +}) is applied to lane elements, ! * and the identity value is {@code 0}. ! * ! * @param m the mask controlling lane selection ! * @return the addition of all the lane elements of this vector ! */ ! public abstract double addAll(Mask<Double> m); ! ! /** ! * Subtracts all lane elements of this vector. ! * <p> ! * This is an associative vector reduction operation where the subtraction ! * operation ({@code -}) is applied to lane elements, ! * and the identity value is {@code 0}. * ! * @return the subtraction of all the lane elements of this vector ! */ ! public abstract double subAll(); ! ! /** ! * Subtracts all lane elements of this vector, selecting lane elements ! * controlled by a mask. ! * <p> ! * This is an associative vector reduction operation where the subtraction ! * operation ({@code -}) is applied to lane elements, ! * and the identity value is {@code 0}. * * @param m the mask controlling lane selection ! * @return the subtraction of all the lane elements of this vector */ ! public abstract double subAll(Mask<Double> m); /** * Multiplies all lane elements of this vector. * <p> ! * This is an associative vector reduction operation where the * multiplication operation ({@code *}) is applied to lane elements, ! * and the identity value is {@code 1}. * * @return the multiplication of all the lane elements of this vector */ public abstract double mulAll(); /** * Multiplies all lane elements of this vector, selecting lane elements * controlled by a mask. * <p> ! * This is an associative vector reduction operation where the * multiplication operation ({@code *}) is applied to lane elements, ! * and the identity value is {@code 1}. * * @param m the mask controlling lane selection * @return the multiplication of all the lane elements of this vector */ public abstract double mulAll(Mask<Double> m); --- 1756,1841 ---- @Override public abstract void intoByteBuffer(ByteBuffer bb, int ix, Mask<Double> m); // Type specific horizontal reductions /** * Adds all lane elements of this vector. * <p> ! * This is a vector reduction operation where the addition * operation ({@code +}) is applied to lane elements, ! * and the identity value is {@code 0.0}. ! * ! * <p>The value of a floating-point sum is a function both of the input values as well ! * as the order of addition operations. The order of addition operations of this method ! * is intentionally not defined to allow for JVM to generate optimal machine ! * code for the underlying platform at runtime. If the platform supports a vector ! * instruction to add all values in the vector, or if there is some other efficient machine ! * code sequence, then the JVM has the option of generating this machine code. Otherwise, ! * the default implementation of adding vectors sequentially from left to right is used. ! * For this reason, the output of this method may vary for the same input values. * * @return the addition of all the lane elements of this vector */ public abstract double addAll(); /** * Adds all lane elements of this vector, selecting lane elements * controlled by a mask. * <p> ! * This is a vector reduction operation where the addition * operation ({@code +}) is applied to lane elements, ! * and the identity value is {@code 0.0}. * ! * <p>The value of a floating-point sum is a function both of the input values as well ! * as the order of addition operations. The order of addition operations of this method ! * is intentionally not defined to allow for JVM to generate optimal machine ! * code for the underlying platform at runtime. If the platform supports a vector ! * instruction to add all values in the vector, or if there is some other efficient machine ! * code sequence, then the JVM has the option of generating this machine code. Otherwise, ! * the default implementation of adding vectors sequentially from left to right is used. ! * 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 * multiplication operation ({@code *}) is applied to lane elements, ! * and the identity value is {@code 1.0}. ! * ! * <p>The order of multiplication operations of this method ! * is intentionally not defined to allow for JVM to generate optimal machine ! * code for the underlying platform at runtime. If the platform supports a vector ! * instruction to multiply all values in the vector, or if there is some other efficient machine ! * code sequence, then the JVM has the option of generating this machine code. Otherwise, ! * the default implementation of multiplying vectors sequentially from left to right is used. ! * For this reason, the output of this method may vary on the same input values. * * @return the multiplication of all the lane elements of this vector */ public abstract double mulAll(); /** * Multiplies all lane elements of this vector, selecting lane elements * controlled by a mask. * <p> ! * This is a vector reduction operation where the * multiplication operation ({@code *}) is applied to lane elements, ! * and the identity value is {@code 1.0}. ! * ! * <p>The order of multiplication operations of this method ! * is intentionally not defined to allow for JVM to generate optimal machine ! * code for the underlying platform at runtime. If the platform supports a vector ! * instruction to multiply all values in the vector, or if there is some other efficient machine ! * code sequence, then the JVM has the option of generating this machine code. Otherwise, ! * the default implementation of multiplying vectors sequentially from left to right is used. ! * 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);
*** 1716,1726 **** /** * Returns the minimum lane element of this vector. * <p> * This is an associative vector reduction operation where the operation * {@code (a, b) -> Math.min(a, b)} is applied to lane elements, ! * and the identity value is {@link Double#MAX_VALUE}. * * @return the minimum lane element of this vector */ public abstract double minAll(); --- 1843,1854 ---- /** * Returns the minimum lane element of this vector. * <p> * This is an associative vector reduction operation where the operation * {@code (a, b) -> Math.min(a, b)} is applied to lane elements, ! * and the identity value is ! * {@link Double#POSITIVE_INFINITY}. * * @return the minimum lane element of this vector */ public abstract double minAll();
*** 1728,1738 **** * Returns the minimum lane element of this vector, selecting lane elements * controlled by a mask. * <p> * This is an associative vector reduction operation where the operation * {@code (a, b) -> Math.min(a, b)} is applied to lane elements, ! * and the identity value is {@link Double#MAX_VALUE}. * * @param m the mask controlling lane selection * @return the minimum lane element of this vector */ public abstract double minAll(Mask<Double> m); --- 1856,1867 ---- * Returns the minimum lane element of this vector, selecting lane elements * controlled by a mask. * <p> * This is an associative vector reduction operation where the operation * {@code (a, b) -> Math.min(a, b)} is applied to lane elements, ! * and the identity value is ! * {@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);
*** 1740,1750 **** /** * Returns the maximum lane element of this vector. * <p> * This is an associative vector reduction operation where the operation * {@code (a, b) -> Math.max(a, b)} is applied to lane elements, ! * and the identity value is {@link Double#MIN_VALUE}. * * @return the maximum lane element of this vector */ public abstract double maxAll(); --- 1869,1880 ---- /** * Returns the maximum lane element of this vector. * <p> * This is an associative vector reduction operation where the operation * {@code (a, b) -> Math.max(a, b)} is applied to lane elements, ! * and the identity value is ! * {@link Double#NEGATIVE_INFINITY}. * * @return the maximum lane element of this vector */ public abstract double maxAll();
*** 1752,1762 **** * Returns the maximum lane element of this vector, selecting lane elements * controlled by a mask. * <p> * This is an associative vector reduction operation where the operation * {@code (a, b) -> Math.max(a, b)} is applied to lane elements, ! * and the identity value is {@link Double#MIN_VALUE}. * * @param m the mask controlling lane selection * @return the maximum lane element of this vector */ public abstract double maxAll(Mask<Double> m); --- 1882,1893 ---- * Returns the maximum lane element of this vector, selecting lane elements * controlled by a mask. * <p> * This is an associative vector reduction operation where the operation * {@code (a, b) -> Math.max(a, b)} is applied to lane elements, ! * and the identity value is ! * {@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);
*** 1948,1958 **** /** * Returns a vector where each lane element is set to a randomly * generated primitive value. * * The semantics are equivalent to calling ! * {@link ThreadLocalRandom#nextDouble } * * @return a vector where each lane elements is set to a randomly * generated primitive value */ public DoubleVector random() { --- 2079,2089 ---- /** * Returns a vector where each lane element is set to a randomly * generated primitive value. * * The semantics are equivalent to calling ! * {@code ThreadLocalRandom#nextDouble}. * * @return a vector where each lane elements is set to a randomly * generated primitive value */ public DoubleVector random() {
< prev index next >