< prev index next >

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

Print this page
rev 55885 : 8222752: [vector] Javadoc changes for Vector api
Summary: Javadoc changes for Vector api
Reviewed-by: jrose, briangoetz, vlivanov, sviswanathan


 108      *
 109      * @param species species of desired vector
 110      * @return a zero vector of given species
 111      */
 112     @ForceInline
 113     @SuppressWarnings("unchecked")
 114     public static IntVector zero(VectorSpecies<Integer> species) {
 115         return VectorIntrinsics.broadcastCoerced((Class<IntVector>) species.boxType(), int.class, species.length(),
 116                                                  0, species,
 117                                                  ((bits, s) -> ((IntSpecies)s).op(i -> (int)bits)));
 118     }
 119 
 120     /**
 121      * Loads a vector from a byte array starting at an offset.
 122      * <p>
 123      * Bytes are composed into primitive lane elements according to the
 124      * native byte order of the underlying platform
 125      * <p>
 126      * This method behaves as if it returns the result of calling the
 127      * byte buffer, offset, and mask accepting
 128      * {@link #fromByteBuffer(VectorSpecies<Integer>, ByteBuffer, int, VectorMask) method} as follows:
 129      * <pre>{@code
 130      * return this.fromByteBuffer(ByteBuffer.wrap(a), i, this.maskAllTrue());
 131      * }</pre>
 132      *
 133      * @param species species of desired vector
 134      * @param a the byte array
 135      * @param ix the offset into the array
 136      * @return a vector loaded from a byte array
 137      * @throws IndexOutOfBoundsException if {@code i < 0} or
 138      * {@code i > a.length - (this.length() * this.elementSize() / Byte.SIZE)}
 139      */
 140     @ForceInline
 141     @SuppressWarnings("unchecked")
 142     public static IntVector fromByteArray(VectorSpecies<Integer> species, byte[] a, int ix) {
 143         Objects.requireNonNull(a);
 144         ix = VectorIntrinsics.checkIndex(ix, a.length, species.bitSize() / Byte.SIZE);
 145         return VectorIntrinsics.load((Class<IntVector>) species.boxType(), int.class, species.length(),
 146                                      a, ((long) ix) + Unsafe.ARRAY_BYTE_BASE_OFFSET,
 147                                      a, ix, species,
 148                                      (c, idx, s) -> {
 149                                          ByteBuffer bbc = ByteBuffer.wrap(c, idx, a.length - idx).order(ByteOrder.nativeOrder());
 150                                          IntBuffer tb = bbc.asIntBuffer();
 151                                          return ((IntSpecies)s).op(i -> tb.get());
 152                                      });
 153     }
 154 
 155     /**
 156      * Loads a vector from a byte array starting at an offset and using a
 157      * mask.
 158      * <p>
 159      * Bytes are composed into primitive lane elements according to the
 160      * native byte order of the underlying platform.
 161      * <p>
 162      * This method behaves as if it returns the result of calling the
 163      * byte buffer, offset, and mask accepting
 164      * {@link #fromByteBuffer(VectorSpecies<Integer>, ByteBuffer, int, VectorMask) method} as follows:
 165      * <pre>{@code
 166      * return this.fromByteBuffer(ByteBuffer.wrap(a), i, m);
 167      * }</pre>
 168      *
 169      * @param species species of desired vector
 170      * @param a the byte array
 171      * @param ix the offset into the array
 172      * @param m the mask
 173      * @return a vector loaded from a byte array
 174      * @throws IndexOutOfBoundsException if {@code i < 0} or
 175      * {@code i > a.length - (this.length() * this.elementSize() / Byte.SIZE)}
 176      * @throws IndexOutOfBoundsException if the offset is {@code < 0},
 177      * or {@code > a.length},
 178      * for any vector lane index {@code N} where the mask at lane {@code N}
 179      * is set
 180      * {@code i >= a.length - (N * this.elementSize() / Byte.SIZE)}
 181      */
 182     @ForceInline
 183     public static IntVector fromByteArray(VectorSpecies<Integer> species, byte[] a, int ix, VectorMask<Integer> m) {
 184         return zero(species).blend(fromByteArray(species, a, ix), m);
 185     }
 186 
 187     /**
 188      * Loads a vector from an array starting at offset.
 189      * <p>
 190      * For each vector lane, where {@code N} is the vector lane index, the
 191      * array element at index {@code i + N} is placed into the
 192      * resulting vector at lane index {@code N}.
 193      *
 194      * @param species species of desired vector
 195      * @param a the array
 196      * @param i the offset into the array
 197      * @return the vector loaded from an array
 198      * @throws IndexOutOfBoundsException if {@code i < 0}, or
 199      * {@code i > a.length - this.length()}
 200      */
 201     @ForceInline
 202     @SuppressWarnings("unchecked")
 203     public static IntVector fromArray(VectorSpecies<Integer> species, int[] a, int i){
 204         Objects.requireNonNull(a);
 205         i = VectorIntrinsics.checkIndex(i, a.length, species.length());
 206         return VectorIntrinsics.load((Class<IntVector>) species.boxType(), int.class, species.length(),
 207                                      a, (((long) i) << ARRAY_SHIFT) + Unsafe.ARRAY_INT_BASE_OFFSET,
 208                                      a, i, species,
 209                                      (c, idx, s) -> ((IntSpecies)s).op(n -> c[idx + n]));
 210     }
 211 
 212 
 213     /**
 214      * Loads a vector from an array starting at offset and using a mask.
 215      * <p>
 216      * For each vector lane, where {@code N} is the vector lane index,
 217      * if the mask lane at index {@code N} is set then the array element at
 218      * index {@code i + N} is placed into the resulting vector at lane index
 219      * {@code N}, otherwise the default element value is placed into the
 220      * resulting vector at lane index {@code N}.
 221      *
 222      * @param species species of desired vector
 223      * @param a the array
 224      * @param i the offset into the array
 225      * @param m the mask
 226      * @return the vector loaded from an array
 227      * @throws IndexOutOfBoundsException if {@code i < 0}, or
 228      * for any vector lane index {@code N} where the mask at lane {@code N}
 229      * is set {@code i > a.length - N}
 230      */
 231     @ForceInline
 232     public static IntVector fromArray(VectorSpecies<Integer> species, int[] a, int i, VectorMask<Integer> m) {
 233         return zero(species).blend(fromArray(species, a, i), m);
 234     }
 235 
 236     /**
 237      * Loads a vector from an array using indexes obtained from an index
 238      * map.
 239      * <p>
 240      * For each vector lane, where {@code N} is the vector lane index, the
 241      * array element at index {@code i + indexMap[j + N]} is placed into the
 242      * resulting vector at lane index {@code N}.
 243      *
 244      * @param species species of desired vector
 245      * @param a the array
 246      * @param i the offset into the array, may be negative if relative
 247      * indexes in the index map compensate to produce a value within the
 248      * array bounds
 249      * @param indexMap the index map
 250      * @param j the offset into the index map
 251      * @return the vector loaded from an array
 252      * @throws IndexOutOfBoundsException if {@code j < 0}, or
 253      * {@code j > indexMap.length - this.length()},
 254      * or for any vector lane index {@code N} the result of
 255      * {@code i + indexMap[j + N]} is {@code < 0} or {@code >= a.length}
 256      */
 257     @ForceInline
 258     @SuppressWarnings("unchecked")
 259     public static IntVector fromArray(VectorSpecies<Integer> species, int[] a, int i, int[] indexMap, int j) {
 260         Objects.requireNonNull(a);
 261         Objects.requireNonNull(indexMap);
 262 
 263 
 264         // Index vector: vix[0:n] = k -> i + indexMap[j + k]
 265         IntVector vix = IntVector.fromArray(IntVector.species(species.indexShape()), indexMap, j).add(i);
 266 
 267         vix = VectorIntrinsics.checkIndex(vix, a.length);
 268 
 269         return VectorIntrinsics.loadWithMap((Class<IntVector>) species.boxType(), int.class, species.length(),
 270                                             IntVector.species(species.indexShape()).boxType(), a, Unsafe.ARRAY_INT_BASE_OFFSET, vix,
 271                                             a, i, indexMap, j, species,
 272                                             (int[] c, int idx, int[] iMap, int idy, VectorSpecies<Integer> s) ->
 273                                                 ((IntSpecies)s).op(n -> c[idx + iMap[idy+n]]));
 274         }
 275 
 276     /**
 277      * Loads a vector from an array using indexes obtained from an index
 278      * map and using a mask.
 279      * <p>
 280      * For each vector lane, where {@code N} is the vector lane index,
 281      * if the mask lane at index {@code N} is set then the array element at
 282      * index {@code i + indexMap[j + N]} is placed into the resulting vector
 283      * at lane index {@code N}.
 284      *
 285      * @param species species of desired vector
 286      * @param a the array
 287      * @param i the offset into the array, may be negative if relative
 288      * indexes in the index map compensate to produce a value within the
 289      * array bounds
 290      * @param m the mask
 291      * @param indexMap the index map
 292      * @param j the offset into the index map
 293      * @return the vector loaded from an array
 294      * @throws IndexOutOfBoundsException if {@code j < 0}, or
 295      * {@code j > indexMap.length - this.length()},
 296      * or for any vector lane index {@code N} where the mask at lane
 297      * {@code N} is set the result of {@code i + indexMap[j + N]} is
 298      * {@code < 0} or {@code >= a.length}
 299      */
 300     @ForceInline
 301     @SuppressWarnings("unchecked")
 302     public static IntVector fromArray(VectorSpecies<Integer> species, int[] a, int i, VectorMask<Integer> m, int[] indexMap, int j) {
 303         // @@@ This can result in out of bounds errors for unset mask lanes
 304         return zero(species).blend(fromArray(species, a, i, indexMap, j), m);
 305     }
 306 
 307 
 308     /**
 309      * Loads a vector from a {@link ByteBuffer byte buffer} starting at an
 310      * offset into the byte buffer.
 311      * <p>
 312      * Bytes are composed into primitive lane elements according to the
 313      * native byte order of the underlying platform.
 314      * <p>
 315      * This method behaves as if it returns the result of calling the
 316      * byte buffer, offset, and mask accepting
 317      * {@link #fromByteBuffer(VectorSpecies<Integer>, ByteBuffer, int, VectorMask)} method} as follows:
 318      * <pre>{@code
 319      *   return this.fromByteBuffer(b, i, this.maskAllTrue())
 320      * }</pre>
 321      *
 322      * @param species species of desired vector
 323      * @param bb the byte buffer
 324      * @param ix the offset into the byte buffer
 325      * @return a vector loaded from a byte buffer
 326      * @throws IndexOutOfBoundsException if the offset is {@code < 0},
 327      * or {@code > b.limit()},
 328      * or if there are fewer than
 329      * {@code this.length() * this.elementSize() / Byte.SIZE} bytes
 330      * remaining in the byte buffer from the given offset
 331      */
 332     @ForceInline
 333     @SuppressWarnings("unchecked")
 334     public static IntVector fromByteBuffer(VectorSpecies<Integer> species, ByteBuffer bb, int ix) {
 335         if (bb.order() != ByteOrder.nativeOrder()) {
 336             throw new IllegalArgumentException();
 337         }
 338         ix = VectorIntrinsics.checkIndex(ix, bb.limit(), species.bitSize() / Byte.SIZE);
 339         return VectorIntrinsics.load((Class<IntVector>) species.boxType(), int.class, species.length(),
 340                                      U.getReference(bb, BYTE_BUFFER_HB), U.getLong(bb, BUFFER_ADDRESS) + ix,
 341                                      bb, ix, species,
 342                                      (c, idx, s) -> {
 343                                          ByteBuffer bbc = c.duplicate().position(idx).order(ByteOrder.nativeOrder());
 344                                          IntBuffer tb = bbc.asIntBuffer();
 345                                          return ((IntSpecies)s).op(i -> tb.get());
 346                                      });
 347     }
 348 
 349     /**
 350      * Loads a vector from a {@link ByteBuffer byte buffer} starting at an
 351      * offset into the byte buffer and using a mask.
 352      * <p>
 353      * This method behaves as if the byte buffer is viewed as a primitive
 354      * {@link java.nio.Buffer buffer} for the primitive element type,
 355      * according to the native byte order of the underlying platform, and
 356      * the returned vector is loaded with a mask from a primitive array
 357      * obtained from the primitive buffer.
 358      * The following pseudocode expresses the behaviour, where
 359      * {@coce EBuffer} is the primitive buffer type, {@code e} is the
 360      * primitive element type, and {@code ESpecies<S>} is the primitive
 361      * species for {@code e}:
 362      * <pre>{@code
 363      * EBuffer eb = b.duplicate().
 364      *     order(ByteOrder.nativeOrder()).position(i).
 365      *     asEBuffer();
 366      * e[] es = new e[this.length()];
 367      * for (int n = 0; n < t.length; n++) {
 368      *     if (m.isSet(n))
 369      *         es[n] = eb.get(n);
 370      * }
 371      * Vector<E> r = ((ESpecies<S>)this).fromArray(es, 0, m);
 372      * }</pre>
 373      *
 374      * @param species species of desired vector
 375      * @param bb the byte buffer
 376      * @param ix the offset into the byte buffer
 377      * @param m the mask
 378      * @return a vector loaded from a byte buffer
 379      * @throws IndexOutOfBoundsException if the offset is {@code < 0},
 380      * or {@code > b.limit()},
 381      * for any vector lane index {@code N} where the mask at lane {@code N}
 382      * is set
 383      * {@code i >= b.limit() - (N * this.elementSize() / Byte.SIZE)}
 384      */
 385     @ForceInline
 386     public static IntVector fromByteBuffer(VectorSpecies<Integer> species, ByteBuffer bb, int ix, VectorMask<Integer> m) {
 387         return zero(species).blend(fromByteBuffer(species, bb, ix), m);
 388     }
 389 
 390     /**
 391      * Returns a vector where all lane elements are set to the primitive
 392      * value {@code e}.
 393      *
 394      * @param s species of the desired vector
 395      * @param e the value
 396      * @return a vector of vector where all lane elements are set to
 397      * the primitive value {@code e}
 398      */
 399     @ForceInline
 400     @SuppressWarnings("unchecked")
 401     public static IntVector broadcast(VectorSpecies<Integer> s, int e) {
 402         return VectorIntrinsics.broadcastCoerced(
 403             (Class<IntVector>) s.boxType(), int.class, s.length(),
 404             e, s,
 405             ((bits, sp) -> ((IntSpecies)sp).op(i -> (int)bits)));
 406     }
 407 
 408     /**
 409      * Returns a vector where each lane element is set to a given
 410      * primitive value.
 411      * <p>
 412      * For each vector lane, where {@code N} is the vector lane index, the
 413      * the primitive value at index {@code N} is placed into the resulting
 414      * vector at lane index {@code N}.
 415      *
 416      * @param s species of the desired vector
 417      * @param es the given primitive values
 418      * @return a vector where each lane element is set to a given primitive
 419      * value
 420      * @throws IndexOutOfBoundsException if {@code es.length < this.length()}
 421      */
 422     @ForceInline
 423     @SuppressWarnings("unchecked")
 424     public static IntVector scalars(VectorSpecies<Integer> s, int... es) {
 425         Objects.requireNonNull(es);
 426         int ix = VectorIntrinsics.checkIndex(0, es.length, s.length());
 427         return VectorIntrinsics.load((Class<IntVector>) s.boxType(), int.class, s.length(),
 428                                      es, Unsafe.ARRAY_INT_BASE_OFFSET,
 429                                      es, ix, s,
 430                                      (c, idx, sp) -> ((IntSpecies)sp).op(n -> c[idx + n]));
 431     }
 432 
 433     /**
 434      * Returns a vector where the first lane element is set to the primtive
 435      * value {@code e}, all other lane elements are set to the default
 436      * value.
 437      *
 438      * @param s species of the desired vector
 439      * @param e the value
 440      * @return a vector where the first lane element is set to the primitive
 441      * value {@code e}
 442      */
 443     @ForceInline
 444     public static final IntVector single(VectorSpecies<Integer> s, int e) {
 445         return zero(s).with(0, e);
 446     }
 447 
 448     /**
 449      * Returns a vector where each lane element is set to a randomly
 450      * generated primitive value.
 451      *
 452      * The semantics are equivalent to calling
 453      * {@link ThreadLocalRandom#nextInt()}
 454      *
 455      * @param s species of the desired vector
 456      * @return a vector where each lane elements is set to a randomly
 457      * generated primitive value
 458      */
 459     public static IntVector random(VectorSpecies<Integer> s) {
 460         ThreadLocalRandom r = ThreadLocalRandom.current();
 461         return ((IntSpecies)s).op(i -> r.nextInt());
 462     }
 463 
 464     // Ops
 465 



 466     @Override
 467     public abstract IntVector add(Vector<Integer> v);
 468 
 469     /**
 470      * Adds this vector to the broadcast of an input scalar.
 471      * <p>
 472      * This is a vector binary operation where the primitive addition operation
 473      * ({@code +}) is applied to lane elements.
 474      *
 475      * @param s the input scalar
 476      * @return the result of adding this vector to the broadcast of an input
 477      * scalar
 478      */
 479     public abstract IntVector add(int s);
 480 



 481     @Override
 482     public abstract IntVector add(Vector<Integer> v, VectorMask<Integer> m);
 483 
 484     /**
 485      * Adds this vector to broadcast of an input scalar,
 486      * selecting lane elements controlled by a mask.
 487      * <p>
 488      * This is a vector binary operation where the primitive addition operation
 489      * ({@code +}) is applied to lane elements.
 490      *
 491      * @param s the input scalar
 492      * @param m the mask controlling lane selection
 493      * @return the result of adding this vector to the broadcast of an input
 494      * scalar
 495      */
 496     public abstract IntVector add(int s, VectorMask<Integer> m);
 497 



 498     @Override
 499     public abstract IntVector sub(Vector<Integer> v);
 500 
 501     /**
 502      * Subtracts the broadcast of an input scalar from this vector.
 503      * <p>
 504      * This is a vector binary operation where the primitive subtraction
 505      * operation ({@code -}) is applied to lane elements.
 506      *
 507      * @param s the input scalar
 508      * @return the result of subtracting the broadcast of an input
 509      * scalar from this vector
 510      */
 511     public abstract IntVector sub(int s);
 512 



 513     @Override
 514     public abstract IntVector sub(Vector<Integer> v, VectorMask<Integer> m);
 515 
 516     /**
 517      * Subtracts the broadcast of an input scalar from this vector, selecting
 518      * lane elements controlled by a mask.
 519      * <p>
 520      * This is a vector binary operation where the primitive subtraction
 521      * operation ({@code -}) is applied to lane elements.
 522      *
 523      * @param s the input scalar
 524      * @param m the mask controlling lane selection
 525      * @return the result of subtracting the broadcast of an input
 526      * scalar from this vector
 527      */
 528     public abstract IntVector sub(int s, VectorMask<Integer> m);
 529 



 530     @Override
 531     public abstract IntVector mul(Vector<Integer> v);
 532 
 533     /**
 534      * Multiplies this vector with the broadcast of an input scalar.
 535      * <p>
 536      * This is a vector binary operation where the primitive multiplication
 537      * operation ({@code *}) is applied to lane elements.
 538      *
 539      * @param s the input scalar
 540      * @return the result of multiplying this vector with the broadcast of an
 541      * input scalar
 542      */
 543     public abstract IntVector mul(int s);
 544 



 545     @Override
 546     public abstract IntVector mul(Vector<Integer> v, VectorMask<Integer> m);
 547 
 548     /**
 549      * Multiplies this vector with the broadcast of an input scalar, selecting
 550      * lane elements controlled by a mask.
 551      * <p>
 552      * This is a vector binary operation where the primitive multiplication
 553      * operation ({@code *}) is applied to lane elements.
 554      *
 555      * @param s the input scalar
 556      * @param m the mask controlling lane selection
 557      * @return the result of multiplying this vector with the broadcast of an
 558      * input scalar
 559      */
 560     public abstract IntVector mul(int s, VectorMask<Integer> m);
 561 



 562     @Override
 563     public abstract IntVector neg();
 564 



 565     @Override
 566     public abstract IntVector neg(VectorMask<Integer> m);
 567 



 568     @Override
 569     public abstract IntVector abs();
 570 



 571     @Override
 572     public abstract IntVector abs(VectorMask<Integer> m);
 573 



 574     @Override
 575     public abstract IntVector min(Vector<Integer> v);
 576 



 577     @Override
 578     public abstract IntVector min(Vector<Integer> v, VectorMask<Integer> m);
 579 
 580     /**
 581      * Returns the minimum of this vector and the broadcast of an input scalar.
 582      * <p>
 583      * This is a vector binary operation where the operation
 584      * {@code (a, b) -> Math.min(a, b)} is applied to lane elements.
 585      *
 586      * @param s the input scalar
 587      * @return the minimum of this vector and the broadcast of an input scalar
 588      */
 589     public abstract IntVector min(int s);
 590 



 591     @Override
 592     public abstract IntVector max(Vector<Integer> v);
 593 



 594     @Override
 595     public abstract IntVector max(Vector<Integer> v, VectorMask<Integer> m);
 596 
 597     /**
 598      * Returns the maximum of this vector and the broadcast of an input scalar.
 599      * <p>
 600      * This is a vector binary operation where the operation
 601      * {@code (a, b) -> Math.max(a, b)} is applied to lane elements.
 602      *
 603      * @param s the input scalar
 604      * @return the maximum of this vector and the broadcast of an input scalar
 605      */
 606     public abstract IntVector max(int s);
 607 



 608     @Override
 609     public abstract VectorMask<Integer> equal(Vector<Integer> v);
 610 
 611     /**
 612      * Tests if this vector is equal to the broadcast of an input scalar.
 613      * <p>
 614      * This is a vector binary test operation where the primitive equals
 615      * operation ({@code ==}) is applied to lane elements.
 616      *
 617      * @param s the input scalar
 618      * @return the result mask of testing if this vector is equal to the
 619      * broadcast of an input scalar
 620      */
 621     public abstract VectorMask<Integer> equal(int s);
 622 



 623     @Override
 624     public abstract VectorMask<Integer> notEqual(Vector<Integer> v);
 625 
 626     /**
 627      * Tests if this vector is not equal to the broadcast of an input scalar.
 628      * <p>
 629      * This is a vector binary test operation where the primitive not equals
 630      * operation ({@code !=}) is applied to lane elements.
 631      *
 632      * @param s the input scalar
 633      * @return the result mask of testing if this vector is not equal to the
 634      * broadcast of an input scalar
 635      */
 636     public abstract VectorMask<Integer> notEqual(int s);
 637 



 638     @Override
 639     public abstract VectorMask<Integer> lessThan(Vector<Integer> v);
 640 
 641     /**
 642      * Tests if this vector is less than the broadcast of an input scalar.
 643      * <p>
 644      * This is a vector binary test operation where the primitive less than
 645      * operation ({@code <}) is applied to lane elements.
 646      *
 647      * @param s the input scalar
 648      * @return the mask result of testing if this vector is less than the
 649      * broadcast of an input scalar
 650      */
 651     public abstract VectorMask<Integer> lessThan(int s);
 652 



 653     @Override
 654     public abstract VectorMask<Integer> lessThanEq(Vector<Integer> v);
 655 
 656     /**
 657      * Tests if this vector is less or equal to the broadcast of an input scalar.
 658      * <p>
 659      * This is a vector binary test operation where the primitive less than
 660      * or equal to operation ({@code <=}) is applied to lane elements.
 661      *
 662      * @param s the input scalar
 663      * @return the mask result of testing if this vector is less than or equal
 664      * to the broadcast of an input scalar
 665      */
 666     public abstract VectorMask<Integer> lessThanEq(int s);
 667 



 668     @Override
 669     public abstract VectorMask<Integer> greaterThan(Vector<Integer> v);
 670 
 671     /**
 672      * Tests if this vector is greater than the broadcast of an input scalar.
 673      * <p>
 674      * This is a vector binary test operation where the primitive greater than
 675      * operation ({@code >}) is applied to lane elements.
 676      *
 677      * @param s the input scalar
 678      * @return the mask result of testing if this vector is greater than the
 679      * broadcast of an input scalar
 680      */
 681     public abstract VectorMask<Integer> greaterThan(int s);
 682 



 683     @Override
 684     public abstract VectorMask<Integer> greaterThanEq(Vector<Integer> v);
 685 
 686     /**
 687      * Tests if this vector is greater than or equal to the broadcast of an
 688      * input scalar.
 689      * <p>
 690      * This is a vector binary test operation where the primitive greater than
 691      * or equal to operation ({@code >=}) is applied to lane elements.
 692      *
 693      * @param s the input scalar
 694      * @return the mask result of testing if this vector is greater than or
 695      * equal to the broadcast of an input scalar
 696      */
 697     public abstract VectorMask<Integer> greaterThanEq(int s);
 698 



 699     @Override
 700     public abstract IntVector blend(Vector<Integer> v, VectorMask<Integer> m);
 701 
 702     /**
 703      * Blends the lane elements of this vector with those of the broadcast of an
 704      * input scalar, selecting lanes controlled by a mask.
 705      * <p>
 706      * For each lane of the mask, at lane index {@code N}, if the mask lane
 707      * is set then the lane element at {@code N} from the input vector is
 708      * selected and placed into the resulting vector at {@code N},
 709      * otherwise the the lane element at {@code N} from this input vector is
 710      * selected and placed into the resulting vector at {@code N}.
 711      *
 712      * @param s the input scalar
 713      * @param m the mask controlling lane selection
 714      * @return the result of blending the lane elements of this vector with
 715      * those of the broadcast of an input scalar
 716      */
 717     public abstract IntVector blend(int s, VectorMask<Integer> m);
 718 



 719     @Override
 720     public abstract IntVector rearrange(Vector<Integer> v,
 721                                                       VectorShuffle<Integer> s, VectorMask<Integer> m);
 722 



 723     @Override
 724     public abstract IntVector rearrange(VectorShuffle<Integer> m);
 725 



 726     @Override
 727     public abstract IntVector reshape(VectorSpecies<Integer> s);
 728 



 729     @Override
 730     public abstract IntVector rotateEL(int i);
 731 



 732     @Override
 733     public abstract IntVector rotateER(int i);
 734 



 735     @Override
 736     public abstract IntVector shiftEL(int i);
 737 



 738     @Override
 739     public abstract IntVector shiftER(int i);
 740 
 741 
 742 
 743     /**
 744      * Bitwise ANDs this vector with an input vector.
 745      * <p>
 746      * This is a vector binary operation where the primitive bitwise AND
 747      * operation ({@code &}) is applied to lane elements.
 748      *
 749      * @param v the input vector
 750      * @return the bitwise AND of this vector with the input vector
 751      */
 752     public abstract IntVector and(Vector<Integer> v);
 753 
 754     /**
 755      * Bitwise ANDs this vector with the broadcast of an input scalar.
 756      * <p>
 757      * This is a vector binary operation where the primitive bitwise AND
 758      * operation ({@code &}) is applied to lane elements.
 759      *
 760      * @param s the input scalar
 761      * @return the bitwise AND of this vector with the broadcast of an input
 762      * scalar
 763      */
 764     public abstract IntVector and(int s);
 765 
 766     /**
 767      * Bitwise ANDs this vector with an input vector, selecting lane elements
 768      * controlled by a mask.
 769      * <p>
 770      * This is a vector binary operation where the primitive bitwise AND
 771      * operation ({@code &}) is applied to lane elements.
 772      *
 773      * @param v the input vector
 774      * @param m the mask controlling lane selection
 775      * @return the bitwise AND of this vector with the input vector
 776      */
 777     public abstract IntVector and(Vector<Integer> v, VectorMask<Integer> m);
 778 
 779     /**
 780      * Bitwise ANDs this vector with the broadcast of an input scalar, selecting
 781      * lane elements controlled by a mask.
 782      * <p>
 783      * This is a vector binary operation where the primitive bitwise AND
 784      * operation ({@code &}) is applied to lane elements.
 785      *
 786      * @param s the input scalar
 787      * @param m the mask controlling lane selection
 788      * @return the bitwise AND of this vector with the broadcast of an input
 789      * scalar
 790      */
 791     public abstract IntVector and(int s, VectorMask<Integer> m);
 792 
 793     /**
 794      * Bitwise ORs this vector with an input vector.
 795      * <p>
 796      * This is a vector binary operation where the primitive bitwise OR
 797      * operation ({@code |}) is applied to lane elements.
 798      *
 799      * @param v the input vector
 800      * @return the bitwise OR of this vector with the input vector
 801      */
 802     public abstract IntVector or(Vector<Integer> v);
 803 
 804     /**
 805      * Bitwise ORs this vector with the broadcast of an input scalar.
 806      * <p>
 807      * This is a vector binary operation where the primitive bitwise OR
 808      * operation ({@code |}) is applied to lane elements.
 809      *
 810      * @param s the input scalar
 811      * @return the bitwise OR of this vector with the broadcast of an input
 812      * scalar
 813      */
 814     public abstract IntVector or(int s);
 815 
 816     /**
 817      * Bitwise ORs this vector with an input vector, selecting lane elements
 818      * controlled by a mask.
 819      * <p>
 820      * This is a vector binary operation where the primitive bitwise OR
 821      * operation ({@code |}) is applied to lane elements.
 822      *
 823      * @param v the input vector
 824      * @param m the mask controlling lane selection
 825      * @return the bitwise OR of this vector with the input vector
 826      */
 827     public abstract IntVector or(Vector<Integer> v, VectorMask<Integer> m);
 828 
 829     /**
 830      * Bitwise ORs this vector with the broadcast of an input scalar, selecting
 831      * lane elements controlled by a mask.
 832      * <p>
 833      * This is a vector binary operation where the primitive bitwise OR
 834      * operation ({@code |}) is applied to lane elements.
 835      *
 836      * @param s the input scalar
 837      * @param m the mask controlling lane selection
 838      * @return the bitwise OR of this vector with the broadcast of an input
 839      * scalar
 840      */
 841     public abstract IntVector or(int s, VectorMask<Integer> m);
 842 
 843     /**
 844      * Bitwise XORs this vector with an input vector.
 845      * <p>
 846      * This is a vector binary operation where the primitive bitwise XOR
 847      * operation ({@code ^}) is applied to lane elements.
 848      *
 849      * @param v the input vector
 850      * @return the bitwise XOR of this vector with the input vector
 851      */
 852     public abstract IntVector xor(Vector<Integer> v);
 853 
 854     /**
 855      * Bitwise XORs this vector with the broadcast of an input scalar.
 856      * <p>
 857      * This is a vector binary operation where the primitive bitwise XOR
 858      * operation ({@code ^}) is applied to lane elements.
 859      *
 860      * @param s the input scalar
 861      * @return the bitwise XOR of this vector with the broadcast of an input
 862      * scalar
 863      */
 864     public abstract IntVector xor(int s);
 865 
 866     /**
 867      * Bitwise XORs this vector with an input vector, selecting lane elements
 868      * controlled by a mask.
 869      * <p>
 870      * This is a vector binary operation where the primitive bitwise XOR
 871      * operation ({@code ^}) is applied to lane elements.
 872      *
 873      * @param v the input vector
 874      * @param m the mask controlling lane selection
 875      * @return the bitwise XOR of this vector with the input vector
 876      */
 877     public abstract IntVector xor(Vector<Integer> v, VectorMask<Integer> m);
 878 
 879     /**
 880      * Bitwise XORs this vector with the broadcast of an input scalar, selecting
 881      * lane elements controlled by a mask.
 882      * <p>
 883      * This is a vector binary operation where the primitive bitwise XOR
 884      * operation ({@code ^}) is applied to lane elements.
 885      *
 886      * @param s the input scalar
 887      * @param m the mask controlling lane selection
 888      * @return the bitwise XOR of this vector with the broadcast of an input
 889      * scalar
 890      */
 891     public abstract IntVector xor(int s, VectorMask<Integer> m);
 892 
 893     /**
 894      * Bitwise NOTs this vector.
 895      * <p>
 896      * This is a vector unary operation where the primitive bitwise NOT
 897      * operation ({@code ~}) is applied to lane elements.
 898      *
 899      * @return the bitwise NOT of this vector
 900      */
 901     public abstract IntVector not();
 902 
 903     /**
 904      * Bitwise NOTs this vector, selecting lane elements controlled by a mask.
 905      * <p>
 906      * This is a vector unary operation where the primitive bitwise NOT
 907      * operation ({@code ~}) is applied to lane elements.
 908      *
 909      * @param m the mask controlling lane selection
 910      * @return the bitwise NOT of this vector
 911      */
 912     public abstract IntVector not(VectorMask<Integer> m);
 913 
 914     /**
 915      * Logically left shifts this vector by the broadcast of an input scalar.
 916      * <p>
 917      * This is a vector binary operation where the primitive logical left shift
 918      * operation ({@code <<}) is applied to lane elements.
 919      *
 920      * @param s the input scalar; the number of the bits to left shift
 921      * @return the result of logically left shifting left this vector by the
 922      * broadcast of an input scalar
 923      */
 924     public abstract IntVector shiftL(int s);
 925 
 926     /**
 927      * Logically left shifts this vector by the broadcast of an input scalar,
 928      * selecting lane elements controlled by a mask.
 929      * <p>
 930      * This is a vector binary operation where the primitive logical left shift
 931      * operation ({@code <<}) is applied to lane elements.
 932      *
 933      * @param s the input scalar; the number of the bits to left shift
 934      * @param m the mask controlling lane selection
 935      * @return the result of logically left shifting this vector by the
 936      * broadcast of an input scalar
 937      */
 938     public abstract IntVector shiftL(int s, VectorMask<Integer> m);
 939 
 940     /**
 941      * Logically left shifts this vector by an input vector.
 942      * <p>
 943      * This is a vector binary operation where the primitive logical left shift
 944      * operation ({@code <<}) is applied to lane elements.
 945      *
 946      * @param v the input vector
 947      * @return the result of logically left shifting this vector by the input
 948      * vector
 949      */
 950     public abstract IntVector shiftL(Vector<Integer> v);
 951 
 952     /**
 953      * Logically left shifts this vector by an input vector, selecting lane
 954      * elements controlled by a mask.
 955      * <p>
 956      * This is a vector binary operation where the primitive logical left shift
 957      * operation ({@code <<}) is applied to lane elements.
 958      *
 959      * @param v the input vector
 960      * @param m the mask controlling lane selection
 961      * @return the result of logically left shifting this vector by the input
 962      * vector
 963      */
 964     public IntVector shiftL(Vector<Integer> v, VectorMask<Integer> m) {
 965         return bOp(v, m, (i, a, b) -> (int) (a << b));
 966     }
 967 
 968     // logical, or unsigned, shift right
 969 
 970     /**
 971      * Logically right shifts (or unsigned right shifts) this vector by the
 972      * broadcast of an input scalar.
 973      * <p>
 974      * This is a vector binary operation where the primitive logical right shift
 975      * operation ({@code >>>}) is applied to lane elements.
 976      *
 977      * @param s the input scalar; the number of the bits to right shift
 978      * @return the result of logically right shifting this vector by the
 979      * broadcast of an input scalar
 980      */
 981     public abstract IntVector shiftR(int s);
 982 
 983     /**
 984      * Logically right shifts (or unsigned right shifts) this vector by the
 985      * broadcast of an input scalar, selecting lane elements controlled by a
 986      * mask.
 987      * <p>
 988      * This is a vector binary operation where the primitive logical right shift
 989      * operation ({@code >>>}) is applied to lane elements.
 990      *
 991      * @param s the input scalar; the number of the bits to right shift
 992      * @param m the mask controlling lane selection
 993      * @return the result of logically right shifting this vector by the
 994      * broadcast of an input scalar
 995      */
 996     public abstract IntVector shiftR(int s, VectorMask<Integer> m);
 997 
 998     /**
 999      * Logically right shifts (or unsigned right shifts) this vector by an
1000      * input vector.
1001      * <p>
1002      * This is a vector binary operation where the primitive logical right shift
1003      * operation ({@code >>>}) is applied to lane elements.
1004      *
1005      * @param v the input vector
1006      * @return the result of logically right shifting this vector by the
1007      * input vector
1008      */
1009     public abstract IntVector shiftR(Vector<Integer> v);
1010 
1011     /**
1012      * Logically right shifts (or unsigned right shifts) this vector by an
1013      * input vector, selecting lane elements controlled by a mask.
1014      * <p>
1015      * This is a vector binary operation where the primitive logical right shift
1016      * operation ({@code >>>}) is applied to lane elements.
1017      *
1018      * @param v the input vector
1019      * @param m the mask controlling lane selection
1020      * @return the result of logically right shifting this vector by the
1021      * input vector
1022      */
1023     public IntVector shiftR(Vector<Integer> v, VectorMask<Integer> m) {
1024         return bOp(v, m, (i, a, b) -> (int) (a >>> b));
1025     }
1026 
1027     /**
1028      * Arithmetically right shifts (or signed right shifts) this vector by the
1029      * broadcast of an input scalar.
1030      * <p>
1031      * This is a vector binary operation where the primitive arithmetic right
1032      * shift operation ({@code >>}) is applied to lane elements.
1033      *
1034      * @param s the input scalar; the number of the bits to right shift
1035      * @return the result of arithmetically right shifting this vector by the
1036      * broadcast of an input scalar
1037      */
1038     public abstract IntVector aShiftR(int s);
1039 
1040     /**
1041      * Arithmetically right shifts (or signed right shifts) this vector by the
1042      * broadcast of an input scalar, selecting lane elements controlled by a
1043      * mask.
1044      * <p>
1045      * This is a vector binary operation where the primitive arithmetic right
1046      * shift operation ({@code >>}) is applied to lane elements.
1047      *
1048      * @param s the input scalar; the number of the bits to right shift
1049      * @param m the mask controlling lane selection
1050      * @return the result of arithmetically right shifting this vector by the
1051      * broadcast of an input scalar
1052      */
1053     public abstract IntVector aShiftR(int s, VectorMask<Integer> m);
1054 
1055     /**
1056      * Arithmetically right shifts (or signed right shifts) this vector by an
1057      * input vector.
1058      * <p>
1059      * This is a vector binary operation where the primitive arithmetic right
1060      * shift operation ({@code >>}) is applied to lane elements.
1061      *
1062      * @param v the input vector
1063      * @return the result of arithmetically right shifting this vector by the
1064      * input vector
1065      */
1066     public abstract IntVector aShiftR(Vector<Integer> v);
1067 
1068     /**
1069      * Arithmetically right shifts (or signed right shifts) this vector by an
1070      * input vector, selecting lane elements controlled by a mask.
1071      * <p>
1072      * This is a vector binary operation where the primitive arithmetic right
1073      * shift operation ({@code >>}) is applied to lane elements.
1074      *
1075      * @param v the input vector
1076      * @param m the mask controlling lane selection
1077      * @return the result of arithmetically right shifting this vector by the
1078      * input vector
1079      */
1080     public IntVector aShiftR(Vector<Integer> v, VectorMask<Integer> m) {
1081         return bOp(v, m, (i, a, b) -> (int) (a >> b));
1082     }
1083 
1084     /**
1085      * Rotates left this vector by the broadcast of an input scalar.
1086      * <p>
1087      * This is a vector binary operation where the operation
1088      * {@link Integer#rotateLeft} is applied to lane elements and where
1089      * lane elements of this vector apply to the first argument, and lane
1090      * elements of the broadcast vector apply to the second argument (the
1091      * rotation distance).
1092      *
1093      * @param s the input scalar; the number of the bits to rotate left
1094      * @return the result of rotating left this vector by the broadcast of an
1095      * input scalar
1096      */
1097     @ForceInline
1098     public final IntVector rotateL(int s) {
1099         return shiftL(s).or(shiftR(-s));
1100     }
1101 
1102     /**
1103      * Rotates left this vector by the broadcast of an input scalar, selecting
1104      * lane elements controlled by a mask.
1105      * <p>
1106      * This is a vector binary operation where the operation
1107      * {@link Integer#rotateLeft} is applied to lane elements and where
1108      * lane elements of this vector apply to the first argument, and lane
1109      * elements of the broadcast vector apply to the second argument (the
1110      * rotation distance).
1111      *
1112      * @param s the input scalar; the number of the bits to rotate left
1113      * @param m the mask controlling lane selection
1114      * @return the result of rotating left this vector by the broadcast of an
1115      * input scalar
1116      */
1117     @ForceInline
1118     public final IntVector rotateL(int s, VectorMask<Integer> m) {
1119         return shiftL(s, m).or(shiftR(-s, m), m);
1120     }
1121 
1122     /**
1123      * Rotates right this vector by the broadcast of an input scalar.
1124      * <p>
1125      * This is a vector binary operation where the operation
1126      * {@link Integer#rotateRight} is applied to lane elements and where
1127      * lane elements of this vector apply to the first argument, and lane
1128      * elements of the broadcast vector apply to the second argument (the
1129      * rotation distance).
1130      *
1131      * @param s the input scalar; the number of the bits to rotate right
1132      * @return the result of rotating right this vector by the broadcast of an
1133      * input scalar
1134      */
1135     @ForceInline
1136     public final IntVector rotateR(int s) {
1137         return shiftR(s).or(shiftL(-s));
1138     }
1139 
1140     /**
1141      * Rotates right this vector by the broadcast of an input scalar, selecting
1142      * lane elements controlled by a mask.
1143      * <p>
1144      * This is a vector binary operation where the operation
1145      * {@link Integer#rotateRight} is applied to lane elements and where
1146      * lane elements of this vector apply to the first argument, and lane
1147      * elements of the broadcast vector apply to the second argument (the
1148      * rotation distance).
1149      *
1150      * @param s the input scalar; the number of the bits to rotate right
1151      * @param m the mask controlling lane selection
1152      * @return the result of rotating right this vector by the broadcast of an
1153      * input scalar
1154      */
1155     @ForceInline
1156     public final IntVector rotateR(int s, VectorMask<Integer> m) {
1157         return shiftR(s, m).or(shiftL(-s, m), m);
1158     }
1159 



