494 @Override
495 public abstract FloatVector 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,float)
514 * @see VectorSpecies#checkValue(VectorSpecies,float)
515 */
516 public static FloatVector broadcast(VectorSpecies<Float> species, long e) {
517 FloatSpecies vsp = (FloatSpecies) species;
518 return vsp.broadcast(e);
519 }
520
521 /*package-private*/
522 @ForceInline
523 final FloatVector 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 *
1330 * Because the underlying scalar operator is an IEEE
1331 * floating point number, division by zero in fact will
1332 * not throw an exception, but will yield a signed
1333 * infinity or NaN.
1334 *
1335 * @param e the input scalar
1336 * @return the result of dividing each lane of this vector by the scalar
1337 * @see #div(Vector)
1338 * @see #broadcast(float)
1339 * @see #div(int,VectorMask)
1340 * @see VectorOperators#DIV
1341 * @see #lanewise(VectorOperators.Binary,Vector)
1342 * @see #lanewise(VectorOperators.Binary,float)
1343 */
1344 @ForceInline
1345 public final FloatVector div(float e) {
1346 return lanewise(DIV, e);
1347 }
1348
1349 /**
1350 /**
1351 * {@inheritDoc} <!--workaround-->
1352 * @see #div(float,VectorMask)
1353 * <p> Because the underlying scalar operator is an IEEE
1354 * floating point number, division by zero in fact will
1355 * not throw an exception, but will yield a signed
1356 * infinity or NaN.
1357 */
1358 @Override
1359 @ForceInline
1360 public final FloatVector div(Vector<Float> v,
1361 VectorMask<Float> m) {
1362 return lanewise(DIV, v, m);
1363 }
1364
1365 /**
1366 * Divides this vector by the broadcast of an input scalar,
1367 * selecting lane elements controlled by a mask.
1368 *
1369 * This is a masked lane-wise binary operation which applies
1370 * the primitive division operation ({@code /}) to each lane.
1701 /**
1702 * Tests this vector by comparing it with an input scalar,
1703 * according to the given comparison operation.
1704 *
1705 * This is a lane-wise binary test operation which applies
1706 * the comparison operation to each lane.
1707 * <p>
1708 * The result is the same as
1709 * {@code compare(op, broadcast(species(), e))}.
1710 * That is, the scalar may be regarded as broadcast to
1711 * a vector of the same species, and then compared
1712 * against the original vector, using the selected
1713 * comparison operation.
1714 *
1715 * @param e the input scalar
1716 * @return the mask result of testing lane-wise if this vector
1717 * compares to the input, according to the selected
1718 * comparison operator
1719 * @see FloatVector#compare(VectorOperators.Comparison,Vector)
1720 * @see #eq(float)
1721 * @see #lessThan(float)
1722 */
1723 public abstract
1724 VectorMask<Float> compare(Comparison op, float e);
1725
1726 /*package-private*/
1727 @ForceInline
1728 final
1729 <M extends VectorMask<Float>>
1730 M compareTemplate(Class<M> maskType, Comparison op, float e) {
1731 return compareTemplate(maskType, op, broadcast(e));
1732 }
1733
1734 /**
1735 * Tests this vector by comparing it with an input scalar,
1736 * according to the given comparison operation,
1737 * in lanes selected by a mask.
1738 *
1739 * This is a masked lane-wise binary test operation which applies
1740 * to each pair of corresponding lane values.
1741 *
2540 * The vector is arranged into lanes according to
2541 * <a href="Vector.html#lane-order">memory ordering</a>.
2542 * <p>
2543 * This method behaves as if it returns the result of calling
2544 * {@link #fromByteBuffer(VectorSpecies,ByteBuffer,int,ByteOrder,VectorMask)
2545 * fromByteBuffer()} as follows:
2546 * <pre>{@code
2547 * var bb = ByteBuffer.wrap(a);
2548 * var bo = ByteOrder.LITTLE_ENDIAN;
2549 * return fromByteBuffer(species, bb, offset, bo, m);
2550 * }</pre>
2551 *
2552 * @param species species of desired vector
2553 * @param a the byte array
2554 * @param offset the offset into the array
2555 * @param m the mask controlling lane selection
2556 * @return a vector loaded from a byte array
2557 * @throws IndexOutOfBoundsException
2558 * if {@code offset+N*ESIZE < 0}
2559 * or {@code offset+(N+1)*ESIZE > a.length}
2560 * for any lane {@code N} in the vector
2561 */
2562 @ForceInline
2563 public static
2564 FloatVector fromByteArray(VectorSpecies<Float> species,
2565 byte[] a, int offset,
2566 VectorMask<Float> m) {
2567 return fromByteArray(species, a, offset, ByteOrder.LITTLE_ENDIAN, m);
2568 }
2569
2570 /**
2571 * Loads a vector from a byte array starting at an offset
2572 * and using a mask.
2573 * Lanes where the mask is unset are filled with the default
2574 * value of {@code float} (zero).
2575 * Bytes are composed into primitive lane elements according
2576 * to {@linkplain ByteOrder#LITTLE_ENDIAN little endian} ordering.
2577 * The vector is arranged into lanes according to
2578 * <a href="Vector.html#lane-order">memory ordering</a>.
2579 * <p>
2580 * This method behaves as if it returns the result of calling
2773 * of the buffer must be little-endian.
2774 * <p>
2775 * This method behaves as if it returns the result of calling
2776 * {@link #fromByteBuffer(VectorSpecies,ByteBuffer,int,ByteOrder,VectorMask)
2777 * fromByteBuffer()} as follows:
2778 * <pre>{@code
2779 * var bb = ByteBuffer.wrap(a);
2780 * var bo = ByteOrder.LITTLE_ENDIAN;
2781 * var m = species.maskAll(true);
2782 * return fromByteBuffer(species, bb, offset, m, bo);
2783 * }</pre>
2784 *
2785 * @param species species of desired vector
2786 * @param bb the byte buffer
2787 * @param offset the offset into the byte buffer
2788 * @return a vector loaded from a byte buffer
2789 * @throws IllegalArgumentException if byte order of bb
2790 * is not {@link ByteOrder#LITTLE_ENDIAN}
2791 * @throws IndexOutOfBoundsException
2792 * if {@code offset+N*4 < 0}
2793 * or {@code offset+N**4 >= bb.limit()}
2794 * for any lane {@code N} in the vector
2795 */
2796 @ForceInline
2797 public static
2798 FloatVector fromByteBuffer(VectorSpecies<Float> species,
2799 ByteBuffer bb, int offset,
2800 ByteOrder bo) {
2801 FloatSpecies vsp = (FloatSpecies) species;
2802 offset = checkFromIndexSize(offset,
2803 vsp.laneCount(),
2804 bb.limit());
2805 return vsp.dummyVector()
2806 .fromByteBuffer0(bb, offset).maybeSwap(bo);
2807 }
2808
2809 /**
2810 * Loads a vector from a {@linkplain ByteBuffer byte buffer}
2811 * starting at an offset into the byte buffer
2812 * and using a mask.
2813 * <p>
2819 * <p>
2820 * This method behaves as if it returns the result of calling
2821 * {@link #fromByteBuffer(VectorSpecies,ByteBuffer,int,ByteOrder,VectorMask)
2822 * fromByteBuffer()} as follows:
2823 * <pre>{@code
2824 * var bb = ByteBuffer.wrap(a);
2825 * var bo = ByteOrder.LITTLE_ENDIAN;
2826 * var m = species.maskAll(true);
2827 * return fromByteBuffer(species, bb, offset, m, bo);
2828 * }</pre>
2829 *
2830 * @param species species of desired vector
2831 * @param bb the byte buffer
2832 * @param offset the offset into the byte buffer
2833 * @param m the mask controlling lane selection
2834 * @return a vector loaded from a byte buffer
2835 * @throws IllegalArgumentException if byte order of bb
2836 * is not {@link ByteOrder#LITTLE_ENDIAN}
2837 * @throws IndexOutOfBoundsException
2838 * if {@code offset+N*4 < 0}
2839 * or {@code offset+N**4 >= bb.limit()}
2840 * for any lane {@code N} in the vector
2841 * where the mask is set
2842 */
2843 @ForceInline
2844 public static
2845 FloatVector fromByteBuffer(VectorSpecies<Float> species,
2846 ByteBuffer bb, int offset,
2847 ByteOrder bo,
2848 VectorMask<Float> m) {
2849 if (m.allTrue()) {
2850 return fromByteBuffer(species, bb, offset, bo);
2851 }
2852 FloatSpecies vsp = (FloatSpecies) species;
2853 checkMaskFromIndexSize(offset,
2854 vsp, m, 1,
2855 bb.limit());
2856 FloatVector zero = zero(vsp);
2857 FloatVector v = zero.fromByteBuffer0(bb, offset);
2858 return zero.blend(v.maybeSwap(bo), m);
2859 }
|
494 @Override
495 public abstract FloatVector 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,float)
514 * @see VectorSpecies#checkValue(VectorSpecies,long)
515 */
516 public static FloatVector broadcast(VectorSpecies<Float> species, long e) {
517 FloatSpecies vsp = (FloatSpecies) species;
518 return vsp.broadcast(e);
519 }
520
521 /*package-private*/
522 @ForceInline
523 final FloatVector 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 *
1330 * Because the underlying scalar operator is an IEEE
1331 * floating point number, division by zero in fact will
1332 * not throw an exception, but will yield a signed
1333 * infinity or NaN.
1334 *
1335 * @param e the input scalar
1336 * @return the result of dividing each lane of this vector by the scalar
1337 * @see #div(Vector)
1338 * @see #broadcast(float)
1339 * @see #div(int,VectorMask)
1340 * @see VectorOperators#DIV
1341 * @see #lanewise(VectorOperators.Binary,Vector)
1342 * @see #lanewise(VectorOperators.Binary,float)
1343 */
1344 @ForceInline
1345 public final FloatVector div(float e) {
1346 return lanewise(DIV, e);
1347 }
1348
1349 /**
1350 * {@inheritDoc} <!--workaround-->
1351 * @see #div(float,VectorMask)
1352 * <p> Because the underlying scalar operator is an IEEE
1353 * floating point number, division by zero in fact will
1354 * not throw an exception, but will yield a signed
1355 * infinity or NaN.
1356 */
1357 @Override
1358 @ForceInline
1359 public final FloatVector div(Vector<Float> v,
1360 VectorMask<Float> m) {
1361 return lanewise(DIV, v, m);
1362 }
1363
1364 /**
1365 * Divides this vector by the broadcast of an input scalar,
1366 * selecting lane elements controlled by a mask.
1367 *
1368 * This is a masked lane-wise binary operation which applies
1369 * the primitive division operation ({@code /}) to each lane.
1700 /**
1701 * Tests this vector by comparing it with an input scalar,
1702 * according to the given comparison operation.
1703 *
1704 * This is a lane-wise binary test operation which applies
1705 * the comparison operation to each lane.
1706 * <p>
1707 * The result is the same as
1708 * {@code compare(op, broadcast(species(), e))}.
1709 * That is, the scalar may be regarded as broadcast to
1710 * a vector of the same species, and then compared
1711 * against the original vector, using the selected
1712 * comparison operation.
1713 *
1714 * @param e the input scalar
1715 * @return the mask result of testing lane-wise if this vector
1716 * compares to the input, according to the selected
1717 * comparison operator
1718 * @see FloatVector#compare(VectorOperators.Comparison,Vector)
1719 * @see #eq(float)
1720 * @see #lt(float)
1721 */
1722 public abstract
1723 VectorMask<Float> compare(Comparison op, float e);
1724
1725 /*package-private*/
1726 @ForceInline
1727 final
1728 <M extends VectorMask<Float>>
1729 M compareTemplate(Class<M> maskType, Comparison op, float e) {
1730 return compareTemplate(maskType, op, broadcast(e));
1731 }
1732
1733 /**
1734 * Tests this vector by comparing it with an input scalar,
1735 * according to the given comparison operation,
1736 * in lanes selected by a mask.
1737 *
1738 * This is a masked lane-wise binary test operation which applies
1739 * to each pair of corresponding lane values.
1740 *
2539 * The vector is arranged into lanes according to
2540 * <a href="Vector.html#lane-order">memory ordering</a>.
2541 * <p>
2542 * This method behaves as if it returns the result of calling
2543 * {@link #fromByteBuffer(VectorSpecies,ByteBuffer,int,ByteOrder,VectorMask)
2544 * fromByteBuffer()} as follows:
2545 * <pre>{@code
2546 * var bb = ByteBuffer.wrap(a);
2547 * var bo = ByteOrder.LITTLE_ENDIAN;
2548 * return fromByteBuffer(species, bb, offset, bo, m);
2549 * }</pre>
2550 *
2551 * @param species species of desired vector
2552 * @param a the byte array
2553 * @param offset the offset into the array
2554 * @param m the mask controlling lane selection
2555 * @return a vector loaded from a byte array
2556 * @throws IndexOutOfBoundsException
2557 * if {@code offset+N*ESIZE < 0}
2558 * or {@code offset+(N+1)*ESIZE > a.length}
2559 * for any lane {@code N} in the vector where
2560 * the mask is set
2561 */
2562 @ForceInline
2563 public static
2564 FloatVector fromByteArray(VectorSpecies<Float> species,
2565 byte[] a, int offset,
2566 VectorMask<Float> m) {
2567 return fromByteArray(species, a, offset, ByteOrder.LITTLE_ENDIAN, m);
2568 }
2569
2570 /**
2571 * Loads a vector from a byte array starting at an offset
2572 * and using a mask.
2573 * Lanes where the mask is unset are filled with the default
2574 * value of {@code float} (zero).
2575 * Bytes are composed into primitive lane elements according
2576 * to {@linkplain ByteOrder#LITTLE_ENDIAN little endian} ordering.
2577 * The vector is arranged into lanes according to
2578 * <a href="Vector.html#lane-order">memory ordering</a>.
2579 * <p>
2580 * This method behaves as if it returns the result of calling
2773 * of the buffer must be little-endian.
2774 * <p>
2775 * This method behaves as if it returns the result of calling
2776 * {@link #fromByteBuffer(VectorSpecies,ByteBuffer,int,ByteOrder,VectorMask)
2777 * fromByteBuffer()} as follows:
2778 * <pre>{@code
2779 * var bb = ByteBuffer.wrap(a);
2780 * var bo = ByteOrder.LITTLE_ENDIAN;
2781 * var m = species.maskAll(true);
2782 * return fromByteBuffer(species, bb, offset, m, bo);
2783 * }</pre>
2784 *
2785 * @param species species of desired vector
2786 * @param bb the byte buffer
2787 * @param offset the offset into the byte buffer
2788 * @return a vector loaded from a byte buffer
2789 * @throws IllegalArgumentException if byte order of bb
2790 * is not {@link ByteOrder#LITTLE_ENDIAN}
2791 * @throws IndexOutOfBoundsException
2792 * if {@code offset+N*4 < 0}
2793 * or {@code offset+N*4 >= bb.limit()}
2794 * for any lane {@code N} in the vector
2795 */
2796 @ForceInline
2797 public static
2798 FloatVector fromByteBuffer(VectorSpecies<Float> species,
2799 ByteBuffer bb, int offset,
2800 ByteOrder bo) {
2801 FloatSpecies vsp = (FloatSpecies) species;
2802 offset = checkFromIndexSize(offset,
2803 vsp.laneCount(),
2804 bb.limit());
2805 return vsp.dummyVector()
2806 .fromByteBuffer0(bb, offset).maybeSwap(bo);
2807 }
2808
2809 /**
2810 * Loads a vector from a {@linkplain ByteBuffer byte buffer}
2811 * starting at an offset into the byte buffer
2812 * and using a mask.
2813 * <p>
2819 * <p>
2820 * This method behaves as if it returns the result of calling
2821 * {@link #fromByteBuffer(VectorSpecies,ByteBuffer,int,ByteOrder,VectorMask)
2822 * fromByteBuffer()} as follows:
2823 * <pre>{@code
2824 * var bb = ByteBuffer.wrap(a);
2825 * var bo = ByteOrder.LITTLE_ENDIAN;
2826 * var m = species.maskAll(true);
2827 * return fromByteBuffer(species, bb, offset, m, bo);
2828 * }</pre>
2829 *
2830 * @param species species of desired vector
2831 * @param bb the byte buffer
2832 * @param offset the offset into the byte buffer
2833 * @param m the mask controlling lane selection
2834 * @return a vector loaded from a byte buffer
2835 * @throws IllegalArgumentException if byte order of bb
2836 * is not {@link ByteOrder#LITTLE_ENDIAN}
2837 * @throws IndexOutOfBoundsException
2838 * if {@code offset+N*4 < 0}
2839 * or {@code offset+N*4 >= bb.limit()}
2840 * for any lane {@code N} in the vector
2841 * where the mask is set
2842 */
2843 @ForceInline
2844 public static
2845 FloatVector fromByteBuffer(VectorSpecies<Float> species,
2846 ByteBuffer bb, int offset,
2847 ByteOrder bo,
2848 VectorMask<Float> m) {
2849 if (m.allTrue()) {
2850 return fromByteBuffer(species, bb, offset, bo);
2851 }
2852 FloatSpecies vsp = (FloatSpecies) species;
2853 checkMaskFromIndexSize(offset,
2854 vsp, m, 1,
2855 bb.limit());
2856 FloatVector zero = zero(vsp);
2857 FloatVector v = zero.fromByteBuffer0(bb, offset);
2858 return zero.blend(v.maybeSwap(bo), m);
2859 }
|