< prev index next >

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

Print this page
rev 56969 : Javadoc corrections


1307      * <p>
1308      * If the underlying scalar operator does not support
1309      * division by zero, but is presented with a zero divisor,
1310      * an {@code ArithmeticException} will be thrown.
1311      *
1312      * @param e the input scalar
1313      * @return the result of dividing each lane of this vector by the scalar
1314      * @see #div(Vector)
1315      * @see #broadcast(long)
1316      * @see #div(int,VectorMask)
1317      * @see VectorOperators#DIV
1318      * @see #lanewise(VectorOperators.Binary,Vector)
1319      * @see #lanewise(VectorOperators.Binary,long)
1320      */
1321     @ForceInline
1322     public final LongVector div(long e) {
1323         return lanewise(DIV, e);
1324     }
1325 
1326     /**
1327     /**
1328      * {@inheritDoc} <!--workaround-->
1329      * @see #div(long,VectorMask)
1330      */
1331     @Override
1332     @ForceInline
1333     public final LongVector div(Vector<Long> v,
1334                                           VectorMask<Long> m) {
1335         return lanewise(DIV, v, m);
1336     }
1337 
1338     /**
1339      * Divides this vector by the broadcast of an input scalar,
1340      * selecting lane elements controlled by a mask.
1341      *
1342      * This is a masked lane-wise binary operation which applies
1343      * the primitive division operation ({@code /}) to each lane.
1344      *
1345      * This method is also equivalent to the expression
1346      * {@link #lanewise(VectorOperators.Binary,long,VectorMask)
1347      *    lanewise}{@code (}{@link VectorOperators#DIV


1587      *
1588      * This is a lane-wise binary operation which applies the
1589      * the primitive bitwise "not" operation ({@code ~})
1590      * to each lane value.
1591      *
1592      * This method is also equivalent to the expression
1593      * {@link #lanewise(VectorOperators.Unary,Vector)
1594      *    lanewise}{@code (}{@link VectorOperators#NOT
1595      *    NOT}{@code )}.
1596      *
1597      * <p>
1598      * This is not a full-service named operation like
1599      * {@link #add(Vector) add}.  A masked version of
1600      * version of this operation is not directly available
1601      * but may be obtained via the masked version of
1602      * {@code lanewise}.
1603      *
1604      * @return the bitwise complement {@code ~} of this vector
1605      * @see #and(Vector)
1606      * @see VectorOperators#NOT
1607      * @see #lanewise(VectorOperators.Unary,Vector,VectorMask)
1608      */
1609     @ForceInline
1610     public final LongVector not() {
1611         return lanewise(NOT);
1612     }
1613 
1614 
1615     /// COMPARISONS
1616 
1617     /**
1618      * {@inheritDoc} <!--workaround-->
1619      */
1620     @Override
1621     @ForceInline
1622     public final
1623     VectorMask<Long> eq(Vector<Long> v) {
1624         return compare(EQ, v);
1625     }
1626 
1627     /**


1727     /**
1728      * Tests this vector by comparing it with an input scalar,
1729      * according to the given comparison operation.
1730      *
1731      * This is a lane-wise binary test operation which applies
1732      * the comparison operation to each lane.
1733      * <p>
1734      * The result is the same as
1735      * {@code compare(op, broadcast(species(), e))}.
1736      * That is, the scalar may be regarded as broadcast to
1737      * a vector of the same species, and then compared
1738      * against the original vector, using the selected
1739      * comparison operation.
1740      *
1741      * @param e the input scalar
1742      * @return the mask result of testing lane-wise if this vector
1743      *         compares to the input, according to the selected
1744      *         comparison operator
1745      * @see LongVector#compare(VectorOperators.Comparison,Vector)
1746      * @see #eq(long)
1747      * @see #lessThan(long)
1748      */
1749     public abstract
1750     VectorMask<Long> compare(Comparison op, long e);
1751 
1752     /*package-private*/
1753     @ForceInline
1754     final
1755     <M extends VectorMask<Long>>
1756     M compareTemplate(Class<M> maskType, Comparison op, long e) {
1757         return compareTemplate(maskType, op, broadcast(e));
1758     }
1759 
1760     /**
1761      * Tests this vector by comparing it with an input scalar,
1762      * according to the given comparison operation,
1763      * in lanes selected by a mask.
1764      *
1765      * This is a masked lane-wise binary test operation which applies
1766      * to each pair of corresponding lane values.
1767      *


2533      * The vector is arranged into lanes according to
2534      * <a href="Vector.html#lane-order">memory ordering</a>.
2535      * <p>
2536      * This method behaves as if it returns the result of calling
2537      * {@link #fromByteBuffer(VectorSpecies,ByteBuffer,int,ByteOrder,VectorMask)
2538      * fromByteBuffer()} as follows:
2539      * <pre>{@code
2540      * var bb = ByteBuffer.wrap(a);
2541      * var bo = ByteOrder.LITTLE_ENDIAN;
2542      * return fromByteBuffer(species, bb, offset, bo, m);
2543      * }</pre>
2544      *
2545      * @param species species of desired vector
2546      * @param a the byte array
2547      * @param offset the offset into the array
2548      * @param m the mask controlling lane selection
2549      * @return a vector loaded from a byte array
2550      * @throws IndexOutOfBoundsException
2551      *         if {@code offset+N*ESIZE < 0}
2552      *         or {@code offset+(N+1)*ESIZE > a.length}
2553      *         for any lane {@code N} in the vector

2554      */
2555     @ForceInline
2556     public static
2557     LongVector fromByteArray(VectorSpecies<Long> species,
2558                                        byte[] a, int offset,
2559                                        VectorMask<Long> m) {
2560         return fromByteArray(species, a, offset, ByteOrder.LITTLE_ENDIAN, m);
2561     }
2562 
2563     /**
2564      * Loads a vector from a byte array starting at an offset
2565      * and using a mask.
2566      * Lanes where the mask is unset are filled with the default
2567      * value of {@code long} (zero).
2568      * Bytes are composed into primitive lane elements according
2569      * to {@linkplain ByteOrder#LITTLE_ENDIAN little endian} ordering.
2570      * The vector is arranged into lanes according to
2571      * <a href="Vector.html#lane-order">memory ordering</a>.
2572      * <p>
2573      * This method behaves as if it returns the result of calling


2769      * of the buffer must be little-endian.
2770      * <p>
2771      * This method behaves as if it returns the result of calling
2772      * {@link #fromByteBuffer(VectorSpecies,ByteBuffer,int,ByteOrder,VectorMask)
2773      * fromByteBuffer()} as follows:
2774      * <pre>{@code
2775      * var bb = ByteBuffer.wrap(a);
2776      * var bo = ByteOrder.LITTLE_ENDIAN;
2777      * var m = species.maskAll(true);
2778      * return fromByteBuffer(species, bb, offset, m, bo);
2779      * }</pre>
2780      *
2781      * @param species species of desired vector
2782      * @param bb the byte buffer
2783      * @param offset the offset into the byte buffer
2784      * @return a vector loaded from a byte buffer
2785      * @throws IllegalArgumentException if byte order of bb
2786      *         is not {@link ByteOrder#LITTLE_ENDIAN}
2787      * @throws IndexOutOfBoundsException
2788      *         if {@code offset+N*8 < 0}
2789      *         or {@code offset+N**8 >= bb.limit()}
2790      *         for any lane {@code N} in the vector
2791      */
2792     @ForceInline
2793     public static
2794     LongVector fromByteBuffer(VectorSpecies<Long> species,
2795                                         ByteBuffer bb, int offset,
2796                                         ByteOrder bo) {
2797         LongSpecies vsp = (LongSpecies) species;
2798         offset = checkFromIndexSize(offset,
2799                                     vsp.laneCount(),
2800                                     bb.limit());
2801         return vsp.dummyVector()
2802             .fromByteBuffer0(bb, offset).maybeSwap(bo);
2803     }
2804 
2805     /**
2806      * Loads a vector from a {@linkplain ByteBuffer byte buffer}
2807      * starting at an offset into the byte buffer
2808      * and using a mask.
2809      * <p>


2815      * <p>
2816      * This method behaves as if it returns the result of calling
2817      * {@link #fromByteBuffer(VectorSpecies,ByteBuffer,int,ByteOrder,VectorMask)
2818      * fromByteBuffer()} as follows:
2819      * <pre>{@code
2820      * var bb = ByteBuffer.wrap(a);
2821      * var bo = ByteOrder.LITTLE_ENDIAN;
2822      * var m = species.maskAll(true);
2823      * return fromByteBuffer(species, bb, offset, m, bo);
2824      * }</pre>
2825      *
2826      * @param species species of desired vector
2827      * @param bb the byte buffer
2828      * @param offset the offset into the byte buffer
2829      * @param m the mask controlling lane selection
2830      * @return a vector loaded from a byte buffer
2831      * @throws IllegalArgumentException if byte order of bb
2832      *         is not {@link ByteOrder#LITTLE_ENDIAN}
2833      * @throws IndexOutOfBoundsException
2834      *         if {@code offset+N*8 < 0}
2835      *         or {@code offset+N**8 >= bb.limit()}
2836      *         for any lane {@code N} in the vector
2837      *         where the mask is set
2838      */
2839     @ForceInline
2840     public static
2841     LongVector fromByteBuffer(VectorSpecies<Long> species,
2842                                         ByteBuffer bb, int offset,
2843                                         ByteOrder bo,
2844                                         VectorMask<Long> m) {
2845         if (m.allTrue()) {
2846             return fromByteBuffer(species, bb, offset, bo);
2847         }
2848         LongSpecies vsp = (LongSpecies) species;
2849         checkMaskFromIndexSize(offset,
2850                                vsp, m, 1,
2851                                bb.limit());
2852         LongVector zero = zero(vsp);
2853         LongVector v = zero.fromByteBuffer0(bb, offset);
2854         return zero.blend(v.maybeSwap(bo), m);
2855     }