1160     @Override
1161     public abstract void intoByteArray(byte[] a, int ix);
1162 



1163     @Override
1164     public abstract void intoByteArray(byte[] a, int ix, VectorMask<Integer> m);
1165 



1166     @Override
1167     public abstract void intoByteBuffer(ByteBuffer bb, int ix);
1168 



1169     @Override
1170     public abstract void intoByteBuffer(ByteBuffer bb, int ix, VectorMask<Integer> m);
1171 
1172 
1173     // Type specific horizontal reductions
1174     /**
1175      * Adds all lane elements of this vector.
1176      * <p>
1177      * This is an associative vector reduction operation where the addition
1178      * operation ({@code +}) is applied to lane elements,
1179      * and the identity value is {@code 0}.
1180      *
1181      * @return the addition of all the lane elements of this vector
1182      */
1183     public abstract int addAll();
1184 
1185     /**
1186      * Adds all lane elements of this vector, selecting lane elements
1187      * controlled by a mask.
1188      * <p>
1189      * This is an associative vector reduction operation where the addition
1190      * operation ({@code +}) is applied to lane elements,
1191      * and the identity value is {@code 0}.
1192      *
1193      * @param m the mask controlling lane selection
1194      * @return the addition of the selected lane elements of this vector
1195      */
1196     public abstract int addAll(VectorMask<Integer> m);
1197 
1198     /**
1199      * Multiplies all lane elements of this vector.
1200      * <p>
1201      * This is an associative vector reduction operation where the
1202      * multiplication operation ({@code *}) is applied to lane elements,
1203      * and the identity value is {@code 1}.
1204      *
1205      * @return the multiplication of all the lane elements of this vector
1206      */
1207     public abstract int mulAll();
1208 
1209     /**
1210      * Multiplies all lane elements of this vector, selecting lane elements
1211      * controlled by a mask.
1212      * <p>
1213      * This is an associative vector reduction operation where the
1214      * multiplication operation ({@code *}) is applied to lane elements,
1215      * and the identity value is {@code 1}.
1216      *
1217      * @param m the mask controlling lane selection
1218      * @return the multiplication of all the lane elements of this vector
1219      */
1220     public abstract int mulAll(VectorMask<Integer> m);
1221 
1222     /**
1223      * Returns the minimum lane element of this vector.
1224      * <p>
1225      * This is an associative vector reduction operation where the operation
1226      * {@code (a, b) -> Math.min(a, b)} is applied to lane elements,
1227      * and the identity value is
1228      * {@link Integer#MAX_VALUE}.
1229      *
1230      * @return the minimum lane element of this vector
1231      */
1232     public abstract int minAll();
1233 
1234     /**
1235      * Returns the minimum lane element of this vector, selecting lane elements
1236      * controlled by a mask.
1237      * <p>
1238      * This is an associative vector reduction operation where the operation
1239      * {@code (a, b) -> Math.min(a, b)} is applied to lane elements,
1240      * and the identity value is
1241      * {@link Integer#MAX_VALUE}.
1242      *
1243      * @param m the mask controlling lane selection
1244      * @return the minimum lane element of this vector
1245      */
1246     public abstract int minAll(VectorMask<Integer> m);
1247 
1248     /**
1249      * Returns the maximum lane element of this vector.
1250      * <p>
1251      * This is an associative vector reduction operation where the operation
1252      * {@code (a, b) -> Math.max(a, b)} is applied to lane elements,
1253      * and the identity value is
1254      * {@link Integer#MIN_VALUE}.
1255      *
1256      * @return the maximum lane element of this vector
1257      */
1258     public abstract int maxAll();
1259 
1260     /**
1261      * Returns the maximum lane element of this vector, selecting lane elements
1262      * controlled by a mask.
1263      * <p>
1264      * This is an associative vector reduction operation where the operation
1265      * {@code (a, b) -> Math.max(a, b)} is applied to lane elements,
1266      * and the identity value is
1267      * {@link Integer#MIN_VALUE}.
1268      *
1269      * @param m the mask controlling lane selection
1270      * @return the maximum lane element of this vector
1271      */
1272     public abstract int maxAll(VectorMask<Integer> m);
1273 
1274     /**
1275      * Logically ORs all lane elements of this vector.
1276      * <p>
1277      * This is an associative vector reduction operation where the logical OR
1278      * operation ({@code |}) is applied to lane elements,
1279      * and the identity value is {@code 0}.
1280      *
1281      * @return the logical OR all the lane elements of this vector
1282      */
1283     public abstract int orAll();
1284 
1285     /**
1286      * Logically ORs all lane elements of this vector, selecting lane elements
1287      * controlled by a mask.
1288      * <p>
1289      * This is an associative vector reduction operation where the logical OR
1290      * operation ({@code |}) is applied to lane elements,
1291      * and the identity value is {@code 0}.
1292      *
1293      * @param m the mask controlling lane selection
1294      * @return the logical OR all the lane elements of this vector
1295      */
1296     public abstract int orAll(VectorMask<Integer> m);
1297 
1298     /**
1299      * Logically ANDs all lane elements of this vector.
1300      * <p>
1301      * This is an associative vector reduction operation where the logical AND
1302      * operation ({@code |}) is applied to lane elements,
1303      * and the identity value is {@code -1}.
1304      *
1305      * @return the logical AND all the lane elements of this vector
1306      */
1307     public abstract int andAll();
1308 
1309     /**
1310      * Logically ANDs all lane elements of this vector, selecting lane elements
1311      * controlled by a mask.
1312      * <p>
1313      * This is an associative vector reduction operation where the logical AND
1314      * operation ({@code |}) is applied to lane elements,
1315      * and the identity value is {@code -1}.
1316      *
1317      * @param m the mask controlling lane selection
1318      * @return the logical AND all the lane elements of this vector
1319      */
1320     public abstract int andAll(VectorMask<Integer> m);
1321 
1322     /**
1323      * Logically XORs all lane elements of this vector.
1324      * <p>
1325      * This is an associative vector reduction operation where the logical XOR
1326      * operation ({@code ^}) is applied to lane elements,
1327      * and the identity value is {@code 0}.
1328      *
1329      * @return the logical XOR all the lane elements of this vector
1330      */
1331     public abstract int xorAll();
1332 
1333     /**
1334      * Logically XORs all lane elements of this vector, selecting lane elements
1335      * controlled by a mask.
1336      * <p>
1337      * This is an associative vector reduction operation where the logical XOR
1338      * operation ({@code ^}) is applied to lane elements,
1339      * and the identity value is {@code 0}.
1340      *
1341      * @param m the mask controlling lane selection
1342      * @return the logical XOR all the lane elements of this vector
1343      */
1344     public abstract int xorAll(VectorMask<Integer> m);
1345 
1346     // Type specific accessors
1347 
1348     /**
1349      * Gets the lane element at lane index {@code i}
1350      *
1351      * @param i the lane index
1352      * @return the lane element at lane index {@code i}
1353      * @throws IllegalArgumentException if the index is is out of range
1354      * ({@code < 0 || >= length()})
1355      */
1356     public abstract int get(int i);
1357 
1358     /**
1359      * Replaces the lane element of this vector at lane index {@code i} with
1360      * value {@code e}.
1361      * <p>
1362      * This is a cross-lane operation and behaves as if it returns the result
1363      * of blending this vector with an input vector that is the result of
1364      * broadcasting {@code e} and a mask that has only one lane set at lane
1365      * index {@code i}.
1366      *
1367      * @param i the lane index of the lane element to be replaced
1368      * @param e the value to be placed
1369      * @return the result of replacing the lane element of this vector at lane
1370      * index {@code i} with value {@code e}.
1371      * @throws IllegalArgumentException if the index is is out of range
1372      * ({@code < 0 || >= length()})
1373      */
1374     public abstract IntVector with(int i, int e);
1375 
1376     // Type specific extractors


