< prev index next >

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

Print this page
rev 55237 : javadoc changes


  88     }
  89 
  90     abstract Mask<Double> bTest(Vector<Double> v, FBinTest f);
  91 
  92     // Foreach
  93 
  94     interface FUnCon {
  95         void apply(int i, double a);
  96     }
  97 
  98     abstract void forEach(FUnCon f);
  99 
 100     abstract void forEach(Mask<Double> 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 DoubleVector zero(DoubleSpecies 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(DoubleSpecies, 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 DoubleVector fromByteArray(DoubleSpecies 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<DoubleVector>) species.boxType(), double.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                                          DoubleBuffer tb = bbc.asDoubleBuffer();
 146                                          return ((DoubleSpecies)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(DoubleSpecies, 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 DoubleVector fromByteArray(DoubleSpecies species, byte[] a, int ix, Mask<Double> 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 DoubleVector fromArray(DoubleSpecies species, double[] a, int i){
 197         Objects.requireNonNull(a);
 198         i = VectorIntrinsics.checkIndex(i, a.length, species.length());
 199         return VectorIntrinsics.load((Class<DoubleVector>) species.boxType(), double.class, species.length(),
 200                                      a, (((long) i) << ARRAY_SHIFT) + Unsafe.ARRAY_DOUBLE_BASE_OFFSET,
 201                                      a, i, species,
 202                                      (c, idx, s) -> ((DoubleSpecies)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 DoubleVector fromArray(DoubleSpecies species, double[] a, int i, Mask<Double> 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 DoubleVector fromArray(DoubleSpecies species, double[] a, int i, int[] indexMap, int j) {
 251         Objects.requireNonNull(a);
 252         Objects.requireNonNull(indexMap);
 253 
 254         if (species.length() == 1) {
 255           return DoubleVector.fromArray(species, a, i + indexMap[j]);


 258         // Index vector: vix[0:n] = k -> i + indexMap[j + i]
 259         IntVector vix = IntVector.fromArray(species.indexSpecies(), indexMap, j).add(i);
 260 
 261         vix = VectorIntrinsics.checkIndex(vix, a.length);
 262 
 263         return VectorIntrinsics.loadWithMap((Class<DoubleVector>) species.boxType(), double.class, species.length(),
 264                                             species.indexSpecies().vectorType(), a, Unsafe.ARRAY_DOUBLE_BASE_OFFSET, vix,
 265                                             a, i, indexMap, j, species,
 266                                            (c, idx, iMap, idy, s) -> ((DoubleSpecies)s).op(n -> c[idx + iMap[idy+n]]));
 267         }
 268 
 269     /**
 270      * Loads a vector from an array using indexes obtained from an index
 271      * map and using a mask.
 272      * <p>
 273      * For each vector lane, where {@code N} is the vector lane index,
 274      * if the mask lane at index {@code N} is set then the array element at
 275      * index {@code i + indexMap[j + N]} is placed into the resulting vector
 276      * at lane index {@code N}.
 277      *

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

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

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


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

 364      * @param bb the byte buffer
 365      * @param ix the offset into the byte buffer

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













 378     @ForceInline
 379     public static Mask<Double> maskFromValues(DoubleSpecies species, boolean... bits) {
 380         if (species.boxType() == DoubleMaxVector.class)
 381             return new DoubleMaxVector.DoubleMaxMask(bits);
 382         switch (species.bitSize()) {
 383             case 64: return new Double64Vector.Double64Mask(bits);
 384             case 128: return new Double128Vector.Double128Mask(bits);
 385             case 256: return new Double256Vector.Double256Mask(bits);
 386             case 512: return new Double512Vector.Double512Mask(bits);
 387             default: throw new IllegalArgumentException(Integer.toString(species.bitSize()));
 388         }
 389     }
 390 
 391     // @@@ This is a bad implementation -- makes lambdas capturing -- fix this
 392     static Mask<Double> trueMask(DoubleSpecies species) {
 393         if (species.boxType() == DoubleMaxVector.class)
 394             return DoubleMaxVector.DoubleMaxMask.TRUE_MASK;
 395         switch (species.bitSize()) {
 396             case 64: return Double64Vector.Double64Mask.TRUE_MASK;
 397             case 128: return Double128Vector.Double128Mask.TRUE_MASK;
 398             case 256: return Double256Vector.Double256Mask.TRUE_MASK;
 399             case 512: return Double512Vector.Double512Mask.TRUE_MASK;
 400             default: throw new IllegalArgumentException(Integer.toString(species.bitSize()));
 401         }
 402     }
 403 
 404     static Mask<Double> falseMask(DoubleSpecies species) {
 405         if (species.boxType() == DoubleMaxVector.class)
 406             return DoubleMaxVector.DoubleMaxMask.FALSE_MASK;
 407         switch (species.bitSize()) {
 408             case 64: return Double64Vector.Double64Mask.FALSE_MASK;
 409             case 128: return Double128Vector.Double128Mask.FALSE_MASK;
 410             case 256: return Double256Vector.Double256Mask.FALSE_MASK;
 411             case 512: return Double512Vector.Double512Mask.FALSE_MASK;
 412             default: throw new IllegalArgumentException(Integer.toString(species.bitSize()));
 413         }
 414     }
 415 














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






 427     @ForceInline
 428     @SuppressWarnings("unchecked")
 429     public static Mask<Double> maskAllTrue(DoubleSpecies species) {
 430         return VectorIntrinsics.broadcastCoerced((Class<Mask<Double>>) species.maskType(), long.class, species.length(),
 431                                                  (long)-1,  species,
 432                                                  ((z, s) -> trueMask((DoubleSpecies)s)));
 433     }
 434 






 435     @ForceInline
 436     @SuppressWarnings("unchecked")
 437     public static Mask<Double> maskAllFalse(DoubleSpecies species) {
 438         return VectorIntrinsics.broadcastCoerced((Class<Mask<Double>>) species.maskType(), long.class, species.length(),
 439                                                  0, species, 
 440                                                  ((z, s) -> falseMask((DoubleSpecies)s)));
 441     }
 442 
























 443     @ForceInline
 444     public static Shuffle<Double> shuffle(DoubleSpecies species, IntUnaryOperator f) {
 445         if (species.boxType() == DoubleMaxVector.class)
 446             return new DoubleMaxVector.DoubleMaxShuffle(f);
 447         switch (species.bitSize()) {
 448             case 64: return new Double64Vector.Double64Shuffle(f);
 449             case 128: return new Double128Vector.Double128Shuffle(f);
 450             case 256: return new Double256Vector.Double256Shuffle(f);
 451             case 512: return new Double512Vector.Double512Shuffle(f);
 452             default: throw new IllegalArgumentException(Integer.toString(species.bitSize()));
 453         }
 454     }
 455 













 456     @ForceInline
 457     public static Shuffle<Double> shuffleIota(DoubleSpecies species) {
 458         if (species.boxType() == DoubleMaxVector.class)
 459             return new DoubleMaxVector.DoubleMaxShuffle(AbstractShuffle.IDENTITY);
 460         switch (species.bitSize()) {
 461             case 64: return new Double64Vector.Double64Shuffle(AbstractShuffle.IDENTITY);
 462             case 128: return new Double128Vector.Double128Shuffle(AbstractShuffle.IDENTITY);
 463             case 256: return new Double256Vector.Double256Shuffle(AbstractShuffle.IDENTITY);
 464             case 512: return new Double512Vector.Double512Shuffle(AbstractShuffle.IDENTITY);
 465             default: throw new IllegalArgumentException(Integer.toString(species.bitSize()));
 466         }
 467     }
 468 
















 469     @ForceInline
 470     public static Shuffle<Double> shuffleFromValues(DoubleSpecies species, int... ixs) {
 471         if (species.boxType() == DoubleMaxVector.class)
 472             return new DoubleMaxVector.DoubleMaxShuffle(ixs);
 473         switch (species.bitSize()) {
 474             case 64: return new Double64Vector.Double64Shuffle(ixs);
 475             case 128: return new Double128Vector.Double128Shuffle(ixs);
 476             case 256: return new Double256Vector.Double256Shuffle(ixs);
 477             case 512: return new Double512Vector.Double512Shuffle(ixs);
 478             default: throw new IllegalArgumentException(Integer.toString(species.bitSize()));
 479         }
 480     }
 481 















 482     @ForceInline
 483     public static Shuffle<Double> shuffleFromArray(DoubleSpecies species, int[] ixs, int i) {
 484         if (species.boxType() == DoubleMaxVector.class)
 485             return new DoubleMaxVector.DoubleMaxShuffle(ixs, i);
 486         switch (species.bitSize()) {
 487             case 64: return new Double64Vector.Double64Shuffle(ixs, i);
 488             case 128: return new Double128Vector.Double128Shuffle(ixs, i);
 489             case 256: return new Double256Vector.Double256Shuffle(ixs, i);
 490             case 512: return new Double512Vector.Double512Shuffle(ixs, i);
 491             default: throw new IllegalArgumentException(Integer.toString(species.bitSize()));
 492         }
 493     }
 494 
 495 
 496     // Ops
 497 
 498     @Override
 499     public abstract DoubleVector add(Vector<Double> v);
 500 
 501     /**


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









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








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








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

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

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

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

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


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




  88     }
  89 
  90     abstract Mask<Double> bTest(Vector<Double> v, FBinTest f);
  91 
  92     // Foreach
  93 
  94     interface FUnCon {
  95         void apply(int i, double a);
  96     }
  97 
  98     abstract void forEach(FUnCon f);
  99 
 100     abstract void forEach(Mask<Double> 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 DoubleVector zero(DoubleSpecies 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(DoubleSpecies, 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 DoubleVector fromByteArray(DoubleSpecies 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<DoubleVector>) species.boxType(), double.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                                          DoubleBuffer tb = bbc.asDoubleBuffer();
 148                                          return ((DoubleSpecies)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(DoubleSpecies, 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 DoubleVector fromByteArray(DoubleSpecies species, byte[] a, int ix, Mask<Double> 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 DoubleVector fromArray(DoubleSpecies species, double[] a, int i){
 201         Objects.requireNonNull(a);
 202         i = VectorIntrinsics.checkIndex(i, a.length, species.length());
 203         return VectorIntrinsics.load((Class<DoubleVector>) species.boxType(), double.class, species.length(),
 204                                      a, (((long) i) << ARRAY_SHIFT) + Unsafe.ARRAY_DOUBLE_BASE_OFFSET,
 205                                      a, i, species,
 206                                      (c, idx, s) -> ((DoubleSpecies)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 DoubleVector fromArray(DoubleSpecies species, double[] a, int i, Mask<Double> 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 DoubleVector fromArray(DoubleSpecies species, double[] a, int i, int[] indexMap, int j) {
 257         Objects.requireNonNull(a);
 258         Objects.requireNonNull(indexMap);
 259 
 260         if (species.length() == 1) {
 261           return DoubleVector.fromArray(species, a, i + indexMap[j]);


 264         // Index vector: vix[0:n] = k -> i + indexMap[j + i]
 265         IntVector vix = IntVector.fromArray(species.indexSpecies(), indexMap, j).add(i);
 266 
 267         vix = VectorIntrinsics.checkIndex(vix, a.length);
 268 
 269         return VectorIntrinsics.loadWithMap((Class<DoubleVector>) species.boxType(), double.class, species.length(),
 270                                             species.indexSpecies().vectorType(), a, Unsafe.ARRAY_DOUBLE_BASE_OFFSET, vix,
 271                                             a, i, indexMap, j, species,
 272                                            (c, idx, iMap, idy, s) -> ((DoubleSpecies)s).op(n -> c[idx + iMap[idy+n]]));
 273         }
 274 
 275     /**
 276      * Loads a vector from an array using indexes obtained from an index
 277      * map and using a mask.
 278      * <p>
 279      * For each vector lane, where {@code N} is the vector lane index,
 280      * if the mask lane at index {@code N} is set then the array element at
 281      * index {@code i + indexMap[j + N]} is placed into the resulting vector
 282      * at lane index {@code N}.
 283      *
 284      * @param species species of desired vector
 285      * @param a the array
 286      * @param i the offset into the array, may be negative if relative
 287      * indexes in the index map compensate to produce a value within the
 288      * array bounds
 289      * @param m the mask
 290      * @param indexMap the index map
 291      * @param j the offset into the index map
 292      * @return the vector loaded from an array
 293      * @throws IndexOutOfBoundsException if {@code j < 0}, or
 294      * {@code j > indexMap.length - this.length()},
 295      * or for any vector lane index {@code N} where the mask at lane
 296      * {@code N} is set the result of {@code i + indexMap[j + N]} is
 297      * {@code < 0} or {@code >= a.length}
 298      */
 299     @ForceInline
 300     @SuppressWarnings("unchecked")
 301     public static DoubleVector fromArray(DoubleSpecies species, double[] a, int i, Mask<Double> m, int[] indexMap, int j) {
 302         // @@@ This can result in out of bounds errors for unset mask lanes
 303         return zero(species).blend(fromArray(species, a, i, indexMap, j), m);
 304     }
 305 
 306 
 307     /**
 308      * Loads a vector from a {@link ByteBuffer byte buffer} starting at an
 309      * offset into the byte buffer.
 310      * <p>
 311      * Bytes are composed into primitive lane elements according to the
 312      * native byte order of the underlying platform.
 313      * <p>
 314      * This method behaves as if it returns the result of calling the
 315      * byte buffer, offset, and mask accepting
 316      * {@link #fromByteBuffer(DoubleSpecies, ByteBuffer, int, Mask)} method} as follows:
 317      * <pre>{@code
 318      *   return this.fromByteBuffer(b, i, this.maskAllTrue())
 319      * }</pre>
 320      *
 321      * @param species species of desired vector
 322      * @param bb the byte buffer
 323      * @param ix the offset into the byte buffer
 324      * @return a vector loaded from a byte buffer
 325      * @throws IndexOutOfBoundsException if the offset is {@code < 0},
 326      * or {@code > b.limit()},
 327      * or if there are fewer than
 328      * {@code this.length() * this.elementSize() / Byte.SIZE} bytes
 329      * remaining in the byte buffer from the given offset
 330      */
 331     @ForceInline
 332     @SuppressWarnings("unchecked")
 333     public static DoubleVector fromByteBuffer(DoubleSpecies species, ByteBuffer bb, int ix) {
 334         if (bb.order() != ByteOrder.nativeOrder()) {
 335             throw new IllegalArgumentException();
 336         }
 337         ix = VectorIntrinsics.checkIndex(ix, bb.limit(), species.bitSize() / Byte.SIZE);
 338         return VectorIntrinsics.load((Class<DoubleVector>) species.boxType(), double.class, species.length(),
 339                                      U.getReference(bb, BYTE_BUFFER_HB), U.getLong(bb, BUFFER_ADDRESS) + ix,
 340                                      bb, ix, species,
 341                                      (c, idx, s) -> {


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


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

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












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



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


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


< prev index next >