--- old/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/ShortVector.java 2019-04-19 11:39:56.818087600 -0700 +++ new/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/ShortVector.java 2019-04-19 11:39:56.365053100 -0700 @@ -125,26 +125,26 @@ *

* This method behaves as if it returns the result of calling the * byte buffer, offset, and mask accepting - * {@link #fromByteBuffer(VectorSpecies, ByteBuffer, int, VectorMask) method} as follows: + * {@link #fromByteBuffer(VectorSpecies, ByteBuffer, int, VectorMask) method} as follows: *

{@code
-     * return this.fromByteBuffer(ByteBuffer.wrap(a), i, this.maskAllTrue());
+     * return fromByteBuffer(species, ByteBuffer.wrap(a), offset, VectorMask.allTrue());
      * }
* * @param species species of desired vector * @param a the byte array - * @param ix the offset into the array + * @param offset 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)} + * {@code offset > a.length - (species.length() * species.elementSize() / Byte.SIZE)} */ @ForceInline @SuppressWarnings("unchecked") - public static ShortVector fromByteArray(VectorSpecies species, byte[] a, int ix) { + public static ShortVector fromByteArray(VectorSpecies species, byte[] a, int offset) { Objects.requireNonNull(a); - ix = VectorIntrinsics.checkIndex(ix, a.length, species.bitSize() / Byte.SIZE); + offset = VectorIntrinsics.checkIndex(offset, a.length, species.bitSize() / Byte.SIZE); return VectorIntrinsics.load((Class) species.boxType(), short.class, species.length(), - a, ((long) ix) + Unsafe.ARRAY_BYTE_BASE_OFFSET, - a, ix, species, + a, ((long) offset) + Unsafe.ARRAY_BYTE_BASE_OFFSET, + a, offset, species, (c, idx, s) -> { ByteBuffer bbc = ByteBuffer.wrap(c, idx, a.length - idx).order(ByteOrder.nativeOrder()); ShortBuffer tb = bbc.asShortBuffer(); @@ -161,51 +161,48 @@ *

* This method behaves as if it returns the result of calling the * byte buffer, offset, and mask accepting - * {@link #fromByteBuffer(VectorSpecies, ByteBuffer, int, VectorMask) method} as follows: + * {@link #fromByteBuffer(VectorSpecies, ByteBuffer, int, VectorMask) method} as follows: *

{@code
-     * return this.fromByteBuffer(ByteBuffer.wrap(a), i, m);
+     * return fromByteBuffer(species, ByteBuffer.wrap(a), offset, m);
      * }
* * @param species species of desired vector * @param a the byte array - * @param ix the offset into the array + * @param offset the offset into the array * @param m the mask * @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)} - * @throws IndexOutOfBoundsException if the offset is {@code < 0}, - * or {@code > a.length}, + * @throws IndexOutOfBoundsException if {@code offset < 0} or * 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)} + * {@code offset >= a.length - (N * species.elementSize() / Byte.SIZE)} */ @ForceInline - public static ShortVector fromByteArray(VectorSpecies species, byte[] a, int ix, VectorMask m) { - return zero(species).blend(fromByteArray(species, a, ix), m); + public static ShortVector fromByteArray(VectorSpecies species, byte[] a, int offset, VectorMask m) { + return zero(species).blend(fromByteArray(species, a, offset), m); } /** * Loads a vector from an array starting at offset. *

* For each vector lane, where {@code N} is the vector lane index, the - * array element at index {@code i + N} is placed into the + * array element at index {@code offset + 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 + * @param offset 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()} + * @throws IndexOutOfBoundsException if {@code offset < 0}, or + * {@code offset > a.length - species.length()} */ @ForceInline @SuppressWarnings("unchecked") - public static ShortVector fromArray(VectorSpecies species, short[] a, int i){ + public static ShortVector fromArray(VectorSpecies species, short[] a, int offset){ Objects.requireNonNull(a); - i = VectorIntrinsics.checkIndex(i, a.length, species.length()); + offset = VectorIntrinsics.checkIndex(offset, a.length, species.length()); return VectorIntrinsics.load((Class) species.boxType(), short.class, species.length(), - a, (((long) i) << ARRAY_SHIFT) + Unsafe.ARRAY_SHORT_BASE_OFFSET, - a, i, species, + a, (((long) offset) << ARRAY_SHIFT) + Unsafe.ARRAY_SHORT_BASE_OFFSET, + a, offset, species, (c, idx, s) -> ((ShortSpecies)s).op(n -> c[idx + n])); } @@ -215,22 +212,22 @@ *

* 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 + N} is placed into the resulting vector at lane index + * index {@code offset + 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 offset the offset into the array * @param m the mask * @return the vector loaded from an array - * @throws IndexOutOfBoundsException if {@code i < 0}, or + * @throws IndexOutOfBoundsException if {@code offset < 0}, or * for any vector lane index {@code N} where the mask at lane {@code N} - * is set {@code i > a.length - N} + * is set {@code offset > a.length - N} */ @ForceInline - public static ShortVector fromArray(VectorSpecies species, short[] a, int i, VectorMask m) { - return zero(species).blend(fromArray(species, a, i), m); + public static ShortVector fromArray(VectorSpecies species, short[] a, int offset, VectorMask m) { + return zero(species).blend(fromArray(species, a, offset), m); } /** @@ -238,24 +235,24 @@ * map. *

* 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 + * array element at index {@code a_offset + indexMap[i_offset + 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 + * @param a_offset 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 - * @param j the offset into the index map + * @param i_offset 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()}, + * @throws IndexOutOfBoundsException if {@code i_offset < 0}, or + * {@code i_offset > indexMap.length - species.length()}, * or for any vector lane index {@code N} the result of - * {@code i + indexMap[j + N]} is {@code < 0} or {@code >= a.length} + * {@code a_offset + indexMap[i_offset + N]} is {@code < 0} or {@code >= a.length} */ - public static ShortVector fromArray(VectorSpecies species, short[] a, int i, int[] indexMap, int j) { - return ((ShortSpecies)species).op(n -> a[i + indexMap[j + n]]); + public static ShortVector fromArray(VectorSpecies species, short[] a, int a_offset, int[] indexMap, int i_offset) { + return ((ShortSpecies)species).op(n -> a[a_offset + indexMap[i_offset + n]]); } /** * Loads a vector from an array using indexes obtained from an index @@ -263,26 +260,26 @@ *

* 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 + * index {@code a_offset + indexMap[i_offset + 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 + * @param a_offset 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 + * @param i_offset 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()}, + * @throws IndexOutOfBoundsException if {@code i_offset < 0}, or + * {@code i_offset > indexMap.length - species.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 N} is set the result of {@code a_offset + indexMap[i_offset + N]} is * {@code < 0} or {@code >= a.length} */ - public static ShortVector fromArray(VectorSpecies species, short[] a, int i, VectorMask m, int[] indexMap, int j) { - return ((ShortSpecies)species).op(m, n -> a[i + indexMap[j + n]]); + public static ShortVector fromArray(VectorSpecies species, short[] a, int a_offset, VectorMask m, int[] indexMap, int i_offset) { + return ((ShortSpecies)species).op(m, n -> a[a_offset + indexMap[i_offset + n]]); } /** @@ -294,31 +291,31 @@ *

* This method behaves as if it returns the result of calling the * byte buffer, offset, and mask accepting - * {@link #fromByteBuffer(VectorSpecies, ByteBuffer, int, VectorMask)} method} as follows: + * {@link #fromByteBuffer(VectorSpecies, ByteBuffer, int, VectorMask)} method} as follows: *

{@code
-     *   return this.fromByteBuffer(b, i, this.maskAllTrue())
+     *   return fromByteBuffer(b, offset, VectorMask.allTrue())
      * }
* * @param species species of desired vector * @param bb the byte buffer - * @param ix the offset into the byte buffer + * @param offset 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()}, * or if there are fewer than - * {@code this.length() * this.elementSize() / Byte.SIZE} bytes + * {@code species.length() * species.elementSize() / Byte.SIZE} bytes * remaining in the byte buffer from the given offset */ @ForceInline @SuppressWarnings("unchecked") - public static ShortVector fromByteBuffer(VectorSpecies species, ByteBuffer bb, int ix) { + public static ShortVector fromByteBuffer(VectorSpecies species, ByteBuffer bb, int offset) { if (bb.order() != ByteOrder.nativeOrder()) { throw new IllegalArgumentException(); } - ix = VectorIntrinsics.checkIndex(ix, bb.limit(), species.bitSize() / Byte.SIZE); + offset = VectorIntrinsics.checkIndex(offset, bb.limit(), species.bitSize() / Byte.SIZE); return VectorIntrinsics.load((Class) species.boxType(), short.class, species.length(), - U.getReference(bb, BYTE_BUFFER_HB), U.getLong(bb, BUFFER_ADDRESS) + ix, - bb, ix, species, + U.getReference(bb, BYTE_BUFFER_HB), U.getLong(bb, BUFFER_ADDRESS) + offset, + bb, offset, species, (c, idx, s) -> { ByteBuffer bbc = c.duplicate().position(idx).order(ByteOrder.nativeOrder()); ShortBuffer tb = bbc.asShortBuffer(); @@ -336,77 +333,77 @@ * the returned vector is loaded with a mask from a primitive array * obtained from the primitive buffer. * The following pseudocode expresses the behaviour, where - * {@coce EBuffer} is the primitive buffer type, {@code e} is the - * primitive element type, and {@code ESpecies} is the primitive + * {@code EBuffer} is the primitive buffer type, {@code e} is the + * primitive element type, and {@code ESpecies} is the primitive * species for {@code e}: *
{@code
      * EBuffer eb = b.duplicate().
-     *     order(ByteOrder.nativeOrder()).position(i).
+     *     order(ByteOrder.nativeOrder()).position(offset).
      *     asEBuffer();
-     * e[] es = new e[this.length()];
+     * e[] es = new e[species.length()];
      * for (int n = 0; n < t.length; n++) {
      *     if (m.isSet(n))
      *         es[n] = eb.get(n);
      * }
-     * Vector r = ((ESpecies)this).fromArray(es, 0, m);
+     * EVector r = EVector.fromArray(es, 0, m);
      * }
* * @param species species of desired vector * @param bb the byte buffer - * @param ix the offset into the byte buffer + * @param offset 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 - * {@code i >= b.limit() - (N * this.elementSize() / Byte.SIZE)} + * {@code offset >= b.limit() - (N * species.elementSize() / Byte.SIZE)} */ @ForceInline - public static ShortVector fromByteBuffer(VectorSpecies species, ByteBuffer bb, int ix, VectorMask m) { - return zero(species).blend(fromByteBuffer(species, bb, ix), m); + public static ShortVector fromByteBuffer(VectorSpecies species, ByteBuffer bb, int offset, VectorMask m) { + return zero(species).blend(fromByteBuffer(species, bb, offset), m); } /** * Returns a vector where all lane elements are set to the primitive * value {@code e}. * - * @param s species of the desired vector + * @param species species of the desired vector * @param e the value * @return a vector of vector where all lane elements are set to * the primitive value {@code e} */ @ForceInline @SuppressWarnings("unchecked") - public static ShortVector broadcast(VectorSpecies s, short e) { + public static ShortVector broadcast(VectorSpecies species, short e) { return VectorIntrinsics.broadcastCoerced( - (Class) s.boxType(), short.class, s.length(), - e, s, + (Class) species.boxType(), short.class, species.length(), + e, species, ((bits, sp) -> ((ShortSpecies)sp).op(i -> (short)bits))); } /** - * Returns a vector where each lane element is set to a given - * primitive value. + * Returns a vector where each lane element is set to given + * primitive values. *

* For each vector lane, where {@code N} is the vector lane index, the * the primitive value at index {@code N} is placed into the resulting * vector at lane index {@code N}. * - * @param s species of the desired vector + * @param species species of the desired vector * @param es the given primitive values - * @return a vector where each lane element is set to a given primitive - * value - * @throws IndexOutOfBoundsException if {@code es.length < this.length()} + * @return a vector where each lane element is set to given primitive + * values + * @throws IndexOutOfBoundsException if {@code es.length < species.length()} */ @ForceInline @SuppressWarnings("unchecked") - public static ShortVector scalars(VectorSpecies s, short... es) { + public static ShortVector scalars(VectorSpecies species, short... es) { Objects.requireNonNull(es); - int ix = VectorIntrinsics.checkIndex(0, es.length, s.length()); - return VectorIntrinsics.load((Class) s.boxType(), short.class, s.length(), + int ix = VectorIntrinsics.checkIndex(0, es.length, species.length()); + return VectorIntrinsics.load((Class) species.boxType(), short.class, species.length(), es, Unsafe.ARRAY_SHORT_BASE_OFFSET, - es, ix, s, + es, ix, species, (c, idx, sp) -> ((ShortSpecies)sp).op(n -> c[idx + n])); } @@ -415,14 +412,14 @@ * value {@code e}, all other lane elements are set to the default * value. * - * @param s species of the desired vector + * @param species species of the desired vector * @param e the value * @return a vector where the first lane element is set to the primitive * value {@code e} */ @ForceInline - public static final ShortVector single(VectorSpecies s, short e) { - return zero(s).with(0, e); + public static final ShortVector single(VectorSpecies species, short e) { + return zero(species).with(0, e); } /** @@ -432,25 +429,28 @@ * The semantics are equivalent to calling * (short){@link ThreadLocalRandom#nextInt()} * - * @param s species of the desired vector + * @param species species of the desired vector * @return a vector where each lane elements is set to a randomly * generated primitive value */ - public static ShortVector random(VectorSpecies s) { + public static ShortVector random(VectorSpecies species) { ThreadLocalRandom r = ThreadLocalRandom.current(); - return ((ShortSpecies)s).op(i -> (short) r.nextInt()); + return ((ShortSpecies)species).op(i -> (short) r.nextInt()); } // Ops + /** + * {@inheritDoc} + */ @Override public abstract ShortVector add(Vector v); /** * Adds this vector to the broadcast of an input scalar. *

- * This is a vector binary operation where the primitive addition operation - * ({@code +}) is applied to lane elements. + * This is a lane-wise binary operation which applies the primitive addition operation + * ({@code +}) to each lane. * * @param s the input scalar * @return the result of adding this vector to the broadcast of an input @@ -458,6 +458,9 @@ */ public abstract ShortVector add(short s); + /** + * {@inheritDoc} + */ @Override public abstract ShortVector add(Vector v, VectorMask m); @@ -465,8 +468,8 @@ * Adds this vector to broadcast of an input scalar, * selecting lane elements controlled by a mask. *

- * This is a vector binary operation where the primitive addition operation - * ({@code +}) is applied to lane elements. + * This is a lane-wise binary operation which applies the primitive addition operation + * ({@code +}) to each lane. * * @param s the input scalar * @param m the mask controlling lane selection @@ -475,14 +478,17 @@ */ public abstract ShortVector add(short s, VectorMask m); + /** + * {@inheritDoc} + */ @Override public abstract ShortVector sub(Vector v); /** * Subtracts the broadcast of an input scalar from this vector. *

- * This is a vector binary operation where the primitive subtraction - * operation ({@code -}) is applied to lane elements. + * This is a lane-wise binary operation which applies the primitive subtraction + * operation ({@code -}) to each lane. * * @param s the input scalar * @return the result of subtracting the broadcast of an input @@ -490,6 +496,9 @@ */ public abstract ShortVector sub(short s); + /** + * {@inheritDoc} + */ @Override public abstract ShortVector sub(Vector v, VectorMask m); @@ -497,8 +506,8 @@ * Subtracts the broadcast of an input scalar from this vector, selecting * lane elements controlled by a mask. *

- * This is a vector binary operation where the primitive subtraction - * operation ({@code -}) is applied to lane elements. + * This is a lane-wise binary operation which applies the primitive subtraction + * operation ({@code -}) to each lane. * * @param s the input scalar * @param m the mask controlling lane selection @@ -507,14 +516,17 @@ */ public abstract ShortVector sub(short s, VectorMask m); + /** + * {@inheritDoc} + */ @Override public abstract ShortVector mul(Vector v); /** * Multiplies this vector with the broadcast of an input scalar. *

- * This is a vector binary operation where the primitive multiplication - * operation ({@code *}) is applied to lane elements. + * This is a lane-wise binary operation which applies the primitive multiplication + * operation ({@code *}) to each lane. * * @param s the input scalar * @return the result of multiplying this vector with the broadcast of an @@ -522,6 +534,9 @@ */ public abstract ShortVector mul(short s); + /** + * {@inheritDoc} + */ @Override public abstract ShortVector mul(Vector v, VectorMask m); @@ -529,8 +544,8 @@ * Multiplies this vector with the broadcast of an input scalar, selecting * lane elements controlled by a mask. *

- * This is a vector binary operation where the primitive multiplication - * operation ({@code *}) is applied to lane elements. + * This is a lane-wise binary operation which applies the primitive multiplication + * operation ({@code *}) to each lane. * * @param s the input scalar * @param m the mask controlling lane selection @@ -539,60 +554,87 @@ */ public abstract ShortVector mul(short s, VectorMask m); + /** + * {@inheritDoc} + */ @Override public abstract ShortVector neg(); + /** + * {@inheritDoc} + */ @Override public abstract ShortVector neg(VectorMask m); + /** + * {@inheritDoc} + */ @Override public abstract ShortVector abs(); + /** + * {@inheritDoc} + */ @Override public abstract ShortVector abs(VectorMask m); + /** + * {@inheritDoc} + */ @Override public abstract ShortVector min(Vector v); + /** + * {@inheritDoc} + */ @Override public abstract ShortVector min(Vector v, VectorMask m); /** * Returns the minimum of this vector and the broadcast of an input scalar. *

- * This is a vector binary operation where the operation - * {@code (a, b) -> Math.min(a, b)} is applied to lane elements. + * This is a lane-wise binary operation which applies the operation + * {@code (a, b) -> Math.min(a, b)} to each lane. * * @param s the input scalar * @return the minimum of this vector and the broadcast of an input scalar */ public abstract ShortVector min(short s); + /** + * {@inheritDoc} + */ @Override public abstract ShortVector max(Vector v); + /** + * {@inheritDoc} + */ @Override public abstract ShortVector max(Vector v, VectorMask m); /** * Returns the maximum of this vector and the broadcast of an input scalar. *

- * This is a vector binary operation where the operation - * {@code (a, b) -> Math.max(a, b)} is applied to lane elements. + * This is a lane-wise binary operation which applies the operation + * {@code (a, b) -> Math.max(a, b)} to each lane. * * @param s the input scalar * @return the maximum of this vector and the broadcast of an input scalar */ public abstract ShortVector max(short s); + /** + * {@inheritDoc} + */ @Override public abstract VectorMask equal(Vector v); /** * Tests if this vector is equal to the broadcast of an input scalar. *

- * This is a vector binary test operation where the primitive equals - * operation ({@code ==}) is applied to lane elements. + * This is a lane-wise binary test operation which applies the primitive equals + * operation ({@code ==}) each lane. * * @param s the input scalar * @return the result mask of testing if this vector is equal to the @@ -600,14 +642,17 @@ */ public abstract VectorMask equal(short s); + /** + * {@inheritDoc} + */ @Override public abstract VectorMask notEqual(Vector v); /** * Tests if this vector is not equal to the broadcast of an input scalar. *

- * This is a vector binary test operation where the primitive not equals - * operation ({@code !=}) is applied to lane elements. + * This is a lane-wise binary test operation which applies the primitive not equals + * operation ({@code !=}) to each lane. * * @param s the input scalar * @return the result mask of testing if this vector is not equal to the @@ -615,14 +660,17 @@ */ public abstract VectorMask notEqual(short s); + /** + * {@inheritDoc} + */ @Override public abstract VectorMask lessThan(Vector v); /** * Tests if this vector is less than the broadcast of an input scalar. *

- * This is a vector binary test operation where the primitive less than - * operation ({@code <}) is applied to lane elements. + * This is a lane-wise binary test operation which applies the primitive less than + * operation ({@code <}) to each lane. * * @param s the input scalar * @return the mask result of testing if this vector is less than the @@ -630,14 +678,17 @@ */ public abstract VectorMask lessThan(short s); + /** + * {@inheritDoc} + */ @Override public abstract VectorMask lessThanEq(Vector v); /** * Tests if this vector is less or equal to the broadcast of an input scalar. *

- * This is a vector binary test operation where the primitive less than - * or equal to operation ({@code <=}) is applied to lane elements. + * This is a lane-wise binary test operation which applies the primitive less than + * or equal to operation ({@code <=}) to each lane. * * @param s the input scalar * @return the mask result of testing if this vector is less than or equal @@ -645,14 +696,17 @@ */ public abstract VectorMask lessThanEq(short s); + /** + * {@inheritDoc} + */ @Override public abstract VectorMask greaterThan(Vector v); /** * Tests if this vector is greater than the broadcast of an input scalar. *

- * This is a vector binary test operation where the primitive greater than - * operation ({@code >}) is applied to lane elements. + * This is a lane-wise binary test operation which applies the primitive greater than + * operation ({@code >}) to each lane. * * @param s the input scalar * @return the mask result of testing if this vector is greater than the @@ -660,6 +714,9 @@ */ public abstract VectorMask greaterThan(short s); + /** + * {@inheritDoc} + */ @Override public abstract VectorMask greaterThanEq(Vector v); @@ -667,8 +724,8 @@ * Tests if this vector is greater than or equal to the broadcast of an * input scalar. *

- * This is a vector binary test operation where the primitive greater than - * or equal to operation ({@code >=}) is applied to lane elements. + * This is a lane-wise binary test operation which applies the primitive greater than + * or equal to operation ({@code >=}) to each lane. * * @param s the input scalar * @return the mask result of testing if this vector is greater than or @@ -676,6 +733,9 @@ */ public abstract VectorMask greaterThanEq(short s); + /** + * {@inheritDoc} + */ @Override public abstract ShortVector blend(Vector v, VectorMask m); @@ -696,25 +756,46 @@ */ public abstract ShortVector blend(short s, VectorMask m); + /** + * {@inheritDoc} + */ @Override public abstract ShortVector rearrange(Vector v, VectorShuffle s, VectorMask m); + /** + * {@inheritDoc} + */ @Override public abstract ShortVector rearrange(VectorShuffle m); + /** + * {@inheritDoc} + */ @Override public abstract ShortVector reshape(VectorSpecies s); + /** + * {@inheritDoc} + */ @Override public abstract ShortVector rotateEL(int i); + /** + * {@inheritDoc} + */ @Override public abstract ShortVector rotateER(int i); + /** + * {@inheritDoc} + */ @Override public abstract ShortVector shiftEL(int i); + /** + * {@inheritDoc} + */ @Override public abstract ShortVector shiftER(int i); @@ -723,8 +804,8 @@ /** * Bitwise ANDs this vector with an input vector. *

- * This is a vector binary operation where the primitive bitwise AND - * operation ({@code &}) is applied to lane elements. + * This is a lane-wise binary operation which applies the primitive bitwise AND + * operation ({@code &}) to each lane. * * @param v the input vector * @return the bitwise AND of this vector with the input vector @@ -734,8 +815,8 @@ /** * Bitwise ANDs this vector with the broadcast of an input scalar. *

- * This is a vector binary operation where the primitive bitwise AND - * operation ({@code &}) is applied to lane elements. + * This is a lane-wise binary operation which applies the primitive bitwise AND + * operation ({@code &}) to each lane. * * @param s the input scalar * @return the bitwise AND of this vector with the broadcast of an input @@ -747,8 +828,8 @@ * Bitwise ANDs this vector with an input vector, selecting lane elements * controlled by a mask. *

- * This is a vector binary operation where the primitive bitwise AND - * operation ({@code &}) is applied to lane elements. + * This is a lane-wise binary operation which applies the primitive bitwise AND + * operation ({@code &}) to each lane. * * @param v the input vector * @param m the mask controlling lane selection @@ -760,8 +841,8 @@ * Bitwise ANDs this vector with the broadcast of an input scalar, selecting * lane elements controlled by a mask. *

- * This is a vector binary operation where the primitive bitwise AND - * operation ({@code &}) is applied to lane elements. + * This is a lane-wise binary operation which applies the primitive bitwise AND + * operation ({@code &}) to each lane. * * @param s the input scalar * @param m the mask controlling lane selection @@ -773,8 +854,8 @@ /** * Bitwise ORs this vector with an input vector. *

- * This is a vector binary operation where the primitive bitwise OR - * operation ({@code |}) is applied to lane elements. + * This is a lane-wise binary operation which applies the primitive bitwise OR + * operation ({@code |}) to each lane. * * @param v the input vector * @return the bitwise OR of this vector with the input vector @@ -784,8 +865,8 @@ /** * Bitwise ORs this vector with the broadcast of an input scalar. *

- * This is a vector binary operation where the primitive bitwise OR - * operation ({@code |}) is applied to lane elements. + * This is a lane-wise binary operation which applies the primitive bitwise OR + * operation ({@code |}) to each lane. * * @param s the input scalar * @return the bitwise OR of this vector with the broadcast of an input @@ -797,8 +878,8 @@ * Bitwise ORs this vector with an input vector, selecting lane elements * controlled by a mask. *

- * This is a vector binary operation where the primitive bitwise OR - * operation ({@code |}) is applied to lane elements. + * This is a lane-wise binary operation which applies the primitive bitwise OR + * operation ({@code |}) to each lane. * * @param v the input vector * @param m the mask controlling lane selection @@ -810,8 +891,8 @@ * Bitwise ORs this vector with the broadcast of an input scalar, selecting * lane elements controlled by a mask. *

- * This is a vector binary operation where the primitive bitwise OR - * operation ({@code |}) is applied to lane elements. + * This is a lane-wise binary operation which applies the primitive bitwise OR + * operation ({@code |}) to each lane. * * @param s the input scalar * @param m the mask controlling lane selection @@ -823,8 +904,8 @@ /** * Bitwise XORs this vector with an input vector. *

- * This is a vector binary operation where the primitive bitwise XOR - * operation ({@code ^}) is applied to lane elements. + * This is a lane-wise binary operation which applies the primitive bitwise XOR + * operation ({@code ^}) to each lane. * * @param v the input vector * @return the bitwise XOR of this vector with the input vector @@ -834,8 +915,8 @@ /** * Bitwise XORs this vector with the broadcast of an input scalar. *

- * This is a vector binary operation where the primitive bitwise XOR - * operation ({@code ^}) is applied to lane elements. + * This is a lane-wise binary operation which applies the primitive bitwise XOR + * operation ({@code ^}) to each lane. * * @param s the input scalar * @return the bitwise XOR of this vector with the broadcast of an input @@ -847,8 +928,8 @@ * Bitwise XORs this vector with an input vector, selecting lane elements * controlled by a mask. *

- * This is a vector binary operation where the primitive bitwise XOR - * operation ({@code ^}) is applied to lane elements. + * This is a lane-wise binary operation which applies the primitive bitwise XOR + * operation ({@code ^}) to each lane. * * @param v the input vector * @param m the mask controlling lane selection @@ -860,8 +941,8 @@ * Bitwise XORs this vector with the broadcast of an input scalar, selecting * lane elements controlled by a mask. *

- * This is a vector binary operation where the primitive bitwise XOR - * operation ({@code ^}) is applied to lane elements. + * This is a lane-wise binary operation which applies the primitive bitwise XOR + * operation ({@code ^}) to each lane. * * @param s the input scalar * @param m the mask controlling lane selection @@ -873,8 +954,8 @@ /** * Bitwise NOTs this vector. *

- * This is a vector unary operation where the primitive bitwise NOT - * operation ({@code ~}) is applied to lane elements. + * This is a lane-wise unary operation which applies the primitive bitwise NOT + * operation ({@code ~}) to each lane. * * @return the bitwise NOT of this vector */ @@ -883,8 +964,8 @@ /** * Bitwise NOTs this vector, selecting lane elements controlled by a mask. *

- * This is a vector unary operation where the primitive bitwise NOT - * operation ({@code ~}) is applied to lane elements. + * This is a lane-wise unary operation which applies the primitive bitwise NOT + * operation ({@code ~}) to each lane. * * @param m the mask controlling lane selection * @return the bitwise NOT of this vector @@ -894,8 +975,8 @@ /** * Logically left shifts this vector by the broadcast of an input scalar. *

- * This is a vector binary operation where the primitive logical left shift - * operation ({@code <<}) is applied to lane elements to left shift the + * This is a lane-wise binary operation which applies the primitive logical left shift + * operation ({@code <<}) to each lane to left shift the * element by shift value as specified by the input scalar. Only the 4 * lowest-order bits of shift value are used. It is as if the shift value * were subjected to a bitwise logical AND operator ({@code &}) with the mask value 0xF. @@ -911,8 +992,8 @@ * Logically left shifts this vector by the broadcast of an input scalar, * selecting lane elements controlled by a mask. *

- * This is a vector binary operation where the primitive logical left shift - * operation ({@code <<}) is applied to lane elements to left shift the + * This is a lane-wise binary operation which applies the primitive logical left shift + * operation ({@code <<}) to each lane to left shift the * element by shift value as specified by the input scalar. Only the 4 * lowest-order bits of shift value are used. It is as if the shift value * were subjected to a bitwise logical AND operator ({@code &}) with the mask value 0xF. @@ -932,8 +1013,8 @@ * Logically right shifts (or unsigned right shifts) this vector by the * broadcast of an input scalar. *

- * This is a vector binary operation where the primitive logical right shift - * operation ({@code >>>}) is applied to lane elements to logically right shift the + * This is a lane-wise binary operation which applies the primitive logical right shift + * operation ({@code >>>}) to each lane to logically right shift the * element by shift value as specified by the input scalar. Only the 4 * lowest-order bits of shift value are used. It is as if the shift value * were subjected to a bitwise logical AND operator ({@code &}) with the mask value 0xF. @@ -950,8 +1031,8 @@ * broadcast of an input scalar, selecting lane elements controlled by a * mask. *

- * This is a vector binary operation where the primitive logical right shift - * operation ({@code >>>}) is applied to lane elements to logically right shift the + * This is a lane-wise binary operation which applies the primitive logical right shift + * operation ({@code >>>}) to each lane to logically right shift the * element by shift value as specified by the input scalar. Only the 4 * lowest-order bits of shift value are used. It is as if the shift value * were subjected to a bitwise logical AND operator ({@code &}) with the mask value 0xF. @@ -969,8 +1050,8 @@ * Arithmetically right shifts (or signed right shifts) this vector by the * broadcast of an input scalar. *

- * This is a vector binary operation where the primitive arithmetic right - * shift operation ({@code >>}) is applied to lane elements to arithmetically + * This is a lane-wise binary operation which applies the primitive arithmetic right + * shift operation ({@code >>}) to each lane to arithmetically * right shift the element by shift value as specified by the input scalar. * Only the 4 lowest-order bits of shift value are used. It is as if the shift * value were subjected to a bitwise logical AND operator ({@code &}) with the mask value 0xF. @@ -987,8 +1068,8 @@ * broadcast of an input scalar, selecting lane elements controlled by a * mask. *

- * This is a vector binary operation where the primitive arithmetic right - * shift operation ({@code >>}) is applied to lane elements to arithmetically + * This is a lane-wise binary operation which applies the primitive arithmetic right + * shift operation ({@code >>}) to each lane to arithmetically * right shift the element by shift value as specified by the input scalar. * Only the 4 lowest-order bits of shift value are used. It is as if the shift * value were subjected to a bitwise logical AND operator ({@code &}) with the mask value 0xF. @@ -1002,15 +1083,27 @@ public abstract ShortVector aShiftR(int s, VectorMask m); + /** + * {@inheritDoc} + */ @Override public abstract void intoByteArray(byte[] a, int ix); + /** + * {@inheritDoc} + */ @Override public abstract void intoByteArray(byte[] a, int ix, VectorMask m); + /** + * {@inheritDoc} + */ @Override public abstract void intoByteBuffer(ByteBuffer bb, int ix); + /** + * {@inheritDoc} + */ @Override public abstract void intoByteBuffer(ByteBuffer bb, int ix, VectorMask m); @@ -1019,8 +1112,8 @@ /** * Adds all lane elements of this vector. *

- * This is an associative vector reduction operation where the addition - * operation ({@code +}) is applied to lane elements, + * This is an associative cross-lane reduction operation which applies the addition + * operation ({@code +}) to lane elements, * and the identity value is {@code 0}. * * @return the addition of all the lane elements of this vector @@ -1031,8 +1124,8 @@ * Adds all lane elements of this vector, selecting lane elements * controlled by a mask. *

- * This is an associative vector reduction operation where the addition - * operation ({@code +}) is applied to lane elements, + * This is an associative cross-lane reduction operation which applies the addition + * operation ({@code +}) to lane elements, * and the identity value is {@code 0}. * * @param m the mask controlling lane selection @@ -1043,8 +1136,8 @@ /** * Multiplies all lane elements of this vector. *

- * This is an associative vector reduction operation where the - * multiplication operation ({@code *}) is applied to lane elements, + * This is an associative cross-lane reduction operation which applies the + * multiplication operation ({@code *}) to lane elements, * and the identity value is {@code 1}. * * @return the multiplication of all the lane elements of this vector @@ -1055,8 +1148,8 @@ * Multiplies all lane elements of this vector, selecting lane elements * controlled by a mask. *

- * This is an associative vector reduction operation where the - * multiplication operation ({@code *}) is applied to lane elements, + * This is an associative cross-lane reduction operation which applies the + * multiplication operation ({@code *}) to lane elements, * and the identity value is {@code 1}. * * @param m the mask controlling lane selection @@ -1067,8 +1160,8 @@ /** * Returns the minimum lane element of this vector. *

- * This is an associative vector reduction operation where the operation - * {@code (a, b) -> Math.min(a, b)} is applied to lane elements, + * This is an associative cross-lane reduction operation which applies the operation + * {@code (a, b) -> Math.min(a, b)} to lane elements, * and the identity value is * {@link Short#MAX_VALUE}. * @@ -1080,8 +1173,8 @@ * Returns the minimum lane element of this vector, selecting lane elements * controlled by a mask. *

- * This is an associative vector reduction operation where the operation - * {@code (a, b) -> Math.min(a, b)} is applied to lane elements, + * This is an associative cross-lane reduction operation which applies the operation + * {@code (a, b) -> Math.min(a, b)} to lane elements, * and the identity value is * {@link Short#MAX_VALUE}. * @@ -1093,8 +1186,8 @@ /** * Returns the maximum lane element of this vector. *

- * This is an associative vector reduction operation where the operation - * {@code (a, b) -> Math.max(a, b)} is applied to lane elements, + * This is an associative cross-lane reduction operation which applies the operation + * {@code (a, b) -> Math.max(a, b)} to lane elements, * and the identity value is * {@link Short#MIN_VALUE}. * @@ -1106,8 +1199,8 @@ * Returns the maximum lane element of this vector, selecting lane elements * controlled by a mask. *

- * This is an associative vector reduction operation where the operation - * {@code (a, b) -> Math.max(a, b)} is applied to lane elements, + * This is an associative cross-lane reduction operation which applies the operation + * {@code (a, b) -> Math.max(a, b)} to lane elements, * and the identity value is * {@link Short#MIN_VALUE}. * @@ -1119,8 +1212,8 @@ /** * Logically ORs all lane elements of this vector. *

- * This is an associative vector reduction operation where the logical OR - * operation ({@code |}) is applied to lane elements, + * This is an associative cross-lane reduction operation which applies the logical OR + * operation ({@code |}) to lane elements, * and the identity value is {@code 0}. * * @return the logical OR all the lane elements of this vector @@ -1131,8 +1224,8 @@ * Logically ORs all lane elements of this vector, selecting lane elements * controlled by a mask. *

- * This is an associative vector reduction operation where the logical OR - * operation ({@code |}) is applied to lane elements, + * This is an associative cross-lane reduction operation which applies the logical OR + * operation ({@code |}) to lane elements, * and the identity value is {@code 0}. * * @param m the mask controlling lane selection @@ -1143,8 +1236,8 @@ /** * Logically ANDs all lane elements of this vector. *

- * This is an associative vector reduction operation where the logical AND - * operation ({@code |}) is applied to lane elements, + * This is an associative cross-lane reduction operation which applies the logical AND + * operation ({@code |}) to lane elements, * and the identity value is {@code -1}. * * @return the logical AND all the lane elements of this vector @@ -1155,8 +1248,8 @@ * Logically ANDs all lane elements of this vector, selecting lane elements * controlled by a mask. *

- * This is an associative vector reduction operation where the logical AND - * operation ({@code |}) is applied to lane elements, + * This is an associative cross-lane reduction operation which applies the logical AND + * operation ({@code |}) to lane elements, * and the identity value is {@code -1}. * * @param m the mask controlling lane selection @@ -1167,8 +1260,8 @@ /** * Logically XORs all lane elements of this vector. *

- * This is an associative vector reduction operation where the logical XOR - * operation ({@code ^}) is applied to lane elements, + * This is an associative cross-lane reduction operation which applies the logical XOR + * operation ({@code ^}) to lane elements, * and the identity value is {@code 0}. * * @return the logical XOR all the lane elements of this vector @@ -1179,8 +1272,8 @@ * Logically XORs all lane elements of this vector, selecting lane elements * controlled by a mask. *

- * This is an associative vector reduction operation where the logical XOR - * operation ({@code ^}) is applied to lane elements, + * This is an associative cross-lane reduction operation which applies the logical XOR + * operation ({@code ^}) to lane elements, * and the identity value is {@code 0}. * * @param m the mask controlling lane selection @@ -1198,7 +1291,7 @@ * @throws IllegalArgumentException if the index is is out of range * ({@code < 0 || >= length()}) */ - public abstract short get(int i); + public abstract short lane(int i); /** * Replaces the lane element of this vector at lane index {@code i} with @@ -1245,30 +1338,30 @@ *

* For each vector lane, where {@code N} is the vector lane index, * the lane element at index {@code N} is stored into the array at index - * {@code i + N}. + * {@code offset + N}. * * @param a the array - * @param i the offset into the array - * @throws IndexOutOfBoundsException if {@code i < 0}, or - * {@code i > a.length - this.length()} + * @param offset the offset into the array + * @throws IndexOutOfBoundsException if {@code offset < 0}, or + * {@code offset > a.length - this.length()} */ - public abstract void intoArray(short[] a, int i); + public abstract void intoArray(short[] a, int offset); /** * Stores this vector into an array starting at offset and using a mask. *

* For each vector lane, where {@code N} is the vector lane index, * if the mask lane at index {@code N} is set then the lane element at - * index {@code N} is stored into the array index {@code i + N}. + * index {@code N} is stored into the array index {@code offset + N}. * * @param a the array - * @param i the offset into the array + * @param offset the offset into the array * @param m the mask - * @throws IndexOutOfBoundsException if {@code i < 0}, or + * @throws IndexOutOfBoundsException if {@code offset < 0}, or * for any vector lane index {@code N} where the mask at lane {@code N} - * is set {@code i >= a.length - N} + * is set {@code offset >= a.length - N} */ - public abstract void intoArray(short[] a, int i, VectorMask m); + public abstract void intoArray(short[] a, int offset, VectorMask m); /** * Stores this vector into an array using indexes obtained from an index @@ -1276,21 +1369,21 @@ *

* For each vector lane, where {@code N} is the vector lane index, the * lane element at index {@code N} is stored into the array at index - * {@code i + indexMap[j + N]}. + * {@code a_offset + indexMap[i_offset + N]}. * * @param a the array - * @param i the offset into the array, may be negative if relative + * @param a_offset 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 - * @param j the offset into the index map - * @throws IndexOutOfBoundsException if {@code j < 0}, or - * {@code j > indexMap.length - this.length()}, + * @param i_offset the offset into the index map + * @throws IndexOutOfBoundsException if {@code i_offset < 0}, or + * {@code i_offset > indexMap.length - this.length()}, * or for any vector lane index {@code N} the result of - * {@code i + indexMap[j + N]} is {@code < 0} or {@code >= a.length} + * {@code a_offset + indexMap[i_offset + N]} is {@code < 0} or {@code >= a.length} */ - public void intoArray(short[] a, int i, int[] indexMap, int j) { - forEach((n, e) -> a[i + indexMap[j + n]] = e); + public void intoArray(short[] a, int a_offset, int[] indexMap, int i_offset) { + forEach((n, e) -> a[a_offset + indexMap[i_offset + n]] = e); } /** @@ -1300,26 +1393,29 @@ * For each vector lane, where {@code N} is the vector lane index, * if the mask lane at index {@code N} is set then the lane element at * index {@code N} is stored into the array at index - * {@code i + indexMap[j + N]}. + * {@code a_offset + indexMap[i_offset + N]}. * * @param a the array - * @param i the offset into the array, may be negative if relative + * @param a_offset 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 + * @param i_offset the offset into the index map * @throws IndexOutOfBoundsException if {@code j < 0}, or - * {@code j > indexMap.length - this.length()}, + * {@code i_offset > 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 N} is set the result of {@code a_offset + indexMap[i_offset + N]} is * {@code < 0} or {@code >= a.length} */ - public void intoArray(short[] a, int i, VectorMask m, int[] indexMap, int j) { - forEach(m, (n, e) -> a[i + indexMap[j + n]] = e); + public void intoArray(short[] a, int a_offset, VectorMask m, int[] indexMap, int i_offset) { + forEach(m, (n, e) -> a[a_offset + indexMap[i_offset + n]] = e); } // Species + /** + * {@inheritDoc} + */ @Override public abstract VectorSpecies species();