< prev index next >

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

Print this page
rev 55237 : javadoc changes


  88     }
  89 
  90     abstract Mask<Long> bTest(Vector<Long> v, FBinTest f);
  91 
  92     // Foreach
  93 
  94     interface FUnCon {
  95         void apply(int i, long a);
  96     }
  97 
  98     abstract void forEach(FUnCon f);
  99 
 100     abstract void forEach(Mask<Long> 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 LongVector zero(LongSpecies 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(LongSpecies, 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 LongVector fromByteArray(LongSpecies 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<LongVector>) species.boxType(), long.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                                          LongBuffer tb = bbc.asLongBuffer();
 146                                          return ((LongSpecies)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(LongSpecies, 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 LongVector fromByteArray(LongSpecies species, byte[] a, int ix, Mask<Long> 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 LongVector fromArray(LongSpecies species, long[] a, int i){
 197         Objects.requireNonNull(a);
 198         i = VectorIntrinsics.checkIndex(i, a.length, species.length());
 199         return VectorIntrinsics.load((Class<LongVector>) species.boxType(), long.class, species.length(),
 200                                      a, (((long) i) << ARRAY_SHIFT) + Unsafe.ARRAY_LONG_BASE_OFFSET,
 201                                      a, i, species,
 202                                      (c, idx, s) -> ((LongSpecies)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 LongVector fromArray(LongSpecies species, long[] a, int i, Mask<Long> 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 LongVector fromArray(LongSpecies species, long[] a, int i, int[] indexMap, int j) {
 251         Objects.requireNonNull(a);
 252         Objects.requireNonNull(indexMap);
 253 
 254         if (species.length() == 1) {
 255           return LongVector.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<LongVector>) species.boxType(), long.class, species.length(),
 264                                             species.indexSpecies().vectorType(), a, Unsafe.ARRAY_LONG_BASE_OFFSET, vix,
 265                                             a, i, indexMap, j, species,
 266                                            (c, idx, iMap, idy, s) -> ((LongSpecies)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 LongVector fromArray(LongSpecies species, long[] a, int i, Mask<Long> 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(LongSpecies, 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 LongVector fromByteBuffer(LongSpecies 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<LongVector>) species.boxType(), long.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 LongVector fromByteBuffer(LongSpecies species, ByteBuffer bb, int ix, Mask<Long> m) {
 375         return zero(species).blend(fromByteBuffer(species, bb, ix), m);
 376     }
 377 













 378     @ForceInline
 379     public static Mask<Long> maskFromValues(LongSpecies species, boolean... bits) {
 380         if (species.boxType() == LongMaxVector.class)
 381             return new LongMaxVector.LongMaxMask(bits);
 382         switch (species.bitSize()) {
 383             case 64: return new Long64Vector.Long64Mask(bits);
 384             case 128: return new Long128Vector.Long128Mask(bits);
 385             case 256: return new Long256Vector.Long256Mask(bits);
 386             case 512: return new Long512Vector.Long512Mask(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<Long> trueMask(LongSpecies species) {
 393         if (species.boxType() == LongMaxVector.class)
 394             return LongMaxVector.LongMaxMask.TRUE_MASK;
 395         switch (species.bitSize()) {
 396             case 64: return Long64Vector.Long64Mask.TRUE_MASK;
 397             case 128: return Long128Vector.Long128Mask.TRUE_MASK;
 398             case 256: return Long256Vector.Long256Mask.TRUE_MASK;
 399             case 512: return Long512Vector.Long512Mask.TRUE_MASK;
 400             default: throw new IllegalArgumentException(Integer.toString(species.bitSize()));
 401         }
 402     }
 403 
 404     static Mask<Long> falseMask(LongSpecies species) {
 405         if (species.boxType() == LongMaxVector.class)
 406             return LongMaxVector.LongMaxMask.FALSE_MASK;
 407         switch (species.bitSize()) {
 408             case 64: return Long64Vector.Long64Mask.FALSE_MASK;
 409             case 128: return Long128Vector.Long128Mask.FALSE_MASK;
 410             case 256: return Long256Vector.Long256Mask.FALSE_MASK;
 411             case 512: return Long512Vector.Long512Mask.FALSE_MASK;
 412             default: throw new IllegalArgumentException(Integer.toString(species.bitSize()));
 413         }
 414     }
 415 














 416     @ForceInline
 417     @SuppressWarnings("unchecked")
 418     public static Mask<Long> maskFromArray(LongSpecies species, boolean[] bits, int ix) {
 419         Objects.requireNonNull(bits);
 420         ix = VectorIntrinsics.checkIndex(ix, bits.length, species.length());
 421         return VectorIntrinsics.load((Class<Mask<Long>>) 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<Long>) ((LongSpecies)s).opm(n -> c[idx + n]));
 425     }
 426 






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






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
























 443     @ForceInline
 444     public static Shuffle<Long> shuffle(LongSpecies species, IntUnaryOperator f) {
 445         if (species.boxType() == LongMaxVector.class)
 446             return new LongMaxVector.LongMaxShuffle(f);
 447         switch (species.bitSize()) {
 448             case 64: return new Long64Vector.Long64Shuffle(f);
 449             case 128: return new Long128Vector.Long128Shuffle(f);
 450             case 256: return new Long256Vector.Long256Shuffle(f);
 451             case 512: return new Long512Vector.Long512Shuffle(f);
 452             default: throw new IllegalArgumentException(Integer.toString(species.bitSize()));
 453         }
 454     }
 455 













 456     @ForceInline
 457     public static Shuffle<Long> shuffleIota(LongSpecies species) {
 458         if (species.boxType() == LongMaxVector.class)
 459             return new LongMaxVector.LongMaxShuffle(AbstractShuffle.IDENTITY);
 460         switch (species.bitSize()) {
 461             case 64: return new Long64Vector.Long64Shuffle(AbstractShuffle.IDENTITY);
 462             case 128: return new Long128Vector.Long128Shuffle(AbstractShuffle.IDENTITY);
 463             case 256: return new Long256Vector.Long256Shuffle(AbstractShuffle.IDENTITY);
 464             case 512: return new Long512Vector.Long512Shuffle(AbstractShuffle.IDENTITY);
 465             default: throw new IllegalArgumentException(Integer.toString(species.bitSize()));
 466         }
 467     }
 468 
















 469     @ForceInline
 470     public static Shuffle<Long> shuffleFromValues(LongSpecies species, int... ixs) {
 471         if (species.boxType() == LongMaxVector.class)
 472             return new LongMaxVector.LongMaxShuffle(ixs);
 473         switch (species.bitSize()) {
 474             case 64: return new Long64Vector.Long64Shuffle(ixs);
 475             case 128: return new Long128Vector.Long128Shuffle(ixs);
 476             case 256: return new Long256Vector.Long256Shuffle(ixs);
 477             case 512: return new Long512Vector.Long512Shuffle(ixs);
 478             default: throw new IllegalArgumentException(Integer.toString(species.bitSize()));
 479         }
 480     }
 481 















 482     @ForceInline
 483     public static Shuffle<Long> shuffleFromArray(LongSpecies species, int[] ixs, int i) {
 484         if (species.boxType() == LongMaxVector.class)
 485             return new LongMaxVector.LongMaxShuffle(ixs, i);
 486         switch (species.bitSize()) {
 487             case 64: return new Long64Vector.Long64Shuffle(ixs, i);
 488             case 128: return new Long128Vector.Long128Shuffle(ixs, i);
 489             case 256: return new Long256Vector.Long256Shuffle(ixs, i);
 490             case 512: return new Long512Vector.Long512Shuffle(ixs, i);
 491             default: throw new IllegalArgumentException(Integer.toString(species.bitSize()));
 492         }
 493     }
 494 
 495 
 496     // Ops
 497 
 498     @Override
 499     public abstract LongVector add(Vector<Long> v);
 500 
 501     /**


1004      * broadcast of an input scalar.
1005      * <p>
1006      * This is a vector binary operation where the primitive logical right shift
1007      * operation ({@code >>>}) is applied to lane elements.
1008      *
1009      * @param s the input scalar; the number of the bits to right shift
1010      * @return the result of logically right shifting this vector by the
1011      * broadcast of an input scalar
1012      */
1013     public abstract LongVector shiftR(int s);
1014 
1015     /**
1016      * Logically right shifts (or unsigned right shifts) this vector by the
1017      * broadcast of an input scalar, selecting lane elements controlled by a
1018      * mask.
1019      * <p>
1020      * This is a vector binary operation where the primitive logical right shift
1021      * operation ({@code >>>}) is applied to lane elements.
1022      *
1023      * @param s the input scalar; the number of the bits to right shift

1024      * @return the result of logically right shifting this vector by the
1025      * broadcast of an input scalar
1026      */
1027     public abstract LongVector shiftR(int s, Mask<Long> m);
1028 
1029     /**
1030      * Logically right shifts (or unsigned right shifts) this vector by an
1031      * input vector.
1032      * <p>
1033      * This is a vector binary operation where the primitive logical right shift
1034      * operation ({@code >>>}) is applied to lane elements.
1035      *
1036      * @param v the input vector
1037      * @return the result of logically right shifting this vector by the
1038      * input vector
1039      */
1040     public abstract LongVector shiftR(Vector<Long> v);
1041 
1042     /**
1043      * Logically right shifts (or unsigned right shifts) this vector by an


1185      */
1186     @ForceInline
1187     public final LongVector rotateR(int s, Mask<Long> m) {
1188         return shiftR(s, m).or(shiftL(-s, m), m);
1189     }
1190 
1191     @Override
1192     public abstract void intoByteArray(byte[] a, int ix);
1193 
1194     @Override
1195     public abstract void intoByteArray(byte[] a, int ix, Mask<Long> m);
1196 
1197     @Override
1198     public abstract void intoByteBuffer(ByteBuffer bb, int ix);
1199 
1200     @Override
1201     public abstract void intoByteBuffer(ByteBuffer bb, int ix, Mask<Long> m);
1202 
1203 
1204     // Type specific horizontal reductions
1205 
1206     /**
1207      * Adds all lane elements of this vector.
1208      * <p>
1209      * This is an associative vector reduction operation where the addition
1210      * operation ({@code +}) is applied to lane elements,
1211      * and the identity value is {@code 0}.
1212      *
1213      * @return the addition of all the lane elements of this vector
1214      */
1215     public abstract long addAll();
1216 
1217     /**
1218      * Adds all lane elements of this vector, selecting lane elements
1219      * controlled by a mask.
1220      * <p>
1221      * This is an associative vector reduction operation where the addition
1222      * operation ({@code +}) is applied to lane elements,
1223      * and the identity value is {@code 0}.
1224      *
1225      * @param m the mask controlling lane selection
1226      * @return the addition of all the lane elements of this vector
1227      */
1228     public abstract long addAll(Mask<Long> m);
1229 
1230     /**
1231      * Subtracts all lane elements of this vector.
1232      * <p>
1233      * This is an associative vector reduction operation where the subtraction
1234      * operation ({@code -}) is applied to lane elements,
1235      * and the identity value is {@code 0}.
1236      *
1237      * @return the subtraction of all the lane elements of this vector
1238      */
1239     public abstract long subAll();
1240 
1241     /**
1242      * Subtracts all lane elements of this vector, selecting lane elements
1243      * controlled by a mask.
1244      * <p>
1245      * This is an associative vector reduction operation where the subtraction
1246      * operation ({@code -}) is applied to lane elements,
1247      * and the identity value is {@code 0}.
1248      *
1249      * @param m the mask controlling lane selection
1250      * @return the subtraction of all the lane elements of this vector
1251      */
1252     public abstract long subAll(Mask<Long> m);
1253 
1254     /**
1255      * Multiplies all lane elements of this vector.
1256      * <p>
1257      * This is an associative vector reduction operation where the
1258      * multiplication operation ({@code *}) is applied to lane elements,
1259      * and the identity value is {@code 1}.
1260      *
1261      * @return the multiplication of all the lane elements of this vector
1262      */
1263     public abstract long mulAll();
1264 
1265     /**
1266      * Multiplies all lane elements of this vector, selecting lane elements
1267      * controlled by a mask.
1268      * <p>
1269      * This is an associative vector reduction operation where the
1270      * multiplication operation ({@code *}) is applied to lane elements,
1271      * and the identity value is {@code 1}.
1272      *
1273      * @param m the mask controlling lane selection
1274      * @return the multiplication of all the lane elements of this vector
1275      */
1276     public abstract long mulAll(Mask<Long> m);
1277 
1278     /**
1279      * Returns the minimum lane element of this vector.
1280      * <p>
1281      * This is an associative vector reduction operation where the operation
1282      * {@code (a, b) -> Math.min(a, b)} is applied to lane elements,
1283      * and the identity value is {@link Long#MAX_VALUE}.

1284      *
1285      * @return the minimum lane element of this vector
1286      */
1287     public abstract long minAll();
1288 
1289     /**
1290      * Returns the minimum lane element of this vector, selecting lane elements
1291      * controlled by a mask.
1292      * <p>
1293      * This is an associative vector reduction operation where the operation
1294      * {@code (a, b) -> Math.min(a, b)} is applied to lane elements,
1295      * and the identity value is {@link Long#MAX_VALUE}.

1296      *
1297      * @param m the mask controlling lane selection
1298      * @return the minimum lane element of this vector
1299      */
1300     public abstract long minAll(Mask<Long> m);
1301 
1302     /**
1303      * Returns the maximum lane element of this vector.
1304      * <p>
1305      * This is an associative vector reduction operation where the operation
1306      * {@code (a, b) -> Math.max(a, b)} is applied to lane elements,
1307      * and the identity value is {@link Long#MIN_VALUE}.

1308      *
1309      * @return the maximum lane element of this vector
1310      */
1311     public abstract long maxAll();
1312 
1313     /**
1314      * Returns the maximum lane element of this vector, selecting lane elements
1315      * controlled by a mask.
1316      * <p>
1317      * This is an associative vector reduction operation where the operation
1318      * {@code (a, b) -> Math.max(a, b)} is applied to lane elements,
1319      * and the identity value is {@link Long#MIN_VALUE}.

1320      *
1321      * @param m the mask controlling lane selection
1322      * @return the maximum lane element of this vector
1323      */
1324     public abstract long maxAll(Mask<Long> m);
1325 
1326     /**
1327      * Logically ORs all lane elements of this vector.
1328      * <p>
1329      * This is an associative vector reduction operation where the logical OR
1330      * operation ({@code |}) is applied to lane elements,
1331      * and the identity value is {@code 0}.
1332      *
1333      * @return the logical OR all the lane elements of this vector
1334      */
1335     public abstract long orAll();
1336 
1337     /**
1338      * Logically ORs all lane elements of this vector, selecting lane elements
1339      * controlled by a mask.


1566 
1567         /**
1568          * Returns a vector where the first lane element is set to the primtive
1569          * value {@code e}, all other lane elements are set to the default
1570          * value.
1571          *
1572          * @param e the value
1573          * @return a vector where the first lane element is set to the primitive
1574          * value {@code e}
1575          */
1576         @ForceInline
1577         public final LongVector single(long e) {
1578             return zero().with(0, e);
1579         }
1580 
1581         /**
1582          * Returns a vector where each lane element is set to a randomly
1583          * generated primitive value.
1584          *
1585          * The semantics are equivalent to calling
1586          * {@link (long)ThreadLocalRandom#nextInt() }
1587          *
1588          * @return a vector where each lane elements is set to a randomly
1589          * generated primitive value
1590          */
1591         public LongVector random() {
1592             ThreadLocalRandom r = ThreadLocalRandom.current();
1593             return op(i -> r.nextLong());
1594         }
1595 
1596         /**
1597          * Returns a vector where each lane element is set to a given
1598          * primitive value.
1599          * <p>
1600          * For each vector lane, where {@code N} is the vector lane index, the
1601          * the primitive value at index {@code N} is placed into the resulting
1602          * vector at lane index {@code N}.
1603          *
1604          * @param es the given primitive values
1605          * @return a vector where each lane element is set to a given primitive
1606          * value




  88     }
  89 
  90     abstract Mask<Long> bTest(Vector<Long> v, FBinTest f);
  91 
  92     // Foreach
  93 
  94     interface FUnCon {
  95         void apply(int i, long a);
  96     }
  97 
  98     abstract void forEach(FUnCon f);
  99 
 100     abstract void forEach(Mask<Long> 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 LongVector zero(LongSpecies 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(LongSpecies, 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 LongVector fromByteArray(LongSpecies 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<LongVector>) species.boxType(), long.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                                          LongBuffer tb = bbc.asLongBuffer();
 148                                          return ((LongSpecies)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(LongSpecies, 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 LongVector fromByteArray(LongSpecies species, byte[] a, int ix, Mask<Long> 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 LongVector fromArray(LongSpecies species, long[] a, int i){
 201         Objects.requireNonNull(a);
 202         i = VectorIntrinsics.checkIndex(i, a.length, species.length());
 203         return VectorIntrinsics.load((Class<LongVector>) species.boxType(), long.class, species.length(),
 204                                      a, (((long) i) << ARRAY_SHIFT) + Unsafe.ARRAY_LONG_BASE_OFFSET,
 205                                      a, i, species,
 206                                      (c, idx, s) -> ((LongSpecies)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 LongVector fromArray(LongSpecies species, long[] a, int i, Mask<Long> 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 LongVector fromArray(LongSpecies species, long[] a, int i, int[] indexMap, int j) {
 257         Objects.requireNonNull(a);
 258         Objects.requireNonNull(indexMap);
 259 
 260         if (species.length() == 1) {
 261           return LongVector.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<LongVector>) species.boxType(), long.class, species.length(),
 270                                             species.indexSpecies().vectorType(), a, Unsafe.ARRAY_LONG_BASE_OFFSET, vix,
 271                                             a, i, indexMap, j, species,
 272                                            (c, idx, iMap, idy, s) -> ((LongSpecies)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 LongVector fromArray(LongSpecies species, long[] a, int i, Mask<Long> 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(LongSpecies, 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 LongVector fromByteBuffer(LongSpecies 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<LongVector>) species.boxType(), long.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 LongVector fromByteBuffer(LongSpecies species, ByteBuffer bb, int ix, Mask<Long> 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<Long> maskFromValues(LongSpecies species, boolean... bits) {
 404         if (species.boxType() == LongMaxVector.class)
 405             return new LongMaxVector.LongMaxMask(bits);
 406         switch (species.bitSize()) {
 407             case 64: return new Long64Vector.Long64Mask(bits);
 408             case 128: return new Long128Vector.Long128Mask(bits);
 409             case 256: return new Long256Vector.Long256Mask(bits);
 410             case 512: return new Long512Vector.Long512Mask(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<Long> trueMask(LongSpecies species) {
 417         if (species.boxType() == LongMaxVector.class)
 418             return LongMaxVector.LongMaxMask.TRUE_MASK;
 419         switch (species.bitSize()) {
 420             case 64: return Long64Vector.Long64Mask.TRUE_MASK;
 421             case 128: return Long128Vector.Long128Mask.TRUE_MASK;
 422             case 256: return Long256Vector.Long256Mask.TRUE_MASK;
 423             case 512: return Long512Vector.Long512Mask.TRUE_MASK;
 424             default: throw new IllegalArgumentException(Integer.toString(species.bitSize()));
 425         }
 426     }
 427 
 428     static Mask<Long> falseMask(LongSpecies species) {
 429         if (species.boxType() == LongMaxVector.class)
 430             return LongMaxVector.LongMaxMask.FALSE_MASK;
 431         switch (species.bitSize()) {
 432             case 64: return Long64Vector.Long64Mask.FALSE_MASK;
 433             case 128: return Long128Vector.Long128Mask.FALSE_MASK;
 434             case 256: return Long256Vector.Long256Mask.FALSE_MASK;
 435             case 512: return Long512Vector.Long512Mask.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<Long> maskFromArray(LongSpecies species, boolean[] bits, int ix) {
 457         Objects.requireNonNull(bits);
 458         ix = VectorIntrinsics.checkIndex(ix, bits.length, species.length());
 459         return VectorIntrinsics.load((Class<Mask<Long>>) 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<Long>) ((LongSpecies)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<Long> maskAllTrue(LongSpecies species) {
 474         return VectorIntrinsics.broadcastCoerced((Class<Mask<Long>>) species.maskType(), long.class, species.length(),
 475                                                  (long)-1,  species,
 476                                                  ((z, s) -> trueMask((LongSpecies)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<Long> maskAllFalse(LongSpecies species) {
 488         return VectorIntrinsics.broadcastCoerced((Class<Mask<Long>>) species.maskType(), long.class, species.length(),
 489                                                  0, species, 
 490                                                  ((z, s) -> falseMask((LongSpecies)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<Long> shuffle(LongSpecies species, IntUnaryOperator f) {
 519         if (species.boxType() == LongMaxVector.class)
 520             return new LongMaxVector.LongMaxShuffle(f);
 521         switch (species.bitSize()) {
 522             case 64: return new Long64Vector.Long64Shuffle(f);
 523             case 128: return new Long128Vector.Long128Shuffle(f);
 524             case 256: return new Long256Vector.Long256Shuffle(f);
 525             case 512: return new Long512Vector.Long512Shuffle(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<Long> shuffleIota(LongSpecies species) {
 545         if (species.boxType() == LongMaxVector.class)
 546             return new LongMaxVector.LongMaxShuffle(AbstractShuffle.IDENTITY);
 547         switch (species.bitSize()) {
 548             case 64: return new Long64Vector.Long64Shuffle(AbstractShuffle.IDENTITY);
 549             case 128: return new Long128Vector.Long128Shuffle(AbstractShuffle.IDENTITY);
 550             case 256: return new Long256Vector.Long256Shuffle(AbstractShuffle.IDENTITY);
 551             case 512: return new Long512Vector.Long512Shuffle(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<Long> shuffleFromValues(LongSpecies species, int... ixs) {
 574         if (species.boxType() == LongMaxVector.class)
 575             return new LongMaxVector.LongMaxShuffle(ixs);
 576         switch (species.bitSize()) {
 577             case 64: return new Long64Vector.Long64Shuffle(ixs);
 578             case 128: return new Long128Vector.Long128Shuffle(ixs);
 579             case 256: return new Long256Vector.Long256Shuffle(ixs);
 580             case 512: return new Long512Vector.Long512Shuffle(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<Long> shuffleFromArray(LongSpecies species, int[] ixs, int i) {
 602         if (species.boxType() == LongMaxVector.class)
 603             return new LongMaxVector.LongMaxShuffle(ixs, i);
 604         switch (species.bitSize()) {
 605             case 64: return new Long64Vector.Long64Shuffle(ixs, i);
 606             case 128: return new Long128Vector.Long128Shuffle(ixs, i);
 607             case 256: return new Long256Vector.Long256Shuffle(ixs, i);
 608             case 512: return new Long512Vector.Long512Shuffle(ixs, i);
 609             default: throw new IllegalArgumentException(Integer.toString(species.bitSize()));
 610         }
 611     }
 612 
 613 
 614     // Ops
 615 
 616     @Override
 617     public abstract LongVector add(Vector<Long> v);
 618 
 619     /**


1122      * broadcast of an input scalar.
1123      * <p>
1124      * This is a vector binary operation where the primitive logical right shift
1125      * operation ({@code >>>}) is applied to lane elements.
1126      *
1127      * @param s the input scalar; the number of the bits to right shift
1128      * @return the result of logically right shifting this vector by the
1129      * broadcast of an input scalar
1130      */
1131     public abstract LongVector shiftR(int s);
1132 
1133     /**
1134      * Logically right shifts (or unsigned right shifts) this vector by the
1135      * broadcast of an input scalar, selecting lane elements controlled by a
1136      * mask.
1137      * <p>
1138      * This is a vector binary operation where the primitive logical right shift
1139      * operation ({@code >>>}) is applied to lane elements.
1140      *
1141      * @param s the input scalar; the number of the bits to right shift
1142      * @param m the mask controlling lane selection
1143      * @return the result of logically right shifting this vector by the
1144      * broadcast of an input scalar
1145      */
1146     public abstract LongVector shiftR(int s, Mask<Long> m);
1147 
1148     /**
1149      * Logically right shifts (or unsigned right shifts) this vector by an
1150      * input vector.
1151      * <p>
1152      * This is a vector binary operation where the primitive logical right shift
1153      * operation ({@code >>>}) is applied to lane elements.
1154      *
1155      * @param v the input vector
1156      * @return the result of logically right shifting this vector by the
1157      * input vector
1158      */
1159     public abstract LongVector shiftR(Vector<Long> v);
1160 
1161     /**
1162      * Logically right shifts (or unsigned right shifts) this vector by an


1304      */
1305     @ForceInline
1306     public final LongVector rotateR(int s, Mask<Long> m) {
1307         return shiftR(s, m).or(shiftL(-s, m), m);
1308     }
1309 
1310     @Override
1311     public abstract void intoByteArray(byte[] a, int ix);
1312 
1313     @Override
1314     public abstract void intoByteArray(byte[] a, int ix, Mask<Long> m);
1315 
1316     @Override
1317     public abstract void intoByteBuffer(ByteBuffer bb, int ix);
1318 
1319     @Override
1320     public abstract void intoByteBuffer(ByteBuffer bb, int ix, Mask<Long> m);
1321 
1322 
1323     // Type specific horizontal reductions

1324     /**
1325      * Adds all lane elements of this vector.
1326      * <p>
1327      * This is an associative vector reduction operation where the addition
1328      * operation ({@code +}) is applied to lane elements,
1329      * and the identity value is {@code 0}.
1330      *
1331      * @return the addition of all the lane elements of this vector
1332      */
1333     public abstract long addAll();
1334 
1335     /**
1336      * Adds all lane elements of this vector, selecting lane elements
1337      * controlled by a mask.
1338      * <p>
1339      * This is an associative vector reduction operation where the addition
1340      * operation ({@code +}) is applied to lane elements,
1341      * and the identity value is {@code 0}.
1342      *
1343      * @param m the mask controlling lane selection
1344      * @return the addition of the selected lane elements of this vector
1345      */
1346     public abstract long addAll(Mask<Long> m);
1347 
1348     /**
























1349      * Multiplies all lane elements of this vector.
1350      * <p>
1351      * This is an associative vector reduction operation where the
1352      * multiplication operation ({@code *}) is applied to lane elements,
1353      * and the identity value is {@code 1}.
1354      *
1355      * @return the multiplication of all the lane elements of this vector
1356      */
1357     public abstract long mulAll();
1358 
1359     /**
1360      * Multiplies all lane elements of this vector, selecting lane elements
1361      * controlled by a mask.
1362      * <p>
1363      * This is an associative vector reduction operation where the
1364      * multiplication operation ({@code *}) is applied to lane elements,
1365      * and the identity value is {@code 1}.
1366      *
1367      * @param m the mask controlling lane selection
1368      * @return the multiplication of all the lane elements of this vector
1369      */
1370     public abstract long mulAll(Mask<Long> m);
1371 
1372     /**
1373      * Returns the minimum lane element of this vector.
1374      * <p>
1375      * This is an associative vector reduction operation where the operation
1376      * {@code (a, b) -> Math.min(a, b)} is applied to lane elements,
1377      * and the identity value is
1378      * {@link Long#MAX_VALUE}.
1379      *
1380      * @return the minimum lane element of this vector
1381      */
1382     public abstract long minAll();
1383 
1384     /**
1385      * Returns the minimum lane element of this vector, selecting lane elements
1386      * controlled by a mask.
1387      * <p>
1388      * This is an associative vector reduction operation where the operation
1389      * {@code (a, b) -> Math.min(a, b)} is applied to lane elements,
1390      * and the identity value is
1391      * {@link Long#MAX_VALUE}.
1392      *
1393      * @param m the mask controlling lane selection
1394      * @return the minimum lane element of this vector
1395      */
1396     public abstract long minAll(Mask<Long> m);
1397 
1398     /**
1399      * Returns the maximum lane element of this vector.
1400      * <p>
1401      * This is an associative vector reduction operation where the operation
1402      * {@code (a, b) -> Math.max(a, b)} is applied to lane elements,
1403      * and the identity value is
1404      * {@link Long#MIN_VALUE}.
1405      *
1406      * @return the maximum lane element of this vector
1407      */
1408     public abstract long maxAll();
1409 
1410     /**
1411      * Returns the maximum lane element of this vector, selecting lane elements
1412      * controlled by a mask.
1413      * <p>
1414      * This is an associative vector reduction operation where the operation
1415      * {@code (a, b) -> Math.max(a, b)} is applied to lane elements,
1416      * and the identity value is
1417      * {@link Long#MIN_VALUE}.
1418      *
1419      * @param m the mask controlling lane selection
1420      * @return the maximum lane element of this vector
1421      */
1422     public abstract long maxAll(Mask<Long> m);
1423 
1424     /**
1425      * Logically ORs all lane elements of this vector.
1426      * <p>
1427      * This is an associative vector reduction operation where the logical OR
1428      * operation ({@code |}) is applied to lane elements,
1429      * and the identity value is {@code 0}.
1430      *
1431      * @return the logical OR all the lane elements of this vector
1432      */
1433     public abstract long orAll();
1434 
1435     /**
1436      * Logically ORs all lane elements of this vector, selecting lane elements
1437      * controlled by a mask.


1664 
1665         /**
1666          * Returns a vector where the first lane element is set to the primtive
1667          * value {@code e}, all other lane elements are set to the default
1668          * value.
1669          *
1670          * @param e the value
1671          * @return a vector where the first lane element is set to the primitive
1672          * value {@code e}
1673          */
1674         @ForceInline
1675         public final LongVector single(long e) {
1676             return zero().with(0, e);
1677         }
1678 
1679         /**
1680          * Returns a vector where each lane element is set to a randomly
1681          * generated primitive value.
1682          *
1683          * The semantics are equivalent to calling
1684          * {@code (long)ThreadLocalRandom#nextInt()}.
1685          *
1686          * @return a vector where each lane elements is set to a randomly
1687          * generated primitive value
1688          */
1689         public LongVector random() {
1690             ThreadLocalRandom r = ThreadLocalRandom.current();
1691             return op(i -> r.nextLong());
1692         }
1693 
1694         /**
1695          * Returns a vector where each lane element is set to a given
1696          * primitive value.
1697          * <p>
1698          * For each vector lane, where {@code N} is the vector lane index, the
1699          * the primitive value at index {@code N} is placed into the resulting
1700          * vector at lane index {@code N}.
1701          *
1702          * @param es the given primitive values
1703          * @return a vector where each lane element is set to a given primitive
1704          * value


< prev index next >