1383      * <pre>{@code
1384      *   int[] a = new int[this.length()];
1385      *   this.intoArray(a, 0);
1386      *   return a;
1387      * }</pre>
1388      *
1389      * @return an array containing the the lane elements of this vector
1390      */
1391     @ForceInline
1392     public final int[] toArray() {
1393         int[] a = new int[species().length()];
1394         intoArray(a, 0);
1395         return a;
1396     }
1397 
1398     /**
1399      * Stores this vector into an array starting at offset.
1400      * <p>
1401      * For each vector lane, where {@code N} is the vector lane index,
1402      * the lane element at index {@code N} is stored into the array at index
1403      * {@code i + N}.
1404      *
1405      * @param a the array
1406      * @param i the offset into the array
1407      * @throws IndexOutOfBoundsException if {@code i < 0}, or
1408      * {@code i > a.length - this.length()}
1409      */
1410     public abstract void intoArray(int[] a, int i);
1411 
1412     /**
1413      * Stores this vector into an array starting at offset and using a mask.
1414      * <p>
1415      * For each vector lane, where {@code N} is the vector lane index,
1416      * if the mask lane at index {@code N} is set then the lane element at
1417      * index {@code N} is stored into the array index {@code i + N}.
1418      *
1419      * @param a the array
1420      * @param i the offset into the array
1421      * @param m the mask
1422      * @throws IndexOutOfBoundsException if {@code i < 0}, or
1423      * for any vector lane index {@code N} where the mask at lane {@code N}
1424      * is set {@code i >= a.length - N}
1425      */
1426     public abstract void intoArray(int[] a, int i, VectorMask<Integer> m);
1427 
1428     /**
1429      * Stores this vector into an array using indexes obtained from an index
1430      * map.
1431      * <p>
1432      * For each vector lane, where {@code N} is the vector lane index, the
1433      * lane element at index {@code N} is stored into the array at index
1434      * {@code i + indexMap[j + N]}.
1435      *
1436      * @param a the array
1437      * @param i the offset into the array, may be negative if relative
1438      * indexes in the index map compensate to produce a value within the
1439      * array bounds
1440      * @param indexMap the index map
1441      * @param j the offset into the index map
1442      * @throws IndexOutOfBoundsException if {@code j < 0}, or
1443      * {@code j > indexMap.length - this.length()},
1444      * or for any vector lane index {@code N} the result of
1445      * {@code i + indexMap[j + N]} is {@code < 0} or {@code >= a.length}
1446      */
1447     public abstract void intoArray(int[] a, int i, int[] indexMap, int j);
1448 
1449     /**
1450      * Stores this vector into an array using indexes obtained from an index
1451      * map and using a mask.
1452      * <p>
1453      * For each vector lane, where {@code N} is the vector lane index,
1454      * if the mask lane at index {@code N} is set then the lane element at
1455      * index {@code N} is stored into the array at index
1456      * {@code i + indexMap[j + N]}.
1457      *
1458      * @param a the array
1459      * @param i the offset into the array, may be negative if relative
1460      * indexes in the index map compensate to produce a value within the
1461      * array bounds
1462      * @param m the mask
1463      * @param indexMap the index map
1464      * @param j the offset into the index map
1465      * @throws IndexOutOfBoundsException if {@code j < 0}, or
1466      * {@code j > indexMap.length - this.length()},
1467      * or for any vector lane index {@code N} where the mask at lane
1468      * {@code N} is set the result of {@code i + indexMap[j + N]} is
1469      * {@code < 0} or {@code >= a.length}
1470      */
1471     public abstract void intoArray(int[] a, int i, VectorMask<Integer> m, int[] indexMap, int j);
1472     // Species
1473 



