< prev index next >

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

Print this page
rev 56969 : Javadoc corrections


 494     @Override
 495     public abstract IntVector 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,int)
 514      * @see VectorSpecies#checkValue(VectorSpecies,int)
 515      */
 516     public static IntVector broadcast(VectorSpecies<Integer> species, long e) {
 517         IntSpecies vsp = (IntSpecies) species;
 518         return vsp.broadcast(e);
 519     }
 520 
 521     /*package-private*/
 522     @ForceInline
 523     final IntVector 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      *


1388      * <p>
1389      * If the underlying scalar operator does not support
1390      * division by zero, but is presented with a zero divisor,
1391      * an {@code ArithmeticException} will be thrown.
1392      *
1393      * @param e the input scalar
1394      * @return the result of dividing each lane of this vector by the scalar
1395      * @see #div(Vector)
1396      * @see #broadcast(int)
1397      * @see #div(int,VectorMask)
1398      * @see VectorOperators#DIV
1399      * @see #lanewise(VectorOperators.Binary,Vector)
1400      * @see #lanewise(VectorOperators.Binary,int)
1401      */
1402     @ForceInline
1403     public final IntVector div(int e) {
1404         return lanewise(DIV, e);
1405     }
1406 
1407     /**
1408     /**
1409      * {@inheritDoc} <!--workaround-->
1410      * @see #div(int,VectorMask)
1411      */
1412     @Override
1413     @ForceInline
1414     public final IntVector div(Vector<Integer> v,
1415                                           VectorMask<Integer> 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,int,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,Vector,VectorMask)
1689      */
1690     @ForceInline
1691     public final IntVector 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<Integer> eq(Vector<Integer> 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 IntVector#compare(VectorOperators.Comparison,Vector)
1827      * @see #eq(int)
1828      * @see #lessThan(int)
1829      */
1830     public abstract
1831     VectorMask<Integer> compare(Comparison op, int e);
1832 
1833     /*package-private*/
1834     @ForceInline
1835     final
1836     <M extends VectorMask<Integer>>
1837     M compareTemplate(Class<M> maskType, Comparison op, int 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

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


2897      * of the buffer must be little-endian.
2898      * <p>
2899      * This method behaves as if it returns the result of calling
2900      * {@link #fromByteBuffer(VectorSpecies,ByteBuffer,int,ByteOrder,VectorMask)
2901      * fromByteBuffer()} as follows:
2902      * <pre>{@code
2903      * var bb = ByteBuffer.wrap(a);
2904      * var bo = ByteOrder.LITTLE_ENDIAN;
2905      * var m = species.maskAll(true);
2906      * return fromByteBuffer(species, bb, offset, m, bo);
2907      * }</pre>
2908      *
2909      * @param species species of desired vector
2910      * @param bb the byte buffer
2911      * @param offset the offset into the byte buffer
2912      * @return a vector loaded from a byte buffer
2913      * @throws IllegalArgumentException if byte order of bb
2914      *         is not {@link ByteOrder#LITTLE_ENDIAN}
2915      * @throws IndexOutOfBoundsException
2916      *         if {@code offset+N*4 < 0}
2917      *         or {@code offset+N**4 >= bb.limit()}
2918      *         for any lane {@code N} in the vector
2919      */
2920     @ForceInline
2921     public static
2922     IntVector fromByteBuffer(VectorSpecies<Integer> species,
2923                                         ByteBuffer bb, int offset,
2924                                         ByteOrder bo) {
2925         IntSpecies vsp = (IntSpecies) species;
2926         offset = checkFromIndexSize(offset,
2927                                     vsp.laneCount(),
2928                                     bb.limit());
2929         return vsp.dummyVector()
2930             .fromByteBuffer0(bb, offset).maybeSwap(bo);
2931     }
2932 
2933     /**
2934      * Loads a vector from a {@linkplain ByteBuffer byte buffer}
2935      * starting at an offset into the byte buffer
2936      * and using a mask.
2937      * <p>


2943      * <p>
2944      * This method behaves as if it returns the result of calling
2945      * {@link #fromByteBuffer(VectorSpecies,ByteBuffer,int,ByteOrder,VectorMask)
2946      * fromByteBuffer()} as follows:
2947      * <pre>{@code
2948      * var bb = ByteBuffer.wrap(a);
2949      * var bo = ByteOrder.LITTLE_ENDIAN;
2950      * var m = species.maskAll(true);
2951      * return fromByteBuffer(species, bb, offset, m, bo);
2952      * }</pre>
2953      *
2954      * @param species species of desired vector
2955      * @param bb the byte buffer
2956      * @param offset the offset into the byte buffer
2957      * @param m the mask controlling lane selection
2958      * @return a vector loaded from a byte buffer
2959      * @throws IllegalArgumentException if byte order of bb
2960      *         is not {@link ByteOrder#LITTLE_ENDIAN}
2961      * @throws IndexOutOfBoundsException
2962      *         if {@code offset+N*4 < 0}
2963      *         or {@code offset+N**4 >= bb.limit()}
2964      *         for any lane {@code N} in the vector
2965      *         where the mask is set
2966      */
2967     @ForceInline
2968     public static
2969     IntVector fromByteBuffer(VectorSpecies<Integer> species,
2970                                         ByteBuffer bb, int offset,
2971                                         ByteOrder bo,
2972                                         VectorMask<Integer> m) {
2973         if (m.allTrue()) {
2974             return fromByteBuffer(species, bb, offset, bo);
2975         }
2976         IntSpecies vsp = (IntSpecies) species;
2977         checkMaskFromIndexSize(offset,
2978                                vsp, m, 1,
2979                                bb.limit());
2980         IntVector zero = zero(vsp);
2981         IntVector v = zero.fromByteBuffer0(bb, offset);
2982         return zero.blend(v.maybeSwap(bo), m);
2983     }




 494     @Override
 495     public abstract IntVector 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,int)
 514      * @see VectorSpecies#checkValue(VectorSpecies,long)
 515      */
 516     public static IntVector broadcast(VectorSpecies<Integer> species, long e) {
 517         IntSpecies vsp = (IntSpecies) species;
 518         return vsp.broadcast(e);
 519     }
 520 
 521     /*package-private*/
 522     @ForceInline
 523     final IntVector 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      *


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

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


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


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


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


2897      * of the buffer must be little-endian.
2898      * <p>
2899      * This method behaves as if it returns the result of calling
2900      * {@link #fromByteBuffer(VectorSpecies,ByteBuffer,int,ByteOrder,VectorMask)
2901      * fromByteBuffer()} as follows:
2902      * <pre>{@code
2903      * var bb = ByteBuffer.wrap(a);
2904      * var bo = ByteOrder.LITTLE_ENDIAN;
2905      * var m = species.maskAll(true);
2906      * return fromByteBuffer(species, bb, offset, m, bo);
2907      * }</pre>
2908      *
2909      * @param species species of desired vector
2910      * @param bb the byte buffer
2911      * @param offset the offset into the byte buffer
2912      * @return a vector loaded from a byte buffer
2913      * @throws IllegalArgumentException if byte order of bb
2914      *         is not {@link ByteOrder#LITTLE_ENDIAN}
2915      * @throws IndexOutOfBoundsException
2916      *         if {@code offset+N*4 < 0}
2917      *         or {@code offset+N*4 >= bb.limit()}
2918      *         for any lane {@code N} in the vector
2919      */
2920     @ForceInline
2921     public static
2922     IntVector fromByteBuffer(VectorSpecies<Integer> species,
2923                                         ByteBuffer bb, int offset,
2924                                         ByteOrder bo) {
2925         IntSpecies vsp = (IntSpecies) species;
2926         offset = checkFromIndexSize(offset,
2927                                     vsp.laneCount(),
2928                                     bb.limit());
2929         return vsp.dummyVector()
2930             .fromByteBuffer0(bb, offset).maybeSwap(bo);
2931     }
2932 
2933     /**
2934      * Loads a vector from a {@linkplain ByteBuffer byte buffer}
2935      * starting at an offset into the byte buffer
2936      * and using a mask.
2937      * <p>


2943      * <p>
2944      * This method behaves as if it returns the result of calling
2945      * {@link #fromByteBuffer(VectorSpecies,ByteBuffer,int,ByteOrder,VectorMask)
2946      * fromByteBuffer()} as follows:
2947      * <pre>{@code
2948      * var bb = ByteBuffer.wrap(a);
2949      * var bo = ByteOrder.LITTLE_ENDIAN;
2950      * var m = species.maskAll(true);
2951      * return fromByteBuffer(species, bb, offset, m, bo);
2952      * }</pre>
2953      *
2954      * @param species species of desired vector
2955      * @param bb the byte buffer
2956      * @param offset the offset into the byte buffer
2957      * @param m the mask controlling lane selection
2958      * @return a vector loaded from a byte buffer
2959      * @throws IllegalArgumentException if byte order of bb
2960      *         is not {@link ByteOrder#LITTLE_ENDIAN}
2961      * @throws IndexOutOfBoundsException
2962      *         if {@code offset+N*4 < 0}
2963      *         or {@code offset+N*4 >= bb.limit()}
2964      *         for any lane {@code N} in the vector
2965      *         where the mask is set
2966      */
2967     @ForceInline
2968     public static
2969     IntVector fromByteBuffer(VectorSpecies<Integer> species,
2970                                         ByteBuffer bb, int offset,
2971                                         ByteOrder bo,
2972                                         VectorMask<Integer> m) {
2973         if (m.allTrue()) {
2974             return fromByteBuffer(species, bb, offset, bo);
2975         }
2976         IntSpecies vsp = (IntSpecies) species;
2977         checkMaskFromIndexSize(offset,
2978                                vsp, m, 1,
2979                                bb.limit());
2980         IntVector zero = zero(vsp);
2981         IntVector v = zero.fromByteBuffer0(bb, offset);
2982         return zero.blend(v.maybeSwap(bo), m);
2983     }


< prev index next >