1307      * <p>
1308      * If the underlying scalar operator does not support
1309      * division by zero, but is presented with a zero divisor,
1310      * an {@code ArithmeticException} will be thrown.
1311      *
1312      * @param e the input scalar
1313      * @return the result of dividing each lane of this vector by the scalar
1314      * @see #div(Vector)
1315      * @see #broadcast(long)
1316      * @see #div(int,VectorMask)
1317      * @see VectorOperators#DIV
1318      * @see #lanewise(VectorOperators.Binary,Vector)
1319      * @see #lanewise(VectorOperators.Binary,long)
1320      */
1321     @ForceInline
1322     public final LongVector div(long e) {
1323         return lanewise(DIV, e);
1324     }
1325 
1326     /**

1327      * {@inheritDoc} <!--workaround-->
1328      * @see #div(long,VectorMask)
1329      */
1330     @Override
1331     @ForceInline
1332     public final LongVector div(Vector<Long> v,
1333                                           VectorMask<Long> m) {
1334         return lanewise(DIV, v, m);
1335     }
1336 
1337     /**
1338      * Divides this vector by the broadcast of an input scalar,
1339      * selecting lane elements controlled by a mask.
1340      *
1341      * This is a masked lane-wise binary operation which applies
1342      * the primitive division operation ({@code /}) to each lane.
1343      *
1344      * This method is also equivalent to the expression
1345      * {@link #lanewise(VectorOperators.Binary,long,VectorMask)
1346      *    lanewise}{@code (}{@link VectorOperators#DIV


1586      *
1587      * This is a lane-wise binary operation which applies the
1588      * the primitive bitwise "not" operation ({@code ~})
1589      * to each lane value.
1590      *
1591      * This method is also equivalent to the expression
1592      * {@link #lanewise(VectorOperators.Unary,Vector)
1593      *    lanewise}{@code (}{@link VectorOperators#NOT
1594      *    NOT}{@code )}.
1595      *
1596      * <p>
1597      * This is not a full-service named operation like
1598      * {@link #add(Vector) add}.  A masked version of
1599      * version of this operation is not directly available
1600      * but may be obtained via the masked version of
1601      * {@code lanewise}.
1602      *
1603      * @return the bitwise complement {@code ~} of this vector
1604      * @see #and(Vector)
1605      * @see VectorOperators#NOT
1606      * @see #lanewise(VectorOperators.Unary,VectorMask)
1607      */
1608     @ForceInline
1609     public final LongVector not() {
1610         return lanewise(NOT);
1611     }
1612 
1613 
1614     /// COMPARISONS
1615 
1616     /**
1617      * {@inheritDoc} <!--workaround-->
1618      */
1619     @Override
1620     @ForceInline
1621     public final
1622     VectorMask<Long> eq(Vector<Long> v) {
1623         return compare(EQ, v);
1624     }
1625 
1626     /**


1726     /**
1727      * Tests this vector by comparing it with an input scalar,
1728      * according to the given comparison operation.
1729      *
1730      * This is a lane-wise binary test operation which applies
1731      * the comparison operation to each lane.
1732      * <p>
1733      * The result is the same as
1734      * {@code compare(op, broadcast(species(), e))}.
1735      * That is, the scalar may be regarded as broadcast to
1736      * a vector of the same species, and then compared
1737      * against the original vector, using the selected
1738      * comparison operation.
1739      *
1740      * @param e the input scalar
1741      * @return the mask result of testing lane-wise if this vector
1742      *         compares to the input, according to the selected
1743      *         comparison operator
1744      * @see LongVector#compare(VectorOperators.Comparison,Vector)
1745      * @see #eq(long)
1746      * @see #lt(long)
1747      */
1748     public abstract
1749     VectorMask<Long> compare(Comparison op, long e);
1750 
1751     /*package-private*/
1752     @ForceInline
1753     final
1754     <M extends VectorMask<Long>>
1755     M compareTemplate(Class<M> maskType, Comparison op, long e) {
1756         return compareTemplate(maskType, op, broadcast(e));
1757     }
1758 
1759     /**
1760      * Tests this vector by comparing it with an input scalar,
1761      * according to the given comparison operation,
1762      * in lanes selected by a mask.
1763      *
1764      * This is a masked lane-wise binary test operation which applies
1765      * to each pair of corresponding lane values.
1766      *


2532      * The vector is arranged into lanes according to
2533      * <a href="Vector.html#lane-order">memory ordering</a>.
2534      * <p>
2535      * This method behaves as if it returns the result of calling
2536      * {@link #fromByteBuffer(VectorSpecies,ByteBuffer,int,ByteOrder,VectorMask)
2537      * fromByteBuffer()} as follows:
2538      * <pre>{@code
2539      * var bb = ByteBuffer.wrap(a);
2540      * var bo = ByteOrder.LITTLE_ENDIAN;
2541      * return fromByteBuffer(species, bb, offset, bo, m);
2542      * }</pre>
2543      *
2544      * @param species species of desired vector
2545      * @param a the byte array
2546      * @param offset the offset into the array
2547      * @param m the mask controlling lane selection
2548      * @return a vector loaded from a byte array
2549      * @throws IndexOutOfBoundsException
2550      *         if {@code offset+N*ESIZE < 0}
2551      *         or {@code offset+(N+1)*ESIZE > a.length}
2552      *         for any lane {@code N} in the vector where
2553      *         the mask is set
2554      */
2555     @ForceInline
2556     public static
2557     LongVector fromByteArray(VectorSpecies<Long> species,
2558                                        byte[] a, int offset,
2559                                        VectorMask<Long> m) {
2560         return fromByteArray(species, a, offset, ByteOrder.LITTLE_ENDIAN, m);
2561     }
2562 
2563     /**
2564      * Loads a vector from a byte array starting at an offset
2565      * and using a mask.
2566      * Lanes where the mask is unset are filled with the default
2567      * value of {@code long} (zero).
2568      * Bytes are composed into primitive lane elements according
2569      * to {@linkplain ByteOrder#LITTLE_ENDIAN little endian} ordering.
2570      * The vector is arranged into lanes according to
2571      * <a href="Vector.html#lane-order">memory ordering</a>.
2572      * <p>
2573      * This method behaves as if it returns the result of calling


2769      * of the buffer must be little-endian.
2770      * <p>
2771      * This method behaves as if it returns the result of calling
2772      * {@link #fromByteBuffer(VectorSpecies,ByteBuffer,int,ByteOrder,VectorMask)
2773      * fromByteBuffer()} as follows:
2774      * <pre>{@code
2775      * var bb = ByteBuffer.wrap(a);
2776      * var bo = ByteOrder.LITTLE_ENDIAN;
2777      * var m = species.maskAll(true);
2778      * return fromByteBuffer(species, bb, offset, m, bo);
2779      * }</pre>
2780      *
2781      * @param species species of desired vector
2782      * @param bb the byte buffer
2783      * @param offset the offset into the byte buffer
2784      * @return a vector loaded from a byte buffer
2785      * @throws IllegalArgumentException if byte order of bb
2786      *         is not {@link ByteOrder#LITTLE_ENDIAN}
2787      * @throws IndexOutOfBoundsException
2788      *         if {@code offset+N*8 < 0}
2789      *         or {@code offset+N*8 >= bb.limit()}
2790      *         for any lane {@code N} in the vector
2791      */
2792     @ForceInline
2793     public static
2794     LongVector fromByteBuffer(VectorSpecies<Long> species,
2795                                         ByteBuffer bb, int offset,
2796                                         ByteOrder bo) {
2797         LongSpecies vsp = (LongSpecies) species;
2798         offset = checkFromIndexSize(offset,
2799                                     vsp.laneCount(),
2800                                     bb.limit());
2801         return vsp.dummyVector()
2802             .fromByteBuffer0(bb, offset).maybeSwap(bo);
2803     }
2804 
2805     /**
2806      * Loads a vector from a {@linkplain ByteBuffer byte buffer}
2807      * starting at an offset into the byte buffer
2808      * and using a mask.
2809      * <p>


2815      * <p>
2816      * This method behaves as if it returns the result of calling
2817      * {@link #fromByteBuffer(VectorSpecies,ByteBuffer,int,ByteOrder,VectorMask)
2818      * fromByteBuffer()} as follows:
2819      * <pre>{@code
2820      * var bb = ByteBuffer.wrap(a);
2821      * var bo = ByteOrder.LITTLE_ENDIAN;
2822      * var m = species.maskAll(true);
2823      * return fromByteBuffer(species, bb, offset, m, bo);
2824      * }</pre>
2825      *
2826      * @param species species of desired vector
2827      * @param bb the byte buffer
2828      * @param offset the offset into the byte buffer
2829      * @param m the mask controlling lane selection
2830      * @return a vector loaded from a byte buffer
2831      * @throws IllegalArgumentException if byte order of bb
2832      *         is not {@link ByteOrder#LITTLE_ENDIAN}
2833      * @throws IndexOutOfBoundsException
2834      *         if {@code offset+N*8 < 0}
2835      *         or {@code offset+N*8 >= bb.limit()}
2836      *         for any lane {@code N} in the vector
2837      *         where the mask is set
2838      */
2839     @ForceInline
2840     public static
2841     LongVector fromByteBuffer(VectorSpecies<Long> species,
2842                                         ByteBuffer bb, int offset,
2843                                         ByteOrder bo,
2844                                         VectorMask<Long> m) {
2845         if (m.allTrue()) {
2846             return fromByteBuffer(species, bb, offset, bo);
2847         }
2848         LongSpecies vsp = (LongSpecies) species;
2849         checkMaskFromIndexSize(offset,
2850                                vsp, m, 1,
2851                                bb.limit());
2852         LongVector zero = zero(vsp);
2853         LongVector v = zero.fromByteBuffer0(bb, offset);
2854         return zero.blend(v.maybeSwap(bo), m);
2855     }


< prev index next >