1474     @Override
1475     public abstract VectorSpecies<Integer> species();
1476 
1477     /**
1478      * Class representing {@link IntVector}'s of the same {@link VectorShape VectorShape}.
1479      */
1480     static final class IntSpecies extends AbstractSpecies<Integer> {
1481         final Function<int[], IntVector> vectorFactory;
1482 
1483         private IntSpecies(VectorShape shape,
1484                           Class<?> boxType,
1485                           Class<?> maskType,
1486                           Function<int[], IntVector> vectorFactory,
1487                           Function<boolean[], VectorMask<Integer>> maskFactory,
1488                           Function<IntUnaryOperator, VectorShuffle<Integer>> shuffleFromArrayFactory,
1489                           fShuffleFromArray<Integer> shuffleFromOpFactory) {
1490             super(shape, int.class, Integer.SIZE, boxType, maskType, maskFactory,
1491                   shuffleFromArrayFactory, shuffleFromOpFactory);
1492             this.vectorFactory = vectorFactory;
1493         }




 108      *
 109      * @param species species of desired vector
 110      * @return a zero vector of given species
 111      */
 112     @ForceInline
 113     @SuppressWarnings("unchecked")
 114     public static IntVector zero(VectorSpecies<Integer> species) {
 115         return VectorIntrinsics.broadcastCoerced((Class<IntVector>) species.boxType(), int.class, species.length(),
 116                                                  0, species,
 117                                                  ((bits, s) -> ((IntSpecies)s).op(i -> (int)bits)));
 118     }
 119 
 120     /**
 121      * Loads a vector from a byte array starting at an offset.
 122      * <p>
 123      * Bytes are composed into primitive lane elements according to the
 124      * native byte order of the underlying platform
 125      * <p>
 126      * This method behaves as if it returns the result of calling the
 127      * byte buffer, offset, and mask accepting
 128      * {@link #fromByteBuffer(VectorSpecies, ByteBuffer, int, VectorMask) method} as follows:
 129      * <pre>{@code
 130      * return fromByteBuffer(species, ByteBuffer.wrap(a), offset, VectorMask.allTrue());
 131      * }</pre>
 132      *
 133      * @param species species of desired vector
 134      * @param a the byte array
 135      * @param offset the offset into the array
 136      * @return a vector loaded from a byte array
 137      * @throws IndexOutOfBoundsException if {@code i < 0} or
 138      * {@code offset > a.length - (species.length() * species.elementSize() / Byte.SIZE)}
 139      */
 140     @ForceInline
 141     @SuppressWarnings("unchecked")
 142     public static IntVector fromByteArray(VectorSpecies<Integer> species, byte[] a, int offset) {
 143         Objects.requireNonNull(a);
 144         offset = VectorIntrinsics.checkIndex(offset, a.length, species.bitSize() / Byte.SIZE);
 145         return VectorIntrinsics.load((Class<IntVector>) species.boxType(), int.class, species.length(),
 146                                      a, ((long) offset) + Unsafe.ARRAY_BYTE_BASE_OFFSET,
 147                                      a, offset, species,
 148                                      (c, idx, s) -> {
 149                                          ByteBuffer bbc = ByteBuffer.wrap(c, idx, a.length - idx).order(ByteOrder.nativeOrder());
 150                                          IntBuffer tb = bbc.asIntBuffer();
 151                                          return ((IntSpecies)s).op(i -> tb.get());
 152                                      });
 153     }
 154 
 155     /**
 156      * Loads a vector from a byte array starting at an offset and using a
 157      * mask.
 158      * <p>
 159      * Bytes are composed into primitive lane elements according to the
 160      * native byte order of the underlying platform.
 161      * <p>
 162      * This method behaves as if it returns the result of calling the
 163      * byte buffer, offset, and mask accepting
 164      * {@link #fromByteBuffer(VectorSpecies, ByteBuffer, int, VectorMask) method} as follows:
 165      * <pre>{@code
 166      * return fromByteBuffer(species, ByteBuffer.wrap(a), offset, m);
 167      * }</pre>
 168      *
 169      * @param species species of desired vector
 170      * @param a the byte array
 171      * @param offset the offset into the array
 172      * @param m the mask
 173      * @return a vector loaded from a byte array
 174      * @throws IndexOutOfBoundsException if {@code offset < 0} or



 175      * for any vector lane index {@code N} where the mask at lane {@code N}
 176      * is set
 177      * {@code offset >= a.length - (N * species.elementSize() / Byte.SIZE)}
 178      */
 179     @ForceInline
 180     public static IntVector fromByteArray(VectorSpecies<Integer> species, byte[] a, int offset, VectorMask<Integer> m) {
 181         return zero(species).blend(fromByteArray(species, a, offset), 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 offset + 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 offset the offset into the array
 194      * @return the vector loaded from an array
 195      * @throws IndexOutOfBoundsException if {@code offset < 0}, or
 196      * {@code offset > a.length - species.length()}
 197      */
 198     @ForceInline
 199     @SuppressWarnings("unchecked")
 200     public static IntVector fromArray(VectorSpecies<Integer> species, int[] a, int offset){
 201         Objects.requireNonNull(a);
 202         offset = VectorIntrinsics.checkIndex(offset, a.length, species.length());
 203         return VectorIntrinsics.load((Class<IntVector>) species.boxType(), int.class, species.length(),
 204                                      a, (((long) offset) << ARRAY_SHIFT) + Unsafe.ARRAY_INT_BASE_OFFSET,
 205                                      a, offset, species,
 206                                      (c, idx, s) -> ((IntSpecies)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 offset + 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 offset the offset into the array
 222      * @param m the mask
 223      * @return the vector loaded from an array
 224      * @throws IndexOutOfBoundsException if {@code offset < 0}, or
 225      * for any vector lane index {@code N} where the mask at lane {@code N}
 226      * is set {@code offset > a.length - N}
 227      */
 228     @ForceInline
 229     public static IntVector fromArray(VectorSpecies<Integer> species, int[] a, int offset, VectorMask<Integer> m) {
 230         return zero(species).blend(fromArray(species, a, offset), 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 a_offset + indexMap[i_offset + 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 a_offset 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 i_offset the offset into the index map
 248      * @return the vector loaded from an array
 249      * @throws IndexOutOfBoundsException if {@code i_offset < 0}, or
 250      * {@code i_offset > indexMap.length - species.length()},
 251      * or for any vector lane index {@code N} the result of
 252      * {@code a_offset + indexMap[i_offset + N]} is {@code < 0} or {@code >= a.length}
 253      */
 254     @ForceInline
 255     @SuppressWarnings("unchecked")
 256     public static IntVector fromArray(VectorSpecies<Integer> species, int[] a, int a_offset, int[] indexMap, int i_offset) {
 257         Objects.requireNonNull(a);
 258         Objects.requireNonNull(indexMap);
 259 
 260 
 261         // Index vector: vix[0:n] = k -> a_offset + indexMap[i_offset + k]
 262         IntVector vix = IntVector.fromArray(IntVector.species(species.indexShape()), indexMap, i_offset).add(a_offset);
 263 
 264         vix = VectorIntrinsics.checkIndex(vix, a.length);
 265 
 266         return VectorIntrinsics.loadWithMap((Class<IntVector>) species.boxType(), int.class, species.length(),
 267                                             IntVector.species(species.indexShape()).boxType(), a, Unsafe.ARRAY_INT_BASE_OFFSET, vix,
 268                                             a, a_offset, indexMap, i_offset, species,
 269                                             (int[] c, int idx, int[] iMap, int idy, VectorSpecies<Integer> s) ->
 270                                                 ((IntSpecies)s).op(n -> c[idx + iMap[idy+n]]));
 271         }
 272 
 273     /**
 274      * Loads a vector from an array using indexes obtained from an index
 275      * map and using a mask.
 276      * <p>
 277      * For each vector lane, where {@code N} is the vector lane index,
 278      * if the mask lane at index {@code N} is set then the array element at
 279      * index {@code a_offset + indexMap[i_offset + N]} is placed into the resulting vector
 280      * at lane index {@code N}.
 281      *
 282      * @param species species of desired vector
 283      * @param a the array
 284      * @param a_offset the offset into the array, may be negative if relative
 285      * indexes in the index map compensate to produce a value within the
 286      * array bounds
 287      * @param m the mask
 288      * @param indexMap the index map
 289      * @param i_offset the offset into the index map
 290      * @return the vector loaded from an array
 291      * @throws IndexOutOfBoundsException if {@code i_offset < 0}, or
 292      * {@code i_offset > indexMap.length - species.length()},
 293      * or for any vector lane index {@code N} where the mask at lane
 294      * {@code N} is set the result of {@code a_offset + indexMap[i_offset + N]} is
 295      * {@code < 0} or {@code >= a.length}
 296      */
 297     @ForceInline
 298     @SuppressWarnings("unchecked")
 299     public static IntVector fromArray(VectorSpecies<Integer> species, int[] a, int a_offset, VectorMask<Integer> m, int[] indexMap, int i_offset) {
 300         // @@@ This can result in out of bounds errors for unset mask lanes
 301         return zero(species).blend(fromArray(species, a, a_offset, indexMap, i_offset), m);
 302     }
 303 
 304 
 305     /**
 306      * Loads a vector from a {@link ByteBuffer byte buffer} starting at an
 307      * offset into the byte buffer.
 308      * <p>
 309      * Bytes are composed into primitive lane elements according to the
 310      * native byte order of the underlying platform.
 311      * <p>
 312      * This method behaves as if it returns the result of calling the
 313      * byte buffer, offset, and mask accepting
 314      * {@link #fromByteBuffer(VectorSpecies, ByteBuffer, int, VectorMask)} method} as follows:
 315      * <pre>{@code
 316      *   return fromByteBuffer(b, offset, VectorMask.allTrue())
 317      * }</pre>
 318      *
 319      * @param species species of desired vector
 320      * @param bb the byte buffer
 321      * @param offset the offset into the byte buffer
 322      * @return a vector loaded from a byte buffer
 323      * @throws IndexOutOfBoundsException if the offset is {@code < 0},
 324      * or {@code > b.limit()},
 325      * or if there are fewer than
 326      * {@code species.length() * species.elementSize() / Byte.SIZE} bytes
 327      * remaining in the byte buffer from the given offset
 328      */
 329     @ForceInline
 330     @SuppressWarnings("unchecked")
 331     public static IntVector fromByteBuffer(VectorSpecies<Integer> species, ByteBuffer bb, int offset) {
 332         if (bb.order() != ByteOrder.nativeOrder()) {
 333             throw new IllegalArgumentException();
 334         }
 335         offset = VectorIntrinsics.checkIndex(offset, bb.limit(), species.bitSize() / Byte.SIZE);
 336         return VectorIntrinsics.load((Class<IntVector>) species.boxType(), int.class, species.length(),
 337                                      U.getReference(bb, BYTE_BUFFER_HB), U.getLong(bb, BUFFER_ADDRESS) + offset,
 338                                      bb, offset, species,
 339                                      (c, idx, s) -> {
 340                                          ByteBuffer bbc = c.duplicate().position(idx).order(ByteOrder.nativeOrder());
 341                                          IntBuffer tb = bbc.asIntBuffer();
 342                                          return ((IntSpecies)s).op(i -> tb.get());
 343                                      });
 344     }
 345 
 346     /**
 347      * Loads a vector from a {@link ByteBuffer byte buffer} starting at an
 348      * offset into the byte buffer and using a mask.
 349      * <p>
 350      * This method behaves as if the byte buffer is viewed as a primitive
 351      * {@link java.nio.Buffer buffer} for the primitive element type,
 352      * according to the native byte order of the underlying platform, and
 353      * the returned vector is loaded with a mask from a primitive array
 354      * obtained from the primitive buffer.
 355      * The following pseudocode expresses the behaviour, where
 356      * {@code EBuffer} is the primitive buffer type, {@code e} is the
 357      * primitive element type, and {@code ESpecies} is the primitive
 358      * species for {@code e}:
 359      * <pre>{@code
 360      * EBuffer eb = b.duplicate().
 361      *     order(ByteOrder.nativeOrder()).position(offset).
 362      *     asEBuffer();
 363      * e[] es = new e[species.length()];
 364      * for (int n = 0; n < t.length; n++) {
 365      *     if (m.isSet(n))
 366      *         es[n] = eb.get(n);
 367      * }
 368      * EVector r = EVector.fromArray(es, 0, m);
 369      * }</pre>
 370      *
 371      * @param species species of desired vector
 372      * @param bb the byte buffer
 373      * @param offset the offset into the byte buffer
 374      * @param m the mask
 375      * @return a vector loaded from a byte buffer
 376      * @throws IndexOutOfBoundsException if the offset is {@code < 0},
 377      * or {@code > b.limit()},
 378      * for any vector lane index {@code N} where the mask at lane {@code N}
 379      * is set
 380      * {@code offset >= b.limit() - (N * species.elementSize() / Byte.SIZE)}
 381      */
 382     @ForceInline
 383     public static IntVector fromByteBuffer(VectorSpecies<Integer> species, ByteBuffer bb, int offset, VectorMask<Integer> m) {
 384         return zero(species).blend(fromByteBuffer(species, bb, offset), m);
 385     }
 386 
 387     /**
 388      * Returns a vector where all lane elements are set to the primitive
 389      * value {@code e}.
 390      *
 391      * @param species species of the desired vector
 392      * @param e the value
 393      * @return a vector of vector where all lane elements are set to
 394      * the primitive value {@code e}
 395      */
 396     @ForceInline
 397     @SuppressWarnings("unchecked")
 398     public static IntVector broadcast(VectorSpecies<Integer> species, int e) {
 399         return VectorIntrinsics.broadcastCoerced(
 400             (Class<IntVector>) species.boxType(), int.class, species.length(),
 401             e, species,
 402             ((bits, sp) -> ((IntSpecies)sp).op(i -> (int)bits)));
 403     }
 404 
 405     /**
 406      * Returns a vector where each lane element is set to given
 407      * primitive values.
 408      * <p>
 409      * For each vector lane, where {@code N} is the vector lane index, the
 410      * the primitive value at index {@code N} is placed into the resulting
 411      * vector at lane index {@code N}.
 412      *
 413      * @param species species of the desired vector
 414      * @param es the given primitive values
 415      * @return a vector where each lane element is set to given primitive
 416      * values
 417      * @throws IndexOutOfBoundsException if {@code es.length < species.length()}
 418      */
 419     @ForceInline
 420     @SuppressWarnings("unchecked")
 421     public static IntVector scalars(VectorSpecies<Integer> species, int... es) {
 422         Objects.requireNonNull(es);
 423         int ix = VectorIntrinsics.checkIndex(0, es.length, species.length());
 424         return VectorIntrinsics.load((Class<IntVector>) species.boxType(), int.class, species.length(),
 425                                      es, Unsafe.ARRAY_INT_BASE_OFFSET,
 426                                      es, ix, species,
 427                                      (c, idx, sp) -> ((IntSpecies)sp).op(n -> c[idx + n]));
 428     }
 429 
 430     /**
 431      * Returns a vector where the first lane element is set to the primtive
 432      * value {@code e}, all other lane elements are set to the default
 433      * value.
 434      *
 435      * @param species species of the desired vector
 436      * @param e the value
 437      * @return a vector where the first lane element is set to the primitive
 438      * value {@code e}
 439      */
 440     @ForceInline
 441     public static final IntVector single(VectorSpecies<Integer> species, int e) {
 442         return zero(species).with(0, e);
 443     }
 444 
 445     /**
 446      * Returns a vector where each lane element is set to a randomly
 447      * generated primitive value.
 448      *
 449      * The semantics are equivalent to calling
 450      * {@link ThreadLocalRandom#nextInt()}
 451      *
 452      * @param species species of the desired vector
 453      * @return a vector where each lane elements is set to a randomly
 454      * generated primitive value
 455      */
 456     public static IntVector random(VectorSpecies<Integer> species) {
 457         ThreadLocalRandom r = ThreadLocalRandom.current();
 458         return ((IntSpecies)species).op(i -> r.nextInt());
 459     }
 460 
 461     // Ops
 462 
 463     /**
 464      * {@inheritDoc}
 465      */
 466     @Override
 467     public abstract IntVector add(Vector<Integer> v);
 468 
 469     /**
 470      * Adds this vector to the broadcast of an input scalar.
 471      * <p>
 472      * This is a lane-wise binary operation which applies the primitive addition operation
 473      * ({@code +}) to each lane.
 474      *
 475      * @param s the input scalar
 476      * @return the result of adding this vector to the broadcast of an input
 477      * scalar
 478      */
 479     public abstract IntVector add(int s);
 480 
 481     /**
 482      * {@inheritDoc}
 483      */
 484     @Override
 485     public abstract IntVector add(Vector<Integer> v, VectorMask<Integer> m);
 486 
 487     /**
 488      * Adds this vector to broadcast of an input scalar,
 489      * selecting lane elements controlled by a mask.
 490      * <p>
 491      * This is a lane-wise binary operation which applies the primitive addition operation
 492      * ({@code +}) to each lane.
 493      *
 494      * @param s the input scalar
 495      * @param m the mask controlling lane selection
 496      * @return the result of adding this vector to the broadcast of an input
 497      * scalar
 498      */
 499     public abstract IntVector add(int s, VectorMask<Integer> m);
 500 
 501     /**
 502      * {@inheritDoc}
 503      */
 504     @Override
 505     public abstract IntVector sub(Vector<Integer> v);
 506 
 507     /**
 508      * Subtracts the broadcast of an input scalar from this vector.
 509      * <p>
 510      * This is a lane-wise binary operation which applies the primitive subtraction
 511      * operation ({@code -}) to each lane.
 512      *
 513      * @param s the input scalar
 514      * @return the result of subtracting the broadcast of an input
 515      * scalar from this vector
 516      */
 517     public abstract IntVector sub(int s);
 518 
 519     /**
 520      * {@inheritDoc}
 521      */
 522     @Override
 523     public abstract IntVector sub(Vector<Integer> v, VectorMask<Integer> m);
 524 
 525     /**
 526      * Subtracts the broadcast of an input scalar from this vector, selecting
 527      * lane elements controlled by a mask.
 528      * <p>
 529      * This is a lane-wise binary operation which applies the primitive subtraction
 530      * operation ({@code -}) to each lane.
 531      *
 532      * @param s the input scalar
 533      * @param m the mask controlling lane selection
 534      * @return the result of subtracting the broadcast of an input
 535      * scalar from this vector
 536      */
 537     public abstract IntVector sub(int s, VectorMask<Integer> m);
 538 
 539     /**
 540      * {@inheritDoc}
 541      */
 542     @Override
 543     public abstract IntVector mul(Vector<Integer> v);
 544 
 545     /**
 546      * Multiplies this vector with the broadcast of an input scalar.
 547      * <p>
 548      * This is a lane-wise binary operation which applies the primitive multiplication
 549      * operation ({@code *}) to each lane.
 550      *
 551      * @param s the input scalar
 552      * @return the result of multiplying this vector with the broadcast of an
 553      * input scalar
 554      */
 555     public abstract IntVector mul(int s);
 556 
 557     /**
 558      * {@inheritDoc}
 559      */
 560     @Override
 561     public abstract IntVector mul(Vector<Integer> v, VectorMask<Integer> m);
 562 
 563     /**
 564      * Multiplies this vector with the broadcast of an input scalar, selecting
 565      * lane elements controlled by a mask.
 566      * <p>
 567      * This is a lane-wise binary operation which applies the primitive multiplication
 568      * operation ({@code *}) to each lane.
 569      *
 570      * @param s the input scalar
 571      * @param m the mask controlling lane selection
 572      * @return the result of multiplying this vector with the broadcast of an
 573      * input scalar
 574      */
 575     public abstract IntVector mul(int s, VectorMask<Integer> m);
 576 
 577     /**
 578      * {@inheritDoc}
 579      */
 580     @Override
 581     public abstract IntVector neg();
 582 
 583     /**
 584      * {@inheritDoc}
 585      */
 586     @Override
 587     public abstract IntVector neg(VectorMask<Integer> m);
 588 
 589     /**
 590      * {@inheritDoc}
 591      */
 592     @Override
 593     public abstract IntVector abs();
 594 
 595     /**
 596      * {@inheritDoc}
 597      */
 598     @Override
 599     public abstract IntVector abs(VectorMask<Integer> m);
 600 
 601     /**
 602      * {@inheritDoc}
 603      */
 604     @Override
 605     public abstract IntVector min(Vector<Integer> v);
 606 
 607     /**
 608      * {@inheritDoc}
 609      */
 610     @Override
 611     public abstract IntVector min(Vector<Integer> v, VectorMask<Integer> m);
 612 
 613     /**
 614      * Returns the minimum of this vector and the broadcast of an input scalar.
 615      * <p>
 616      * This is a lane-wise binary operation which applies the operation
 617      * {@code (a, b) -> Math.min(a, b)} to each lane.
 618      *
 619      * @param s the input scalar
 620      * @return the minimum of this vector and the broadcast of an input scalar
 621      */
 622     public abstract IntVector min(int s);
 623 
 624     /**
 625      * {@inheritDoc}
 626      */
 627     @Override
 628     public abstract IntVector max(Vector<Integer> v);
 629 
 630     /**
 631      * {@inheritDoc}
 632      */
 633     @Override
 634     public abstract IntVector max(Vector<Integer> v, VectorMask<Integer> m);
 635 
 636     /**
 637      * Returns the maximum of this vector and the broadcast of an input scalar.
 638      * <p>
 639      * This is a lane-wise binary operation which applies the operation
 640      * {@code (a, b) -> Math.max(a, b)} to each lane.
 641      *
 642      * @param s the input scalar
 643      * @return the maximum of this vector and the broadcast of an input scalar
 644      */
 645     public abstract IntVector max(int s);
 646 
 647     /**
 648      * {@inheritDoc}
 649      */
 650     @Override
 651     public abstract VectorMask<Integer> equal(Vector<Integer> v);
 652 
 653     /**
 654      * Tests if this vector is equal to the broadcast of an input scalar.
 655      * <p>
 656      * This is a lane-wise binary test operation which applies the primitive equals
 657      * operation ({@code ==}) each lane.
 658      *
 659      * @param s the input scalar
 660      * @return the result mask of testing if this vector is equal to the
 661      * broadcast of an input scalar
 662      */
 663     public abstract VectorMask<Integer> equal(int s);
 664 
 665     /**
 666      * {@inheritDoc}
 667      */
 668     @Override
 669     public abstract VectorMask<Integer> notEqual(Vector<Integer> v);
 670 
 671     /**
 672      * Tests if this vector is not equal to the broadcast of an input scalar.
 673      * <p>
 674      * This is a lane-wise binary test operation which applies the primitive not equals
 675      * operation ({@code !=}) to each lane.
 676      *
 677      * @param s the input scalar
 678      * @return the result mask of testing if this vector is not equal to the
 679      * broadcast of an input scalar
 680      */
 681     public abstract VectorMask<Integer> notEqual(int s);
 682 
 683     /**
 684      * {@inheritDoc}
 685      */
 686     @Override
 687     public abstract VectorMask<Integer> lessThan(Vector<Integer> v);
 688 
 689     /**
 690      * Tests if this vector is less than the broadcast of an input scalar.
 691      * <p>
 692      * This is a lane-wise binary test operation which applies the primitive less than
 693      * operation ({@code <}) to each lane.
 694      *
 695      * @param s the input scalar
 696      * @return the mask result of testing if this vector is less than the
 697      * broadcast of an input scalar
 698      */
 699     public abstract VectorMask<Integer> lessThan(int s);
 700 
 701     /**
 702      * {@inheritDoc}
 703      */
 704     @Override
 705     public abstract VectorMask<Integer> lessThanEq(Vector<Integer> v);
 706 
 707     /**
 708      * Tests if this vector is less or equal to the broadcast of an input scalar.
 709      * <p>
 710      * This is a lane-wise binary test operation which applies the primitive less than
 711      * or equal to operation ({@code <=}) to each lane.
 712      *
 713      * @param s the input scalar
 714      * @return the mask result of testing if this vector is less than or equal
 715      * to the broadcast of an input scalar
 716      */
 717     public abstract VectorMask<Integer> lessThanEq(int s);
 718 
 719     /**
 720      * {@inheritDoc}
 721      */
 722     @Override
 723     public abstract VectorMask<Integer> greaterThan(Vector<Integer> v);
 724 
 725     /**
 726      * Tests if this vector is greater than the broadcast of an input scalar.
 727      * <p>
 728      * This is a lane-wise binary test operation which applies the primitive greater than
 729      * operation ({@code >}) to each lane.
 730      *
 731      * @param s the input scalar
 732      * @return the mask result of testing if this vector is greater than the
 733      * broadcast of an input scalar
 734      */
 735     public abstract VectorMask<Integer> greaterThan(int s);
 736 
 737     /**
 738      * {@inheritDoc}
 739      */
 740     @Override
 741     public abstract VectorMask<Integer> greaterThanEq(Vector<Integer> v);
 742 
 743     /**
 744      * Tests if this vector is greater than or equal to the broadcast of an
 745      * input scalar.
 746      * <p>
 747      * This is a lane-wise binary test operation which applies the primitive greater than
 748      * or equal to operation ({@code >=}) to each lane.
 749      *
 750      * @param s the input scalar
 751      * @return the mask result of testing if this vector is greater than or
 752      * equal to the broadcast of an input scalar
 753      */
 754     public abstract VectorMask<Integer> greaterThanEq(int s);
 755 
 756     /**
 757      * {@inheritDoc}
 758      */
 759     @Override
 760     public abstract IntVector blend(Vector<Integer> v, VectorMask<Integer> m);
 761 
 762     /**
 763      * Blends the lane elements of this vector with those of the broadcast of an
 764      * input scalar, selecting lanes controlled by a mask.
 765      * <p>
 766      * For each lane of the mask, at lane index {@code N}, if the mask lane
 767      * is set then the lane element at {@code N} from the input vector is
 768      * selected and placed into the resulting vector at {@code N},
 769      * otherwise the the lane element at {@code N} from this input vector is
 770      * selected and placed into the resulting vector at {@code N}.
 771      *
 772      * @param s the input scalar
 773      * @param m the mask controlling lane selection
 774      * @return the result of blending the lane elements of this vector with
 775      * those of the broadcast of an input scalar
 776      */
 777     public abstract IntVector blend(int s, VectorMask<Integer> m);
 778 
 779     /**
 780      * {@inheritDoc}
 781      */
 782     @Override
 783     public abstract IntVector rearrange(Vector<Integer> v,
 784                                                       VectorShuffle<Integer> s, VectorMask<Integer> m);
 785 
 786     /**
 787      * {@inheritDoc}
 788      */
 789     @Override
 790     public abstract IntVector rearrange(VectorShuffle<Integer> m);
 791 
 792     /**
 793      * {@inheritDoc}
 794      */
 795     @Override
 796     public abstract IntVector reshape(VectorSpecies<Integer> s);
 797 
 798     /**
 799      * {@inheritDoc}
 800      */
 801     @Override
 802     public abstract IntVector rotateEL(int i);
 803 
 804     /**
 805      * {@inheritDoc}
 806      */
 807     @Override
 808     public abstract IntVector rotateER(int i);
 809 
 810     /**
 811      * {@inheritDoc}
 812      */
 813     @Override
 814     public abstract IntVector shiftEL(int i);
 815 
 816     /**
 817      * {@inheritDoc}
 818      */
 819     @Override
 820     public abstract IntVector shiftER(int i);
 821 
 822 
 823 
 824     /**
 825      * Bitwise ANDs this vector with an input vector.
 826      * <p>
 827      * This is a lane-wise binary operation which applies the primitive bitwise AND
 828      * operation ({@code &}) to each lane.
 829      *
 830      * @param v the input vector
 831      * @return the bitwise AND of this vector with the input vector
 832      */
 833     public abstract IntVector and(Vector<Integer> v);
 834 
 835     /**
 836      * Bitwise ANDs this vector with the broadcast of an input scalar.
 837      * <p>
 838      * This is a lane-wise binary operation which applies the primitive bitwise AND
 839      * operation ({@code &}) to each lane.
 840      *
 841      * @param s the input scalar
 842      * @return the bitwise AND of this vector with the broadcast of an input
 843      * scalar
 844      */
 845     public abstract IntVector and(int s);
 846 
 847     /**
 848      * Bitwise ANDs this vector with an input vector, selecting lane elements
 849      * controlled by a mask.
 850      * <p>
 851      * This is a lane-wise binary operation which applies the primitive bitwise AND
 852      * operation ({@code &}) to each lane.
 853      *
 854      * @param v the input vector
 855      * @param m the mask controlling lane selection
 856      * @return the bitwise AND of this vector with the input vector
 857      */
 858     public abstract IntVector and(Vector<Integer> v, VectorMask<Integer> m);
 859 
 860     /**
 861      * Bitwise ANDs this vector with the broadcast of an input scalar, selecting
 862      * lane elements controlled by a mask.
 863      * <p>
 864      * This is a lane-wise binary operation which applies the primitive bitwise AND
 865      * operation ({@code &}) to each lane.
 866      *
 867      * @param s the input scalar
 868      * @param m the mask controlling lane selection
 869      * @return the bitwise AND of this vector with the broadcast of an input
 870      * scalar
 871      */
 872     public abstract IntVector and(int s, VectorMask<Integer> m);
 873 
 874     /**
 875      * Bitwise ORs this vector with an input vector.
 876      * <p>
 877      * This is a lane-wise binary operation which applies the primitive bitwise OR
 878      * operation ({@code |}) to each lane.
 879      *
 880      * @param v the input vector
 881      * @return the bitwise OR of this vector with the input vector
 882      */
 883     public abstract IntVector or(Vector<Integer> v);
 884 
 885     /**
 886      * Bitwise ORs this vector with the broadcast of an input scalar.
 887      * <p>
 888      * This is a lane-wise binary operation which applies the primitive bitwise OR
 889      * operation ({@code |}) to each lane.
 890      *
 891      * @param s the input scalar
 892      * @return the bitwise OR of this vector with the broadcast of an input
 893      * scalar
 894      */
 895     public abstract IntVector or(int s);
 896 
 897     /**
 898      * Bitwise ORs this vector with an input vector, selecting lane elements
 899      * controlled by a mask.
 900      * <p>
 901      * This is a lane-wise binary operation which applies the primitive bitwise OR
 902      * operation ({@code |}) to each lane.
 903      *
 904      * @param v the input vector
 905      * @param m the mask controlling lane selection
 906      * @return the bitwise OR of this vector with the input vector
 907      */
 908     public abstract IntVector or(Vector<Integer> v, VectorMask<Integer> m);
 909 
 910     /**
 911      * Bitwise ORs this vector with the broadcast of an input scalar, selecting
 912      * lane elements controlled by a mask.
 913      * <p>
 914      * This is a lane-wise binary operation which applies the primitive bitwise OR
 915      * operation ({@code |}) to each lane.
 916      *
 917      * @param s the input scalar
 918      * @param m the mask controlling lane selection
 919      * @return the bitwise OR of this vector with the broadcast of an input
 920      * scalar
 921      */
 922     public abstract IntVector or(int s, VectorMask<Integer> m);
 923 
 924     /**
 925      * Bitwise XORs this vector with an input vector.
 926      * <p>
 927      * This is a lane-wise binary operation which applies the primitive bitwise XOR
 928      * operation ({@code ^}) to each lane.
 929      *
 930      * @param v the input vector
 931      * @return the bitwise XOR of this vector with the input vector
 932      */
 933     public abstract IntVector xor(Vector<Integer> v);
 934 
 935     /**
 936      * Bitwise XORs this vector with the broadcast of an input scalar.
 937      * <p>
 938      * This is a lane-wise binary operation which applies the primitive bitwise XOR
 939      * operation ({@code ^}) to each lane.
 940      *
 941      * @param s the input scalar
 942      * @return the bitwise XOR of this vector with the broadcast of an input
 943      * scalar
 944      */
 945     public abstract IntVector xor(int s);
 946 
 947     /**
 948      * Bitwise XORs this vector with an input vector, selecting lane elements
 949      * controlled by a mask.
 950      * <p>
 951      * This is a lane-wise binary operation which applies the primitive bitwise XOR
 952      * operation ({@code ^}) to each lane.
 953      *
 954      * @param v the input vector
 955      * @param m the mask controlling lane selection
 956      * @return the bitwise XOR of this vector with the input vector
 957      */
 958     public abstract IntVector xor(Vector<Integer> v, VectorMask<Integer> m);
 959 
 960     /**
 961      * Bitwise XORs this vector with the broadcast of an input scalar, selecting
 962      * lane elements controlled by a mask.
 963      * <p>
 964      * This is a lane-wise binary operation which applies the primitive bitwise XOR
 965      * operation ({@code ^}) to each lane.
 966      *
 967      * @param s the input scalar
 968      * @param m the mask controlling lane selection
 969      * @return the bitwise XOR of this vector with the broadcast of an input
 970      * scalar
 971      */
 972     public abstract IntVector xor(int s, VectorMask<Integer> m);
 973 
 974     /**
 975      * Bitwise NOTs this vector.
 976      * <p>
 977      * This is a lane-wise unary operation which applies the primitive bitwise NOT
 978      * operation ({@code ~}) to each lane.
 979      *
 980      * @return the bitwise NOT of this vector
 981      */
 982     public abstract IntVector not();
 983 
 984     /**
 985      * Bitwise NOTs this vector, selecting lane elements controlled by a mask.
 986      * <p>
 987      * This is a lane-wise unary operation which applies the primitive bitwise NOT
 988      * operation ({@code ~}) to each lane.
 989      *
 990      * @param m the mask controlling lane selection
 991      * @return the bitwise NOT of this vector
 992      */
 993     public abstract IntVector not(VectorMask<Integer> m);
 994 
 995     /**
 996      * Logically left shifts this vector by the broadcast of an input scalar.
 997      * <p>
 998      * This is a lane-wise binary operation which applies the primitive logical left shift
 999      * operation ({@code <<}) to each lane.
1000      *
1001      * @param s the input scalar; the number of the bits to left shift
1002      * @return the result of logically left shifting left this vector by the
1003      * broadcast of an input scalar
1004      */
1005     public abstract IntVector shiftL(int s);
1006 
1007     /**
1008      * Logically left shifts this vector by the broadcast of an input scalar,
1009      * selecting lane elements controlled by a mask.
1010      * <p>
1011      * This is a lane-wise binary operation which applies the primitive logical left shift
1012      * operation ({@code <<}) to each lane.
1013      *
1014      * @param s the input scalar; the number of the bits to left shift
1015      * @param m the mask controlling lane selection
1016      * @return the result of logically left shifting this vector by the
1017      * broadcast of an input scalar
1018      */
1019     public abstract IntVector shiftL(int s, VectorMask<Integer> m);
1020 
1021     /**
1022      * Logically left shifts this vector by an input vector.
1023      * <p>
1024      * This is a lane-wise binary operation which applies the primitive logical left shift
1025      * operation ({@code <<}) to each lane.
1026      *
1027      * @param v the input vector
1028      * @return the result of logically left shifting this vector by the input
1029      * vector
1030      */
1031     public abstract IntVector shiftL(Vector<Integer> v);
1032 
1033     /**
1034      * Logically left shifts this vector by an input vector, selecting lane
1035      * elements controlled by a mask.
1036      * <p>
1037      * This is a lane-wise binary operation which applies the primitive logical left shift
1038      * operation ({@code <<}) to each lane.
1039      *
1040      * @param v the input vector
1041      * @param m the mask controlling lane selection
1042      * @return the result of logically left shifting this vector by the input
1043      * vector
1044      */
1045     public IntVector shiftL(Vector<Integer> v, VectorMask<Integer> m) {
1046         return bOp(v, m, (i, a, b) -> (int) (a << b));
1047     }
1048 
1049     // logical, or unsigned, shift right
1050 
1051     /**
1052      * Logically right shifts (or unsigned right shifts) this vector by the
1053      * broadcast of an input scalar.
1054      * <p>
1055      * This is a lane-wise binary operation which applies the primitive logical right shift
1056      * operation ({@code >>>}) to each lane.
1057      *
1058      * @param s the input scalar; the number of the bits to right shift
1059      * @return the result of logically right shifting this vector by the
1060      * broadcast of an input scalar
1061      */
1062     public abstract IntVector shiftR(int s);
1063 
1064     /**
1065      * Logically right shifts (or unsigned right shifts) this vector by the
1066      * broadcast of an input scalar, selecting lane elements controlled by a
1067      * mask.
1068      * <p>
1069      * This is a lane-wise binary operation which applies the primitive logical right shift
1070      * operation ({@code >>>}) to each lane.
1071      *
1072      * @param s the input scalar; the number of the bits to right shift
1073      * @param m the mask controlling lane selection
1074      * @return the result of logically right shifting this vector by the
1075      * broadcast of an input scalar
1076      */
1077     public abstract IntVector shiftR(int s, VectorMask<Integer> m);
1078 
1079     /**
1080      * Logically right shifts (or unsigned right shifts) this vector by an
1081      * input vector.
1082      * <p>
1083      * This is a lane-wise binary operation which applies the primitive logical right shift
1084      * operation ({@code >>>}) to each lane.
1085      *
1086      * @param v the input vector
1087      * @return the result of logically right shifting this vector by the
1088      * input vector
1089      */
1090     public abstract IntVector shiftR(Vector<Integer> v);
1091 
1092     /**
1093      * Logically right shifts (or unsigned right shifts) this vector by an
1094      * input vector, selecting lane elements controlled by a mask.
1095      * <p>
1096      * This is a lane-wise binary operation which applies the primitive logical right shift
1097      * operation ({@code >>>}) to each lane.
1098      *
1099      * @param v the input vector
1100      * @param m the mask controlling lane selection
1101      * @return the result of logically right shifting this vector by the
1102      * input vector
1103      */
1104     public IntVector shiftR(Vector<Integer> v, VectorMask<Integer> m) {
1105         return bOp(v, m, (i, a, b) -> (int) (a >>> b));
1106     }
1107 
1108     /**
1109      * Arithmetically right shifts (or signed right shifts) this vector by the
1110      * broadcast of an input scalar.
1111      * <p>
1112      * This is a lane-wise binary operation which applies the primitive arithmetic right
1113      * shift operation ({@code >>}) to each lane.
1114      *
1115      * @param s the input scalar; the number of the bits to right shift
1116      * @return the result of arithmetically right shifting this vector by the
1117      * broadcast of an input scalar
1118      */
1119     public abstract IntVector aShiftR(int s);
1120 
1121     /**
1122      * Arithmetically right shifts (or signed right shifts) this vector by the
1123      * broadcast of an input scalar, selecting lane elements controlled by a
1124      * mask.
1125      * <p>
1126      * This is a lane-wise binary operation which applies the primitive arithmetic right
1127      * shift operation ({@code >>}) to each lane.
1128      *
1129      * @param s the input scalar; the number of the bits to right shift
1130      * @param m the mask controlling lane selection
1131      * @return the result of arithmetically right shifting this vector by the
1132      * broadcast of an input scalar
1133      */
1134     public abstract IntVector aShiftR(int s, VectorMask<Integer> m);
1135 
1136     /**
1137      * Arithmetically right shifts (or signed right shifts) this vector by an
1138      * input vector.
1139      * <p>
1140      * This is a lane-wise binary operation which applies the primitive arithmetic right
1141      * shift operation ({@code >>}) to each lane.
1142      *
1143      * @param v the input vector
1144      * @return the result of arithmetically right shifting this vector by the
1145      * input vector
1146      */
1147     public abstract IntVector aShiftR(Vector<Integer> v);
1148 
1149     /**
1150      * Arithmetically right shifts (or signed right shifts) this vector by an
1151      * input vector, selecting lane elements controlled by a mask.
1152      * <p>
1153      * This is a lane-wise binary operation which applies the primitive arithmetic right
1154      * shift operation ({@code >>}) to each lane.
1155      *
1156      * @param v the input vector
1157      * @param m the mask controlling lane selection
1158      * @return the result of arithmetically right shifting this vector by the
1159      * input vector
1160      */
1161     public IntVector aShiftR(Vector<Integer> v, VectorMask<Integer> m) {
1162         return bOp(v, m, (i, a, b) -> (int) (a >> b));
1163     }
1164 
1165     /**
1166      * Rotates left this vector by the broadcast of an input scalar.
1167      * <p>
1168      * This is a lane-wise binary operation which applies the operation
1169      * {@link Integer#rotateLeft} to each lane and where
1170      * lane elements of this vector apply to the first argument, and lane
1171      * elements of the broadcast vector apply to the second argument (the
1172      * rotation distance).
1173      *
1174      * @param s the input scalar; the number of the bits to rotate left
1175      * @return the result of rotating left this vector by the broadcast of an
1176      * input scalar
1177      */
1178     @ForceInline
1179     public final IntVector rotateL(int s) {
1180         return shiftL(s).or(shiftR(-s));
1181     }
1182 
1183     /**
1184      * Rotates left this vector by the broadcast of an input scalar, selecting
1185      * lane elements controlled by a mask.
1186      * <p>
1187      * This is a lane-wise binary operation which applies the operation
1188      * {@link Integer#rotateLeft} to each lane and where
1189      * lane elements of this vector apply to the first argument, and lane
1190      * elements of the broadcast vector apply to the second argument (the
1191      * rotation distance).
1192      *
1193      * @param s the input scalar; the number of the bits to rotate left
1194      * @param m the mask controlling lane selection
1195      * @return the result of rotating left this vector by the broadcast of an
1196      * input scalar
1197      */
1198     @ForceInline
1199     public final IntVector rotateL(int s, VectorMask<Integer> m) {
1200         return shiftL(s, m).or(shiftR(-s, m), m);
1201     }
1202 
1203     /**
1204      * Rotates right this vector by the broadcast of an input scalar.
1205      * <p>
1206      * This is a lane-wise binary operation which applies the operation
1207      * {@link Integer#rotateRight} to each lane and where
1208      * lane elements of this vector apply to the first argument, and lane
1209      * elements of the broadcast vector apply to the second argument (the
1210      * rotation distance).
1211      *
1212      * @param s the input scalar; the number of the bits to rotate right
1213      * @return the result of rotating right this vector by the broadcast of an
1214      * input scalar
1215      */
1216     @ForceInline
1217     public final IntVector rotateR(int s) {
1218         return shiftR(s).or(shiftL(-s));
1219     }
1220 
1221     /**
1222      * Rotates right this vector by the broadcast of an input scalar, selecting
1223      * lane elements controlled by a mask.
1224      * <p>
1225      * This is a lane-wise binary operation which applies the operation
1226      * {@link Integer#rotateRight} to each lane and where
1227      * lane elements of this vector apply to the first argument, and lane
1228      * elements of the broadcast vector apply to the second argument (the
1229      * rotation distance).
1230      *
1231      * @param s the input scalar; the number of the bits to rotate right
1232      * @param m the mask controlling lane selection
1233      * @return the result of rotating right this vector by the broadcast of an
1234      * input scalar
1235      */
1236     @ForceInline
1237     public final IntVector rotateR(int s, VectorMask<Integer> m) {
1238         return shiftR(s, m).or(shiftL(-s, m), m);
1239     }
1240 
1241     /**
1242      * {@inheritDoc}
1243      */
1244     @Override
1245     public abstract void intoByteArray(byte[] a, int ix);
1246 
1247     /**
1248      * {@inheritDoc}
1249      */
1250     @Override
1251     public abstract void intoByteArray(byte[] a, int ix, VectorMask<Integer> m);
1252 
1253     /**
1254      * {@inheritDoc}
1255      */
1256     @Override
1257     public abstract void intoByteBuffer(ByteBuffer bb, int ix);
1258 
1259     /**
1260      * {@inheritDoc}
1261      */
1262     @Override
1263     public abstract void intoByteBuffer(ByteBuffer bb, int ix, VectorMask<Integer> m);
1264 
1265 
1266     // Type specific horizontal reductions
1267     /**
1268      * Adds all lane elements of this vector.
1269      * <p>
1270      * This is an associative cross-lane reduction operation which applies the addition
1271      * operation ({@code +}) to lane elements,
1272      * and the identity value is {@code 0}.
1273      *
1274      * @return the addition of all the lane elements of this vector
1275      */
1276     public abstract int addAll();
1277 
1278     /**
1279      * Adds all lane elements of this vector, selecting lane elements
1280      * controlled by a mask.
1281      * <p>
1282      * This is an associative cross-lane reduction operation which applies the addition
1283      * operation ({@code +}) to lane elements,
1284      * and the identity value is {@code 0}.
1285      *
1286      * @param m the mask controlling lane selection
1287      * @return the addition of the selected lane elements of this vector
1288      */
1289     public abstract int addAll(VectorMask<Integer> m);
1290 
1291     /**
1292      * Multiplies all lane elements of this vector.
1293      * <p>
1294      * This is an associative cross-lane reduction operation which applies the
1295      * multiplication operation ({@code *}) to lane elements,
1296      * and the identity value is {@code 1}.
1297      *
1298      * @return the multiplication of all the lane elements of this vector
1299      */
1300     public abstract int mulAll();
1301 
1302     /**
1303      * Multiplies all lane elements of this vector, selecting lane elements
1304      * controlled by a mask.
1305      * <p>
1306      * This is an associative cross-lane reduction operation which applies the
1307      * multiplication operation ({@code *}) to lane elements,
1308      * and the identity value is {@code 1}.
1309      *
1310      * @param m the mask controlling lane selection
1311      * @return the multiplication of all the lane elements of this vector
1312      */
1313     public abstract int mulAll(VectorMask<Integer> m);
1314 
1315     /**
1316      * Returns the minimum lane element of this vector.
1317      * <p>
1318      * This is an associative cross-lane reduction operation which applies the operation
1319      * {@code (a, b) -> Math.min(a, b)} to lane elements,
1320      * and the identity value is
1321      * {@link Integer#MAX_VALUE}.
1322      *
1323      * @return the minimum lane element of this vector
1324      */
1325     public abstract int minAll();
1326 
1327     /**
1328      * Returns the minimum lane element of this vector, selecting lane elements
1329      * controlled by a mask.
1330      * <p>
1331      * This is an associative cross-lane reduction operation which applies the operation
1332      * {@code (a, b) -> Math.min(a, b)} to lane elements,
1333      * and the identity value is
1334      * {@link Integer#MAX_VALUE}.
1335      *
1336      * @param m the mask controlling lane selection
1337      * @return the minimum lane element of this vector
1338      */
1339     public abstract int minAll(VectorMask<Integer> m);
1340 
1341     /**
1342      * Returns the maximum lane element of this vector.
1343      * <p>
1344      * This is an associative cross-lane reduction operation which applies the operation
1345      * {@code (a, b) -> Math.max(a, b)} to lane elements,
1346      * and the identity value is
1347      * {@link Integer#MIN_VALUE}.
1348      *
1349      * @return the maximum lane element of this vector
1350      */
1351     public abstract int maxAll();
1352 
1353     /**
1354      * Returns the maximum lane element of this vector, selecting lane elements
1355      * controlled by a mask.
1356      * <p>
1357      * This is an associative cross-lane reduction operation which applies the operation
1358      * {@code (a, b) -> Math.max(a, b)} to lane elements,
1359      * and the identity value is
1360      * {@link Integer#MIN_VALUE}.
1361      *
1362      * @param m the mask controlling lane selection
1363      * @return the maximum lane element of this vector
1364      */
1365     public abstract int maxAll(VectorMask<Integer> m);
1366 
1367     /**
1368      * Logically ORs all lane elements of this vector.
1369      * <p>
1370      * This is an associative cross-lane reduction operation which applies the logical OR
1371      * operation ({@code |}) to lane elements,
1372      * and the identity value is {@code 0}.
1373      *
1374      * @return the logical OR all the lane elements of this vector
1375      */
1376     public abstract int orAll();
1377 
1378     /**
1379      * Logically ORs all lane elements of this vector, selecting lane elements
1380      * controlled by a mask.
1381      * <p>
1382      * This is an associative cross-lane reduction operation which applies the logical OR
1383      * operation ({@code |}) to lane elements,
1384      * and the identity value is {@code 0}.
1385      *
1386      * @param m the mask controlling lane selection
1387      * @return the logical OR all the lane elements of this vector
1388      */
1389     public abstract int orAll(VectorMask<Integer> m);
1390 
1391     /**
1392      * Logically ANDs all lane elements of this vector.
1393      * <p>
1394      * This is an associative cross-lane reduction operation which applies the logical AND
1395      * operation ({@code |}) to lane elements,
1396      * and the identity value is {@code -1}.
1397      *
1398      * @return the logical AND all the lane elements of this vector
1399      */
1400     public abstract int andAll();
1401 
1402     /**
1403      * Logically ANDs all lane elements of this vector, selecting lane elements
1404      * controlled by a mask.
1405      * <p>
1406      * This is an associative cross-lane reduction operation which applies the logical AND
1407      * operation ({@code |}) to lane elements,
1408      * and the identity value is {@code -1}.
1409      *
1410      * @param m the mask controlling lane selection
1411      * @return the logical AND all the lane elements of this vector
1412      */
1413     public abstract int andAll(VectorMask<Integer> m);
1414 
1415     /**
1416      * Logically XORs all lane elements of this vector.
1417      * <p>
1418      * This is an associative cross-lane reduction operation which applies the logical XOR
1419      * operation ({@code ^}) to lane elements,
1420      * and the identity value is {@code 0}.
1421      *
1422      * @return the logical XOR all the lane elements of this vector
1423      */
1424     public abstract int xorAll();
1425 
1426     /**
1427      * Logically XORs all lane elements of this vector, selecting lane elements
1428      * controlled by a mask.
1429      * <p>
1430      * This is an associative cross-lane reduction operation which applies the logical XOR
1431      * operation ({@code ^}) to lane elements,
1432      * and the identity value is {@code 0}.
1433      *
1434      * @param m the mask controlling lane selection
1435      * @return the logical XOR all the lane elements of this vector
1436      */
1437     public abstract int xorAll(VectorMask<Integer> m);
1438 
1439     // Type specific accessors
1440 
1441     /**
1442      * Gets the lane element at lane index {@code i}
1443      *
1444      * @param i the lane index
1445      * @return the lane element at lane index {@code i}
1446      * @throws IllegalArgumentException if the index is is out of range
1447      * ({@code < 0 || >= length()})
1448      */
1449     public abstract int lane(int i);
1450 
1451     /**
1452      * Replaces the lane element of this vector at lane index {@code i} with
1453      * value {@code e}.
1454      * <p>
1455      * This is a cross-lane operation and behaves as if it returns the result
1456      * of blending this vector with an input vector that is the result of
1457      * broadcasting {@code e} and a mask that has only one lane set at lane
1458      * index {@code i}.
1459      *
1460      * @param i the lane index of the lane element to be replaced
1461      * @param e the value to be placed
1462      * @return the result of replacing the lane element of this vector at lane
1463      * index {@code i} with value {@code e}.
1464      * @throws IllegalArgumentException if the index is is out of range
1465      * ({@code < 0 || >= length()})
1466      */
1467     public abstract IntVector with(int i, int e);
1468 
1469     // Type specific extractors


1476      * <pre>{@code
1477      *   int[] a = new int[this.length()];
1478      *   this.intoArray(a, 0);
1479      *   return a;
1480      * }</pre>
1481      *
1482      * @return an array containing the the lane elements of this vector
1483      */
1484     @ForceInline
1485     public final int[] toArray() {
1486         int[] a = new int[species().length()];
1487         intoArray(a, 0);
1488         return a;
1489     }
1490 
1491     /**
1492      * Stores this vector into an array starting at offset.
1493      * <p>
1494      * For each vector lane, where {@code N} is the vector lane index,
1495      * the lane element at index {@code N} is stored into the array at index
1496      * {@code offset + N}.
1497      *
1498      * @param a the array
1499      * @param offset the offset into the array
1500      * @throws IndexOutOfBoundsException if {@code offset < 0}, or
1501      * {@code offset > a.length - this.length()}
1502      */
1503     public abstract void intoArray(int[] a, int offset);
1504 
1505     /**
1506      * Stores this vector into an array starting at offset and using a mask.
1507      * <p>
1508      * For each vector lane, where {@code N} is the vector lane index,
1509      * if the mask lane at index {@code N} is set then the lane element at
1510      * index {@code N} is stored into the array index {@code offset + N}.
1511      *
1512      * @param a the array
1513      * @param offset the offset into the array
1514      * @param m the mask
1515      * @throws IndexOutOfBoundsException if {@code offset < 0}, or
1516      * for any vector lane index {@code N} where the mask at lane {@code N}
1517      * is set {@code offset >= a.length - N}
1518      */
1519     public abstract void intoArray(int[] a, int offset, VectorMask<Integer> m);
1520 
1521     /**
1522      * Stores this vector into an array using indexes obtained from an index
1523      * map.
1524      * <p>
1525      * For each vector lane, where {@code N} is the vector lane index, the
1526      * lane element at index {@code N} is stored into the array at index
1527      * {@code a_offset + indexMap[i_offset + N]}.
1528      *
1529      * @param a the array
1530      * @param a_offset the offset into the array, may be negative if relative
1531      * indexes in the index map compensate to produce a value within the
1532      * array bounds
1533      * @param indexMap the index map
1534      * @param i_offset the offset into the index map
1535      * @throws IndexOutOfBoundsException if {@code i_offset < 0}, or
1536      * {@code i_offset > indexMap.length - this.length()},
1537      * or for any vector lane index {@code N} the result of
1538      * {@code a_offset + indexMap[i_offset + N]} is {@code < 0} or {@code >= a.length}
1539      */
1540     public abstract void intoArray(int[] a, int a_offset, int[] indexMap, int i_offset);
1541 
1542     /**
1543      * Stores this vector into an array using indexes obtained from an index
1544      * map and using a mask.
1545      * <p>
1546      * For each vector lane, where {@code N} is the vector lane index,
1547      * if the mask lane at index {@code N} is set then the lane element at
1548      * index {@code N} is stored into the array at index
1549      * {@code a_offset + indexMap[i_offset + N]}.
1550      *
1551      * @param a the array
1552      * @param a_offset the offset into the array, may be negative if relative
1553      * indexes in the index map compensate to produce a value within the
1554      * array bounds
1555      * @param m the mask
1556      * @param indexMap the index map
1557      * @param i_offset the offset into the index map
1558      * @throws IndexOutOfBoundsException if {@code j < 0}, or
1559      * {@code i_offset > indexMap.length - this.length()},
1560      * or for any vector lane index {@code N} where the mask at lane
1561      * {@code N} is set the result of {@code a_offset + indexMap[i_offset + N]} is
1562      * {@code < 0} or {@code >= a.length}
1563      */
1564     public abstract void intoArray(int[] a, int a_offset, VectorMask<Integer> m, int[] indexMap, int i_offset);
1565     // Species
1566 
1567     /**
1568      * {@inheritDoc}
1569      */
1570     @Override
1571     public abstract VectorSpecies<Integer> species();
1572 
1573     /**
1574      * Class representing {@link IntVector}'s of the same {@link VectorShape VectorShape}.
1575      */
1576     static final class IntSpecies extends AbstractSpecies<Integer> {
1577         final Function<int[], IntVector> vectorFactory;
1578 
1579         private IntSpecies(VectorShape shape,
1580                           Class<?> boxType,
1581                           Class<?> maskType,
1582                           Function<int[], IntVector> vectorFactory,
1583                           Function<boolean[], VectorMask<Integer>> maskFactory,
1584                           Function<IntUnaryOperator, VectorShuffle<Integer>> shuffleFromArrayFactory,
1585                           fShuffleFromArray<Integer> shuffleFromOpFactory) {
1586             super(shape, int.class, Integer.SIZE, boxType, maskType, maskFactory,
1587                   shuffleFromArrayFactory, shuffleFromOpFactory);
1588             this.vectorFactory = vectorFactory;
1589         }


< prev index next >