< prev index next >

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

Print this page
rev 55237 : javadoc changes


  88     }
  89 
  90     abstract Mask<Float> bTest(Vector<Float> v, FBinTest f);
  91 
  92     // Foreach
  93 
  94     interface FUnCon {
  95         void apply(int i, float a);
  96     }
  97 
  98     abstract void forEach(FUnCon f);
  99 
 100     abstract void forEach(Mask<Float> m, FUnCon f);
 101 
 102     // Static factories
 103 
 104     /**
 105      * Returns a vector where all lane elements are set to the default
 106      * primitive value.
 107      *
 108      * @return a zero vector

 109      */
 110     @ForceInline
 111     @SuppressWarnings("unchecked")
 112     public static FloatVector zero(FloatSpecies species) {
 113         return species.zero();
 114     }
 115 
 116     /**
 117      * Loads a vector from a byte array starting at an offset.
 118      * <p>
 119      * Bytes are composed into primitive lane elements according to the
 120      * native byte order of the underlying platform
 121      * <p>
 122      * This method behaves as if it returns the result of calling the
 123      * byte buffer, offset, and mask accepting
 124      * {@link #fromByteBuffer(FloatSpecies, ByteBuffer, int, Mask) method} as follows:
 125      * <pre>{@code
 126      * return this.fromByteBuffer(ByteBuffer.wrap(a), i, this.maskAllTrue());
 127      * }</pre>
 128      *

 129      * @param a the byte array
 130      * @param ix the offset into the array
 131      * @return a vector loaded from a byte array
 132      * @throws IndexOutOfBoundsException if {@code i < 0} or
 133      * {@code i > a.length - (this.length() * this.elementSize() / Byte.SIZE)}
 134      */
 135     @ForceInline
 136     @SuppressWarnings("unchecked")
 137     public static FloatVector fromByteArray(FloatSpecies species, byte[] a, int ix) {
 138         Objects.requireNonNull(a);
 139         ix = VectorIntrinsics.checkIndex(ix, a.length, species.bitSize() / Byte.SIZE);
 140         return VectorIntrinsics.load((Class<FloatVector>) species.boxType(), float.class, species.length(),
 141                                      a, ((long) ix) + Unsafe.ARRAY_BYTE_BASE_OFFSET,
 142                                      a, ix, species,
 143                                      (c, idx, s) -> {
 144                                          ByteBuffer bbc = ByteBuffer.wrap(c, idx, a.length - idx).order(ByteOrder.nativeOrder());
 145                                          FloatBuffer tb = bbc.asFloatBuffer();
 146                                          return ((FloatSpecies)s).op(i -> tb.get());
 147                                      });
 148     }
 149 
 150     /**
 151      * Loads a vector from a byte array starting at an offset and using a
 152      * mask.
 153      * <p>
 154      * Bytes are composed into primitive lane elements according to the
 155      * native byte order of the underlying platform.
 156      * <p>
 157      * This method behaves as if it returns the result of calling the
 158      * byte buffer, offset, and mask accepting
 159      * {@link #fromByteBuffer(FloatSpecies, ByteBuffer, int, Mask) method} as follows:
 160      * <pre>{@code
 161      * return this.fromByteBuffer(ByteBuffer.wrap(a), i, m);
 162      * }</pre>
 163      *

 164      * @param a the byte array
 165      * @param ix the offset into the array
 166      * @param m the mask
 167      * @return a vector loaded from a byte array
 168      * @throws IndexOutOfBoundsException if {@code i < 0} or
 169      * {@code i > a.length - (this.length() * this.elementSize() / Byte.SIZE)}
 170      * @throws IndexOutOfBoundsException if the offset is {@code < 0},
 171      * or {@code > a.length},
 172      * for any vector lane index {@code N} where the mask at lane {@code N}
 173      * is set
 174      * {@code i >= a.length - (N * this.elementSize() / Byte.SIZE)}
 175      */
 176     @ForceInline
 177     public static FloatVector fromByteArray(FloatSpecies species, byte[] a, int ix, Mask<Float> m) {
 178         return zero(species).blend(fromByteArray(species, a, ix), m);
 179     }
 180 
 181     /**
 182      * Loads a vector from an array starting at offset.
 183      * <p>
 184      * For each vector lane, where {@code N} is the vector lane index, the
 185      * array element at index {@code i + N} is placed into the
 186      * resulting vector at lane index {@code N}.
 187      *

 188      * @param a the array
 189      * @param i the offset into the array
 190      * @return the vector loaded from an array
 191      * @throws IndexOutOfBoundsException if {@code i < 0}, or
 192      * {@code i > a.length - this.length()}
 193      */
 194     @ForceInline
 195     @SuppressWarnings("unchecked")
 196     public static FloatVector fromArray(FloatSpecies species, float[] a, int i){
 197         Objects.requireNonNull(a);
 198         i = VectorIntrinsics.checkIndex(i, a.length, species.length());
 199         return VectorIntrinsics.load((Class<FloatVector>) species.boxType(), float.class, species.length(),
 200                                      a, (((long) i) << ARRAY_SHIFT) + Unsafe.ARRAY_FLOAT_BASE_OFFSET,
 201                                      a, i, species,
 202                                      (c, idx, s) -> ((FloatSpecies)s).op(n -> c[idx + n]));
 203     }
 204 
 205 
 206     /**
 207      * Loads a vector from an array starting at offset and using a mask.
 208      * <p>
 209      * For each vector lane, where {@code N} is the vector lane index,
 210      * if the mask lane at index {@code N} is set then the array element at
 211      * index {@code i + N} is placed into the resulting vector at lane index
 212      * {@code N}, otherwise the default element value is placed into the
 213      * resulting vector at lane index {@code N}.
 214      *

 215      * @param a the array
 216      * @param i the offset into the array
 217      * @param m the mask
 218      * @return the vector loaded from an array
 219      * @throws IndexOutOfBoundsException if {@code i < 0}, or
 220      * for any vector lane index {@code N} where the mask at lane {@code N}
 221      * is set {@code i > a.length - N}
 222      */
 223     @ForceInline
 224     public static FloatVector fromArray(FloatSpecies species, float[] a, int i, Mask<Float> m) {
 225         return zero(species).blend(fromArray(species, a, i), m);
 226     }
 227 
 228     /**
 229      * Loads a vector from an array using indexes obtained from an index
 230      * map.
 231      * <p>
 232      * For each vector lane, where {@code N} is the vector lane index, the
 233      * array element at index {@code i + indexMap[j + N]} is placed into the
 234      * resulting vector at lane index {@code N}.
 235      *

 236      * @param a the array
 237      * @param i the offset into the array, may be negative if relative
 238      * indexes in the index map compensate to produce a value within the
 239      * array bounds
 240      * @param indexMap the index map
 241      * @param j the offset into the index map
 242      * @return the vector loaded from an array
 243      * @throws IndexOutOfBoundsException if {@code j < 0}, or
 244      * {@code j > indexMap.length - this.length()},
 245      * or for any vector lane index {@code N} the result of
 246      * {@code i + indexMap[j + N]} is {@code < 0} or {@code >= a.length}
 247      */
 248     @ForceInline
 249     @SuppressWarnings("unchecked")
 250     public static FloatVector fromArray(FloatSpecies species, float[] a, int i, int[] indexMap, int j) {
 251         Objects.requireNonNull(a);
 252         Objects.requireNonNull(indexMap);
 253 
 254 
 255         // Index vector: vix[0:n] = k -> i + indexMap[j + i]
 256         IntVector vix = IntVector.fromArray(species.indexSpecies(), indexMap, j).add(i);
 257 
 258         vix = VectorIntrinsics.checkIndex(vix, a.length);
 259 
 260         return VectorIntrinsics.loadWithMap((Class<FloatVector>) species.boxType(), float.class, species.length(),
 261                                             species.indexSpecies().vectorType(), a, Unsafe.ARRAY_FLOAT_BASE_OFFSET, vix,
 262                                             a, i, indexMap, j, species,
 263                                            (c, idx, iMap, idy, s) -> ((FloatSpecies)s).op(n -> c[idx + iMap[idy+n]]));
 264         }
 265 
 266     /**
 267      * Loads a vector from an array using indexes obtained from an index
 268      * map and using a mask.
 269      * <p>
 270      * For each vector lane, where {@code N} is the vector lane index,
 271      * if the mask lane at index {@code N} is set then the array element at
 272      * index {@code i + indexMap[j + N]} is placed into the resulting vector
 273      * at lane index {@code N}.
 274      *

 275      * @param a the array
 276      * @param i the offset into the array, may be negative if relative
 277      * indexes in the index map compensate to produce a value within the
 278      * array bounds

 279      * @param indexMap the index map
 280      * @param j the offset into the index map
 281      * @return the vector loaded from an array
 282      * @throws IndexOutOfBoundsException if {@code j < 0}, or
 283      * {@code j > indexMap.length - this.length()},
 284      * or for any vector lane index {@code N} where the mask at lane
 285      * {@code N} is set the result of {@code i + indexMap[j + N]} is
 286      * {@code < 0} or {@code >= a.length}
 287      */
 288     @ForceInline
 289     @SuppressWarnings("unchecked")
 290     public static FloatVector fromArray(FloatSpecies species, float[] a, int i, Mask<Float> m, int[] indexMap, int j) {
 291         // @@@ This can result in out of bounds errors for unset mask lanes
 292         return zero(species).blend(fromArray(species, a, i, indexMap, j), m);
 293     }
 294 
 295 
 296     /**
 297      * Loads a vector from a {@link ByteBuffer byte buffer} starting at an
 298      * offset into the byte buffer.
 299      * <p>
 300      * Bytes are composed into primitive lane elements according to the
 301      * native byte order of the underlying platform.
 302      * <p>
 303      * This method behaves as if it returns the result of calling the
 304      * byte buffer, offset, and mask accepting
 305      * {@link #fromByteBuffer(FloatSpecies, ByteBuffer, int, Mask)} method} as follows:
 306      * <pre>{@code
 307      *   return this.fromByteBuffer(b, i, this.maskAllTrue())
 308      * }</pre>
 309      *

 310      * @param bb the byte buffer
 311      * @param ix the offset into the byte buffer
 312      * @return a vector loaded from a byte buffer
 313      * @throws IndexOutOfBoundsException if the offset is {@code < 0},
 314      * or {@code > b.limit()},
 315      * or if there are fewer than
 316      * {@code this.length() * this.elementSize() / Byte.SIZE} bytes
 317      * remaining in the byte buffer from the given offset
 318      */
 319     @ForceInline
 320     @SuppressWarnings("unchecked")
 321     public static FloatVector fromByteBuffer(FloatSpecies species, ByteBuffer bb, int ix) {
 322         if (bb.order() != ByteOrder.nativeOrder()) {
 323             throw new IllegalArgumentException();
 324         }
 325         ix = VectorIntrinsics.checkIndex(ix, bb.limit(), species.bitSize() / Byte.SIZE);
 326         return VectorIntrinsics.load((Class<FloatVector>) species.boxType(), float.class, species.length(),
 327                                      U.getReference(bb, BYTE_BUFFER_HB), U.getLong(bb, BUFFER_ADDRESS) + ix,
 328                                      bb, ix, species,
 329                                      (c, idx, s) -> {


 341      * {@link java.nio.Buffer buffer} for the primitive element type,
 342      * according to the native byte order of the underlying platform, and
 343      * the returned vector is loaded with a mask from a primitive array
 344      * obtained from the primitive buffer.
 345      * The following pseudocode expresses the behaviour, where
 346      * {@coce EBuffer} is the primitive buffer type, {@code e} is the
 347      * primitive element type, and {@code ESpecies<S>} is the primitive
 348      * species for {@code e}:
 349      * <pre>{@code
 350      * EBuffer eb = b.duplicate().
 351      *     order(ByteOrder.nativeOrder()).position(i).
 352      *     asEBuffer();
 353      * e[] es = new e[this.length()];
 354      * for (int n = 0; n < t.length; n++) {
 355      *     if (m.isSet(n))
 356      *         es[n] = eb.get(n);
 357      * }
 358      * Vector<E> r = ((ESpecies<S>)this).fromArray(es, 0, m);
 359      * }</pre>
 360      *

 361      * @param bb the byte buffer
 362      * @param ix the offset into the byte buffer

 363      * @return a vector loaded from a byte buffer
 364      * @throws IndexOutOfBoundsException if the offset is {@code < 0},
 365      * or {@code > b.limit()},
 366      * for any vector lane index {@code N} where the mask at lane {@code N}
 367      * is set
 368      * {@code i >= b.limit() - (N * this.elementSize() / Byte.SIZE)}
 369      */
 370     @ForceInline
 371     public static FloatVector fromByteBuffer(FloatSpecies species, ByteBuffer bb, int ix, Mask<Float> m) {
 372         return zero(species).blend(fromByteBuffer(species, bb, ix), m);
 373     }
 374 













 375     @ForceInline
 376     public static Mask<Float> maskFromValues(FloatSpecies species, boolean... bits) {
 377         if (species.boxType() == FloatMaxVector.class)
 378             return new FloatMaxVector.FloatMaxMask(bits);
 379         switch (species.bitSize()) {
 380             case 64: return new Float64Vector.Float64Mask(bits);
 381             case 128: return new Float128Vector.Float128Mask(bits);
 382             case 256: return new Float256Vector.Float256Mask(bits);
 383             case 512: return new Float512Vector.Float512Mask(bits);
 384             default: throw new IllegalArgumentException(Integer.toString(species.bitSize()));
 385         }
 386     }
 387 
 388     // @@@ This is a bad implementation -- makes lambdas capturing -- fix this
 389     static Mask<Float> trueMask(FloatSpecies species) {
 390         if (species.boxType() == FloatMaxVector.class)
 391             return FloatMaxVector.FloatMaxMask.TRUE_MASK;
 392         switch (species.bitSize()) {
 393             case 64: return Float64Vector.Float64Mask.TRUE_MASK;
 394             case 128: return Float128Vector.Float128Mask.TRUE_MASK;
 395             case 256: return Float256Vector.Float256Mask.TRUE_MASK;
 396             case 512: return Float512Vector.Float512Mask.TRUE_MASK;
 397             default: throw new IllegalArgumentException(Integer.toString(species.bitSize()));
 398         }
 399     }
 400 
 401     static Mask<Float> falseMask(FloatSpecies species) {
 402         if (species.boxType() == FloatMaxVector.class)
 403             return FloatMaxVector.FloatMaxMask.FALSE_MASK;
 404         switch (species.bitSize()) {
 405             case 64: return Float64Vector.Float64Mask.FALSE_MASK;
 406             case 128: return Float128Vector.Float128Mask.FALSE_MASK;
 407             case 256: return Float256Vector.Float256Mask.FALSE_MASK;
 408             case 512: return Float512Vector.Float512Mask.FALSE_MASK;
 409             default: throw new IllegalArgumentException(Integer.toString(species.bitSize()));
 410         }
 411     }
 412 














 413     @ForceInline
 414     @SuppressWarnings("unchecked")
 415     public static Mask<Float> maskFromArray(FloatSpecies species, boolean[] bits, int ix) {
 416         Objects.requireNonNull(bits);
 417         ix = VectorIntrinsics.checkIndex(ix, bits.length, species.length());
 418         return VectorIntrinsics.load((Class<Mask<Float>>) species.maskType(), int.class, species.length(),
 419                                      bits, (((long) ix) << ARRAY_SHIFT) + Unsafe.ARRAY_BOOLEAN_BASE_OFFSET,
 420                                      bits, ix, species,
 421                                      (c, idx, s) -> (Mask<Float>) ((FloatSpecies)s).opm(n -> c[idx + n]));
 422     }
 423 






 424     @ForceInline
 425     @SuppressWarnings("unchecked")
 426     public static Mask<Float> maskAllTrue(FloatSpecies species) {
 427         return VectorIntrinsics.broadcastCoerced((Class<Mask<Float>>) species.maskType(), int.class, species.length(),
 428                                                  (int)-1,  species,
 429                                                  ((z, s) -> trueMask((FloatSpecies)s)));
 430     }
 431 






 432     @ForceInline
 433     @SuppressWarnings("unchecked")
 434     public static Mask<Float> maskAllFalse(FloatSpecies species) {
 435         return VectorIntrinsics.broadcastCoerced((Class<Mask<Float>>) species.maskType(), int.class, species.length(),
 436                                                  0, species, 
 437                                                  ((z, s) -> falseMask((FloatSpecies)s)));
 438     }
 439 
























 440     @ForceInline
 441     public static Shuffle<Float> shuffle(FloatSpecies species, IntUnaryOperator f) {
 442         if (species.boxType() == FloatMaxVector.class)
 443             return new FloatMaxVector.FloatMaxShuffle(f);
 444         switch (species.bitSize()) {
 445             case 64: return new Float64Vector.Float64Shuffle(f);
 446             case 128: return new Float128Vector.Float128Shuffle(f);
 447             case 256: return new Float256Vector.Float256Shuffle(f);
 448             case 512: return new Float512Vector.Float512Shuffle(f);
 449             default: throw new IllegalArgumentException(Integer.toString(species.bitSize()));
 450         }
 451     }
 452 













 453     @ForceInline
 454     public static Shuffle<Float> shuffleIota(FloatSpecies species) {
 455         if (species.boxType() == FloatMaxVector.class)
 456             return new FloatMaxVector.FloatMaxShuffle(AbstractShuffle.IDENTITY);
 457         switch (species.bitSize()) {
 458             case 64: return new Float64Vector.Float64Shuffle(AbstractShuffle.IDENTITY);
 459             case 128: return new Float128Vector.Float128Shuffle(AbstractShuffle.IDENTITY);
 460             case 256: return new Float256Vector.Float256Shuffle(AbstractShuffle.IDENTITY);
 461             case 512: return new Float512Vector.Float512Shuffle(AbstractShuffle.IDENTITY);
 462             default: throw new IllegalArgumentException(Integer.toString(species.bitSize()));
 463         }
 464     }
 465 
















 466     @ForceInline
 467     public static Shuffle<Float> shuffleFromValues(FloatSpecies species, int... ixs) {
 468         if (species.boxType() == FloatMaxVector.class)
 469             return new FloatMaxVector.FloatMaxShuffle(ixs);
 470         switch (species.bitSize()) {
 471             case 64: return new Float64Vector.Float64Shuffle(ixs);
 472             case 128: return new Float128Vector.Float128Shuffle(ixs);
 473             case 256: return new Float256Vector.Float256Shuffle(ixs);
 474             case 512: return new Float512Vector.Float512Shuffle(ixs);
 475             default: throw new IllegalArgumentException(Integer.toString(species.bitSize()));
 476         }
 477     }
 478 















 479     @ForceInline
 480     public static Shuffle<Float> shuffleFromArray(FloatSpecies species, int[] ixs, int i) {
 481         if (species.boxType() == FloatMaxVector.class)
 482             return new FloatMaxVector.FloatMaxShuffle(ixs, i);
 483         switch (species.bitSize()) {
 484             case 64: return new Float64Vector.Float64Shuffle(ixs, i);
 485             case 128: return new Float128Vector.Float128Shuffle(ixs, i);
 486             case 256: return new Float256Vector.Float256Shuffle(ixs, i);
 487             case 512: return new Float512Vector.Float512Shuffle(ixs, i);
 488             default: throw new IllegalArgumentException(Integer.toString(species.bitSize()));
 489         }
 490     }
 491 
 492 
 493     // Ops
 494 
 495     @Override
 496     public abstract FloatVector add(Vector<Float> v);
 497 
 498     /**


1620      * @return square root of the sum of the squares of this vector and the
1621      * broadcast of an input scalar
1622      */
1623     public abstract FloatVector hypot(float s, Mask<Float> m);
1624 
1625 
1626     @Override
1627     public abstract void intoByteArray(byte[] a, int ix);
1628 
1629     @Override
1630     public abstract void intoByteArray(byte[] a, int ix, Mask<Float> m);
1631 
1632     @Override
1633     public abstract void intoByteBuffer(ByteBuffer bb, int ix);
1634 
1635     @Override
1636     public abstract void intoByteBuffer(ByteBuffer bb, int ix, Mask<Float> m);
1637 
1638 
1639     // Type specific horizontal reductions
1640 
1641     /**
1642      * Adds all lane elements of this vector.
1643      * <p>
1644      * This is an associative vector reduction operation where the addition
1645      * operation ({@code +}) is applied to lane elements,
1646      * and the identity value is {@code 0}.









1647      *
1648      * @return the addition of all the lane elements of this vector
1649      */
1650     public abstract float addAll();
1651 
1652     /**
1653      * Adds all lane elements of this vector, selecting lane elements
1654      * controlled by a mask.
1655      * <p>
1656      * This is an associative vector reduction operation where the addition
1657      * operation ({@code +}) is applied to lane elements,
1658      * and the identity value is {@code 0}.
1659      *
1660      * @param m the mask controlling lane selection
1661      * @return the addition of all the lane elements of this vector
1662      */
1663     public abstract float addAll(Mask<Float> m);
1664 
1665     /**
1666      * Subtracts all lane elements of this vector.
1667      * <p>
1668      * This is an associative vector reduction operation where the subtraction
1669      * operation ({@code -}) is applied to lane elements,
1670      * and the identity value is {@code 0}.
1671      *
1672      * @return the subtraction of all the lane elements of this vector
1673      */
1674     public abstract float subAll();
1675 
1676     /**
1677      * Subtracts all lane elements of this vector, selecting lane elements
1678      * controlled by a mask.
1679      * <p>
1680      * This is an associative vector reduction operation where the subtraction
1681      * operation ({@code -}) is applied to lane elements,
1682      * and the identity value is {@code 0}.
1683      *
1684      * @param m the mask controlling lane selection
1685      * @return the subtraction of all the lane elements of this vector
1686      */
1687     public abstract float subAll(Mask<Float> m);
1688 
1689     /**
1690      * Multiplies all lane elements of this vector.
1691      * <p>
1692      * This is an associative vector reduction operation where the
1693      * multiplication operation ({@code *}) is applied to lane elements,
1694      * and the identity value is {@code 1}.








1695      *
1696      * @return the multiplication of all the lane elements of this vector
1697      */
1698     public abstract float mulAll();
1699 
1700     /**
1701      * Multiplies all lane elements of this vector, selecting lane elements
1702      * controlled by a mask.
1703      * <p>
1704      * This is an associative vector reduction operation where the
1705      * multiplication operation ({@code *}) is applied to lane elements,
1706      * and the identity value is {@code 1}.








1707      *
1708      * @param m the mask controlling lane selection
1709      * @return the multiplication of all the lane elements of this vector
1710      */
1711     public abstract float mulAll(Mask<Float> m);
1712 
1713     /**
1714      * Returns the minimum lane element of this vector.
1715      * <p>
1716      * This is an associative vector reduction operation where the operation
1717      * {@code (a, b) -> Math.min(a, b)} is applied to lane elements,
1718      * and the identity value is {@link Float#MAX_VALUE}.

1719      *
1720      * @return the minimum lane element of this vector
1721      */
1722     public abstract float minAll();
1723 
1724     /**
1725      * Returns the minimum lane element of this vector, selecting lane elements
1726      * controlled by a mask.
1727      * <p>
1728      * This is an associative vector reduction operation where the operation
1729      * {@code (a, b) -> Math.min(a, b)} is applied to lane elements,
1730      * and the identity value is {@link Float#MAX_VALUE}.

1731      *
1732      * @param m the mask controlling lane selection
1733      * @return the minimum lane element of this vector
1734      */
1735     public abstract float minAll(Mask<Float> m);
1736 
1737     /**
1738      * Returns the maximum lane element of this vector.
1739      * <p>
1740      * This is an associative vector reduction operation where the operation
1741      * {@code (a, b) -> Math.max(a, b)} is applied to lane elements,
1742      * and the identity value is {@link Float#MIN_VALUE}.

1743      *
1744      * @return the maximum lane element of this vector
1745      */
1746     public abstract float maxAll();
1747 
1748     /**
1749      * Returns the maximum lane element of this vector, selecting lane elements
1750      * controlled by a mask.
1751      * <p>
1752      * This is an associative vector reduction operation where the operation
1753      * {@code (a, b) -> Math.max(a, b)} is applied to lane elements,
1754      * and the identity value is {@link Float#MIN_VALUE}.

1755      *
1756      * @param m the mask controlling lane selection
1757      * @return the maximum lane element of this vector
1758      */
1759     public abstract float maxAll(Mask<Float> m);
1760 
1761 
1762     // Type specific accessors
1763 
1764     /**
1765      * Gets the lane element at lane index {@code i}
1766      *
1767      * @param i the lane index
1768      * @return the lane element at lane index {@code i}
1769      * @throws IllegalArgumentException if the index is is out of range
1770      * ({@code < 0 || >= length()})
1771      */
1772     public abstract float get(int i);
1773 
1774     /**


1930 
1931         /**
1932          * Returns a vector where the first lane element is set to the primtive
1933          * value {@code e}, all other lane elements are set to the default
1934          * value.
1935          *
1936          * @param e the value
1937          * @return a vector where the first lane element is set to the primitive
1938          * value {@code e}
1939          */
1940         @ForceInline
1941         public final FloatVector single(float e) {
1942             return zero().with(0, e);
1943         }
1944 
1945         /**
1946          * Returns a vector where each lane element is set to a randomly
1947          * generated primitive value.
1948          *
1949          * The semantics are equivalent to calling
1950          * {@link ThreadLocalRandom#nextFloat }
1951          *
1952          * @return a vector where each lane elements is set to a randomly
1953          * generated primitive value
1954          */
1955         public FloatVector random() {
1956             ThreadLocalRandom r = ThreadLocalRandom.current();
1957             return op(i -> r.nextFloat());
1958         }
1959 
1960         /**
1961          * Returns a vector where each lane element is set to a given
1962          * primitive value.
1963          * <p>
1964          * For each vector lane, where {@code N} is the vector lane index, the
1965          * the primitive value at index {@code N} is placed into the resulting
1966          * vector at lane index {@code N}.
1967          *
1968          * @param es the given primitive values
1969          * @return a vector where each lane element is set to a given primitive
1970          * value




  88     }
  89 
  90     abstract Mask<Float> bTest(Vector<Float> v, FBinTest f);
  91 
  92     // Foreach
  93 
  94     interface FUnCon {
  95         void apply(int i, float a);
  96     }
  97 
  98     abstract void forEach(FUnCon f);
  99 
 100     abstract void forEach(Mask<Float> m, FUnCon f);
 101 
 102     // Static factories
 103 
 104     /**
 105      * Returns a vector where all lane elements are set to the default
 106      * primitive value.
 107      *
 108      * @param species species of desired vector
 109      * @return a zero vector of given species
 110      */
 111     @ForceInline
 112     @SuppressWarnings("unchecked")
 113     public static FloatVector zero(FloatSpecies species) {
 114         return species.zero();
 115     }
 116 
 117     /**
 118      * Loads a vector from a byte array starting at an offset.
 119      * <p>
 120      * Bytes are composed into primitive lane elements according to the
 121      * native byte order of the underlying platform
 122      * <p>
 123      * This method behaves as if it returns the result of calling the
 124      * byte buffer, offset, and mask accepting
 125      * {@link #fromByteBuffer(FloatSpecies, ByteBuffer, int, Mask) method} as follows:
 126      * <pre>{@code
 127      * return this.fromByteBuffer(ByteBuffer.wrap(a), i, this.maskAllTrue());
 128      * }</pre>
 129      *
 130      * @param species species of desired vector
 131      * @param a the byte array
 132      * @param ix the offset into the array
 133      * @return a vector loaded from a byte array
 134      * @throws IndexOutOfBoundsException if {@code i < 0} or
 135      * {@code i > a.length - (this.length() * this.elementSize() / Byte.SIZE)}
 136      */
 137     @ForceInline
 138     @SuppressWarnings("unchecked")
 139     public static FloatVector fromByteArray(FloatSpecies species, byte[] a, int ix) {
 140         Objects.requireNonNull(a);
 141         ix = VectorIntrinsics.checkIndex(ix, a.length, species.bitSize() / Byte.SIZE);
 142         return VectorIntrinsics.load((Class<FloatVector>) species.boxType(), float.class, species.length(),
 143                                      a, ((long) ix) + Unsafe.ARRAY_BYTE_BASE_OFFSET,
 144                                      a, ix, species,
 145                                      (c, idx, s) -> {
 146                                          ByteBuffer bbc = ByteBuffer.wrap(c, idx, a.length - idx).order(ByteOrder.nativeOrder());
 147                                          FloatBuffer tb = bbc.asFloatBuffer();
 148                                          return ((FloatSpecies)s).op(i -> tb.get());
 149                                      });
 150     }
 151 
 152     /**
 153      * Loads a vector from a byte array starting at an offset and using a
 154      * mask.
 155      * <p>
 156      * Bytes are composed into primitive lane elements according to the
 157      * native byte order of the underlying platform.
 158      * <p>
 159      * This method behaves as if it returns the result of calling the
 160      * byte buffer, offset, and mask accepting
 161      * {@link #fromByteBuffer(FloatSpecies, ByteBuffer, int, Mask) method} as follows:
 162      * <pre>{@code
 163      * return this.fromByteBuffer(ByteBuffer.wrap(a), i, m);
 164      * }</pre>
 165      *
 166      * @param species species of desired vector
 167      * @param a the byte array
 168      * @param ix the offset into the array
 169      * @param m the mask
 170      * @return a vector loaded from a byte array
 171      * @throws IndexOutOfBoundsException if {@code i < 0} or
 172      * {@code i > a.length - (this.length() * this.elementSize() / Byte.SIZE)}
 173      * @throws IndexOutOfBoundsException if the offset is {@code < 0},
 174      * or {@code > a.length},
 175      * for any vector lane index {@code N} where the mask at lane {@code N}
 176      * is set
 177      * {@code i >= a.length - (N * this.elementSize() / Byte.SIZE)}
 178      */
 179     @ForceInline
 180     public static FloatVector fromByteArray(FloatSpecies species, byte[] a, int ix, Mask<Float> m) {
 181         return zero(species).blend(fromByteArray(species, a, ix), m);
 182     }
 183 
 184     /**
 185      * Loads a vector from an array starting at offset.
 186      * <p>
 187      * For each vector lane, where {@code N} is the vector lane index, the
 188      * array element at index {@code i + N} is placed into the
 189      * resulting vector at lane index {@code N}.
 190      *
 191      * @param species species of desired vector
 192      * @param a the array
 193      * @param i the offset into the array
 194      * @return the vector loaded from an array
 195      * @throws IndexOutOfBoundsException if {@code i < 0}, or
 196      * {@code i > a.length - this.length()}
 197      */
 198     @ForceInline
 199     @SuppressWarnings("unchecked")
 200     public static FloatVector fromArray(FloatSpecies species, float[] a, int i){
 201         Objects.requireNonNull(a);
 202         i = VectorIntrinsics.checkIndex(i, a.length, species.length());
 203         return VectorIntrinsics.load((Class<FloatVector>) species.boxType(), float.class, species.length(),
 204                                      a, (((long) i) << ARRAY_SHIFT) + Unsafe.ARRAY_FLOAT_BASE_OFFSET,
 205                                      a, i, species,
 206                                      (c, idx, s) -> ((FloatSpecies)s).op(n -> c[idx + n]));
 207     }
 208 
 209 
 210     /**
 211      * Loads a vector from an array starting at offset and using a mask.
 212      * <p>
 213      * For each vector lane, where {@code N} is the vector lane index,
 214      * if the mask lane at index {@code N} is set then the array element at
 215      * index {@code i + N} is placed into the resulting vector at lane index
 216      * {@code N}, otherwise the default element value is placed into the
 217      * resulting vector at lane index {@code N}.
 218      *
 219      * @param species species of desired vector
 220      * @param a the array
 221      * @param i the offset into the array
 222      * @param m the mask
 223      * @return the vector loaded from an array
 224      * @throws IndexOutOfBoundsException if {@code i < 0}, or
 225      * for any vector lane index {@code N} where the mask at lane {@code N}
 226      * is set {@code i > a.length - N}
 227      */
 228     @ForceInline
 229     public static FloatVector fromArray(FloatSpecies species, float[] a, int i, Mask<Float> m) {
 230         return zero(species).blend(fromArray(species, a, i), m);
 231     }
 232 
 233     /**
 234      * Loads a vector from an array using indexes obtained from an index
 235      * map.
 236      * <p>
 237      * For each vector lane, where {@code N} is the vector lane index, the
 238      * array element at index {@code i + indexMap[j + N]} is placed into the
 239      * resulting vector at lane index {@code N}.
 240      *
 241      * @param species species of desired vector
 242      * @param a the array
 243      * @param i the offset into the array, may be negative if relative
 244      * indexes in the index map compensate to produce a value within the
 245      * array bounds
 246      * @param indexMap the index map
 247      * @param j the offset into the index map
 248      * @return the vector loaded from an array
 249      * @throws IndexOutOfBoundsException if {@code j < 0}, or
 250      * {@code j > indexMap.length - this.length()},
 251      * or for any vector lane index {@code N} the result of
 252      * {@code i + indexMap[j + N]} is {@code < 0} or {@code >= a.length}
 253      */
 254     @ForceInline
 255     @SuppressWarnings("unchecked")
 256     public static FloatVector fromArray(FloatSpecies species, float[] a, int i, int[] indexMap, int j) {
 257         Objects.requireNonNull(a);
 258         Objects.requireNonNull(indexMap);
 259 
 260 
 261         // Index vector: vix[0:n] = k -> i + indexMap[j + i]
 262         IntVector vix = IntVector.fromArray(species.indexSpecies(), indexMap, j).add(i);
 263 
 264         vix = VectorIntrinsics.checkIndex(vix, a.length);
 265 
 266         return VectorIntrinsics.loadWithMap((Class<FloatVector>) species.boxType(), float.class, species.length(),
 267                                             species.indexSpecies().vectorType(), a, Unsafe.ARRAY_FLOAT_BASE_OFFSET, vix,
 268                                             a, i, indexMap, j, species,
 269                                            (c, idx, iMap, idy, s) -> ((FloatSpecies)s).op(n -> c[idx + iMap[idy+n]]));
 270         }
 271 
 272     /**
 273      * Loads a vector from an array using indexes obtained from an index
 274      * map and using a mask.
 275      * <p>
 276      * For each vector lane, where {@code N} is the vector lane index,
 277      * if the mask lane at index {@code N} is set then the array element at
 278      * index {@code i + indexMap[j + N]} is placed into the resulting vector
 279      * at lane index {@code N}.
 280      *
 281      * @param species species of desired vector
 282      * @param a the array
 283      * @param i the offset into the array, may be negative if relative
 284      * indexes in the index map compensate to produce a value within the
 285      * array bounds
 286      * @param m the mask
 287      * @param indexMap the index map
 288      * @param j the offset into the index map
 289      * @return the vector loaded from an array
 290      * @throws IndexOutOfBoundsException if {@code j < 0}, or
 291      * {@code j > indexMap.length - this.length()},
 292      * or for any vector lane index {@code N} where the mask at lane
 293      * {@code N} is set the result of {@code i + indexMap[j + N]} is
 294      * {@code < 0} or {@code >= a.length}
 295      */
 296     @ForceInline
 297     @SuppressWarnings("unchecked")
 298     public static FloatVector fromArray(FloatSpecies species, float[] a, int i, Mask<Float> m, int[] indexMap, int j) {
 299         // @@@ This can result in out of bounds errors for unset mask lanes
 300         return zero(species).blend(fromArray(species, a, i, indexMap, j), m);
 301     }
 302 
 303 
 304     /**
 305      * Loads a vector from a {@link ByteBuffer byte buffer} starting at an
 306      * offset into the byte buffer.
 307      * <p>
 308      * Bytes are composed into primitive lane elements according to the
 309      * native byte order of the underlying platform.
 310      * <p>
 311      * This method behaves as if it returns the result of calling the
 312      * byte buffer, offset, and mask accepting
 313      * {@link #fromByteBuffer(FloatSpecies, ByteBuffer, int, Mask)} method} as follows:
 314      * <pre>{@code
 315      *   return this.fromByteBuffer(b, i, this.maskAllTrue())
 316      * }</pre>
 317      *
 318      * @param species species of desired vector
 319      * @param bb the byte buffer
 320      * @param ix the offset into the byte buffer
 321      * @return a vector loaded from a byte buffer
 322      * @throws IndexOutOfBoundsException if the offset is {@code < 0},
 323      * or {@code > b.limit()},
 324      * or if there are fewer than
 325      * {@code this.length() * this.elementSize() / Byte.SIZE} bytes
 326      * remaining in the byte buffer from the given offset
 327      */
 328     @ForceInline
 329     @SuppressWarnings("unchecked")
 330     public static FloatVector fromByteBuffer(FloatSpecies species, ByteBuffer bb, int ix) {
 331         if (bb.order() != ByteOrder.nativeOrder()) {
 332             throw new IllegalArgumentException();
 333         }
 334         ix = VectorIntrinsics.checkIndex(ix, bb.limit(), species.bitSize() / Byte.SIZE);
 335         return VectorIntrinsics.load((Class<FloatVector>) species.boxType(), float.class, species.length(),
 336                                      U.getReference(bb, BYTE_BUFFER_HB), U.getLong(bb, BUFFER_ADDRESS) + ix,
 337                                      bb, ix, species,
 338                                      (c, idx, s) -> {


 350      * {@link java.nio.Buffer buffer} for the primitive element type,
 351      * according to the native byte order of the underlying platform, and
 352      * the returned vector is loaded with a mask from a primitive array
 353      * obtained from the primitive buffer.
 354      * The following pseudocode expresses the behaviour, where
 355      * {@coce EBuffer} is the primitive buffer type, {@code e} is the
 356      * primitive element type, and {@code ESpecies<S>} is the primitive
 357      * species for {@code e}:
 358      * <pre>{@code
 359      * EBuffer eb = b.duplicate().
 360      *     order(ByteOrder.nativeOrder()).position(i).
 361      *     asEBuffer();
 362      * e[] es = new e[this.length()];
 363      * for (int n = 0; n < t.length; n++) {
 364      *     if (m.isSet(n))
 365      *         es[n] = eb.get(n);
 366      * }
 367      * Vector<E> r = ((ESpecies<S>)this).fromArray(es, 0, m);
 368      * }</pre>
 369      *
 370      * @param species species of desired vector
 371      * @param bb the byte buffer
 372      * @param ix the offset into the byte buffer
 373      * @param m the mask
 374      * @return a vector loaded from a byte buffer
 375      * @throws IndexOutOfBoundsException if the offset is {@code < 0},
 376      * or {@code > b.limit()},
 377      * for any vector lane index {@code N} where the mask at lane {@code N}
 378      * is set
 379      * {@code i >= b.limit() - (N * this.elementSize() / Byte.SIZE)}
 380      */
 381     @ForceInline
 382     public static FloatVector fromByteBuffer(FloatSpecies species, ByteBuffer bb, int ix, Mask<Float> m) {
 383         return zero(species).blend(fromByteBuffer(species, bb, ix), m);
 384     }
 385 
 386     /**
 387      * Returns a mask where each lane is set or unset according to given
 388      * {@code boolean} values
 389      * <p>
 390      * For each mask lane, where {@code N} is the mask lane index,
 391      * if the given {@code boolean} value at index {@code N} is {@code true}
 392      * then the mask lane at index {@code N} is set, otherwise it is unset.
 393      *
 394      * @param species mask species
 395      * @param bits the given {@code boolean} values
 396      * @return a mask where each lane is set or unset according to the given {@code boolean} value
 397      * @throws IndexOutOfBoundsException if {@code bits.length < species.length()}
 398      */
 399     @ForceInline
 400     public static Mask<Float> maskFromValues(FloatSpecies species, boolean... bits) {
 401         if (species.boxType() == FloatMaxVector.class)
 402             return new FloatMaxVector.FloatMaxMask(bits);
 403         switch (species.bitSize()) {
 404             case 64: return new Float64Vector.Float64Mask(bits);
 405             case 128: return new Float128Vector.Float128Mask(bits);
 406             case 256: return new Float256Vector.Float256Mask(bits);
 407             case 512: return new Float512Vector.Float512Mask(bits);
 408             default: throw new IllegalArgumentException(Integer.toString(species.bitSize()));
 409         }
 410     }
 411 
 412     // @@@ This is a bad implementation -- makes lambdas capturing -- fix this
 413     static Mask<Float> trueMask(FloatSpecies species) {
 414         if (species.boxType() == FloatMaxVector.class)
 415             return FloatMaxVector.FloatMaxMask.TRUE_MASK;
 416         switch (species.bitSize()) {
 417             case 64: return Float64Vector.Float64Mask.TRUE_MASK;
 418             case 128: return Float128Vector.Float128Mask.TRUE_MASK;
 419             case 256: return Float256Vector.Float256Mask.TRUE_MASK;
 420             case 512: return Float512Vector.Float512Mask.TRUE_MASK;
 421             default: throw new IllegalArgumentException(Integer.toString(species.bitSize()));
 422         }
 423     }
 424 
 425     static Mask<Float> falseMask(FloatSpecies species) {
 426         if (species.boxType() == FloatMaxVector.class)
 427             return FloatMaxVector.FloatMaxMask.FALSE_MASK;
 428         switch (species.bitSize()) {
 429             case 64: return Float64Vector.Float64Mask.FALSE_MASK;
 430             case 128: return Float128Vector.Float128Mask.FALSE_MASK;
 431             case 256: return Float256Vector.Float256Mask.FALSE_MASK;
 432             case 512: return Float512Vector.Float512Mask.FALSE_MASK;
 433             default: throw new IllegalArgumentException(Integer.toString(species.bitSize()));
 434         }
 435     }
 436 
 437     /**
 438      * Loads a mask from a {@code boolean} array starting at an offset.
 439      * <p>
 440      * For each mask lane, where {@code N} is the mask lane index,
 441      * if the array element at index {@code i + N} is {@code true} then the
 442      * mask lane at index {@code N} is set, otherwise it is unset.
 443      *
 444      * @param species mask species
 445      * @param bits the {@code boolean} array
 446      * @param ix the offset into the array
 447      * @return the mask loaded from a {@code boolean} array
 448      * @throws IndexOutOfBoundsException if {@code ix < 0}, or
 449      * {@code ix > bits.length - species.length()}
 450      */
 451     @ForceInline
 452     @SuppressWarnings("unchecked")
 453     public static Mask<Float> maskFromArray(FloatSpecies species, boolean[] bits, int ix) {
 454         Objects.requireNonNull(bits);
 455         ix = VectorIntrinsics.checkIndex(ix, bits.length, species.length());
 456         return VectorIntrinsics.load((Class<Mask<Float>>) species.maskType(), int.class, species.length(),
 457                                      bits, (((long) ix) << ARRAY_SHIFT) + Unsafe.ARRAY_BOOLEAN_BASE_OFFSET,
 458                                      bits, ix, species,
 459                                      (c, idx, s) -> (Mask<Float>) ((FloatSpecies)s).opm(n -> c[idx + n]));
 460     }
 461 
 462     /**
 463      * Returns a mask where all lanes are a set.
 464      *
 465      * @param species mask species
 466      * @return a mask where all lanes are a set
 467      */
 468     @ForceInline
 469     @SuppressWarnings("unchecked")
 470     public static Mask<Float> maskAllTrue(FloatSpecies species) {
 471         return VectorIntrinsics.broadcastCoerced((Class<Mask<Float>>) species.maskType(), int.class, species.length(),
 472                                                  (int)-1,  species,
 473                                                  ((z, s) -> trueMask((FloatSpecies)s)));
 474     }
 475 
 476     /**
 477      * Returns a mask where all lanes are a unset.
 478      *
 479      * @param species mask species
 480      * @return a mask where all lanes are a unset
 481      */
 482     @ForceInline
 483     @SuppressWarnings("unchecked")
 484     public static Mask<Float> maskAllFalse(FloatSpecies species) {
 485         return VectorIntrinsics.broadcastCoerced((Class<Mask<Float>>) species.maskType(), int.class, species.length(),
 486                                                  0, species, 
 487                                                  ((z, s) -> falseMask((FloatSpecies)s)));
 488     }
 489 
 490     /**
 491      * Returns a shuffle of mapped indexes where each lane element is
 492      * the result of applying a mapping function to the corresponding lane
 493      * index.
 494      * <p>
 495      * Care should be taken to ensure Shuffle values produced from this
 496      * method are consumed as constants to ensure optimal generation of
 497      * code.  For example, values held in static final fields or values
 498      * held in loop constant local variables.
 499      * <p>
 500      * This method behaves as if a shuffle is created from an array of
 501      * mapped indexes as follows:
 502      * <pre>{@code
 503      *   int[] a = new int[species.length()];
 504      *   for (int i = 0; i < a.length; i++) {
 505      *       a[i] = f.applyAsInt(i);
 506      *   }
 507      *   return this.shuffleFromValues(a);
 508      * }</pre>
 509      *
 510      * @param species shuffle species
 511      * @param f the lane index mapping function
 512      * @return a shuffle of mapped indexes
 513      */
 514     @ForceInline
 515     public static Shuffle<Float> shuffle(FloatSpecies species, IntUnaryOperator f) {
 516         if (species.boxType() == FloatMaxVector.class)
 517             return new FloatMaxVector.FloatMaxShuffle(f);
 518         switch (species.bitSize()) {
 519             case 64: return new Float64Vector.Float64Shuffle(f);
 520             case 128: return new Float128Vector.Float128Shuffle(f);
 521             case 256: return new Float256Vector.Float256Shuffle(f);
 522             case 512: return new Float512Vector.Float512Shuffle(f);
 523             default: throw new IllegalArgumentException(Integer.toString(species.bitSize()));
 524         }
 525     }
 526 
 527     /**
 528      * Returns a shuffle where each lane element is the value of its
 529      * corresponding lane index.
 530      * <p>
 531      * This method behaves as if a shuffle is created from an identity
 532      * index mapping function as follows:
 533      * <pre>{@code
 534      *   return this.shuffle(i -> i);
 535      * }</pre>
 536      *
 537      * @param species shuffle species
 538      * @return a shuffle of lane indexes
 539      */
 540     @ForceInline
 541     public static Shuffle<Float> shuffleIota(FloatSpecies species) {
 542         if (species.boxType() == FloatMaxVector.class)
 543             return new FloatMaxVector.FloatMaxShuffle(AbstractShuffle.IDENTITY);
 544         switch (species.bitSize()) {
 545             case 64: return new Float64Vector.Float64Shuffle(AbstractShuffle.IDENTITY);
 546             case 128: return new Float128Vector.Float128Shuffle(AbstractShuffle.IDENTITY);
 547             case 256: return new Float256Vector.Float256Shuffle(AbstractShuffle.IDENTITY);
 548             case 512: return new Float512Vector.Float512Shuffle(AbstractShuffle.IDENTITY);
 549             default: throw new IllegalArgumentException(Integer.toString(species.bitSize()));
 550         }
 551     }
 552 
 553     /**
 554      * Returns a shuffle where each lane element is set to a given
 555      * {@code int} value logically AND'ed by the species length minus one.
 556      * <p>
 557      * For each shuffle lane, where {@code N} is the shuffle lane index, the
 558      * the {@code int} value at index {@code N} logically AND'ed by
 559      * {@code species.length() - 1} is placed into the resulting shuffle at
 560      * lane index {@code N}.
 561      *
 562      * @param species shuffle species
 563      * @param ixs the given {@code int} values
 564      * @return a shuffle where each lane element is set to a given
 565      * {@code int} value
 566      * @throws IndexOutOfBoundsException if the number of int values is
 567      * {@code < species.length()}
 568      */
 569     @ForceInline
 570     public static Shuffle<Float> shuffleFromValues(FloatSpecies species, int... ixs) {
 571         if (species.boxType() == FloatMaxVector.class)
 572             return new FloatMaxVector.FloatMaxShuffle(ixs);
 573         switch (species.bitSize()) {
 574             case 64: return new Float64Vector.Float64Shuffle(ixs);
 575             case 128: return new Float128Vector.Float128Shuffle(ixs);
 576             case 256: return new Float256Vector.Float256Shuffle(ixs);
 577             case 512: return new Float512Vector.Float512Shuffle(ixs);
 578             default: throw new IllegalArgumentException(Integer.toString(species.bitSize()));
 579         }
 580     }
 581 
 582     /**
 583      * Loads a shuffle from an {@code int} array starting at an offset.
 584      * <p>
 585      * For each shuffle lane, where {@code N} is the shuffle lane index, the
 586      * array element at index {@code i + N} logically AND'ed by
 587      * {@code species.length() - 1} is placed into the resulting shuffle at lane
 588      * index {@code N}.
 589      *
 590      * @param species shuffle species
 591      * @param ixs the {@code int} array
 592      * @param i the offset into the array
 593      * @return a shuffle loaded from the {@code int} array
 594      * @throws IndexOutOfBoundsException if {@code i < 0}, or
 595      * {@code i > a.length - species.length()}
 596      */
 597     @ForceInline
 598     public static Shuffle<Float> shuffleFromArray(FloatSpecies species, int[] ixs, int i) {
 599         if (species.boxType() == FloatMaxVector.class)
 600             return new FloatMaxVector.FloatMaxShuffle(ixs, i);
 601         switch (species.bitSize()) {
 602             case 64: return new Float64Vector.Float64Shuffle(ixs, i);
 603             case 128: return new Float128Vector.Float128Shuffle(ixs, i);
 604             case 256: return new Float256Vector.Float256Shuffle(ixs, i);
 605             case 512: return new Float512Vector.Float512Shuffle(ixs, i);
 606             default: throw new IllegalArgumentException(Integer.toString(species.bitSize()));
 607         }
 608     }
 609 
 610 
 611     // Ops
 612 
 613     @Override
 614     public abstract FloatVector add(Vector<Float> v);
 615 
 616     /**


1738      * @return square root of the sum of the squares of this vector and the
1739      * broadcast of an input scalar
1740      */
1741     public abstract FloatVector hypot(float s, Mask<Float> m);
1742 
1743 
1744     @Override
1745     public abstract void intoByteArray(byte[] a, int ix);
1746 
1747     @Override
1748     public abstract void intoByteArray(byte[] a, int ix, Mask<Float> m);
1749 
1750     @Override
1751     public abstract void intoByteBuffer(ByteBuffer bb, int ix);
1752 
1753     @Override
1754     public abstract void intoByteBuffer(ByteBuffer bb, int ix, Mask<Float> m);
1755 
1756 
1757     // Type specific horizontal reductions

1758     /**
1759      * Adds all lane elements of this vector.
1760      * <p>
1761      * This is a vector reduction operation where the addition
1762      * operation ({@code +}) is applied to lane elements,
1763      * and the identity value is {@code 0.0}.
1764      *
1765      * <p>The value of a floating-point sum is a function both of the input values as well
1766      * as the order of addition operations. The order of addition operations of this method
1767      * is intentionally not defined to allow for JVM to generate optimal machine
1768      * code for the underlying platform at runtime. If the platform supports a vector
1769      * instruction to add all values in the vector, or if there is some other efficient machine
1770      * code sequence, then the JVM has the option of generating this machine code. Otherwise,
1771      * the default implementation of adding vectors sequentially from left to right is used.
1772      * For this reason, the output of this method may vary for the same input values.
1773      *
1774      * @return the addition of all the lane elements of this vector
1775      */
1776     public abstract float addAll();
1777 
1778     /**
1779      * Adds all lane elements of this vector, selecting lane elements
1780      * controlled by a mask.
1781      * <p>
1782      * This is a vector reduction operation where the addition
1783      * operation ({@code +}) is applied to lane elements,
1784      * and the identity value is {@code 0.0}.












1785      *
1786      * <p>The value of a floating-point sum is a function both of the input values as well
1787      * as the order of addition operations. The order of addition operations of this method
1788      * is intentionally not defined to allow for JVM to generate optimal machine
1789      * code for the underlying platform at runtime. If the platform supports a vector
1790      * instruction to add all values in the vector, or if there is some other efficient machine
1791      * code sequence, then the JVM has the option of generating this machine code. Otherwise,
1792      * the default implementation of adding vectors sequentially from left to right is used.
1793      * For this reason, the output of this method may vary on the same input values.



1794      *
1795      * @param m the mask controlling lane selection
1796      * @return the addition of the selected lane elements of this vector
1797      */
1798     public abstract float addAll(Mask<Float> m);
1799 
1800     /**
1801      * Multiplies all lane elements of this vector.
1802      * <p>
1803      * This is a vector reduction operation where the
1804      * multiplication operation ({@code *}) is applied to lane elements,
1805      * and the identity value is {@code 1.0}.
1806      *
1807      * <p>The order of multiplication operations of this method
1808      * is intentionally not defined to allow for JVM to generate optimal machine
1809      * code for the underlying platform at runtime. If the platform supports a vector
1810      * instruction to multiply all values in the vector, or if there is some other efficient machine
1811      * code sequence, then the JVM has the option of generating this machine code. Otherwise,
1812      * the default implementation of multiplying vectors sequentially from left to right is used.
1813      * For this reason, the output of this method may vary on the same input values.
1814      *
1815      * @return the multiplication of all the lane elements of this vector
1816      */
1817     public abstract float mulAll();
1818 
1819     /**
1820      * Multiplies all lane elements of this vector, selecting lane elements
1821      * controlled by a mask.
1822      * <p>
1823      * This is a vector reduction operation where the
1824      * multiplication operation ({@code *}) is applied to lane elements,
1825      * and the identity value is {@code 1.0}.
1826      *
1827      * <p>The order of multiplication operations of this method
1828      * is intentionally not defined to allow for JVM to generate optimal machine
1829      * code for the underlying platform at runtime. If the platform supports a vector
1830      * instruction to multiply all values in the vector, or if there is some other efficient machine
1831      * code sequence, then the JVM has the option of generating this machine code. Otherwise,
1832      * the default implementation of multiplying vectors sequentially from left to right is used.
1833      * For this reason, the output of this method may vary on the same input values.
1834      *
1835      * @param m the mask controlling lane selection
1836      * @return the multiplication of all the lane elements of this vector
1837      */
1838     public abstract float mulAll(Mask<Float> m);
1839 
1840     /**
1841      * Returns the minimum lane element of this vector.
1842      * <p>
1843      * This is an associative vector reduction operation where the operation
1844      * {@code (a, b) -> Math.min(a, b)} is applied to lane elements,
1845      * and the identity value is
1846      * {@link Float#POSITIVE_INFINITY}.
1847      *
1848      * @return the minimum lane element of this vector
1849      */
1850     public abstract float minAll();
1851 
1852     /**
1853      * Returns the minimum lane element of this vector, selecting lane elements
1854      * controlled by a mask.
1855      * <p>
1856      * This is an associative vector reduction operation where the operation
1857      * {@code (a, b) -> Math.min(a, b)} is applied to lane elements,
1858      * and the identity value is
1859      * {@link Float#POSITIVE_INFINITY}.
1860      *
1861      * @param m the mask controlling lane selection
1862      * @return the minimum lane element of this vector
1863      */
1864     public abstract float minAll(Mask<Float> m);
1865 
1866     /**
1867      * Returns the maximum lane element of this vector.
1868      * <p>
1869      * This is an associative vector reduction operation where the operation
1870      * {@code (a, b) -> Math.max(a, b)} is applied to lane elements,
1871      * and the identity value is
1872      * {@link Float#NEGATIVE_INFINITY}.
1873      *
1874      * @return the maximum lane element of this vector
1875      */
1876     public abstract float maxAll();
1877 
1878     /**
1879      * Returns the maximum lane element of this vector, selecting lane elements
1880      * controlled by a mask.
1881      * <p>
1882      * This is an associative vector reduction operation where the operation
1883      * {@code (a, b) -> Math.max(a, b)} is applied to lane elements,
1884      * and the identity value is
1885      * {@link Float#NEGATIVE_INFINITY}.
1886      *
1887      * @param m the mask controlling lane selection
1888      * @return the maximum lane element of this vector
1889      */
1890     public abstract float maxAll(Mask<Float> m);
1891 
1892 
1893     // Type specific accessors
1894 
1895     /**
1896      * Gets the lane element at lane index {@code i}
1897      *
1898      * @param i the lane index
1899      * @return the lane element at lane index {@code i}
1900      * @throws IllegalArgumentException if the index is is out of range
1901      * ({@code < 0 || >= length()})
1902      */
1903     public abstract float get(int i);
1904 
1905     /**


2061 
2062         /**
2063          * Returns a vector where the first lane element is set to the primtive
2064          * value {@code e}, all other lane elements are set to the default
2065          * value.
2066          *
2067          * @param e the value
2068          * @return a vector where the first lane element is set to the primitive
2069          * value {@code e}
2070          */
2071         @ForceInline
2072         public final FloatVector single(float e) {
2073             return zero().with(0, e);
2074         }
2075 
2076         /**
2077          * Returns a vector where each lane element is set to a randomly
2078          * generated primitive value.
2079          *
2080          * The semantics are equivalent to calling
2081          * {@code ThreadLocalRandom#nextFloat}.
2082          *
2083          * @return a vector where each lane elements is set to a randomly
2084          * generated primitive value
2085          */
2086         public FloatVector random() {
2087             ThreadLocalRandom r = ThreadLocalRandom.current();
2088             return op(i -> r.nextFloat());
2089         }
2090 
2091         /**
2092          * Returns a vector where each lane element is set to a given
2093          * primitive value.
2094          * <p>
2095          * For each vector lane, where {@code N} is the vector lane index, the
2096          * the primitive value at index {@code N} is placed into the resulting
2097          * vector at lane index {@code N}.
2098          *
2099          * @param es the given primitive values
2100          * @return a vector where each lane element is set to a given primitive
2101          * value


< prev index next >