< prev index next >

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

Print this page
rev 56969 : Javadoc corrections


 494     @Override
 495     public abstract ShortVector broadcast(long e);
 496 
 497     /**
 498      * Returns a vector of the given species
 499      * where all lane elements are set to
 500      * the primitive value {@code e}.
 501      *
 502      * The {@code long} value must be accurately representable
 503      * by the {@code ETYPE} of the vector species, so that
 504      * {@code e==(long)(ETYPE)e}.
 505      *
 506      * @param species species of the desired vector
 507      * @param e the value to broadcast
 508      * @return a vector where all lane elements are set to
 509      *         the primitive value {@code e}
 510      * @throws IllegalArgumentException
 511      *         if the given {@code long} value cannot
 512      *         be represented by the vector's {@code ETYPE}
 513      * @see #broadcast(VectorSpecies,short)
 514      * @see VectorSpecies#checkValue(VectorSpecies,short)
 515      */
 516     public static ShortVector broadcast(VectorSpecies<Short> species, long e) {
 517         ShortSpecies vsp = (ShortSpecies) species;
 518         return vsp.broadcast(e);
 519     }
 520 
 521     /*package-private*/
 522     @ForceInline
 523     final ShortVector broadcastTemplate(long e) {
 524         return vspecies().broadcast(e);
 525     }
 526 
 527     /**
 528      * Returns a vector where each lane element is set to given
 529      * primitive values.
 530      * <p>
 531      * For each vector lane, where {@code N} is the vector lane index, the
 532      * the primitive value at index {@code N} is placed into the resulting
 533      * vector at lane index {@code N}.
 534      *


1389      * <p>
1390      * If the underlying scalar operator does not support
1391      * division by zero, but is presented with a zero divisor,
1392      * an {@code ArithmeticException} will be thrown.
1393      *
1394      * @param e the input scalar
1395      * @return the result of dividing each lane of this vector by the scalar
1396      * @see #div(Vector)
1397      * @see #broadcast(short)
1398      * @see #div(int,VectorMask)
1399      * @see VectorOperators#DIV
1400      * @see #lanewise(VectorOperators.Binary,Vector)
1401      * @see #lanewise(VectorOperators.Binary,short)
1402      */
1403     @ForceInline
1404     public final ShortVector div(short e) {
1405         return lanewise(DIV, e);
1406     }
1407 
1408     /**
1409     /**
1410      * {@inheritDoc} <!--workaround-->
1411      * @see #div(short,VectorMask)
1412      */
1413     @Override
1414     @ForceInline
1415     public final ShortVector div(Vector<Short> v,
1416                                           VectorMask<Short> m) {
1417         return lanewise(DIV, v, m);
1418     }
1419 
1420     /**
1421      * Divides this vector by the broadcast of an input scalar,
1422      * selecting lane elements controlled by a mask.
1423      *
1424      * This is a masked lane-wise binary operation which applies
1425      * the primitive division operation ({@code /}) to each lane.
1426      *
1427      * This method is also equivalent to the expression
1428      * {@link #lanewise(VectorOperators.Binary,short,VectorMask)
1429      *    lanewise}{@code (}{@link VectorOperators#DIV


1669      *
1670      * This is a lane-wise binary operation which applies the
1671      * the primitive bitwise "not" operation ({@code ~})
1672      * to each lane value.
1673      *
1674      * This method is also equivalent to the expression
1675      * {@link #lanewise(VectorOperators.Unary,Vector)
1676      *    lanewise}{@code (}{@link VectorOperators#NOT
1677      *    NOT}{@code )}.
1678      *
1679      * <p>
1680      * This is not a full-service named operation like
1681      * {@link #add(Vector) add}.  A masked version of
1682      * version of this operation is not directly available
1683      * but may be obtained via the masked version of
1684      * {@code lanewise}.
1685      *
1686      * @return the bitwise complement {@code ~} of this vector
1687      * @see #and(Vector)
1688      * @see VectorOperators#NOT
1689      * @see #lanewise(VectorOperators.Unary,Vector,VectorMask)
1690      */
1691     @ForceInline
1692     public final ShortVector not() {
1693         return lanewise(NOT);
1694     }
1695 
1696 
1697     /// COMPARISONS
1698 
1699     /**
1700      * {@inheritDoc} <!--workaround-->
1701      */
1702     @Override
1703     @ForceInline
1704     public final
1705     VectorMask<Short> eq(Vector<Short> v) {
1706         return compare(EQ, v);
1707     }
1708 
1709     /**


1809     /**
1810      * Tests this vector by comparing it with an input scalar,
1811      * according to the given comparison operation.
1812      *
1813      * This is a lane-wise binary test operation which applies
1814      * the comparison operation to each lane.
1815      * <p>
1816      * The result is the same as
1817      * {@code compare(op, broadcast(species(), e))}.
1818      * That is, the scalar may be regarded as broadcast to
1819      * a vector of the same species, and then compared
1820      * against the original vector, using the selected
1821      * comparison operation.
1822      *
1823      * @param e the input scalar
1824      * @return the mask result of testing lane-wise if this vector
1825      *         compares to the input, according to the selected
1826      *         comparison operator
1827      * @see ShortVector#compare(VectorOperators.Comparison,Vector)
1828      * @see #eq(short)
1829      * @see #lessThan(short)
1830      */
1831     public abstract
1832     VectorMask<Short> compare(Comparison op, short e);
1833 
1834     /*package-private*/
1835     @ForceInline
1836     final
1837     <M extends VectorMask<Short>>
1838     M compareTemplate(Class<M> maskType, Comparison op, short e) {
1839         return compareTemplate(maskType, op, broadcast(e));
1840     }
1841 
1842     /**
1843      * Tests this vector by comparing it with an input scalar,
1844      * according to the given comparison operation,
1845      * in lanes selected by a mask.
1846      *
1847      * This is a masked lane-wise binary test operation which applies
1848      * to each pair of corresponding lane values.
1849      *


2665      * The vector is arranged into lanes according to
2666      * <a href="Vector.html#lane-order">memory ordering</a>.
2667      * <p>
2668      * This method behaves as if it returns the result of calling
2669      * {@link #fromByteBuffer(VectorSpecies,ByteBuffer,int,ByteOrder,VectorMask)
2670      * fromByteBuffer()} as follows:
2671      * <pre>{@code
2672      * var bb = ByteBuffer.wrap(a);
2673      * var bo = ByteOrder.LITTLE_ENDIAN;
2674      * return fromByteBuffer(species, bb, offset, bo, m);
2675      * }</pre>
2676      *
2677      * @param species species of desired vector
2678      * @param a the byte array
2679      * @param offset the offset into the array
2680      * @param m the mask controlling lane selection
2681      * @return a vector loaded from a byte array
2682      * @throws IndexOutOfBoundsException
2683      *         if {@code offset+N*ESIZE < 0}
2684      *         or {@code offset+(N+1)*ESIZE > a.length}
2685      *         for any lane {@code N} in the vector

2686      */
2687     @ForceInline
2688     public static
2689     ShortVector fromByteArray(VectorSpecies<Short> species,
2690                                        byte[] a, int offset,
2691                                        VectorMask<Short> m) {
2692         return fromByteArray(species, a, offset, ByteOrder.LITTLE_ENDIAN, m);
2693     }
2694 
2695     /**
2696      * Loads a vector from a byte array starting at an offset
2697      * and using a mask.
2698      * Lanes where the mask is unset are filled with the default
2699      * value of {@code short} (zero).
2700      * Bytes are composed into primitive lane elements according
2701      * to {@linkplain ByteOrder#LITTLE_ENDIAN little endian} ordering.
2702      * The vector is arranged into lanes according to
2703      * <a href="Vector.html#lane-order">memory ordering</a>.
2704      * <p>
2705      * This method behaves as if it returns the result of calling


2875      * of the buffer must be little-endian.
2876      * <p>
2877      * This method behaves as if it returns the result of calling
2878      * {@link #fromByteBuffer(VectorSpecies,ByteBuffer,int,ByteOrder,VectorMask)
2879      * fromByteBuffer()} as follows:
2880      * <pre>{@code
2881      * var bb = ByteBuffer.wrap(a);
2882      * var bo = ByteOrder.LITTLE_ENDIAN;
2883      * var m = species.maskAll(true);
2884      * return fromByteBuffer(species, bb, offset, m, bo);
2885      * }</pre>
2886      *
2887      * @param species species of desired vector
2888      * @param bb the byte buffer
2889      * @param offset the offset into the byte buffer
2890      * @return a vector loaded from a byte buffer
2891      * @throws IllegalArgumentException if byte order of bb
2892      *         is not {@link ByteOrder#LITTLE_ENDIAN}
2893      * @throws IndexOutOfBoundsException
2894      *         if {@code offset+N*2 < 0}
2895      *         or {@code offset+N**2 >= bb.limit()}
2896      *         for any lane {@code N} in the vector
2897      */
2898     @ForceInline
2899     public static
2900     ShortVector fromByteBuffer(VectorSpecies<Short> species,
2901                                         ByteBuffer bb, int offset,
2902                                         ByteOrder bo) {
2903         ShortSpecies vsp = (ShortSpecies) species;
2904         offset = checkFromIndexSize(offset,
2905                                     vsp.laneCount(),
2906                                     bb.limit());
2907         return vsp.dummyVector()
2908             .fromByteBuffer0(bb, offset).maybeSwap(bo);
2909     }
2910 
2911     /**
2912      * Loads a vector from a {@linkplain ByteBuffer byte buffer}
2913      * starting at an offset into the byte buffer
2914      * and using a mask.
2915      * <p>


2921      * <p>
2922      * This method behaves as if it returns the result of calling
2923      * {@link #fromByteBuffer(VectorSpecies,ByteBuffer,int,ByteOrder,VectorMask)
2924      * fromByteBuffer()} as follows:
2925      * <pre>{@code
2926      * var bb = ByteBuffer.wrap(a);
2927      * var bo = ByteOrder.LITTLE_ENDIAN;
2928      * var m = species.maskAll(true);
2929      * return fromByteBuffer(species, bb, offset, m, bo);
2930      * }</pre>
2931      *
2932      * @param species species of desired vector
2933      * @param bb the byte buffer
2934      * @param offset the offset into the byte buffer
2935      * @param m the mask controlling lane selection
2936      * @return a vector loaded from a byte buffer
2937      * @throws IllegalArgumentException if byte order of bb
2938      *         is not {@link ByteOrder#LITTLE_ENDIAN}
2939      * @throws IndexOutOfBoundsException
2940      *         if {@code offset+N*2 < 0}
2941      *         or {@code offset+N**2 >= bb.limit()}
2942      *         for any lane {@code N} in the vector
2943      *         where the mask is set
2944      */
2945     @ForceInline
2946     public static
2947     ShortVector fromByteBuffer(VectorSpecies<Short> species,
2948                                         ByteBuffer bb, int offset,
2949                                         ByteOrder bo,
2950                                         VectorMask<Short> m) {
2951         if (m.allTrue()) {
2952             return fromByteBuffer(species, bb, offset, bo);
2953         }
2954         ShortSpecies vsp = (ShortSpecies) species;
2955         checkMaskFromIndexSize(offset,
2956                                vsp, m, 1,
2957                                bb.limit());
2958         ShortVector zero = zero(vsp);
2959         ShortVector v = zero.fromByteBuffer0(bb, offset);
2960         return zero.blend(v.maybeSwap(bo), m);
2961     }




 494     @Override
 495     public abstract ShortVector broadcast(long e);
 496 
 497     /**
 498      * Returns a vector of the given species
 499      * where all lane elements are set to
 500      * the primitive value {@code e}.
 501      *
 502      * The {@code long} value must be accurately representable
 503      * by the {@code ETYPE} of the vector species, so that
 504      * {@code e==(long)(ETYPE)e}.
 505      *
 506      * @param species species of the desired vector
 507      * @param e the value to broadcast
 508      * @return a vector where all lane elements are set to
 509      *         the primitive value {@code e}
 510      * @throws IllegalArgumentException
 511      *         if the given {@code long} value cannot
 512      *         be represented by the vector's {@code ETYPE}
 513      * @see #broadcast(VectorSpecies,short)
 514      * @see VectorSpecies#checkValue(VectorSpecies,long)
 515      */
 516     public static ShortVector broadcast(VectorSpecies<Short> species, long e) {
 517         ShortSpecies vsp = (ShortSpecies) species;
 518         return vsp.broadcast(e);
 519     }
 520 
 521     /*package-private*/
 522     @ForceInline
 523     final ShortVector broadcastTemplate(long e) {
 524         return vspecies().broadcast(e);
 525     }
 526 
 527     /**
 528      * Returns a vector where each lane element is set to given
 529      * primitive values.
 530      * <p>
 531      * For each vector lane, where {@code N} is the vector lane index, the
 532      * the primitive value at index {@code N} is placed into the resulting
 533      * vector at lane index {@code N}.
 534      *


1389      * <p>
1390      * If the underlying scalar operator does not support
1391      * division by zero, but is presented with a zero divisor,
1392      * an {@code ArithmeticException} will be thrown.
1393      *
1394      * @param e the input scalar
1395      * @return the result of dividing each lane of this vector by the scalar
1396      * @see #div(Vector)
1397      * @see #broadcast(short)
1398      * @see #div(int,VectorMask)
1399      * @see VectorOperators#DIV
1400      * @see #lanewise(VectorOperators.Binary,Vector)
1401      * @see #lanewise(VectorOperators.Binary,short)
1402      */
1403     @ForceInline
1404     public final ShortVector div(short e) {
1405         return lanewise(DIV, e);
1406     }
1407 
1408     /**

1409      * {@inheritDoc} <!--workaround-->
1410      * @see #div(short,VectorMask)
1411      */
1412     @Override
1413     @ForceInline
1414     public final ShortVector div(Vector<Short> v,
1415                                           VectorMask<Short> m) {
1416         return lanewise(DIV, v, m);
1417     }
1418 
1419     /**
1420      * Divides this vector by the broadcast of an input scalar,
1421      * selecting lane elements controlled by a mask.
1422      *
1423      * This is a masked lane-wise binary operation which applies
1424      * the primitive division operation ({@code /}) to each lane.
1425      *
1426      * This method is also equivalent to the expression
1427      * {@link #lanewise(VectorOperators.Binary,short,VectorMask)
1428      *    lanewise}{@code (}{@link VectorOperators#DIV


1668      *
1669      * This is a lane-wise binary operation which applies the
1670      * the primitive bitwise "not" operation ({@code ~})
1671      * to each lane value.
1672      *
1673      * This method is also equivalent to the expression
1674      * {@link #lanewise(VectorOperators.Unary,Vector)
1675      *    lanewise}{@code (}{@link VectorOperators#NOT
1676      *    NOT}{@code )}.
1677      *
1678      * <p>
1679      * This is not a full-service named operation like
1680      * {@link #add(Vector) add}.  A masked version of
1681      * version of this operation is not directly available
1682      * but may be obtained via the masked version of
1683      * {@code lanewise}.
1684      *
1685      * @return the bitwise complement {@code ~} of this vector
1686      * @see #and(Vector)
1687      * @see VectorOperators#NOT
1688      * @see #lanewise(VectorOperators.Unary,VectorMask)
1689      */
1690     @ForceInline
1691     public final ShortVector not() {
1692         return lanewise(NOT);
1693     }
1694 
1695 
1696     /// COMPARISONS
1697 
1698     /**
1699      * {@inheritDoc} <!--workaround-->
1700      */
1701     @Override
1702     @ForceInline
1703     public final
1704     VectorMask<Short> eq(Vector<Short> v) {
1705         return compare(EQ, v);
1706     }
1707 
1708     /**


1808     /**
1809      * Tests this vector by comparing it with an input scalar,
1810      * according to the given comparison operation.
1811      *
1812      * This is a lane-wise binary test operation which applies
1813      * the comparison operation to each lane.
1814      * <p>
1815      * The result is the same as
1816      * {@code compare(op, broadcast(species(), e))}.
1817      * That is, the scalar may be regarded as broadcast to
1818      * a vector of the same species, and then compared
1819      * against the original vector, using the selected
1820      * comparison operation.
1821      *
1822      * @param e the input scalar
1823      * @return the mask result of testing lane-wise if this vector
1824      *         compares to the input, according to the selected
1825      *         comparison operator
1826      * @see ShortVector#compare(VectorOperators.Comparison,Vector)
1827      * @see #eq(short)
1828      * @see #lt(short)
1829      */
1830     public abstract
1831     VectorMask<Short> compare(Comparison op, short e);
1832 
1833     /*package-private*/
1834     @ForceInline
1835     final
1836     <M extends VectorMask<Short>>
1837     M compareTemplate(Class<M> maskType, Comparison op, short e) {
1838         return compareTemplate(maskType, op, broadcast(e));
1839     }
1840 
1841     /**
1842      * Tests this vector by comparing it with an input scalar,
1843      * according to the given comparison operation,
1844      * in lanes selected by a mask.
1845      *
1846      * This is a masked lane-wise binary test operation which applies
1847      * to each pair of corresponding lane values.
1848      *


2664      * The vector is arranged into lanes according to
2665      * <a href="Vector.html#lane-order">memory ordering</a>.
2666      * <p>
2667      * This method behaves as if it returns the result of calling
2668      * {@link #fromByteBuffer(VectorSpecies,ByteBuffer,int,ByteOrder,VectorMask)
2669      * fromByteBuffer()} as follows:
2670      * <pre>{@code
2671      * var bb = ByteBuffer.wrap(a);
2672      * var bo = ByteOrder.LITTLE_ENDIAN;
2673      * return fromByteBuffer(species, bb, offset, bo, m);
2674      * }</pre>
2675      *
2676      * @param species species of desired vector
2677      * @param a the byte array
2678      * @param offset the offset into the array
2679      * @param m the mask controlling lane selection
2680      * @return a vector loaded from a byte array
2681      * @throws IndexOutOfBoundsException
2682      *         if {@code offset+N*ESIZE < 0}
2683      *         or {@code offset+(N+1)*ESIZE > a.length}
2684      *         for any lane {@code N} in the vector where
2685      *         the mask is set
2686      */
2687     @ForceInline
2688     public static
2689     ShortVector fromByteArray(VectorSpecies<Short> species,
2690                                        byte[] a, int offset,
2691                                        VectorMask<Short> m) {
2692         return fromByteArray(species, a, offset, ByteOrder.LITTLE_ENDIAN, m);
2693     }
2694 
2695     /**
2696      * Loads a vector from a byte array starting at an offset
2697      * and using a mask.
2698      * Lanes where the mask is unset are filled with the default
2699      * value of {@code short} (zero).
2700      * Bytes are composed into primitive lane elements according
2701      * to {@linkplain ByteOrder#LITTLE_ENDIAN little endian} ordering.
2702      * The vector is arranged into lanes according to
2703      * <a href="Vector.html#lane-order">memory ordering</a>.
2704      * <p>
2705      * This method behaves as if it returns the result of calling


2875      * of the buffer must be little-endian.
2876      * <p>
2877      * This method behaves as if it returns the result of calling
2878      * {@link #fromByteBuffer(VectorSpecies,ByteBuffer,int,ByteOrder,VectorMask)
2879      * fromByteBuffer()} as follows:
2880      * <pre>{@code
2881      * var bb = ByteBuffer.wrap(a);
2882      * var bo = ByteOrder.LITTLE_ENDIAN;
2883      * var m = species.maskAll(true);
2884      * return fromByteBuffer(species, bb, offset, m, bo);
2885      * }</pre>
2886      *
2887      * @param species species of desired vector
2888      * @param bb the byte buffer
2889      * @param offset the offset into the byte buffer
2890      * @return a vector loaded from a byte buffer
2891      * @throws IllegalArgumentException if byte order of bb
2892      *         is not {@link ByteOrder#LITTLE_ENDIAN}
2893      * @throws IndexOutOfBoundsException
2894      *         if {@code offset+N*2 < 0}
2895      *         or {@code offset+N*2 >= bb.limit()}
2896      *         for any lane {@code N} in the vector
2897      */
2898     @ForceInline
2899     public static
2900     ShortVector fromByteBuffer(VectorSpecies<Short> species,
2901                                         ByteBuffer bb, int offset,
2902                                         ByteOrder bo) {
2903         ShortSpecies vsp = (ShortSpecies) species;
2904         offset = checkFromIndexSize(offset,
2905                                     vsp.laneCount(),
2906                                     bb.limit());
2907         return vsp.dummyVector()
2908             .fromByteBuffer0(bb, offset).maybeSwap(bo);
2909     }
2910 
2911     /**
2912      * Loads a vector from a {@linkplain ByteBuffer byte buffer}
2913      * starting at an offset into the byte buffer
2914      * and using a mask.
2915      * <p>


2921      * <p>
2922      * This method behaves as if it returns the result of calling
2923      * {@link #fromByteBuffer(VectorSpecies,ByteBuffer,int,ByteOrder,VectorMask)
2924      * fromByteBuffer()} as follows:
2925      * <pre>{@code
2926      * var bb = ByteBuffer.wrap(a);
2927      * var bo = ByteOrder.LITTLE_ENDIAN;
2928      * var m = species.maskAll(true);
2929      * return fromByteBuffer(species, bb, offset, m, bo);
2930      * }</pre>
2931      *
2932      * @param species species of desired vector
2933      * @param bb the byte buffer
2934      * @param offset the offset into the byte buffer
2935      * @param m the mask controlling lane selection
2936      * @return a vector loaded from a byte buffer
2937      * @throws IllegalArgumentException if byte order of bb
2938      *         is not {@link ByteOrder#LITTLE_ENDIAN}
2939      * @throws IndexOutOfBoundsException
2940      *         if {@code offset+N*2 < 0}
2941      *         or {@code offset+N*2 >= bb.limit()}
2942      *         for any lane {@code N} in the vector
2943      *         where the mask is set
2944      */
2945     @ForceInline
2946     public static
2947     ShortVector fromByteBuffer(VectorSpecies<Short> species,
2948                                         ByteBuffer bb, int offset,
2949                                         ByteOrder bo,
2950                                         VectorMask<Short> m) {
2951         if (m.allTrue()) {
2952             return fromByteBuffer(species, bb, offset, bo);
2953         }
2954         ShortSpecies vsp = (ShortSpecies) species;
2955         checkMaskFromIndexSize(offset,
2956                                vsp, m, 1,
2957                                bb.limit());
2958         ShortVector zero = zero(vsp);
2959         ShortVector v = zero.fromByteBuffer0(bb, offset);
2960         return zero.blend(v.maybeSwap(bo), m);
2961     }


< prev index next >