1 /*
   2  * Copyright (c) 2017, Oracle and/or its affiliates. All rights reserved.
   3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
   4  *
   5  * This code is free software; you can redistribute it and/or modify it
   6  * under the terms of the GNU General Public License version 2 only, as
   7  * published by the Free Software Foundation.  Oracle designates this
   8  * particular file as subject to the "Classpath" exception as provided
   9  * by Oracle in the LICENSE file that accompanied this code.
  10  *
  11  * This code is distributed in the hope that it will be useful, but WITHOUT
  12  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  13  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  14  * version 2 for more details (a copy is included in the LICENSE file that
  15  * accompanied this code).
  16  *
  17  * You should have received a copy of the GNU General Public License version
  18  * 2 along with this work; if not, write to the Free Software Foundation,
  19  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  20  *
  21  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  22  * or visit www.oracle.com if you need additional information or have
  23  * questions.
  24  */
  25 package jdk.incubator.vector;
  26 
  27 import java.nio.ByteBuffer;
  28 #if[!byte]
  29 import java.nio.$Type$Buffer;
  30 #end[!byte]
  31 import java.nio.ByteOrder;
  32 import java.util.Objects;
  33 import java.util.function.IntUnaryOperator;
  34 import java.util.function.Function;
  35 import java.util.concurrent.ThreadLocalRandom;
  36 
  37 import jdk.internal.misc.Unsafe;
  38 import jdk.internal.vm.annotation.ForceInline;
  39 import static jdk.incubator.vector.VectorIntrinsics.*;
  40 
  41 
  42 /**
  43  * A specialized {@link Vector} representing an ordered immutable sequence of
  44  * {@code $type$} values.
  45  */
  46 @SuppressWarnings("cast")
  47 public abstract class $abstractvectortype$ extends Vector<$Boxtype$> {
  48 
  49     $abstractvectortype$() {}
  50 
  51     private static final int ARRAY_SHIFT = 31 - Integer.numberOfLeadingZeros(Unsafe.ARRAY_$TYPE$_INDEX_SCALE);
  52 
  53     // Unary operator
  54 
  55     interface FUnOp {
  56         $type$ apply(int i, $type$ a);
  57     }
  58 
  59     abstract $abstractvectortype$ uOp(FUnOp f);
  60 
  61     abstract $abstractvectortype$ uOp(VectorMask<$Boxtype$> m, FUnOp f);
  62 
  63     // Binary operator
  64 
  65     interface FBinOp {
  66         $type$ apply(int i, $type$ a, $type$ b);
  67     }
  68 
  69     abstract $abstractvectortype$ bOp(Vector<$Boxtype$> v, FBinOp f);
  70 
  71     abstract $abstractvectortype$ bOp(Vector<$Boxtype$> v, VectorMask<$Boxtype$> m, FBinOp f);
  72 
  73     // Trinary operator
  74 
  75     interface FTriOp {
  76         $type$ apply(int i, $type$ a, $type$ b, $type$ c);
  77     }
  78 
  79     abstract $abstractvectortype$ tOp(Vector<$Boxtype$> v1, Vector<$Boxtype$> v2, FTriOp f);
  80 
  81     abstract $abstractvectortype$ tOp(Vector<$Boxtype$> v1, Vector<$Boxtype$> v2, VectorMask<$Boxtype$> m, FTriOp f);
  82 
  83     // Reduction operator
  84 
  85     abstract $type$ rOp($type$ v, FBinOp f);
  86 
  87     // Binary test
  88 
  89     interface FBinTest {
  90         boolean apply(int i, $type$ a, $type$ b);
  91     }
  92 
  93     abstract VectorMask<$Boxtype$> bTest(Vector<$Boxtype$> v, FBinTest f);
  94 
  95     // Foreach
  96 
  97     interface FUnCon {
  98         void apply(int i, $type$ a);
  99     }
 100 
 101     abstract void forEach(FUnCon f);
 102 
 103     abstract void forEach(VectorMask<$Boxtype$> m, FUnCon f);
 104 
 105     // Static factories
 106 
 107     /**
 108      * Returns a vector where all lane elements are set to the default
 109      * primitive value.
 110      *
 111      * @param species species of desired vector
 112      * @return a zero vector of given species
 113      */
 114     @ForceInline
 115     @SuppressWarnings("unchecked")
 116     public static $abstractvectortype$ zero(VectorSpecies<$Boxtype$> species) {
 117 #if[FP]
 118         return VectorIntrinsics.broadcastCoerced((Class<$Type$Vector>) species.vectorType(), $type$.class, species.length(),
 119                                                  $Type$.$type$To$Bitstype$Bits(0.0f), species,
 120                                                  ((bits, s) -> (($Type$Species)s).op(i -> $Type$.$bitstype$BitsTo$Type$(($bitstype$)bits))));
 121 #else[FP]
 122         return VectorIntrinsics.broadcastCoerced((Class<$Type$Vector>) species.vectorType(), $type$.class, species.length(),
 123                                                  0, species,
 124                                                  ((bits, s) -> (($Type$Species)s).op(i -> ($type$)bits)));
 125 #end[FP]
 126     }
 127 
 128     /**
 129      * Loads a vector from a byte array starting at an offset.
 130      * <p>
 131      * Bytes are composed into primitive lane elements according to the
 132      * native byte order of the underlying platform
 133      * <p>
 134      * This method behaves as if it returns the result of calling the
 135      * byte buffer, offset, and mask accepting
 136      * {@link #fromByteBuffer(VectorSpecies, ByteBuffer, int, VectorMask) method} as follows:
 137      * <pre>{@code
 138      * return fromByteBuffer(species, ByteBuffer.wrap(a), offset, VectorMask.allTrue());
 139      * }</pre>
 140      *
 141      * @param species species of desired vector
 142      * @param a the byte array
 143      * @param offset the offset into the array
 144      * @return a vector loaded from a byte array
 145      * @throws IndexOutOfBoundsException if {@code i < 0} or
 146      * {@code offset > a.length - (species.length() * species.elementSize() / Byte.SIZE)}
 147      */
 148     @ForceInline
 149     @SuppressWarnings("unchecked")
 150     public static $abstractvectortype$ fromByteArray(VectorSpecies<$Boxtype$> species, byte[] a, int offset) {
 151         Objects.requireNonNull(a);
 152         offset = VectorIntrinsics.checkIndex(offset, a.length, species.bitSize() / Byte.SIZE);
 153         return VectorIntrinsics.load((Class<$abstractvectortype$>) species.vectorType(), $type$.class, species.length(),
 154                                      a, ((long) offset) + Unsafe.ARRAY_BYTE_BASE_OFFSET,
 155                                      a, offset, species,
 156                                      (c, idx, s) -> {
 157                                          ByteBuffer bbc = ByteBuffer.wrap(c, idx, c.length - idx).order(ByteOrder.nativeOrder());
 158                                          $Type$Buffer tb = bbc{#if[byte]?;:.as$Type$Buffer();}
 159                                          return (($Type$Species)s).op(i -> tb.get());
 160                                      });
 161     }
 162 
 163     /**
 164      * Loads a vector from a byte array starting at an offset and using a
 165      * mask.
 166      * <p>
 167      * Bytes are composed into primitive lane elements according to the
 168      * native byte order of the underlying platform.
 169      * <p>
 170      * This method behaves as if it returns the result of calling the
 171      * byte buffer, offset, and mask accepting
 172      * {@link #fromByteBuffer(VectorSpecies, ByteBuffer, int, VectorMask) method} as follows:
 173      * <pre>{@code
 174      * return fromByteBuffer(species, ByteBuffer.wrap(a), offset, m);
 175      * }</pre>
 176      *
 177      * @param species species of desired vector
 178      * @param a the byte array
 179      * @param offset the offset into the array
 180      * @param m the mask
 181      * @return a vector loaded from a byte array
 182      * @throws IndexOutOfBoundsException if {@code offset < 0} or
 183      * for any vector lane index {@code N} where the mask at lane {@code N}
 184      * is set
 185      * {@code offset >= a.length - (N * species.elementSize() / Byte.SIZE)}
 186      */
 187     @ForceInline
 188     public static $abstractvectortype$ fromByteArray(VectorSpecies<$Boxtype$> species, byte[] a, int offset, VectorMask<$Boxtype$> m) {
 189         return zero(species).blend(fromByteArray(species, a, offset), m);
 190     }
 191 
 192     /**
 193      * Loads a vector from an array starting at offset.
 194      * <p>
 195      * For each vector lane, where {@code N} is the vector lane index, the
 196      * array element at index {@code offset + N} is placed into the
 197      * resulting vector at lane index {@code N}.
 198      *
 199      * @param species species of desired vector
 200      * @param a the array
 201      * @param offset the offset into the array
 202      * @return the vector loaded from an array
 203      * @throws IndexOutOfBoundsException if {@code offset < 0}, or
 204      * {@code offset > a.length - species.length()}
 205      */
 206     @ForceInline
 207     @SuppressWarnings("unchecked")
 208     public static $abstractvectortype$ fromArray(VectorSpecies<$Boxtype$> species, $type$[] a, int offset){
 209         Objects.requireNonNull(a);
 210         offset = VectorIntrinsics.checkIndex(offset, a.length, species.length());
 211         return VectorIntrinsics.load((Class<$abstractvectortype$>) species.vectorType(), $type$.class, species.length(),
 212                                      a, (((long) offset) << ARRAY_SHIFT) + Unsafe.ARRAY_$TYPE$_BASE_OFFSET,
 213                                      a, offset, species,
 214                                      (c, idx, s) -> (($Type$Species)s).op(n -> c[idx + n]));
 215     }
 216 
 217 
 218     /**
 219      * Loads a vector from an array starting at offset and using a mask.
 220      * <p>
 221      * For each vector lane, where {@code N} is the vector lane index,
 222      * if the mask lane at index {@code N} is set then the array element at
 223      * index {@code offset + N} is placed into the resulting vector at lane index
 224      * {@code N}, otherwise the default element value is placed into the
 225      * resulting vector at lane index {@code N}.
 226      *
 227      * @param species species of desired vector
 228      * @param a the array
 229      * @param offset the offset into the array
 230      * @param m the mask
 231      * @return the vector loaded from an array
 232      * @throws IndexOutOfBoundsException if {@code offset < 0}, or
 233      * for any vector lane index {@code N} where the mask at lane {@code N}
 234      * is set {@code offset > a.length - N}
 235      */
 236     @ForceInline
 237     public static $abstractvectortype$ fromArray(VectorSpecies<$Boxtype$> species, $type$[] a, int offset, VectorMask<$Boxtype$> m) {
 238         return zero(species).blend(fromArray(species, a, offset), m);
 239     }
 240 
 241     /**
 242      * Loads a vector from an array using indexes obtained from an index
 243      * map.
 244      * <p>
 245      * For each vector lane, where {@code N} is the vector lane index, the
 246      * array element at index {@code a_offset + indexMap[i_offset + N]} is placed into the
 247      * resulting vector at lane index {@code N}.
 248      *
 249      * @param species species of desired vector
 250      * @param a the array
 251      * @param a_offset the offset into the array, may be negative if relative
 252      * indexes in the index map compensate to produce a value within the
 253      * array bounds
 254      * @param indexMap the index map
 255      * @param i_offset the offset into the index map
 256      * @return the vector loaded from an array
 257      * @throws IndexOutOfBoundsException if {@code i_offset < 0}, or
 258      * {@code i_offset > indexMap.length - species.length()},
 259      * or for any vector lane index {@code N} the result of
 260      * {@code a_offset + indexMap[i_offset + N]} is {@code < 0} or {@code >= a.length}
 261      */
 262 #if[byteOrShort]
 263     public static $abstractvectortype$ fromArray(VectorSpecies<$Boxtype$> species, $type$[] a, int a_offset, int[] indexMap, int i_offset) {
 264         return (($Type$Species)species).op(n -> a[a_offset + indexMap[i_offset + n]]);
 265     }
 266 #else[byteOrShort]
 267     @ForceInline
 268     @SuppressWarnings("unchecked")
 269     public static $abstractvectortype$ fromArray(VectorSpecies<$Boxtype$> species, $type$[] a, int a_offset, int[] indexMap, int i_offset) {
 270         Objects.requireNonNull(a);
 271         Objects.requireNonNull(indexMap);
 272 
 273 #if[longOrDouble]
 274         if (species.length() == 1) {
 275           return $abstractvectortype$.fromArray(species, a, a_offset + indexMap[i_offset]);
 276         }
 277 #end[longOrDouble]
 278 
 279         // Index vector: vix[0:n] = k -> a_offset + indexMap[i_offset + k]
 280         IntVector vix = IntVector.fromArray(IntVector.species(species.indexShape()), indexMap, i_offset).add(a_offset);
 281 
 282         vix = VectorIntrinsics.checkIndex(vix, a.length);
 283 
 284         return VectorIntrinsics.loadWithMap((Class<$abstractvectortype$>) species.vectorType(), $type$.class, species.length(),
 285                                             IntVector.species(species.indexShape()).vectorType(), a, Unsafe.ARRAY_$TYPE$_BASE_OFFSET, vix,
 286                                             a, a_offset, indexMap, i_offset, species,
 287                                             ($type$[] c, int idx, int[] iMap, int idy, VectorSpecies<$Boxtype$> s) ->
 288                                                 (($Type$Species)s).op(n -> c[idx + iMap[idy+n]]));
 289         }
 290 
 291 #end[byteOrShort]
 292     /**
 293      * Loads a vector from an array using indexes obtained from an index
 294      * map and using a mask.
 295      * <p>
 296      * For each vector lane, where {@code N} is the vector lane index,
 297      * if the mask lane at index {@code N} is set then the array element at
 298      * index {@code a_offset + indexMap[i_offset + N]} is placed into the resulting vector
 299      * at lane index {@code N}.
 300      *
 301      * @param species species of desired vector
 302      * @param a the array
 303      * @param a_offset the offset into the array, may be negative if relative
 304      * indexes in the index map compensate to produce a value within the
 305      * array bounds
 306      * @param m the mask
 307      * @param indexMap the index map
 308      * @param i_offset the offset into the index map
 309      * @return the vector loaded from an array
 310      * @throws IndexOutOfBoundsException if {@code i_offset < 0}, or
 311      * {@code i_offset > indexMap.length - species.length()},
 312      * or for any vector lane index {@code N} where the mask at lane
 313      * {@code N} is set the result of {@code a_offset + indexMap[i_offset + N]} is
 314      * {@code < 0} or {@code >= a.length}
 315      */
 316 #if[byteOrShort]
 317     public static $abstractvectortype$ fromArray(VectorSpecies<$Boxtype$> species, $type$[] a, int a_offset, VectorMask<$Boxtype$> m, int[] indexMap, int i_offset) {
 318         return (($Type$Species)species).op(m, n -> a[a_offset + indexMap[i_offset + n]]);
 319     }
 320 #else[byteOrShort]
 321     @ForceInline
 322     @SuppressWarnings("unchecked")
 323     public static $abstractvectortype$ fromArray(VectorSpecies<$Boxtype$> species, $type$[] a, int a_offset, VectorMask<$Boxtype$> m, int[] indexMap, int i_offset) {
 324         // @@@ This can result in out of bounds errors for unset mask lanes
 325         return zero(species).blend(fromArray(species, a, a_offset, indexMap, i_offset), m);
 326     }
 327 
 328 #end[byteOrShort]
 329 
 330     /**
 331      * Loads a vector from a {@link ByteBuffer byte buffer} starting at an
 332      * offset into the byte buffer.
 333      * <p>
 334      * Bytes are composed into primitive lane elements according to the
 335      * native byte order of the underlying platform.
 336      * <p>
 337      * This method behaves as if it returns the result of calling the
 338      * byte buffer, offset, and mask accepting
 339      * {@link #fromByteBuffer(VectorSpecies, ByteBuffer, int, VectorMask)} method} as follows:
 340      * <pre>{@code
 341      *   return fromByteBuffer(b, offset, VectorMask.allTrue())
 342      * }</pre>
 343      *
 344      * @param species species of desired vector
 345      * @param bb the byte buffer
 346      * @param offset the offset into the byte buffer
 347      * @return a vector loaded from a byte buffer
 348      * @throws IndexOutOfBoundsException if the offset is {@code < 0},
 349      * or {@code > b.limit()},
 350      * or if there are fewer than
 351      * {@code species.length() * species.elementSize() / Byte.SIZE} bytes
 352      * remaining in the byte buffer from the given offset
 353      */
 354     @ForceInline
 355     @SuppressWarnings("unchecked")
 356     public static $abstractvectortype$ fromByteBuffer(VectorSpecies<$Boxtype$> species, ByteBuffer bb, int offset) {
 357         if (bb.order() != ByteOrder.nativeOrder()) {
 358             throw new IllegalArgumentException();
 359         }
 360         offset = VectorIntrinsics.checkIndex(offset, bb.limit(), species.bitSize() / Byte.SIZE);
 361         return VectorIntrinsics.load((Class<$abstractvectortype$>) species.vectorType(), $type$.class, species.length(),
 362                                      U.getReference(bb, BYTE_BUFFER_HB), U.getLong(bb, BUFFER_ADDRESS) + offset,
 363                                      bb, offset, species,
 364                                      (c, idx, s) -> {
 365                                          ByteBuffer bbc = c.duplicate().position(idx).order(ByteOrder.nativeOrder());
 366                                          $Type$Buffer tb = bbc{#if[byte]?;:.as$Type$Buffer();}
 367                                          return (($Type$Species)s).op(i -> tb.get());
 368                                      });
 369     }
 370 
 371     /**
 372      * Loads a vector from a {@link ByteBuffer byte buffer} starting at an
 373      * offset into the byte buffer and using a mask.
 374      * <p>
 375      * This method behaves as if the byte buffer is viewed as a primitive
 376      * {@link java.nio.Buffer buffer} for the primitive element type,
 377      * according to the native byte order of the underlying platform, and
 378      * the returned vector is loaded with a mask from a primitive array
 379      * obtained from the primitive buffer.
 380      * The following pseudocode expresses the behaviour, where
 381      * {@code EBuffer} is the primitive buffer type, {@code e} is the
 382      * primitive element type, and {@code ESpecies} is the primitive
 383      * species for {@code e}:
 384      * <pre>{@code
 385      * EBuffer eb = b.duplicate().
 386      *     order(ByteOrder.nativeOrder()).position(offset).
 387      *     asEBuffer();
 388      * e[] es = new e[species.length()];
 389      * for (int n = 0; n < t.length; n++) {
 390      *     if (m.isSet(n))
 391      *         es[n] = eb.get(n);
 392      * }
 393      * EVector r = EVector.fromArray(es, 0, m);
 394      * }</pre>
 395      *
 396      * @param species species of desired vector
 397      * @param bb the byte buffer
 398      * @param offset the offset into the byte buffer
 399      * @param m the mask
 400      * @return a vector loaded from a byte buffer
 401      * @throws IndexOutOfBoundsException if the offset is {@code < 0},
 402      * or {@code > b.limit()},
 403      * for any vector lane index {@code N} where the mask at lane {@code N}
 404      * is set
 405      * {@code offset >= b.limit() - (N * species.elementSize() / Byte.SIZE)}
 406      */
 407     @ForceInline
 408     public static $abstractvectortype$ fromByteBuffer(VectorSpecies<$Boxtype$> species, ByteBuffer bb, int offset, VectorMask<$Boxtype$> m) {
 409         return zero(species).blend(fromByteBuffer(species, bb, offset), m);
 410     }
 411 
 412     /**
 413      * Returns a vector where all lane elements are set to the primitive
 414      * value {@code e}.
 415      *
 416      * @param species species of the desired vector
 417      * @param e the value to be broadcasted
 418      * @return a vector of vector where all lane elements are set to
 419      * the primitive value {@code e}
 420      */
 421 #if[FP]
 422     @ForceInline
 423     @SuppressWarnings("unchecked")
 424     public static $abstractvectortype$ broadcast(VectorSpecies<$Boxtype$> species, $type$ e) {
 425         return VectorIntrinsics.broadcastCoerced(
 426             (Class<$abstractvectortype$>) species.vectorType(), $type$.class, species.length(),
 427             $Type$.$type$To$Bitstype$Bits(e), species,
 428             ((bits, sp) -> (($Type$Species)sp).op(i -> $Type$.$bitstype$BitsTo$Type$(($bitstype$)bits))));
 429     }
 430 #else[FP]
 431     @ForceInline
 432     @SuppressWarnings("unchecked")
 433     public static $abstractvectortype$ broadcast(VectorSpecies<$Boxtype$> species, $type$ e) {
 434         return VectorIntrinsics.broadcastCoerced(
 435             (Class<$abstractvectortype$>) species.vectorType(), $type$.class, species.length(),
 436             e, species,
 437             ((bits, sp) -> (($Type$Species)sp).op(i -> ($type$)bits)));
 438     }
 439 #end[FP]
 440 
 441     /**
 442      * Returns a vector where each lane element is set to given
 443      * primitive values.
 444      * <p>
 445      * For each vector lane, where {@code N} is the vector lane index, the
 446      * the primitive value at index {@code N} is placed into the resulting
 447      * vector at lane index {@code N}.
 448      *
 449      * @param species species of the desired vector
 450      * @param es the given primitive values
 451      * @return a vector where each lane element is set to given primitive
 452      * values
 453      * @throws IndexOutOfBoundsException if {@code es.length < species.length()}
 454      */
 455     @ForceInline
 456     @SuppressWarnings("unchecked")
 457     public static $abstractvectortype$ scalars(VectorSpecies<$Boxtype$> species, $type$... es) {
 458         Objects.requireNonNull(es);
 459         int ix = VectorIntrinsics.checkIndex(0, es.length, species.length());
 460         return VectorIntrinsics.load((Class<$abstractvectortype$>) species.vectorType(), $type$.class, species.length(),
 461                                      es, Unsafe.ARRAY_$TYPE$_BASE_OFFSET,
 462                                      es, ix, species,
 463                                      (c, idx, sp) -> (($Type$Species)sp).op(n -> c[idx + n]));
 464     }
 465 
 466     /**
 467      * Returns a vector where the first lane element is set to the primtive
 468      * value {@code e}, all other lane elements are set to the default
 469      * value.
 470      *
 471      * @param species species of the desired vector
 472      * @param e the value
 473      * @return a vector where the first lane element is set to the primitive
 474      * value {@code e}
 475      */
 476     @ForceInline
 477     public static final $abstractvectortype$ single(VectorSpecies<$Boxtype$> species, $type$ e) {
 478         return zero(species).with(0, e);
 479     }
 480 
 481     /**
 482      * Returns a vector where each lane element is set to a randomly
 483      * generated primitive value.
 484      *
 485      * The semantics are equivalent to calling
 486 #if[byteOrShort]
 487      * ($type$){@link ThreadLocalRandom#nextInt()}
 488 #else[byteOrShort]
 489      * {@link ThreadLocalRandom#next$Type$()}
 490 #end[byteOrShort]
 491      *
 492      * @param species species of the desired vector
 493      * @return a vector where each lane elements is set to a randomly
 494      * generated primitive value
 495      */
 496 #if[intOrLong]
 497     public static $abstractvectortype$ random(VectorSpecies<$Boxtype$> species) {
 498         ThreadLocalRandom r = ThreadLocalRandom.current();
 499         return (($Type$Species)species).op(i -> r.next$Type$());
 500     }
 501 #else[intOrLong]
 502 #if[FP]
 503     public static $abstractvectortype$ random(VectorSpecies<$Boxtype$> species) {
 504         ThreadLocalRandom r = ThreadLocalRandom.current();
 505         return (($Type$Species)species).op(i -> r.next$Type$());
 506     }
 507 #else[FP]
 508     public static $abstractvectortype$ random(VectorSpecies<$Boxtype$> species) {
 509         ThreadLocalRandom r = ThreadLocalRandom.current();
 510         return (($Type$Species)species).op(i -> ($type$) r.nextInt());
 511     }
 512 #end[FP]
 513 #end[intOrLong]
 514 
 515     // Ops
 516 
 517     /**
 518      * {@inheritDoc}
 519      */
 520     @Override
 521     public abstract $abstractvectortype$ add(Vector<$Boxtype$> v);
 522 
 523     /**
 524      * Adds this vector to the broadcast of an input scalar.
 525      * <p>
 526      * This is a lane-wise binary operation which applies the primitive addition operation
 527      * ({@code +}) to each lane.
 528      *
 529      * @param s the input scalar
 530      * @return the result of adding this vector to the broadcast of an input
 531      * scalar
 532      */
 533     public abstract $abstractvectortype$ add($type$ s);
 534 
 535     /**
 536      * {@inheritDoc}
 537      */
 538     @Override
 539     public abstract $abstractvectortype$ add(Vector<$Boxtype$> v, VectorMask<$Boxtype$> m);
 540 
 541     /**
 542      * Adds this vector to broadcast of an input scalar,
 543      * selecting lane elements controlled by a mask.
 544      * <p>
 545      * This is a lane-wise binary operation which applies the primitive addition operation
 546      * ({@code +}) to each lane.
 547      *
 548      * @param s the input scalar
 549      * @param m the mask controlling lane selection
 550      * @return the result of adding this vector to the broadcast of an input
 551      * scalar
 552      */
 553     public abstract $abstractvectortype$ add($type$ s, VectorMask<$Boxtype$> m);
 554 
 555     /**
 556      * {@inheritDoc}
 557      */
 558     @Override
 559     public abstract $abstractvectortype$ sub(Vector<$Boxtype$> v);
 560 
 561     /**
 562      * Subtracts the broadcast of an input scalar from this vector.
 563      * <p>
 564      * This is a lane-wise binary operation which applies the primitive subtraction
 565      * operation ({@code -}) to each lane.
 566      *
 567      * @param s the input scalar
 568      * @return the result of subtracting the broadcast of an input
 569      * scalar from this vector
 570      */
 571     public abstract $abstractvectortype$ sub($type$ s);
 572 
 573     /**
 574      * {@inheritDoc}
 575      */
 576     @Override
 577     public abstract $abstractvectortype$ sub(Vector<$Boxtype$> v, VectorMask<$Boxtype$> m);
 578 
 579     /**
 580      * Subtracts the broadcast of an input scalar from this vector, selecting
 581      * lane elements controlled by a mask.
 582      * <p>
 583      * This is a lane-wise binary operation which applies the primitive subtraction
 584      * operation ({@code -}) to each lane.
 585      *
 586      * @param s the input scalar
 587      * @param m the mask controlling lane selection
 588      * @return the result of subtracting the broadcast of an input
 589      * scalar from this vector
 590      */
 591     public abstract $abstractvectortype$ sub($type$ s, VectorMask<$Boxtype$> m);
 592 
 593     /**
 594      * {@inheritDoc}
 595      */
 596     @Override
 597     public abstract $abstractvectortype$ mul(Vector<$Boxtype$> v);
 598 
 599     /**
 600      * Multiplies this vector with the broadcast of an input scalar.
 601      * <p>
 602      * This is a lane-wise binary operation which applies the primitive multiplication
 603      * operation ({@code *}) to each lane.
 604      *
 605      * @param s the input scalar
 606      * @return the result of multiplying this vector with the broadcast of an
 607      * input scalar
 608      */
 609     public abstract $abstractvectortype$ mul($type$ s);
 610 
 611     /**
 612      * {@inheritDoc}
 613      */
 614     @Override
 615     public abstract $abstractvectortype$ mul(Vector<$Boxtype$> v, VectorMask<$Boxtype$> m);
 616 
 617     /**
 618      * Multiplies this vector with the broadcast of an input scalar, selecting
 619      * lane elements controlled by a mask.
 620      * <p>
 621      * This is a lane-wise binary operation which applies the primitive multiplication
 622      * operation ({@code *}) to each lane.
 623      *
 624      * @param s the input scalar
 625      * @param m the mask controlling lane selection
 626      * @return the result of multiplying this vector with the broadcast of an
 627      * input scalar
 628      */
 629     public abstract $abstractvectortype$ mul($type$ s, VectorMask<$Boxtype$> m);
 630 
 631     /**
 632      * {@inheritDoc}
 633      */
 634     @Override
 635     public abstract $abstractvectortype$ neg();
 636 
 637     /**
 638      * {@inheritDoc}
 639      */
 640     @Override
 641     public abstract $abstractvectortype$ neg(VectorMask<$Boxtype$> m);
 642 
 643     /**
 644      * {@inheritDoc}
 645      */
 646     @Override
 647     public abstract $abstractvectortype$ abs();
 648 
 649     /**
 650      * {@inheritDoc}
 651      */
 652     @Override
 653     public abstract $abstractvectortype$ abs(VectorMask<$Boxtype$> m);
 654 
 655     /**
 656      * {@inheritDoc}
 657      */
 658     @Override
 659     public abstract $abstractvectortype$ min(Vector<$Boxtype$> v);
 660 
 661     /**
 662      * {@inheritDoc}
 663      */
 664     @Override
 665     public abstract $abstractvectortype$ min(Vector<$Boxtype$> v, VectorMask<$Boxtype$> m);
 666 
 667     /**
 668      * Returns the minimum of this vector and the broadcast of an input scalar.
 669      * <p>
 670      * This is a lane-wise binary operation which applies the operation
 671      * {@code (a, b) -> Math.min(a, b)} to each lane.
 672      *
 673      * @param s the input scalar
 674      * @return the minimum of this vector and the broadcast of an input scalar
 675      */
 676     public abstract $abstractvectortype$ min($type$ s);
 677 
 678     /**
 679      * {@inheritDoc}
 680      */
 681     @Override
 682     public abstract $abstractvectortype$ max(Vector<$Boxtype$> v);
 683 
 684     /**
 685      * {@inheritDoc}
 686      */
 687     @Override
 688     public abstract $abstractvectortype$ max(Vector<$Boxtype$> v, VectorMask<$Boxtype$> m);
 689 
 690     /**
 691      * Returns the maximum of this vector and the broadcast of an input scalar.
 692      * <p>
 693      * This is a lane-wise binary operation which applies the operation
 694      * {@code (a, b) -> Math.max(a, b)} to each lane.
 695      *
 696      * @param s the input scalar
 697      * @return the maximum of this vector and the broadcast of an input scalar
 698      */
 699     public abstract $abstractvectortype$ max($type$ s);
 700 
 701     /**
 702      * {@inheritDoc}
 703      */
 704     @Override
 705     public abstract VectorMask<$Boxtype$> equal(Vector<$Boxtype$> v);
 706 
 707     /**
 708      * Tests if this vector is equal to the broadcast of an input scalar.
 709      * <p>
 710      * This is a lane-wise binary test operation which applies the primitive equals
 711      * operation ({@code ==}) each lane.
 712      *
 713      * @param s the input scalar
 714      * @return the result mask of testing if this vector is equal to the
 715      * broadcast of an input scalar
 716      */
 717     public abstract VectorMask<$Boxtype$> equal($type$ s);
 718 
 719     /**
 720      * {@inheritDoc}
 721      */
 722     @Override
 723     public abstract VectorMask<$Boxtype$> notEqual(Vector<$Boxtype$> v);
 724 
 725     /**
 726      * Tests if this vector is not equal to the broadcast of an input scalar.
 727      * <p>
 728      * This is a lane-wise binary test operation which applies the primitive not equals
 729      * operation ({@code !=}) to each lane.
 730      *
 731      * @param s the input scalar
 732      * @return the result mask of testing if this vector is not equal to the
 733      * broadcast of an input scalar
 734      */
 735     public abstract VectorMask<$Boxtype$> notEqual($type$ s);
 736 
 737     /**
 738      * {@inheritDoc}
 739      */
 740     @Override
 741     public abstract VectorMask<$Boxtype$> lessThan(Vector<$Boxtype$> v);
 742 
 743     /**
 744      * Tests if this vector is less than the broadcast of an input scalar.
 745      * <p>
 746      * This is a lane-wise binary test operation which applies the primitive less than
 747      * operation ({@code <}) to each lane.
 748      *
 749      * @param s the input scalar
 750      * @return the mask result of testing if this vector is less than the
 751      * broadcast of an input scalar
 752      */
 753     public abstract VectorMask<$Boxtype$> lessThan($type$ s);
 754 
 755     /**
 756      * {@inheritDoc}
 757      */
 758     @Override
 759     public abstract VectorMask<$Boxtype$> lessThanEq(Vector<$Boxtype$> v);
 760 
 761     /**
 762      * Tests if this vector is less or equal to the broadcast of an input scalar.
 763      * <p>
 764      * This is a lane-wise binary test operation which applies the primitive less than
 765      * or equal to operation ({@code <=}) to each lane.
 766      *
 767      * @param s the input scalar
 768      * @return the mask result of testing if this vector is less than or equal
 769      * to the broadcast of an input scalar
 770      */
 771     public abstract VectorMask<$Boxtype$> lessThanEq($type$ s);
 772 
 773     /**
 774      * {@inheritDoc}
 775      */
 776     @Override
 777     public abstract VectorMask<$Boxtype$> greaterThan(Vector<$Boxtype$> v);
 778 
 779     /**
 780      * Tests if this vector is greater than the broadcast of an input scalar.
 781      * <p>
 782      * This is a lane-wise binary test operation which applies the primitive greater than
 783      * operation ({@code >}) to each lane.
 784      *
 785      * @param s the input scalar
 786      * @return the mask result of testing if this vector is greater than the
 787      * broadcast of an input scalar
 788      */
 789     public abstract VectorMask<$Boxtype$> greaterThan($type$ s);
 790 
 791     /**
 792      * {@inheritDoc}
 793      */
 794     @Override
 795     public abstract VectorMask<$Boxtype$> greaterThanEq(Vector<$Boxtype$> v);
 796 
 797     /**
 798      * Tests if this vector is greater than or equal to the broadcast of an
 799      * input scalar.
 800      * <p>
 801      * This is a lane-wise binary test operation which applies the primitive greater than
 802      * or equal to operation ({@code >=}) to each lane.
 803      *
 804      * @param s the input scalar
 805      * @return the mask result of testing if this vector is greater than or
 806      * equal to the broadcast of an input scalar
 807      */
 808     public abstract VectorMask<$Boxtype$> greaterThanEq($type$ s);
 809 
 810     /**
 811      * {@inheritDoc}
 812      */
 813     @Override
 814     public abstract $abstractvectortype$ blend(Vector<$Boxtype$> v, VectorMask<$Boxtype$> m);
 815 
 816     /**
 817      * Blends the lane elements of this vector with those of the broadcast of an
 818      * input scalar, selecting lanes controlled by a mask.
 819      * <p>
 820      * For each lane of the mask, at lane index {@code N}, if the mask lane
 821      * is set then the lane element at {@code N} from the input vector is
 822      * selected and placed into the resulting vector at {@code N},
 823      * otherwise the the lane element at {@code N} from this input vector is
 824      * selected and placed into the resulting vector at {@code N}.
 825      *
 826      * @param s the input scalar
 827      * @param m the mask controlling lane selection
 828      * @return the result of blending the lane elements of this vector with
 829      * those of the broadcast of an input scalar
 830      */
 831     public abstract $abstractvectortype$ blend($type$ s, VectorMask<$Boxtype$> m);
 832 
 833     /**
 834      * {@inheritDoc}
 835      */
 836     @Override
 837     public abstract $abstractvectortype$ rearrange(Vector<$Boxtype$> v,
 838                                                       VectorShuffle<$Boxtype$> s, VectorMask<$Boxtype$> m);
 839 
 840     /**
 841      * {@inheritDoc}
 842      */
 843     @Override
 844     public abstract $abstractvectortype$ rearrange(VectorShuffle<$Boxtype$> m);
 845 
 846     /**
 847      * {@inheritDoc}
 848      */
 849     @Override
 850     public abstract $abstractvectortype$ reshape(VectorSpecies<$Boxtype$> s);
 851 
 852     /**
 853      * {@inheritDoc}
 854      */
 855     @Override
 856     public abstract $abstractvectortype$ rotateLanesLeft(int i);
 857 
 858     /**
 859      * {@inheritDoc}
 860      */
 861     @Override
 862     public abstract $abstractvectortype$ rotateLanesRight(int i);
 863 
 864     /**
 865      * {@inheritDoc}
 866      */
 867     @Override
 868     public abstract $abstractvectortype$ shiftLanesLeft(int i);
 869 
 870     /**
 871      * {@inheritDoc}
 872      */
 873     @Override
 874     public abstract $abstractvectortype$ shiftLanesRight(int i);
 875 
 876 #if[FP]
 877     /**
 878      * Divides this vector by an input vector.
 879      * <p>
 880      * This is a lane-wise binary operation which applies the primitive division
 881      * operation ({@code /}) to each lane.
 882      *
 883      * @param v the input vector
 884      * @return the result of dividing this vector by the input vector
 885      */
 886     public abstract $abstractvectortype$ div(Vector<$Boxtype$> v);
 887 
 888     /**
 889      * Divides this vector by the broadcast of an input scalar.
 890      * <p>
 891      * This is a lane-wise binary operation which applies the primitive division
 892      * operation ({@code /}) to each lane.
 893      *
 894      * @param s the input scalar
 895      * @return the result of dividing this vector by the broadcast of an input
 896      * scalar
 897      */
 898     public abstract $abstractvectortype$ div($type$ s);
 899 
 900     /**
 901      * Divides this vector by an input vector, selecting lane elements
 902      * controlled by a mask.
 903      * <p>
 904      * This is a lane-wise binary operation which applies the primitive division
 905      * operation ({@code /}) to each lane.
 906      *
 907      * @param v the input vector
 908      * @param m the mask controlling lane selection
 909      * @return the result of dividing this vector by the input vector
 910      */
 911     public abstract $abstractvectortype$ div(Vector<$Boxtype$> v, VectorMask<$Boxtype$> m);
 912 
 913     /**
 914      * Divides this vector by the broadcast of an input scalar, selecting lane
 915      * elements controlled by a mask.
 916      * <p>
 917      * This is a lane-wise binary operation which applies the primitive division
 918      * operation ({@code /}) to each lane.
 919      *
 920      * @param s the input scalar
 921      * @param m the mask controlling lane selection
 922      * @return the result of dividing this vector by the broadcast of an input
 923      * scalar
 924      */
 925     public abstract $abstractvectortype$ div($type$ s, VectorMask<$Boxtype$> m);
 926 
 927     /**
 928      * Calculates the square root of this vector.
 929      * <p>
 930      * This is a lane-wise unary operation which applies the {@link Math#sqrt} operation
 931      * to each lane.
 932      *
 933      * @return the square root of this vector
 934      */
 935     public abstract $abstractvectortype$ sqrt();
 936 
 937     /**
 938      * Calculates the square root of this vector, selecting lane elements
 939      * controlled by a mask.
 940      * <p>
 941      * This is a lane-wise unary operation which applies the {@link Math#sqrt} operation
 942      * to each lane.
 943      *
 944      * @param m the mask controlling lane selection
 945      * @return the square root of this vector
 946      */
 947     public $abstractvectortype$ sqrt(VectorMask<$Boxtype$> m) {
 948         return uOp(m, (i, a) -> ($type$) Math.sqrt((double) a));
 949     }
 950 
 951     /**
 952      * Calculates the trigonometric tangent of this vector.
 953      * <p>
 954      * This is a lane-wise unary operation with same semantic definition as
 955      * {@link Math#tan} operation applied to each lane.
 956      * The implementation is not required to return same
 957      * results as {@link Math#tan}, but adheres to rounding, monotonicity,
 958      * and special case semantics as defined in the {@link Math#tan}
 959      * specifications. The computed result will be within 1 ulp of the
 960      * exact result.
 961      *
 962      * @return the tangent of this vector
 963      */
 964     public $abstractvectortype$ tan() {
 965         return uOp((i, a) -> ($type$) Math.tan((double) a));
 966     }
 967 
 968     /**
 969      * Calculates the trigonometric tangent of this vector, selecting lane
 970      * elements controlled by a mask.
 971      * <p>
 972      * Semantics for rounding, monotonicity, and special cases are
 973      * described in {@link $abstractvectortype$#tan}
 974      *
 975      * @param m the mask controlling lane selection
 976      * @return the tangent of this vector
 977      */
 978     public $abstractvectortype$ tan(VectorMask<$Boxtype$> m) {
 979         return uOp(m, (i, a) -> ($type$) Math.tan((double) a));
 980     }
 981 
 982     /**
 983      * Calculates the hyperbolic tangent of this vector.
 984      * <p>
 985      * This is a lane-wise unary operation with same semantic definition as
 986      * {@link Math#tanh} operation applied to each lane.
 987      * The implementation is not required to return same
 988      * results as {@link Math#tanh}, but adheres to rounding, monotonicity,
 989      * and special case semantics as defined in the {@link Math#tanh}
 990      * specifications. The computed result will be within 2.5 ulps of the
 991      * exact result.
 992      *
 993      * @return the hyperbolic tangent of this vector
 994      */
 995     public $abstractvectortype$ tanh() {
 996         return uOp((i, a) -> ($type$) Math.tanh((double) a));
 997     }
 998 
 999     /**
1000      * Calculates the hyperbolic tangent of this vector, selecting lane elements
1001      * controlled by a mask.
1002      * <p>
1003      * Semantics for rounding, monotonicity, and special cases are
1004      * described in {@link $abstractvectortype$#tanh}
1005      *
1006      * @param m the mask controlling lane selection
1007      * @return the hyperbolic tangent of this vector
1008      */
1009     public $abstractvectortype$ tanh(VectorMask<$Boxtype$> m) {
1010         return uOp(m, (i, a) -> ($type$) Math.tanh((double) a));
1011     }
1012 
1013     /**
1014      * Calculates the trigonometric sine of this vector.
1015      * <p>
1016      * This is a lane-wise unary operation with same semantic definition as
1017      * {@link Math#sin} operation applied to each lane.
1018      * The implementation is not required to return same
1019      * results as {@link Math#sin}, but adheres to rounding, monotonicity,
1020      * and special case semantics as defined in the {@link Math#sin}
1021      * specifications. The computed result will be within 1 ulp of the
1022      * exact result.
1023      *
1024      * @return the sine of this vector
1025      */
1026     public $abstractvectortype$ sin() {
1027         return uOp((i, a) -> ($type$) Math.sin((double) a));
1028     }
1029 
1030     /**
1031      * Calculates the trigonometric sine of this vector, selecting lane elements
1032      * controlled by a mask.
1033      * <p>
1034      * Semantics for rounding, monotonicity, and special cases are
1035      * described in {@link $abstractvectortype$#sin}
1036      *
1037      * @param m the mask controlling lane selection
1038      * @return the sine of this vector
1039      */
1040     public $abstractvectortype$ sin(VectorMask<$Boxtype$> m) {
1041         return uOp(m, (i, a) -> ($type$) Math.sin((double) a));
1042     }
1043 
1044     /**
1045      * Calculates the hyperbolic sine of this vector.
1046      * <p>
1047      * This is a lane-wise unary operation with same semantic definition as
1048      * {@link Math#sinh} operation applied to each lane.
1049      * The implementation is not required to return same
1050      * results as  {@link Math#sinh}, but adheres to rounding, monotonicity,
1051      * and special case semantics as defined in the {@link Math#sinh}
1052      * specifications. The computed result will be within 2.5 ulps of the
1053      * exact result.
1054      *
1055      * @return the hyperbolic sine of this vector
1056      */
1057     public $abstractvectortype$ sinh() {
1058         return uOp((i, a) -> ($type$) Math.sinh((double) a));
1059     }
1060 
1061     /**
1062      * Calculates the hyperbolic sine of this vector, selecting lane elements
1063      * controlled by a mask.
1064      * <p>
1065      * Semantics for rounding, monotonicity, and special cases are
1066      * described in {@link $abstractvectortype$#sinh}
1067      *
1068      * @param m the mask controlling lane selection
1069      * @return the hyperbolic sine of this vector
1070      */
1071     public $abstractvectortype$ sinh(VectorMask<$Boxtype$> m) {
1072         return uOp(m, (i, a) -> ($type$) Math.sinh((double) a));
1073     }
1074 
1075     /**
1076      * Calculates the trigonometric cosine of this vector.
1077      * <p>
1078      * This is a lane-wise unary operation with same semantic definition as
1079      * {@link Math#cos} operation applied to each lane.
1080      * The implementation is not required to return same
1081      * results as {@link Math#cos}, but adheres to rounding, monotonicity,
1082      * and special case semantics as defined in the {@link Math#cos}
1083      * specifications. The computed result will be within 1 ulp of the
1084      * exact result.
1085      *
1086      * @return the cosine of this vector
1087      */
1088     public $abstractvectortype$ cos() {
1089         return uOp((i, a) -> ($type$) Math.cos((double) a));
1090     }
1091 
1092     /**
1093      * Calculates the trigonometric cosine of this vector, selecting lane
1094      * elements controlled by a mask.
1095      * <p>
1096      * Semantics for rounding, monotonicity, and special cases are
1097      * described in {@link $abstractvectortype$#cos}
1098      *
1099      * @param m the mask controlling lane selection
1100      * @return the cosine of this vector
1101      */
1102     public $abstractvectortype$ cos(VectorMask<$Boxtype$> m) {
1103         return uOp(m, (i, a) -> ($type$) Math.cos((double) a));
1104     }
1105 
1106     /**
1107      * Calculates the hyperbolic cosine of this vector.
1108      * <p>
1109      * This is a lane-wise unary operation with same semantic definition as
1110      * {@link Math#cosh} operation applied to each lane.
1111      * The implementation is not required to return same
1112      * results as {@link Math#cosh}, but adheres to rounding, monotonicity,
1113      * and special case semantics as defined in the {@link Math#cosh}
1114      * specifications. The computed result will be within 2.5 ulps of the
1115      * exact result.
1116      *
1117      * @return the hyperbolic cosine of this vector
1118      */
1119     public $abstractvectortype$ cosh() {
1120         return uOp((i, a) -> ($type$) Math.cosh((double) a));
1121     }
1122 
1123     /**
1124      * Calculates the hyperbolic cosine of this vector, selecting lane elements
1125      * controlled by a mask.
1126      * <p>
1127      * Semantics for rounding, monotonicity, and special cases are
1128      * described in {@link $abstractvectortype$#cosh}
1129      *
1130      * @param m the mask controlling lane selection
1131      * @return the hyperbolic cosine of this vector
1132      */
1133     public $abstractvectortype$ cosh(VectorMask<$Boxtype$> m) {
1134         return uOp(m, (i, a) -> ($type$) Math.cosh((double) a));
1135     }
1136 
1137     /**
1138      * Calculates the arc sine of this vector.
1139      * <p>
1140      * This is a lane-wise unary operation with same semantic definition as
1141      * {@link Math#asin} operation applied to each lane.
1142      * The implementation is not required to return same
1143      * results as {@link Math#asin}, but adheres to rounding, monotonicity,
1144      * and special case semantics as defined in the {@link Math#asin}
1145      * specifications. The computed result will be within 1 ulp of the
1146      * exact result.
1147      *
1148      * @return the arc sine of this vector
1149      */
1150     public $abstractvectortype$ asin() {
1151         return uOp((i, a) -> ($type$) Math.asin((double) a));
1152     }
1153 
1154     /**
1155      * Calculates the arc sine of this vector, selecting lane elements
1156      * controlled by a mask.
1157      * <p>
1158      * Semantics for rounding, monotonicity, and special cases are
1159      * described in {@link $abstractvectortype$#asin}
1160      *
1161      * @param m the mask controlling lane selection
1162      * @return the arc sine of this vector
1163      */
1164     public $abstractvectortype$ asin(VectorMask<$Boxtype$> m) {
1165         return uOp(m, (i, a) -> ($type$) Math.asin((double) a));
1166     }
1167 
1168     /**
1169      * Calculates the arc cosine of this vector.
1170      * <p>
1171      * This is a lane-wise unary operation with same semantic definition as
1172      * {@link Math#acos} operation applied to each lane.
1173      * The implementation is not required to return same
1174      * results as {@link Math#acos}, but adheres to rounding, monotonicity,
1175      * and special case semantics as defined in the {@link Math#acos}
1176      * specifications. The computed result will be within 1 ulp of the
1177      * exact result.
1178      *
1179      * @return the arc cosine of this vector
1180      */
1181     public $abstractvectortype$ acos() {
1182         return uOp((i, a) -> ($type$) Math.acos((double) a));
1183     }
1184 
1185     /**
1186      * Calculates the arc cosine of this vector, selecting lane elements
1187      * controlled by a mask.
1188      * <p>
1189      * Semantics for rounding, monotonicity, and special cases are
1190      * described in {@link $abstractvectortype$#acos}
1191      *
1192      * @param m the mask controlling lane selection
1193      * @return the arc cosine of this vector
1194      */
1195     public $abstractvectortype$ acos(VectorMask<$Boxtype$> m) {
1196         return uOp(m, (i, a) -> ($type$) Math.acos((double) a));
1197     }
1198 
1199     /**
1200      * Calculates the arc tangent of this vector.
1201      * <p>
1202      * This is a lane-wise unary operation with same semantic definition as
1203      * {@link Math#atan} operation applied to each lane.
1204      * The implementation is not required to return same
1205      * results as {@link Math#atan}, but adheres to rounding, monotonicity,
1206      * and special case semantics as defined in the {@link Math#atan}
1207      * specifications. The computed result will be within 1 ulp of the
1208      * exact result.
1209      *
1210      * @return the arc tangent of this vector
1211      */
1212     public $abstractvectortype$ atan() {
1213         return uOp((i, a) -> ($type$) Math.atan((double) a));
1214     }
1215 
1216     /**
1217      * Calculates the arc tangent of this vector, selecting lane elements
1218      * controlled by a mask.
1219      * <p>
1220      * Semantics for rounding, monotonicity, and special cases are
1221      * described in {@link $abstractvectortype$#atan}
1222      *
1223      * @param m the mask controlling lane selection
1224      * @return the arc tangent of this vector
1225      */
1226     public $abstractvectortype$ atan(VectorMask<$Boxtype$> m) {
1227         return uOp(m, (i, a) -> ($type$) Math.atan((double) a));
1228     }
1229 
1230     /**
1231      * Calculates the arc tangent of this vector divided by an input vector.
1232      * <p>
1233      * This is a lane-wise binary operation with same semantic definition as
1234      * {@link Math#atan2} operation applied to each lane.
1235      * The implementation is not required to return same
1236      * results as {@link Math#atan2}, but adheres to rounding, monotonicity,
1237      * and special case semantics as defined in the {@link Math#atan2}
1238      * specifications. The computed result will be within 2 ulps of the
1239      * exact result.
1240      *
1241      * @param v the input vector
1242      * @return the arc tangent of this vector divided by the input vector
1243      */
1244     public $abstractvectortype$ atan2(Vector<$Boxtype$> v) {
1245         return bOp(v, (i, a, b) -> ($type$) Math.atan2((double) a, (double) b));
1246     }
1247 
1248     /**
1249      * Calculates the arc tangent of this vector divided by the broadcast of an
1250      * an input scalar.
1251      * <p>
1252      * This is a lane-wise binary operation with same semantic definition as
1253      * {@link Math#atan2} operation applied to each lane.
1254      * The implementation is not required to return same
1255      * results as {@link Math#atan2}, but adheres to rounding, monotonicity,
1256      * and special case semantics as defined in the {@link Math#atan2}
1257      * specifications. The computed result will be within 1 ulp of the
1258      * exact result.
1259      *
1260      * @param s the input scalar
1261      * @return the arc tangent of this vector over the input vector
1262      */
1263     public abstract $abstractvectortype$ atan2($type$ s);
1264 
1265     /**
1266      * Calculates the arc tangent of this vector divided by an input vector,
1267      * selecting lane elements controlled by a mask.
1268      * <p>
1269      * Semantics for rounding, monotonicity, and special cases are
1270      * described in {@link $abstractvectortype$#atan2}
1271      *
1272      * @param v the input vector
1273      * @param m the mask controlling lane selection
1274      * @return the arc tangent of this vector divided by the input vector
1275      */
1276     public $abstractvectortype$ atan2(Vector<$Boxtype$> v, VectorMask<$Boxtype$> m) {
1277         return bOp(v, m, (i, a, b) -> ($type$) Math.atan2((double) a, (double) b));
1278     }
1279 
1280     /**
1281      * Calculates the arc tangent of this vector divided by the broadcast of an
1282      * an input scalar, selecting lane elements controlled by a mask.
1283      * <p>
1284      * Semantics for rounding, monotonicity, and special cases are
1285      * described in {@link $abstractvectortype$#atan2}
1286      *
1287      * @param s the input scalar
1288      * @param m the mask controlling lane selection
1289      * @return the arc tangent of this vector over the input vector
1290      */
1291     public abstract $abstractvectortype$ atan2($type$ s, VectorMask<$Boxtype$> m);
1292 
1293     /**
1294      * Calculates the cube root of this vector.
1295      * <p>
1296      * This is a lane-wise unary operation with same semantic definition as
1297      * {@link Math#cbrt} operation applied to each lane.
1298      * The implementation is not required to return same
1299      * results as {@link Math#cbrt}, but adheres to rounding, monotonicity,
1300      * and special case semantics as defined in the {@link Math#cbrt}
1301      * specifications. The computed result will be within 1 ulp of the
1302      * exact result.
1303      *
1304      * @return the cube root of this vector
1305      */
1306     public $abstractvectortype$ cbrt() {
1307         return uOp((i, a) -> ($type$) Math.cbrt((double) a));
1308     }
1309 
1310     /**
1311      * Calculates the cube root of this vector, selecting lane elements
1312      * controlled by a mask.
1313      * <p>
1314      * Semantics for rounding, monotonicity, and special cases are
1315      * described in {@link $abstractvectortype$#cbrt}
1316      *
1317      * @param m the mask controlling lane selection
1318      * @return the cube root of this vector
1319      */
1320     public $abstractvectortype$ cbrt(VectorMask<$Boxtype$> m) {
1321         return uOp(m, (i, a) -> ($type$) Math.cbrt((double) a));
1322     }
1323 
1324     /**
1325      * Calculates the natural logarithm of this vector.
1326      * <p>
1327      * This is a lane-wise unary operation with same semantic definition as
1328      * {@link Math#log} operation applied to each lane.
1329      * The implementation is not required to return same
1330      * results as {@link Math#log}, but adheres to rounding, monotonicity,
1331      * and special case semantics as defined in the {@link Math#log}
1332      * specifications. The computed result will be within 1 ulp of the
1333      * exact result.
1334      *
1335      * @return the natural logarithm of this vector
1336      */
1337     public $abstractvectortype$ log() {
1338         return uOp((i, a) -> ($type$) Math.log((double) a));
1339     }
1340 
1341     /**
1342      * Calculates the natural logarithm of this vector, selecting lane elements
1343      * controlled by a mask.
1344      * <p>
1345      * Semantics for rounding, monotonicity, and special cases are
1346      * described in {@link $abstractvectortype$#log}
1347      *
1348      * @param m the mask controlling lane selection
1349      * @return the natural logarithm of this vector
1350      */
1351     public $abstractvectortype$ log(VectorMask<$Boxtype$> m) {
1352         return uOp(m, (i, a) -> ($type$) Math.log((double) a));
1353     }
1354 
1355     /**
1356      * Calculates the base 10 logarithm of this vector.
1357      * <p>
1358      * This is a lane-wise unary operation with same semantic definition as
1359      * {@link Math#log10} operation applied to each lane.
1360      * The implementation is not required to return same
1361      * results as {@link Math#log10}, but adheres to rounding, monotonicity,
1362      * and special case semantics as defined in the {@link Math#log10}
1363      * specifications. The computed result will be within 1 ulp of the
1364      * exact result.
1365      *
1366      * @return the base 10 logarithm of this vector
1367      */
1368     public $abstractvectortype$ log10() {
1369         return uOp((i, a) -> ($type$) Math.log10((double) a));
1370     }
1371 
1372     /**
1373      * Calculates the base 10 logarithm of this vector, selecting lane elements
1374      * controlled by a mask.
1375      * <p>
1376      * Semantics for rounding, monotonicity, and special cases are
1377      * described in {@link $abstractvectortype$#log10}
1378      *
1379      * @param m the mask controlling lane selection
1380      * @return the base 10 logarithm of this vector
1381      */
1382     public $abstractvectortype$ log10(VectorMask<$Boxtype$> m) {
1383         return uOp(m, (i, a) -> ($type$) Math.log10((double) a));
1384     }
1385 
1386     /**
1387      * Calculates the natural logarithm of the sum of this vector and the
1388      * broadcast of {@code 1}.
1389      * <p>
1390      * This is a lane-wise unary operation with same semantic definition as
1391      * {@link Math#log1p} operation applied to each lane.
1392      * The implementation is not required to return same
1393      * results as  {@link Math#log1p}, but adheres to rounding, monotonicity,
1394      * and special case semantics as defined in the {@link Math#log1p}
1395      * specifications. The computed result will be within 1 ulp of the
1396      * exact result.
1397      *
1398      * @return the natural logarithm of the sum of this vector and the broadcast
1399      * of {@code 1}
1400      */
1401     public $abstractvectortype$ log1p() {
1402         return uOp((i, a) -> ($type$) Math.log1p((double) a));
1403     }
1404 
1405     /**
1406      * Calculates the natural logarithm of the sum of this vector and the
1407      * broadcast of {@code 1}, selecting lane elements controlled by a mask.
1408      * <p>
1409      * Semantics for rounding, monotonicity, and special cases are
1410      * described in {@link $abstractvectortype$#log1p}
1411      *
1412      * @param m the mask controlling lane selection
1413      * @return the natural logarithm of the sum of this vector and the broadcast
1414      * of {@code 1}
1415      */
1416     public $abstractvectortype$ log1p(VectorMask<$Boxtype$> m) {
1417         return uOp(m, (i, a) -> ($type$) Math.log1p((double) a));
1418     }
1419 
1420     /**
1421      * Calculates this vector raised to the power of an input vector.
1422      * <p>
1423      * This is a lane-wise binary operation with same semantic definition as
1424      * {@link Math#pow} operation applied to each lane.
1425      * The implementation is not required to return same
1426      * results as {@link Math#pow}, but adheres to rounding, monotonicity,
1427      * and special case semantics as defined in the {@link Math#pow}
1428      * specifications. The computed result will be within 1 ulp of the
1429      * exact result.
1430      *
1431      * @param v the input vector
1432      * @return this vector raised to the power of an input vector
1433      */
1434     public $abstractvectortype$ pow(Vector<$Boxtype$> v) {
1435         return bOp(v, (i, a, b) -> ($type$) Math.pow((double) a, (double) b));
1436     }
1437 
1438     /**
1439      * Calculates this vector raised to the power of the broadcast of an input
1440      * scalar.
1441      * <p>
1442      * This is a lane-wise binary operation with same semantic definition as
1443      * {@link Math#pow} operation applied to each lane.
1444      * The implementation is not required to return same
1445      * results as {@link Math#pow}, but adheres to rounding, monotonicity,
1446      * and special case semantics as defined in the {@link Math#pow}
1447      * specifications. The computed result will be within 1 ulp of the
1448      * exact result.
1449      *
1450      * @param s the input scalar
1451      * @return this vector raised to the power of the broadcast of an input
1452      * scalar.
1453      */
1454     public abstract $abstractvectortype$ pow($type$ s);
1455 
1456     /**
1457      * Calculates this vector raised to the power of an input vector, selecting
1458      * lane elements controlled by a mask.
1459      * <p>
1460      * Semantics for rounding, monotonicity, and special cases are
1461      * described in {@link $abstractvectortype$#pow}
1462      *
1463      * @param v the input vector
1464      * @param m the mask controlling lane selection
1465      * @return this vector raised to the power of an input vector
1466      */
1467     public $abstractvectortype$ pow(Vector<$Boxtype$> v, VectorMask<$Boxtype$> m) {
1468         return bOp(v, m, (i, a, b) -> ($type$) Math.pow((double) a, (double) b));
1469     }
1470 
1471     /**
1472      * Calculates this vector raised to the power of the broadcast of an input
1473      * scalar, selecting lane elements controlled by a mask.
1474      * <p>
1475      * Semantics for rounding, monotonicity, and special cases are
1476      * described in {@link $abstractvectortype$#pow}
1477      *
1478      * @param s the input scalar
1479      * @param m the mask controlling lane selection
1480      * @return this vector raised to the power of the broadcast of an input
1481      * scalar.
1482      */
1483     public abstract $abstractvectortype$ pow($type$ s, VectorMask<$Boxtype$> m);
1484 
1485     /**
1486      * Calculates the broadcast of Euler's number {@code e} raised to the power
1487      * of this vector.
1488      * <p>
1489      * This is a lane-wise unary operation with same semantic definition as
1490      * {@link Math#exp} operation applied to each lane.
1491      * The implementation is not required to return same
1492      * results as {@link Math#exp}, but adheres to rounding, monotonicity,
1493      * and special case semantics as defined in the {@link Math#exp}
1494      * specifications. The computed result will be within 1 ulp of the
1495      * exact result.
1496      *
1497      * @return the broadcast of Euler's number {@code e} raised to the power of
1498      * this vector
1499      */
1500     public $abstractvectortype$ exp() {
1501         return uOp((i, a) -> ($type$) Math.exp((double) a));
1502     }
1503 
1504     /**
1505      * Calculates the broadcast of Euler's number {@code e} raised to the power
1506      * of this vector, selecting lane elements controlled by a mask.
1507      * <p>
1508      * Semantics for rounding, monotonicity, and special cases are
1509      * described in {@link $abstractvectortype$#exp}
1510      *
1511      * @param m the mask controlling lane selection
1512      * @return the broadcast of Euler's number {@code e} raised to the power of
1513      * this vector
1514      */
1515     public $abstractvectortype$ exp(VectorMask<$Boxtype$> m) {
1516         return uOp(m, (i, a) -> ($type$) Math.exp((double) a));
1517     }
1518 
1519     /**
1520      * Calculates the broadcast of Euler's number {@code e} raised to the power
1521      * of this vector minus the broadcast of {@code -1}.
1522      * More specifically as if the following (ignoring any differences in
1523      * numerical accuracy):
1524      * <pre>{@code
1525      *   this.exp().sub(EVector.broadcast(this.species(), 1))
1526      * }</pre>
1527      * <p>
1528      * This is a lane-wise unary operation with same semantic definition as
1529      * {@link Math#expm1} operation applied to each lane.
1530      * The implementation is not required to return same
1531      * results as {@link Math#expm1}, but adheres to rounding, monotonicity,
1532      * and special case semantics as defined in the {@link Math#expm1}
1533      * specifications. The computed result will be within 1 ulp of the
1534      * exact result.
1535      *
1536      * @return the broadcast of Euler's number {@code e} raised to the power of
1537      * this vector minus the broadcast of {@code -1}
1538      */
1539     public $abstractvectortype$ expm1() {
1540         return uOp((i, a) -> ($type$) Math.expm1((double) a));
1541     }
1542 
1543     /**
1544      * Calculates the broadcast of Euler's number {@code e} raised to the power
1545      * of this vector minus the broadcast of {@code -1}, selecting lane elements
1546      * controlled by a mask
1547      * More specifically as if the following (ignoring any differences in
1548      * numerical accuracy):
1549      * <pre>{@code
1550      *   this.exp(m).sub(EVector.broadcast(this.species(), 1), m)
1551      * }</pre>
1552      * <p>
1553      * Semantics for rounding, monotonicity, and special cases are
1554      * described in {@link $abstractvectortype$#expm1}
1555      *
1556      * @param m the mask controlling lane selection
1557      * @return the broadcast of Euler's number {@code e} raised to the power of
1558      * this vector minus the broadcast of {@code -1}
1559      */
1560     public $abstractvectortype$ expm1(VectorMask<$Boxtype$> m) {
1561         return uOp(m, (i, a) -> ($type$) Math.expm1((double) a));
1562     }
1563 
1564     /**
1565      * Calculates the product of this vector and a first input vector summed
1566      * with a second input vector.
1567      * More specifically as if the following (ignoring any differences in
1568      * numerical accuracy):
1569      * <pre>{@code
1570      *   this.mul(v1).add(v2)
1571      * }</pre>
1572      * <p>
1573      * This is a lane-wise ternary operation which applies the {@link Math#fma} operation
1574      * to each lane.
1575      *
1576      * @param v1 the first input vector
1577      * @param v2 the second input vector
1578      * @return the product of this vector and the first input vector summed with
1579      * the second input vector
1580      */
1581     public abstract $abstractvectortype$ fma(Vector<$Boxtype$> v1, Vector<$Boxtype$> v2);
1582 
1583     /**
1584      * Calculates the product of this vector and the broadcast of a first input
1585      * scalar summed with the broadcast of a second input scalar.
1586      * More specifically as if the following:
1587      * <pre>{@code
1588      *   this.fma(EVector.broadcast(this.species(), s1), EVector.broadcast(this.species(), s2))
1589      * }</pre>
1590      * <p>
1591      * This is a lane-wise ternary operation which applies the {@link Math#fma} operation
1592      * to each lane.
1593      *
1594      * @param s1 the first input scalar
1595      * @param s2 the second input scalar
1596      * @return the product of this vector and the broadcast of a first input
1597      * scalar summed with the broadcast of a second input scalar
1598      */
1599     public abstract $abstractvectortype$ fma($type$ s1, $type$ s2);
1600 
1601     /**
1602      * Calculates the product of this vector and a first input vector summed
1603      * with a second input vector, selecting lane elements controlled by a mask.
1604      * More specifically as if the following (ignoring any differences in
1605      * numerical accuracy):
1606      * <pre>{@code
1607      *   this.mul(v1, m).add(v2, m)
1608      * }</pre>
1609      * <p>
1610      * This is a lane-wise ternary operation which applies the {@link Math#fma} operation
1611      * to each lane.
1612      *
1613      * @param v1 the first input vector
1614      * @param v2 the second input vector
1615      * @param m the mask controlling lane selection
1616      * @return the product of this vector and the first input vector summed with
1617      * the second input vector
1618      */
1619     public $abstractvectortype$ fma(Vector<$Boxtype$> v1, Vector<$Boxtype$> v2, VectorMask<$Boxtype$> m) {
1620         return tOp(v1, v2, m, (i, a, b, c) -> Math.fma(a, b, c));
1621     }
1622 
1623     /**
1624      * Calculates the product of this vector and the broadcast of a first input
1625      * scalar summed with the broadcast of a second input scalar, selecting lane
1626      * elements controlled by a mask
1627      * More specifically as if the following:
1628      * <pre>{@code
1629      *   this.fma(EVector.broadcast(this.species(), s1), EVector.broadcast(this.species(), s2), m)
1630      * }</pre>
1631      * <p>
1632      * This is a lane-wise ternary operation which applies the {@link Math#fma} operation
1633      * to each lane.
1634      *
1635      * @param s1 the first input scalar
1636      * @param s2 the second input scalar
1637      * @param m the mask controlling lane selection
1638      * @return the product of this vector and the broadcast of a first input
1639      * scalar summed with the broadcast of a second input scalar
1640      */
1641     public abstract $abstractvectortype$ fma($type$ s1, $type$ s2, VectorMask<$Boxtype$> m);
1642 
1643     /**
1644      * Calculates square root of the sum of the squares of this vector and an
1645      * input vector.
1646      * More specifically as if the following (ignoring any differences in
1647      * numerical accuracy):
1648      * <pre>{@code
1649      *   this.mul(this).add(v.mul(v)).sqrt()
1650      * }</pre>
1651      * <p>
1652      * This is a lane-wise binary operation with same semantic definition as
1653      * {@link Math#hypot} operation applied to each lane.
1654      * The implementation is not required to return same
1655      * results as {@link Math#hypot}, but adheres to rounding, monotonicity,
1656      * and special case semantics as defined in the {@link Math#hypot}
1657      * specifications. The computed result will be within 1 ulp of the
1658      * exact result.
1659      *
1660      * @param v the input vector
1661      * @return square root of the sum of the squares of this vector and an input
1662      * vector
1663      */
1664     public $abstractvectortype$ hypot(Vector<$Boxtype$> v) {
1665         return bOp(v, (i, a, b) -> ($type$) Math.hypot((double) a, (double) b));
1666     }
1667 
1668     /**
1669      * Calculates square root of the sum of the squares of this vector and the
1670      * broadcast of an input scalar.
1671      * More specifically as if the following (ignoring any differences in
1672      * numerical accuracy):
1673      * <pre>{@code
1674      *   this.mul(this).add(EVector.broadcast(this.species(), s * s)).sqrt()
1675      * }</pre>
1676      * <p>
1677      * This is a lane-wise binary operation with same semantic definition as
1678      * {@link Math#hypot} operation applied to each.
1679      * The implementation is not required to return same
1680      * results as {@link Math#hypot}, but adheres to rounding, monotonicity,
1681      * and special case semantics as defined in the {@link Math#hypot}
1682      * specifications. The computed result will be within 1 ulp of the
1683      * exact result.
1684      *
1685      * @param s the input scalar
1686      * @return square root of the sum of the squares of this vector and the
1687      * broadcast of an input scalar
1688      */
1689     public abstract $abstractvectortype$ hypot($type$ s);
1690 
1691     /**
1692      * Calculates square root of the sum of the squares of this vector and an
1693      * input vector, selecting lane elements controlled by a mask.
1694      * More specifically as if the following (ignoring any differences in
1695      * numerical accuracy):
1696      * <pre>{@code
1697      *   this.mul(this, m).add(v.mul(v), m).sqrt(m)
1698      * }</pre>
1699      * <p>
1700      * Semantics for rounding, monotonicity, and special cases are
1701      * described in {@link $abstractvectortype$#hypot}
1702      *
1703      * @param v the input vector
1704      * @param m the mask controlling lane selection
1705      * @return square root of the sum of the squares of this vector and an input
1706      * vector
1707      */
1708     public $abstractvectortype$ hypot(Vector<$Boxtype$> v, VectorMask<$Boxtype$> m) {
1709         return bOp(v, m, (i, a, b) -> ($type$) Math.hypot((double) a, (double) b));
1710     }
1711 
1712     /**
1713      * Calculates square root of the sum of the squares of this vector and the
1714      * broadcast of an input scalar, selecting lane elements controlled by a
1715      * mask.
1716      * More specifically as if the following (ignoring any differences in
1717      * numerical accuracy):
1718      * <pre>{@code
1719      *   this.mul(this, m).add(EVector.broadcast(this.species(), s * s), m).sqrt(m)
1720      * }</pre>
1721      * <p>
1722      * Semantics for rounding, monotonicity, and special cases are
1723      * described in {@link $abstractvectortype$#hypot}
1724      *
1725      * @param s the input scalar
1726      * @param m the mask controlling lane selection
1727      * @return square root of the sum of the squares of this vector and the
1728      * broadcast of an input scalar
1729      */
1730     public abstract $abstractvectortype$ hypot($type$ s, VectorMask<$Boxtype$> m);
1731 #end[FP]
1732 
1733 #if[BITWISE]
1734 
1735     /**
1736      * Bitwise ANDs this vector with an input vector.
1737      * <p>
1738      * This is a lane-wise binary operation which applies the primitive bitwise AND
1739      * operation ({@code &}) to each lane.
1740      *
1741      * @param v the input vector
1742      * @return the bitwise AND of this vector with the input vector
1743      */
1744     public abstract $abstractvectortype$ and(Vector<$Boxtype$> v);
1745 
1746     /**
1747      * Bitwise ANDs this vector with the broadcast of an input scalar.
1748      * <p>
1749      * This is a lane-wise binary operation which applies the primitive bitwise AND
1750      * operation ({@code &}) to each lane.
1751      *
1752      * @param s the input scalar
1753      * @return the bitwise AND of this vector with the broadcast of an input
1754      * scalar
1755      */
1756     public abstract $abstractvectortype$ and($type$ s);
1757 
1758     /**
1759      * Bitwise ANDs this vector with an input vector, selecting lane elements
1760      * controlled by a mask.
1761      * <p>
1762      * This is a lane-wise binary operation which applies the primitive bitwise AND
1763      * operation ({@code &}) to each lane.
1764      *
1765      * @param v the input vector
1766      * @param m the mask controlling lane selection
1767      * @return the bitwise AND of this vector with the input vector
1768      */
1769     public abstract $abstractvectortype$ and(Vector<$Boxtype$> v, VectorMask<$Boxtype$> m);
1770 
1771     /**
1772      * Bitwise ANDs this vector with the broadcast of an input scalar, selecting
1773      * lane elements controlled by a mask.
1774      * <p>
1775      * This is a lane-wise binary operation which applies the primitive bitwise AND
1776      * operation ({@code &}) to each lane.
1777      *
1778      * @param s the input scalar
1779      * @param m the mask controlling lane selection
1780      * @return the bitwise AND of this vector with the broadcast of an input
1781      * scalar
1782      */
1783     public abstract $abstractvectortype$ and($type$ s, VectorMask<$Boxtype$> m);
1784 
1785     /**
1786      * Bitwise ORs this vector with an input vector.
1787      * <p>
1788      * This is a lane-wise binary operation which applies the primitive bitwise OR
1789      * operation ({@code |}) to each lane.
1790      *
1791      * @param v the input vector
1792      * @return the bitwise OR of this vector with the input vector
1793      */
1794     public abstract $abstractvectortype$ or(Vector<$Boxtype$> v);
1795 
1796     /**
1797      * Bitwise ORs this vector with the broadcast of an input scalar.
1798      * <p>
1799      * This is a lane-wise binary operation which applies the primitive bitwise OR
1800      * operation ({@code |}) to each lane.
1801      *
1802      * @param s the input scalar
1803      * @return the bitwise OR of this vector with the broadcast of an input
1804      * scalar
1805      */
1806     public abstract $abstractvectortype$ or($type$ s);
1807 
1808     /**
1809      * Bitwise ORs this vector with an input vector, selecting lane elements
1810      * controlled by a mask.
1811      * <p>
1812      * This is a lane-wise binary operation which applies the primitive bitwise OR
1813      * operation ({@code |}) to each lane.
1814      *
1815      * @param v the input vector
1816      * @param m the mask controlling lane selection
1817      * @return the bitwise OR of this vector with the input vector
1818      */
1819     public abstract $abstractvectortype$ or(Vector<$Boxtype$> v, VectorMask<$Boxtype$> m);
1820 
1821     /**
1822      * Bitwise ORs this vector with the broadcast of an input scalar, selecting
1823      * lane elements controlled by a mask.
1824      * <p>
1825      * This is a lane-wise binary operation which applies the primitive bitwise OR
1826      * operation ({@code |}) to each lane.
1827      *
1828      * @param s the input scalar
1829      * @param m the mask controlling lane selection
1830      * @return the bitwise OR of this vector with the broadcast of an input
1831      * scalar
1832      */
1833     public abstract $abstractvectortype$ or($type$ s, VectorMask<$Boxtype$> m);
1834 
1835     /**
1836      * Bitwise XORs this vector with an input vector.
1837      * <p>
1838      * This is a lane-wise binary operation which applies the primitive bitwise XOR
1839      * operation ({@code ^}) to each lane.
1840      *
1841      * @param v the input vector
1842      * @return the bitwise XOR of this vector with the input vector
1843      */
1844     public abstract $abstractvectortype$ xor(Vector<$Boxtype$> v);
1845 
1846     /**
1847      * Bitwise XORs this vector with the broadcast of an input scalar.
1848      * <p>
1849      * This is a lane-wise binary operation which applies the primitive bitwise XOR
1850      * operation ({@code ^}) to each lane.
1851      *
1852      * @param s the input scalar
1853      * @return the bitwise XOR of this vector with the broadcast of an input
1854      * scalar
1855      */
1856     public abstract $abstractvectortype$ xor($type$ s);
1857 
1858     /**
1859      * Bitwise XORs this vector with an input vector, selecting lane elements
1860      * controlled by a mask.
1861      * <p>
1862      * This is a lane-wise binary operation which applies the primitive bitwise XOR
1863      * operation ({@code ^}) to each lane.
1864      *
1865      * @param v the input vector
1866      * @param m the mask controlling lane selection
1867      * @return the bitwise XOR of this vector with the input vector
1868      */
1869     public abstract $abstractvectortype$ xor(Vector<$Boxtype$> v, VectorMask<$Boxtype$> m);
1870 
1871     /**
1872      * Bitwise XORs this vector with the broadcast of an input scalar, selecting
1873      * lane elements controlled by a mask.
1874      * <p>
1875      * This is a lane-wise binary operation which applies the primitive bitwise XOR
1876      * operation ({@code ^}) to each lane.
1877      *
1878      * @param s the input scalar
1879      * @param m the mask controlling lane selection
1880      * @return the bitwise XOR of this vector with the broadcast of an input
1881      * scalar
1882      */
1883     public abstract $abstractvectortype$ xor($type$ s, VectorMask<$Boxtype$> m);
1884 
1885     /**
1886      * Bitwise NOTs this vector.
1887      * <p>
1888      * This is a lane-wise unary operation which applies the primitive bitwise NOT
1889      * operation ({@code ~}) to each lane.
1890      *
1891      * @return the bitwise NOT of this vector
1892      */
1893     public abstract $abstractvectortype$ not();
1894 
1895     /**
1896      * Bitwise NOTs this vector, selecting lane elements controlled by a mask.
1897      * <p>
1898      * This is a lane-wise unary operation which applies the primitive bitwise NOT
1899      * operation ({@code ~}) to each lane.
1900      *
1901      * @param m the mask controlling lane selection
1902      * @return the bitwise NOT of this vector
1903      */
1904     public abstract $abstractvectortype$ not(VectorMask<$Boxtype$> m);
1905 
1906     /**
1907      * Logically left shifts this vector by the broadcast of an input scalar.
1908      * <p>
1909      * This is a lane-wise binary operation which applies the primitive logical left shift
1910      * operation ({@code <<}) to each lane to left shift the
1911      * element by shift value as specified by the input scalar.
1912 #if[byte]
1913      * Only the 3 lowest-order bits of shift value are used. It is as if the shift value
1914      * were subjected to a bitwise logical AND operator ({@code &}) with the mask value 0x7.
1915      * The shift distance actually used is therefore always in the range 0 to 7, inclusive.
1916 #end[byte]
1917 #if[short]
1918      * Only the 4 lowest-order bits of shift value are used. It is as if the shift value
1919      * were subjected to a bitwise logical AND operator ({@code &}) with the mask value 0xF.
1920      * The shift distance actually used is therefore always in the range 0 to 15, inclusive.
1921 #end[short]
1922      *
1923      * @param s the input scalar; the number of the bits to left shift
1924      * @return the result of logically left shifting this vector by the
1925      * broadcast of an input scalar
1926      */
1927     public abstract $abstractvectortype$ shiftLeft(int s);
1928 
1929     /**
1930      * Logically left shifts this vector by the broadcast of an input scalar,
1931      * selecting lane elements controlled by a mask.
1932      * <p>
1933      * This is a lane-wise binary operation which applies the primitive logical left shift
1934      * operation ({@code <<}) to each lane to left shift the
1935      * element by shift value as specified by the input scalar.
1936 #if[byte]
1937      * Only the 3 lowest-order bits of shift value are used. It is as if the shift value
1938      * were subjected to a bitwise logical AND operator ({@code &}) with the mask value 0x7.
1939      * The shift distance actually used is therefore always in the range 0 to 7, inclusive.
1940 #end[byte]
1941 #if[short]
1942      * Only the 4 lowest-order bits of shift value are used. It is as if the shift value
1943      * were subjected to a bitwise logical AND operator ({@code &}) with the mask value 0xF.
1944      * The shift distance actually used is therefore always in the range 0 to 15, inclusive.
1945 #end[short]
1946      *
1947      * @param s the input scalar; the number of the bits to left shift
1948      * @param m the mask controlling lane selection
1949      * @return the result of logically left shifting this vector by the
1950      * broadcast of an input scalar
1951      */
1952     public abstract $abstractvectortype$ shiftLeft(int s, VectorMask<$Boxtype$> m);
1953 
1954     /**
1955      * Logically left shifts this vector by an input vector.
1956      * <p>
1957      * This is a lane-wise binary operation which applies the primitive logical left shift
1958      * operation ({@code <<}) to each lane. For each lane of this vector, the
1959      * shift value is the corresponding lane of input vector.
1960 #if[byte]
1961      * Only the 3 lowest-order bits of shift value are used. It is as if the shift value
1962      * were subjected to a bitwise logical AND operator ({@code &}) with the mask value 0x7.
1963      * The shift distance actually used is therefore always in the range 0 to 7, inclusive.
1964 #end[byte]
1965 #if[short]
1966      * Only the 4 lowest-order bits of shift value are used. It is as if the shift value
1967      * were subjected to a bitwise logical AND operator ({@code &}) with the mask value 0xF.
1968      * The shift distance actually used is therefore always in the range 0 to 15, inclusive.
1969 #end[short]
1970      *
1971      * @param v the input vector
1972      * @return the result of logically left shifting this vector by the input
1973      * vector
1974      */
1975     public abstract $abstractvectortype$ shiftLeft(Vector<$Boxtype$> v);
1976 
1977     /**
1978      * Logically left shifts this vector by an input vector, selecting lane
1979      * elements controlled by a mask.
1980      * <p>
1981      * This is a lane-wise binary operation which applies the primitive logical left shift
1982      * operation ({@code <<}) to each lane. For each lane of this vector, the
1983      * shift value is the corresponding lane of input vector.
1984 #if[byte]
1985      * Only the 3 lowest-order bits of shift value are used. It is as if the shift value
1986      * were subjected to a bitwise logical AND operator ({@code &}) with the mask value 0x7.
1987      * The shift distance actually used is therefore always in the range 0 to 7, inclusive.
1988 #end[byte]
1989 #if[short]
1990      * Only the 4 lowest-order bits of shift value are used. It is as if the shift value
1991      * were subjected to a bitwise logical AND operator ({@code &}) with the mask value 0xF.
1992      * The shift distance actually used is therefore always in the range 0 to 15, inclusive.
1993 #end[short]
1994      *
1995      * @param v the input vector
1996      * @param m the mask controlling lane selection
1997      * @return the result of logically left shifting this vector by the input
1998      * vector
1999      */
2000     public $abstractvectortype$ shiftLeft(Vector<$Boxtype$> v, VectorMask<$Boxtype$> m) {
2001         return blend(shiftLeft(v), m);
2002     }
2003 
2004     // logical, or unsigned, shift right
2005 
2006      /**
2007      * Logically right shifts (or unsigned right shifts) this vector by the
2008      * broadcast of an input scalar.
2009      * <p>
2010      * This is a lane-wise binary operation which applies the primitive logical right shift
2011      * operation ({@code >>>}) to each lane to logically right shift the
2012      * element by shift value as specified by the input scalar.
2013 #if[byte]
2014      * Only the 3 lowest-order bits of shift value are used. It is as if the shift value
2015      * were subjected to a bitwise logical AND operator ({@code &}) with the mask value 0x7.
2016      * The shift distance actually used is therefore always in the range 0 to 7, inclusive.
2017 #end[byte]
2018 #if[short]
2019      * Only the 4 lowest-order bits of shift value are used. It is as if the shift value
2020      * were subjected to a bitwise logical AND operator ({@code &}) with the mask value 0xF.
2021      * The shift distance actually used is therefore always in the range 0 to 15, inclusive.
2022 #end[short]
2023      *
2024      * @param s the input scalar; the number of the bits to right shift
2025      * @return the result of logically right shifting this vector by the
2026      * broadcast of an input scalar
2027      */
2028     public abstract $abstractvectortype$ shiftRight(int s);
2029 
2030      /**
2031      * Logically right shifts (or unsigned right shifts) this vector by the
2032      * broadcast of an input scalar, selecting lane elements controlled by a
2033      * mask.
2034      * <p>
2035      * This is a lane-wise binary operation which applies the primitive logical right shift
2036      * operation ({@code >>}) to each lane to logically right shift the
2037      * element by shift value as specified by the input scalar.
2038 #if[byte]
2039      * Only the 3 lowest-order bits of shift value are used. It is as if the shift value
2040      * were subjected to a bitwise logical AND operator ({@code &}) with the mask value 0x7.
2041      * The shift distance actually used is therefore always in the range 0 to 7, inclusive.
2042 #end[byte]
2043 #if[short]
2044      * Only the 4 lowest-order bits of shift value are used. It is as if the shift value
2045      * were subjected to a bitwise logical AND operator ({@code &}) with the mask value 0xF.
2046      * The shift distance actually used is therefore always in the range 0 to 15, inclusive.
2047 #end[short]
2048      *
2049      * @param s the input scalar; the number of the bits to right shift
2050      * @param m the mask controlling lane selection
2051      * @return the result of logically right shifting this vector by the
2052      * broadcast of an input scalar
2053      */
2054     public abstract $abstractvectortype$ shiftRight(int s, VectorMask<$Boxtype$> m);
2055 
2056     /**
2057      * Logically right shifts (or unsigned right shifts) this vector by an
2058      * input vector.
2059      * <p>
2060      * This is a lane-wise binary operation which applies the primitive logical right shift
2061      * operation ({@code >>>}) to each lane. For each lane of this vector, the
2062      * shift value is the corresponding lane of input vector.
2063 #if[byte]
2064      * Only the 3 lowest-order bits of shift value are used. It is as if the shift value
2065      * were subjected to a bitwise logical AND operator ({@code &}) with the mask value 0x7.
2066      * The shift distance actually used is therefore always in the range 0 to 7, inclusive.
2067 #end[byte]
2068 #if[short]
2069      * Only the 4 lowest-order bits of shift value are used. It is as if the shift value
2070      * were subjected to a bitwise logical AND operator ({@code &}) with the mask value 0xF.
2071      * The shift distance actually used is therefore always in the range 0 to 15, inclusive.
2072 #end[short]
2073      *
2074      * @param v the input vector
2075      * @return the result of logically right shifting this vector by the
2076      * input vector
2077      */
2078     public abstract $abstractvectortype$ shiftRight(Vector<$Boxtype$> v);
2079 
2080     /**
2081      * Logically right shifts (or unsigned right shifts) this vector by an
2082      * input vector, selecting lane elements controlled by a mask.
2083      * <p>
2084      * This is a lane-wise binary operation which applies the primitive logical right shift
2085      * operation ({@code >>>}) to each lane. For each lane of this vector, the
2086      * shift value is the corresponding lane of input vector.
2087 #if[byte]
2088      * Only the 3 lowest-order bits of shift value are used. It is as if the shift value
2089      * were subjected to a bitwise logical AND operator ({@code &}) with the mask value 0x7.
2090      * The shift distance actually used is therefore always in the range 0 to 7, inclusive.
2091 #end[byte]
2092 #if[short]
2093      * Only the 4 lowest-order bits of shift value are used. It is as if the shift value
2094      * were subjected to a bitwise logical AND operator ({@code &}) with the mask value 0xF.
2095      * The shift distance actually used is therefore always in the range 0 to 15, inclusive.
2096 #end[short]
2097      *
2098      * @param v the input vector
2099      * @param m the mask controlling lane selection
2100      * @return the result of logically right shifting this vector by the
2101      * input vector
2102      */
2103     public $abstractvectortype$ shiftRight(Vector<$Boxtype$> v, VectorMask<$Boxtype$> m) {
2104         return blend(shiftRight(v), m);
2105     }
2106 
2107     /**
2108      * Arithmetically right shifts (or signed right shifts) this vector by the
2109      * broadcast of an input scalar.
2110      * <p>
2111      * This is a lane-wise binary operation which applies the primitive arithmetic right
2112      * shift operation ({@code >>}) to each lane to arithmetically
2113      * right shift the element by shift value as specified by the input scalar.
2114 #if[byte]
2115      * Only the 3 lowest-order bits of shift value are used. It is as if the shift
2116      * value were subjected to a bitwise logical AND operator ({@code &}) with the mask value 0x7.
2117      * The shift distance actually used is therefore always in the range 0 to 7, inclusive.
2118 #end[byte]
2119 #if[short]
2120      * Only the 4 lowest-order bits of shift value are used. It is as if the shift
2121      * value were subjected to a bitwise logical AND operator ({@code &}) with the mask value 0xF.
2122      * The shift distance actually used is therefore always in the range 0 to 15, inclusive.
2123 #end[short]
2124      *
2125      * @param s the input scalar; the number of the bits to right shift
2126      * @return the result of arithmetically right shifting this vector by the
2127      * broadcast of an input scalar
2128      */
2129     public abstract $abstractvectortype$ shiftArithmeticRight(int s);
2130 
2131     /**
2132      * Arithmetically right shifts (or signed right shifts) this vector by the
2133      * broadcast of an input scalar, selecting lane elements controlled by a
2134      * mask.
2135      * <p>
2136      * This is a lane-wise binary operation which applies the primitive arithmetic right
2137      * shift operation ({@code >>}) to each lane to arithmetically
2138      * right shift the element by shift value as specified by the input scalar.
2139 #if[byte]
2140      * Only the 3 lowest-order bits of shift value are used. It is as if the shift
2141      * value were subjected to a bitwise logical AND operator ({@code &}) with the mask value 0x7.
2142      * The shift distance actually used is therefore always in the range 0 to 7, inclusive.
2143 #end[byte]
2144 #if[short]
2145      * Only the 4 lowest-order bits of shift value are used. It is as if the shift
2146      * value were subjected to a bitwise logical AND operator ({@code &}) with the mask value 0xF.
2147      * The shift distance actually used is therefore always in the range 0 to 15, inclusive.
2148 #end[short]
2149      *
2150      * @param s the input scalar; the number of the bits to right shift
2151      * @param m the mask controlling lane selection
2152      * @return the result of arithmetically right shifting this vector by the
2153      * broadcast of an input scalar
2154      */
2155     public abstract $abstractvectortype$ shiftArithmeticRight(int s, VectorMask<$Boxtype$> m);
2156 
2157     /**
2158      * Arithmetically right shifts (or signed right shifts) this vector by an
2159      * input vector.
2160      * <p>
2161      * This is a lane-wise binary operation which applies the primitive arithmetic right
2162      * shift operation ({@code >>}) to each lane. For each lane of this vector, the
2163      * shift value is the corresponding lane of input vector.
2164 #if[byte]
2165      * Only the 3 lowest-order bits of shift value are used. It is as if the shift
2166      * value were subjected to a bitwise logical AND operator ({@code &}) with the mask value 0x7.
2167      * The shift distance actually used is therefore always in the range 0 to 7, inclusive.
2168 #end[byte]
2169 #if[short]
2170      * Only the 4 lowest-order bits of shift value are used. It is as if the shift
2171      * value were subjected to a bitwise logical AND operator ({@code &}) with the mask value 0xF.
2172      * The shift distance actually used is therefore always in the range 0 to 15, inclusive.
2173 #end[short]
2174      *
2175      * @param v the input vector
2176      * @return the result of arithmetically right shifting this vector by the
2177      * input vector
2178      */
2179     public abstract $abstractvectortype$ shiftArithmeticRight(Vector<$Boxtype$> v);
2180 
2181     /**
2182      * Arithmetically right shifts (or signed right shifts) this vector by an
2183      * input vector, selecting lane elements controlled by a mask.
2184      * <p>
2185      * This is a lane-wise binary operation which applies the primitive arithmetic right
2186      * shift operation ({@code >>}) to each lane. For each lane of this vector, the
2187      * shift value is the corresponding lane of input vector.
2188 #if[byte]
2189      * Only the 3 lowest-order bits of shift value are used. It is as if the shift
2190      * value were subjected to a bitwise logical AND operator ({@code &}) with the mask value 0x7.
2191      * The shift distance actually used is therefore always in the range 0 to 7, inclusive.
2192 #end[byte]
2193 #if[short]
2194      * Only the 4 lowest-order bits of shift value are used. It is as if the shift
2195      * value were subjected to a bitwise logical AND operator ({@code &}) with the mask value 0xF.
2196      * The shift distance actually used is therefore always in the range 0 to 15, inclusive.
2197 #end[short]
2198      *
2199      * @param v the input vector
2200      * @param m the mask controlling lane selection
2201      * @return the result of arithmetically right shifting this vector by the
2202      * input vector
2203      */
2204     public $abstractvectortype$ shiftArithmeticRight(Vector<$Boxtype$> v, VectorMask<$Boxtype$> m) {
2205         return blend(shiftArithmeticRight(v), m);
2206     }
2207 
2208     /**
2209      * Rotates left this vector by the broadcast of an input scalar.
2210      * <p>
2211 #if[intOrLong]
2212      * This is a lane-wise binary operation which applies the operation
2213      * {@link $Wideboxtype$#rotateLeft} to each lane and where
2214      * lane elements of this vector apply to the first argument, and lane
2215      * elements of the broadcast vector apply to the second argument (the
2216      * rotation distance).
2217 #end[intOrLong]
2218 #if[byte]
2219      * This is a lane-wise binary operation which produces the result of rotating left the two's
2220      * complement binary representation of each lane of first operand (this vector) by input scalar.
2221      * Rotation by any multiple of 8 is a no-op, so only the 3 lowest-order bits of input value are used.
2222      * It is as if the input value were subjected to a bitwise logical
2223      * AND operator ({@code &}) with the mask value 0x7.
2224 #end[byte]
2225 #if[short]
2226      * This is a lane-wise binary operation which produces the result of rotating left the two's
2227      * complement binary representation of each lane of first operand (this vector) by input scalar.
2228      * Rotation by any multiple of 16 is a no-op, so only the 4 lowest-order bits of input value are used.
2229      * It is as if the input value were subjected to a bitwise logical
2230      * AND operator ({@code &}) with the mask value 0xF.
2231 #end[short]
2232      *
2233      * @param s the input scalar; the number of the bits to rotate left
2234      * @return the result of rotating left this vector by the broadcast of an
2235      * input scalar
2236      */
2237     @ForceInline
2238     public final $abstractvectortype$ rotateLeft(int s) {
2239         return shiftLeft(s).or(shiftRight(-s));
2240     }
2241 
2242     /**
2243      * Rotates left this vector by the broadcast of an input scalar, selecting
2244      * lane elements controlled by a mask.
2245      * <p>
2246 #if[intOrLong]
2247      * This is a lane-wise binary operation which applies the operation
2248      * {@link $Wideboxtype$#rotateLeft} to each lane and where
2249      * lane elements of this vector apply to the first argument, and lane
2250      * elements of the broadcast vector apply to the second argument (the
2251      * rotation distance).
2252 #end[intOrLong]
2253 #if[byte]
2254      * This is a lane-wise binary operation which produces the result of rotating left the two's
2255      * complement binary representation of each lane of first operand (this vector) by input scalar.
2256      * Rotation by any multiple of 8 is a no-op, so only the 3 lowest-order bits of input value are used.
2257      * It is as if the input value were subjected to a bitwise logical
2258      * AND operator ({@code &}) with the mask value 0x7.
2259 #end[byte]
2260 #if[short]
2261      * This is a lane-wise binary operation which produces the result of rotating left the two's
2262      * complement binary representation of each lane of first operand (this vector) by input scalar.
2263      * Rotation by any multiple of 16 is a no-op, so only the 4 lowest-order bits of input value are used.
2264      * It is as if the input value were subjected to a bitwise logical
2265      * AND operator ({@code &}) with the mask value 0xF.
2266 #end[short]
2267      *
2268      * @param s the input scalar; the number of the bits to rotate left
2269      * @param m the mask controlling lane selection
2270      * @return the result of rotating left this vector by the broadcast of an
2271      * input scalar
2272      */
2273     @ForceInline
2274     public final $abstractvectortype$ rotateLeft(int s, VectorMask<$Boxtype$> m) {
2275         return shiftLeft(s, m).or(shiftRight(-s, m), m);
2276     }
2277 
2278     /**
2279      * Rotates right this vector by the broadcast of an input scalar.
2280      * <p>
2281 #if[intOrLong]
2282      * This is a lane-wise binary operation which applies the operation
2283      * {@link $Wideboxtype$#rotateRight} to each lane and where
2284      * lane elements of this vector apply to the first argument, and lane
2285      * elements of the broadcast vector apply to the second argument (the
2286      * rotation distance).
2287 #end[intOrLong]
2288 #if[byte]
2289      * This is a lane-wise binary operation which produces the result of rotating right the two's
2290      * complement binary representation of each lane of first operand (this vector) by input scalar.
2291      * Rotation by any multiple of 8 is a no-op, so only the 3 lowest-order bits of input value are used.
2292      * It is as if the input value were subjected to a bitwise logical
2293      * AND operator ({@code &}) with the mask value 0x7.
2294 #end[byte]
2295 #if[short]
2296      * This is a lane-wise binary operation which produces the result of rotating right the two's
2297      * complement binary representation of each lane of first operand (this vector) by input scalar.
2298      * Rotation by any multiple of 16 is a no-op, so only the 4 lowest-order bits of input value are used.
2299      * It is as if the input value were subjected to a bitwise logical
2300      * AND operator ({@code &}) with the mask value 0xF.
2301 #end[short]
2302      *
2303      * @param s the input scalar; the number of the bits to rotate right
2304      * @return the result of rotating right this vector by the broadcast of an
2305      * input scalar
2306      */
2307     @ForceInline
2308     public final $abstractvectortype$ rotateRight(int s) {
2309         return shiftRight(s).or(shiftLeft(-s));
2310     }
2311 
2312     /**
2313      * Rotates right this vector by the broadcast of an input scalar, selecting
2314      * lane elements controlled by a mask.
2315      * <p>
2316 #if[intOrLong]
2317      * This is a lane-wise binary operation which applies the operation
2318      * {@link $Wideboxtype$#rotateRight} to each lane and where
2319      * lane elements of this vector apply to the first argument, and lane
2320      * elements of the broadcast vector apply to the second argument (the
2321      * rotation distance).
2322 #end[intOrLong]
2323 #if[byte]
2324      * This is a lane-wise binary operation which produces the result of rotating right the two's
2325      * complement binary representation of each lane of first operand (this vector) by input scalar.
2326      * Rotation by any multiple of 8 is a no-op, so only the 3 lowest-order bits of input value are used.
2327      * It is as if the input value were subjected to a bitwise logical
2328      * AND operator ({@code &}) with the mask value 0x7.
2329 #end[byte]
2330 #if[short]
2331      * This is a lane-wise binary operation which produces the result of rotating right the two's
2332      * complement binary representation of each lane of first operand (this vector) by input scalar.
2333      * Rotation by any multiple of 16 is a no-op, so only the 4 lowest-order bits of input value are used.
2334      * It is as if the input value were subjected to a bitwise logical
2335      * AND operator ({@code &}) with the mask value 0xF.
2336 #end[short]
2337      *
2338      * @param s the input scalar; the number of the bits to rotate right
2339      * @param m the mask controlling lane selection
2340      * @return the result of rotating right this vector by the broadcast of an
2341      * input scalar
2342      */
2343     @ForceInline
2344     public final $abstractvectortype$ rotateRight(int s, VectorMask<$Boxtype$> m) {
2345         return shiftRight(s, m).or(shiftLeft(-s, m), m);
2346     }
2347 #end[BITWISE]
2348 
2349     /**
2350      * {@inheritDoc}
2351      */
2352     @Override
2353     public abstract void intoByteArray(byte[] a, int ix);
2354 
2355     /**
2356      * {@inheritDoc}
2357      */
2358     @Override
2359     public abstract void intoByteArray(byte[] a, int ix, VectorMask<$Boxtype$> m);
2360 
2361     /**
2362      * {@inheritDoc}
2363      */
2364     @Override
2365     public abstract void intoByteBuffer(ByteBuffer bb, int ix);
2366 
2367     /**
2368      * {@inheritDoc}
2369      */
2370     @Override
2371     public abstract void intoByteBuffer(ByteBuffer bb, int ix, VectorMask<$Boxtype$> m);
2372 
2373 
2374     // Type specific horizontal reductions
2375     /**
2376      * Adds all lane elements of this vector.
2377      * <p>
2378 #if[FP]
2379      * This is a cross-lane reduction operation which applies the addition
2380      * operation ({@code +}) to lane elements,
2381      * and the identity value is {@code 0.0}.
2382      *
2383      * <p>The value of a floating-point sum is a function both of the input values as well
2384      * as the order of addition operations. The order of addition operations of this method
2385      * is intentionally not defined to allow for JVM to generate optimal machine
2386      * code for the underlying platform at runtime. If the platform supports a vector
2387      * instruction to add all values in the vector, or if there is some other efficient machine
2388      * code sequence, then the JVM has the option of generating this machine code. Otherwise,
2389      * the default implementation of adding vectors sequentially from left to right is used.
2390      * For this reason, the output of this method may vary for the same input values.
2391 #else[FP]
2392      * This is an associative cross-lane reduction operation which applies the addition
2393      * operation ({@code +}) to lane elements,
2394      * and the identity value is {@code 0}.
2395 #end[FP]
2396      *
2397      * @return the addition of all the lane elements of this vector
2398      */
2399     public abstract $type$ addLanes();
2400 
2401     /**
2402      * Adds all lane elements of this vector, selecting lane elements
2403      * controlled by a mask.
2404      * <p>
2405 #if[FP]
2406      * This is a cross-lane reduction operation which applies the addition
2407      * operation ({@code +}) to lane elements,
2408      * and the identity value is {@code 0.0}.
2409      *
2410      * <p>The value of a floating-point sum is a function both of the input values as well
2411      * as the order of addition operations. The order of addition operations of this method
2412      * is intentionally not defined to allow for JVM to generate optimal machine
2413      * code for the underlying platform at runtime. If the platform supports a vector
2414      * instruction to add all values in the vector, or if there is some other efficient machine
2415      * code sequence, then the JVM has the option of generating this machine code. Otherwise,
2416      * the default implementation of adding vectors sequentially from left to right is used.
2417      * For this reason, the output of this method may vary on the same input values.
2418 #else[FP]
2419      * This is an associative cross-lane reduction operation which applies the addition
2420      * operation ({@code +}) to lane elements,
2421      * and the identity value is {@code 0}.
2422 #end[FP]
2423      *
2424      * @param m the mask controlling lane selection
2425      * @return the addition of the selected lane elements of this vector
2426      */
2427     public abstract $type$ addLanes(VectorMask<$Boxtype$> m);
2428 
2429     /**
2430      * Multiplies all lane elements of this vector.
2431      * <p>
2432 #if[FP]
2433      * This is a cross-lane reduction operation which applies the
2434      * multiplication operation ({@code *}) to lane elements,
2435      * and the identity value is {@code 1.0}.
2436      *
2437      * <p>The order of multiplication operations of this method
2438      * is intentionally not defined to allow for JVM to generate optimal machine
2439      * code for the underlying platform at runtime. If the platform supports a vector
2440      * instruction to multiply all values in the vector, or if there is some other efficient machine
2441      * code sequence, then the JVM has the option of generating this machine code. Otherwise,
2442      * the default implementation of multiplying vectors sequentially from left to right is used.
2443      * For this reason, the output of this method may vary on the same input values.
2444 #else[FP]
2445      * This is an associative cross-lane reduction operation which applies the
2446      * multiplication operation ({@code *}) to lane elements,
2447      * and the identity value is {@code 1}.
2448 #end[FP]
2449      *
2450      * @return the multiplication of all the lane elements of this vector
2451      */
2452     public abstract $type$ mulLanes();
2453 
2454     /**
2455      * Multiplies all lane elements of this vector, selecting lane elements
2456      * controlled by a mask.
2457      * <p>
2458 #if[FP]
2459      * This is a cross-lane reduction operation which applies the
2460      * multiplication operation ({@code *}) to lane elements,
2461      * and the identity value is {@code 1.0}.
2462      *
2463      * <p>The order of multiplication operations of this method
2464      * is intentionally not defined to allow for JVM to generate optimal machine
2465      * code for the underlying platform at runtime. If the platform supports a vector
2466      * instruction to multiply all values in the vector, or if there is some other efficient machine
2467      * code sequence, then the JVM has the option of generating this machine code. Otherwise,
2468      * the default implementation of multiplying vectors sequentially from left to right is used.
2469      * For this reason, the output of this method may vary on the same input values.
2470 #else[FP]
2471      * This is an associative cross-lane reduction operation which applies the
2472      * multiplication operation ({@code *}) to lane elements,
2473      * and the identity value is {@code 1}.
2474 #end[FP]
2475      *
2476      * @param m the mask controlling lane selection
2477      * @return the multiplication of all the lane elements of this vector
2478      */
2479     public abstract $type$ mulLanes(VectorMask<$Boxtype$> m);
2480 
2481     /**
2482      * Returns the minimum lane element of this vector.
2483      * <p>
2484      * This is an associative cross-lane reduction operation which applies the operation
2485      * {@code (a, b) -> Math.min(a, b)} to lane elements,
2486      * and the identity value is
2487 #if[FP]
2488      * {@link $Boxtype$#POSITIVE_INFINITY}.
2489 #else[FP]
2490      * {@link $Boxtype$#MAX_VALUE}.
2491 #end[FP]
2492      *
2493      * @return the minimum lane element of this vector
2494      */
2495     public abstract $type$ minLanes();
2496 
2497     /**
2498      * Returns the minimum lane element of this vector, selecting lane elements
2499      * controlled by a mask.
2500      * <p>
2501      * This is an associative cross-lane reduction operation which applies the operation
2502      * {@code (a, b) -> Math.min(a, b)} to lane elements,
2503      * and the identity value is
2504 #if[FP]
2505      * {@link $Boxtype$#POSITIVE_INFINITY}.
2506 #else[FP]
2507      * {@link $Boxtype$#MAX_VALUE}.
2508 #end[FP]
2509      *
2510      * @param m the mask controlling lane selection
2511      * @return the minimum lane element of this vector
2512      */
2513     public abstract $type$ minLanes(VectorMask<$Boxtype$> m);
2514 
2515     /**
2516      * Returns the maximum lane element of this vector.
2517      * <p>
2518      * This is an associative cross-lane reduction operation which applies the operation
2519      * {@code (a, b) -> Math.max(a, b)} to lane elements,
2520      * and the identity value is
2521 #if[FP]
2522      * {@link $Boxtype$#NEGATIVE_INFINITY}.
2523 #else[FP]
2524      * {@link $Boxtype$#MIN_VALUE}.
2525 #end[FP]
2526      *
2527      * @return the maximum lane element of this vector
2528      */
2529     public abstract $type$ maxLanes();
2530 
2531     /**
2532      * Returns the maximum lane element of this vector, selecting lane elements
2533      * controlled by a mask.
2534      * <p>
2535      * This is an associative cross-lane reduction operation which applies the operation
2536      * {@code (a, b) -> Math.max(a, b)} to lane elements,
2537      * and the identity value is
2538 #if[FP]
2539      * {@link $Boxtype$#NEGATIVE_INFINITY}.
2540 #else[FP]
2541      * {@link $Boxtype$#MIN_VALUE}.
2542 #end[FP]
2543      *
2544      * @param m the mask controlling lane selection
2545      * @return the maximum lane element of this vector
2546      */
2547     public abstract $type$ maxLanes(VectorMask<$Boxtype$> m);
2548 
2549 #if[BITWISE]
2550     /**
2551      * Logically ORs all lane elements of this vector.
2552      * <p>
2553      * This is an associative cross-lane reduction operation which applies the logical OR
2554      * operation ({@code |}) to lane elements,
2555      * and the identity value is {@code 0}.
2556      *
2557      * @return the logical OR all the lane elements of this vector
2558      */
2559     public abstract $type$ orLanes();
2560 
2561     /**
2562      * Logically ORs all lane elements of this vector, selecting lane elements
2563      * controlled by a mask.
2564      * <p>
2565      * This is an associative cross-lane reduction operation which applies the logical OR
2566      * operation ({@code |}) to lane elements,
2567      * and the identity value is {@code 0}.
2568      *
2569      * @param m the mask controlling lane selection
2570      * @return the logical OR all the lane elements of this vector
2571      */
2572     public abstract $type$ orLanes(VectorMask<$Boxtype$> m);
2573 
2574     /**
2575      * Logically ANDs all lane elements of this vector.
2576      * <p>
2577      * This is an associative cross-lane reduction operation which applies the logical AND
2578      * operation ({@code |}) to lane elements,
2579      * and the identity value is {@code -1}.
2580      *
2581      * @return the logical AND all the lane elements of this vector
2582      */
2583     public abstract $type$ andLanes();
2584 
2585     /**
2586      * Logically ANDs all lane elements of this vector, selecting lane elements
2587      * controlled by a mask.
2588      * <p>
2589      * This is an associative cross-lane reduction operation which applies the logical AND
2590      * operation ({@code |}) to lane elements,
2591      * and the identity value is {@code -1}.
2592      *
2593      * @param m the mask controlling lane selection
2594      * @return the logical AND all the lane elements of this vector
2595      */
2596     public abstract $type$ andLanes(VectorMask<$Boxtype$> m);
2597 
2598     /**
2599      * Logically XORs all lane elements of this vector.
2600      * <p>
2601      * This is an associative cross-lane reduction operation which applies the logical XOR
2602      * operation ({@code ^}) to lane elements,
2603      * and the identity value is {@code 0}.
2604      *
2605      * @return the logical XOR all the lane elements of this vector
2606      */
2607     public abstract $type$ xorLanes();
2608 
2609     /**
2610      * Logically XORs all lane elements of this vector, selecting lane elements
2611      * controlled by a mask.
2612      * <p>
2613      * This is an associative cross-lane reduction operation which applies the logical XOR
2614      * operation ({@code ^}) to lane elements,
2615      * and the identity value is {@code 0}.
2616      *
2617      * @param m the mask controlling lane selection
2618      * @return the logical XOR all the lane elements of this vector
2619      */
2620     public abstract $type$ xorLanes(VectorMask<$Boxtype$> m);
2621 #end[BITWISE]
2622 
2623     // Type specific accessors
2624 
2625     /**
2626      * Gets the lane element at lane index {@code i}
2627      *
2628      * @param i the lane index
2629      * @return the lane element at lane index {@code i}
2630      * @throws IllegalArgumentException if the index is is out of range
2631      * ({@code < 0 || >= length()})
2632      */
2633     public abstract $type$ lane(int i);
2634 
2635     /**
2636      * Replaces the lane element of this vector at lane index {@code i} with
2637      * value {@code e}.
2638      * <p>
2639      * This is a cross-lane operation and behaves as if it returns the result
2640      * of blending this vector with an input vector that is the result of
2641      * broadcasting {@code e} and a mask that has only one lane set at lane
2642      * index {@code i}.
2643      *
2644      * @param i the lane index of the lane element to be replaced
2645      * @param e the value to be placed
2646      * @return the result of replacing the lane element of this vector at lane
2647      * index {@code i} with value {@code e}.
2648      * @throws IllegalArgumentException if the index is is out of range
2649      * ({@code < 0 || >= length()})
2650      */
2651     public abstract $abstractvectortype$ with(int i, $type$ e);
2652 
2653     // Type specific extractors
2654 
2655     /**
2656      * Returns an array containing the lane elements of this vector.
2657      * <p>
2658      * This method behaves as if it {@link #intoArray($type$[], int)} stores}
2659      * this vector into an allocated array and returns the array as follows:
2660      * <pre>{@code
2661      *   $type$[] a = new $type$[this.length()];
2662      *   this.intoArray(a, 0);
2663      *   return a;
2664      * }</pre>
2665      *
2666      * @return an array containing the the lane elements of this vector
2667      */
2668     @ForceInline
2669     public final $type$[] toArray() {
2670         $type$[] a = new $type$[species().length()];
2671         intoArray(a, 0);
2672         return a;
2673     }
2674 
2675     /**
2676      * Stores this vector into an array starting at offset.
2677      * <p>
2678      * For each vector lane, where {@code N} is the vector lane index,
2679      * the lane element at index {@code N} is stored into the array at index
2680      * {@code offset + N}.
2681      *
2682      * @param a the array
2683      * @param offset the offset into the array
2684      * @throws IndexOutOfBoundsException if {@code offset < 0}, or
2685      * {@code offset > a.length - this.length()}
2686      */
2687     public abstract void intoArray($type$[] a, int offset);
2688 
2689     /**
2690      * Stores this vector into an array starting at offset and using a mask.
2691      * <p>
2692      * For each vector lane, where {@code N} is the vector lane index,
2693      * if the mask lane at index {@code N} is set then the lane element at
2694      * index {@code N} is stored into the array index {@code offset + N}.
2695      *
2696      * @param a the array
2697      * @param offset the offset into the array
2698      * @param m the mask
2699      * @throws IndexOutOfBoundsException if {@code offset < 0}, or
2700      * for any vector lane index {@code N} where the mask at lane {@code N}
2701      * is set {@code offset >= a.length - N}
2702      */
2703     public abstract void intoArray($type$[] a, int offset, VectorMask<$Boxtype$> m);
2704 
2705     /**
2706      * Stores this vector into an array using indexes obtained from an index
2707      * map.
2708      * <p>
2709      * For each vector lane, where {@code N} is the vector lane index, the
2710      * lane element at index {@code N} is stored into the array at index
2711      * {@code a_offset + indexMap[i_offset + N]}.
2712      *
2713      * @param a the array
2714      * @param a_offset the offset into the array, may be negative if relative
2715      * indexes in the index map compensate to produce a value within the
2716      * array bounds
2717      * @param indexMap the index map
2718      * @param i_offset the offset into the index map
2719      * @throws IndexOutOfBoundsException if {@code i_offset < 0}, or
2720      * {@code i_offset > indexMap.length - this.length()},
2721      * or for any vector lane index {@code N} the result of
2722      * {@code a_offset + indexMap[i_offset + N]} is {@code < 0} or {@code >= a.length}
2723      */
2724 #if[byteOrShort]
2725     public void intoArray($type$[] a, int a_offset, int[] indexMap, int i_offset) {
2726         forEach((n, e) -> a[a_offset + indexMap[i_offset + n]] = e);
2727     }
2728 #else[byteOrShort]
2729     public abstract void intoArray($type$[] a, int a_offset, int[] indexMap, int i_offset);
2730 #end[byteOrShort]
2731 
2732     /**
2733      * Stores this vector into an array using indexes obtained from an index
2734      * map and using a mask.
2735      * <p>
2736      * For each vector lane, where {@code N} is the vector lane index,
2737      * if the mask lane at index {@code N} is set then the lane element at
2738      * index {@code N} is stored into the array at index
2739      * {@code a_offset + indexMap[i_offset + N]}.
2740      *
2741      * @param a the array
2742      * @param a_offset the offset into the array, may be negative if relative
2743      * indexes in the index map compensate to produce a value within the
2744      * array bounds
2745      * @param m the mask
2746      * @param indexMap the index map
2747      * @param i_offset the offset into the index map
2748      * @throws IndexOutOfBoundsException if {@code j < 0}, or
2749      * {@code i_offset > indexMap.length - this.length()},
2750      * or for any vector lane index {@code N} where the mask at lane
2751      * {@code N} is set the result of {@code a_offset + indexMap[i_offset + N]} is
2752      * {@code < 0} or {@code >= a.length}
2753      */
2754 #if[byteOrShort]
2755     public void intoArray($type$[] a, int a_offset, VectorMask<$Boxtype$> m, int[] indexMap, int i_offset) {
2756         forEach(m, (n, e) -> a[a_offset + indexMap[i_offset + n]] = e);
2757     }
2758 #else[byteOrShort]
2759     public abstract void intoArray($type$[] a, int a_offset, VectorMask<$Boxtype$> m, int[] indexMap, int i_offset);
2760 #end[byteOrShort]
2761     // Species
2762 
2763     /**
2764      * {@inheritDoc}
2765      */
2766     @Override
2767     public abstract VectorSpecies<$Boxtype$> species();
2768 
2769     /**
2770      * Class representing {@link $abstractvectortype$}'s of the same {@link VectorShape VectorShape}.
2771      */
2772     static final class $Type$Species extends AbstractSpecies<$Boxtype$> {
2773         final Function<$type$[], $Type$Vector> vectorFactory;
2774 
2775         private $Type$Species(VectorShape shape,
2776                           Class<?> vectorType,
2777                           Class<?> maskType,
2778                           Function<$type$[], $Type$Vector> vectorFactory,
2779                           Function<boolean[], VectorMask<$Boxtype$>> maskFactory,
2780                           Function<IntUnaryOperator, VectorShuffle<$Boxtype$>> shuffleFromArrayFactory,
2781                           fShuffleFromArray<$Boxtype$> shuffleFromOpFactory) {
2782             super(shape, $type$.class, $Boxtype$.SIZE, vectorType, maskType, maskFactory,
2783                   shuffleFromArrayFactory, shuffleFromOpFactory);
2784             this.vectorFactory = vectorFactory;
2785         }
2786 
2787         interface FOp {
2788             $type$ apply(int i);
2789         }
2790 
2791         $Type$Vector op(FOp f) {
2792             $type$[] res = new $type$[length()];
2793             for (int i = 0; i < length(); i++) {
2794                 res[i] = f.apply(i);
2795             }
2796             return vectorFactory.apply(res);
2797         }
2798 
2799         $Type$Vector op(VectorMask<$Boxtype$> o, FOp f) {
2800             $type$[] res = new $type$[length()];
2801             boolean[] mbits = ((AbstractMask<$Boxtype$>)o).getBits();
2802             for (int i = 0; i < length(); i++) {
2803                 if (mbits[i]) {
2804                     res[i] = f.apply(i);
2805                 }
2806             }
2807             return vectorFactory.apply(res);
2808         }
2809     }
2810 
2811     /**
2812      * Finds the preferred species for an element type of {@code $type$}.
2813      * <p>
2814      * A preferred species is a species chosen by the platform that has a
2815      * shape of maximal bit size.  A preferred species for different element
2816      * types will have the same shape, and therefore vectors, masks, and
2817      * shuffles created from such species will be shape compatible.
2818      *
2819      * @return the preferred species for an element type of {@code $type$}
2820      */
2821     private static $Type$Species preferredSpecies() {
2822         return ($Type$Species) VectorSpecies.ofPreferred($type$.class);
2823     }
2824 
2825     /**
2826      * Finds a species for an element type of {@code $type$} and shape.
2827      *
2828      * @param s the shape
2829      * @return a species for an element type of {@code $type$} and shape
2830      * @throws IllegalArgumentException if no such species exists for the shape
2831      */
2832     static $Type$Species species(VectorShape s) {
2833         Objects.requireNonNull(s);
2834         switch (s) {
2835             case S_64_BIT: return ($Type$Species) SPECIES_64;
2836             case S_128_BIT: return ($Type$Species) SPECIES_128;
2837             case S_256_BIT: return ($Type$Species) SPECIES_256;
2838             case S_512_BIT: return ($Type$Species) SPECIES_512;
2839             case S_Max_BIT: return ($Type$Species) SPECIES_MAX;
2840             default: throw new IllegalArgumentException("Bad shape: " + s);
2841         }
2842     }
2843 
2844     /** Species representing {@link $Type$Vector}s of {@link VectorShape#S_64_BIT VectorShape.S_64_BIT}. */
2845     public static final VectorSpecies<$Boxtype$> SPECIES_64 = new $Type$Species(VectorShape.S_64_BIT, $Type$64Vector.class, $Type$64Vector.$Type$64Mask.class,
2846                                                                      $Type$64Vector::new, $Type$64Vector.$Type$64Mask::new,
2847                                                                      $Type$64Vector.$Type$64Shuffle::new, $Type$64Vector.$Type$64Shuffle::new);
2848 
2849     /** Species representing {@link $Type$Vector}s of {@link VectorShape#S_128_BIT VectorShape.S_128_BIT}. */
2850     public static final VectorSpecies<$Boxtype$> SPECIES_128 = new $Type$Species(VectorShape.S_128_BIT, $Type$128Vector.class, $Type$128Vector.$Type$128Mask.class,
2851                                                                       $Type$128Vector::new, $Type$128Vector.$Type$128Mask::new,
2852                                                                       $Type$128Vector.$Type$128Shuffle::new, $Type$128Vector.$Type$128Shuffle::new);
2853 
2854     /** Species representing {@link $Type$Vector}s of {@link VectorShape#S_256_BIT VectorShape.S_256_BIT}. */
2855     public static final VectorSpecies<$Boxtype$> SPECIES_256 = new $Type$Species(VectorShape.S_256_BIT, $Type$256Vector.class, $Type$256Vector.$Type$256Mask.class,
2856                                                                       $Type$256Vector::new, $Type$256Vector.$Type$256Mask::new,
2857                                                                       $Type$256Vector.$Type$256Shuffle::new, $Type$256Vector.$Type$256Shuffle::new);
2858 
2859     /** Species representing {@link $Type$Vector}s of {@link VectorShape#S_512_BIT VectorShape.S_512_BIT}. */
2860     public static final VectorSpecies<$Boxtype$> SPECIES_512 = new $Type$Species(VectorShape.S_512_BIT, $Type$512Vector.class, $Type$512Vector.$Type$512Mask.class,
2861                                                                       $Type$512Vector::new, $Type$512Vector.$Type$512Mask::new,
2862                                                                       $Type$512Vector.$Type$512Shuffle::new, $Type$512Vector.$Type$512Shuffle::new);
2863 
2864     /** Species representing {@link $Type$Vector}s of {@link VectorShape#S_Max_BIT VectorShape.S_Max_BIT}. */
2865     public static final VectorSpecies<$Boxtype$> SPECIES_MAX = new $Type$Species(VectorShape.S_Max_BIT, $Type$MaxVector.class, $Type$MaxVector.$Type$MaxMask.class,
2866                                                                       $Type$MaxVector::new, $Type$MaxVector.$Type$MaxMask::new,
2867                                                                       $Type$MaxVector.$Type$MaxShuffle::new, $Type$MaxVector.$Type$MaxShuffle::new);
2868 
2869     /**
2870      * Preferred species for {@link $Type$Vector}s.
2871      * A preferred species is a species of maximal bit size for the platform.
2872      */
2873     public static final VectorSpecies<$Boxtype$> SPECIES_PREFERRED = (VectorSpecies<$Boxtype$>) preferredSpecies();
2874 }