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.boxType(), $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.boxType(), $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.boxType(), $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, a.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.boxType(), $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.boxType(), $type$.class, species.length(),
 285                                             IntVector.species(species.indexShape()).boxType(), 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.boxType(), $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
 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.boxType(), $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.boxType(), $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.boxType(), $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$ rotateEL(int i);
 857 
 858     /**
 859      * {@inheritDoc}
 860      */
 861     @Override
 862     public abstract $abstractvectortype$ rotateER(int i);
 863 
 864     /**
 865      * {@inheritDoc}
 866      */
 867     @Override
 868     public abstract $abstractvectortype$ shiftEL(int i);
 869 
 870     /**
 871      * {@inheritDoc}
 872      */
 873     @Override
 874     public abstract $abstractvectortype$ shiftER(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 #if[byte]
1907     /**
1908      * Logically left shifts this vector by the broadcast of an input scalar.
1909      * <p>
1910      * This is a lane-wise binary operation which applies the primitive logical left shift
1911      * operation ({@code <<}) to each lane to left shift the
1912      * element by shift value as specified by the input scalar. Only the 3
1913      * 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      *
1917      * @param s the input scalar; the number of the bits to left shift
1918      * @return the result of logically left shifting left this vector by the
1919      * broadcast of an input scalar
1920      */
1921 #end[byte]
1922 #if[short]
1923     /**
1924      * Logically left shifts this vector by the broadcast of an input scalar.
1925      * <p>
1926      * This is a lane-wise binary operation which applies the primitive logical left shift
1927      * operation ({@code <<}) to each lane to left shift the
1928      * element by shift value as specified by the input scalar. Only the 4
1929      * lowest-order bits of shift value are used. It is as if the shift value
1930      * were subjected to a bitwise logical AND operator ({@code &}) with the mask value 0xF.
1931      * The shift distance actually used is therefore always in the range 0 to 15, inclusive.
1932      *
1933      * @param s the input scalar; the number of the bits to left shift
1934      * @return the result of logically left shifting left this vector by the
1935      * broadcast of an input scalar
1936      */
1937 #end[short]
1938 #if[intOrLong]
1939     /**
1940      * Logically left shifts this vector by the broadcast of an input scalar.
1941      * <p>
1942      * This is a lane-wise binary operation which applies the primitive logical left shift
1943      * operation ({@code <<}) to each lane.
1944      *
1945      * @param s the input scalar; the number of the bits to left shift
1946      * @return the result of logically left shifting left this vector by the
1947      * broadcast of an input scalar
1948      */
1949 #end[intOrLong]
1950     public abstract $abstractvectortype$ shiftL(int s);
1951 
1952 #if[byte]
1953     /**
1954      * Logically left shifts this vector by the broadcast of an input scalar,
1955      * selecting lane elements controlled by a mask.
1956      * <p>
1957      * This is a lane-wise binary operation which applies the primitive logical left shift
1958      * operation ({@code <<}) to each lane to left shift the
1959      * element by shift value as specified by the input scalar. Only the 3
1960      * lowest-order bits of shift value are used. It is as if the shift value
1961      * were subjected to a bitwise logical AND operator ({@code &}) with the mask value 0x7.
1962      * The shift distance actually used is therefore always in the range 0 to 7, inclusive.
1963      *
1964      * @param s the input scalar; the number of the bits to left shift
1965      * @param m the mask controlling lane selection
1966      * @return the result of logically left shifting left this vector by the
1967      * broadcast of an input scalar
1968      */
1969 #end[byte]
1970 #if[short]
1971     /**
1972      * Logically left shifts this vector by the broadcast of an input scalar,
1973      * selecting lane elements controlled by a mask.
1974      * <p>
1975      * This is a lane-wise binary operation which applies the primitive logical left shift
1976      * operation ({@code <<}) to each lane to left shift the
1977      * element by shift value as specified by the input scalar. Only the 4
1978      * lowest-order bits of shift value are used. It is as if the shift value
1979      * were subjected to a bitwise logical AND operator ({@code &}) with the mask value 0xF.
1980      * The shift distance actually used is therefore always in the range 0 to 15, inclusive.
1981      *
1982      * @param s the input scalar; the number of the bits to left shift
1983      * @param m the mask controlling lane selection
1984      * @return the result of logically left shifting left this vector by the
1985      * broadcast of an input scalar
1986      */
1987 #end[short]
1988 #if[intOrLong]
1989     /**
1990      * Logically left shifts this vector by the broadcast of an input scalar,
1991      * selecting lane elements controlled by a mask.
1992      * <p>
1993      * This is a lane-wise binary operation which applies the primitive logical left shift
1994      * operation ({@code <<}) to each lane.
1995      *
1996      * @param s the input scalar; the number of the bits to left shift
1997      * @param m the mask controlling lane selection
1998      * @return the result of logically left shifting this vector by the
1999      * broadcast of an input scalar
2000      */
2001 #end[intOrLong]
2002     public abstract $abstractvectortype$ shiftL(int s, VectorMask<$Boxtype$> m);
2003 
2004 #if[intOrLong]
2005     /**
2006      * Logically left shifts this vector by an input vector.
2007      * <p>
2008      * This is a lane-wise binary operation which applies the primitive logical left shift
2009      * operation ({@code <<}) to each lane.
2010      *
2011      * @param v the input vector
2012      * @return the result of logically left shifting this vector by the input
2013      * vector
2014      */
2015     public abstract $abstractvectortype$ shiftL(Vector<$Boxtype$> v);
2016 
2017     /**
2018      * Logically left shifts this vector by an input vector, selecting lane
2019      * elements controlled by a mask.
2020      * <p>
2021      * This is a lane-wise binary operation which applies the primitive logical left shift
2022      * operation ({@code <<}) to each lane.
2023      *
2024      * @param v the input vector
2025      * @param m the mask controlling lane selection
2026      * @return the result of logically left shifting this vector by the input
2027      * vector
2028      */
2029     public $abstractvectortype$ shiftL(Vector<$Boxtype$> v, VectorMask<$Boxtype$> m) {
2030         return bOp(v, m, (i, a, b) -> ($type$) (a << b));
2031     }
2032 #end[intOrLong]
2033 
2034     // logical, or unsigned, shift right
2035 
2036 #if[byte]
2037      /**
2038      * Logically right shifts (or unsigned right shifts) this vector by the
2039      * broadcast of an input scalar.
2040      * <p>
2041      * This is a lane-wise binary operation which applies the primitive logical right shift
2042      * operation ({@code >>>}) to each lane to logically right shift the
2043      * element by shift value as specified by the input scalar. Only the 3
2044      * 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 0x7.
2046      * The shift distance actually used is therefore always in the range 0 to 7, inclusive.
2047      *
2048      * @param s the input scalar; the number of the bits to right shift
2049      * @return the result of logically right shifting this vector by the
2050      * broadcast of an input scalar
2051      */
2052 #end[byte]
2053 #if[short]
2054      /**
2055      * Logically right shifts (or unsigned right shifts) this vector by the
2056      * broadcast of an input scalar.
2057      * <p>
2058      * This is a lane-wise binary operation which applies the primitive logical right shift
2059      * operation ({@code >>>}) to each lane to logically right shift the
2060      * element by shift value as specified by the input scalar. Only the 4
2061      * lowest-order bits of shift value are used. It is as if the shift value
2062      * were subjected to a bitwise logical AND operator ({@code &}) with the mask value 0xF.
2063      * The shift distance actually used is therefore always in the range 0 to 15, inclusive.
2064      *
2065      * @param s the input scalar; the number of the bits to right shift
2066      * @return the result of logically right shifting this vector by the
2067      * broadcast of an input scalar
2068      */
2069 #end[short]
2070 #if[intOrLong]
2071     /**
2072      * Logically right shifts (or unsigned right shifts) this vector by the
2073      * broadcast of an input scalar.
2074      * <p>
2075      * This is a lane-wise binary operation which applies the primitive logical right shift
2076      * operation ({@code >>>}) to each lane.
2077      *
2078      * @param s the input scalar; the number of the bits to right shift
2079      * @return the result of logically right shifting this vector by the
2080      * broadcast of an input scalar
2081      */
2082 #end[intOrLong]
2083     public abstract $abstractvectortype$ shiftR(int s);
2084 
2085 #if[byte]
2086      /**
2087      * Logically right shifts (or unsigned right shifts) this vector by the
2088      * broadcast of an input scalar, selecting lane elements controlled by a
2089      * mask.
2090      * <p>
2091      * This is a lane-wise binary operation which applies the primitive logical right shift
2092      * operation ({@code >>}) to each lane to logically right shift the
2093      * element by shift value as specified by the input scalar. Only the 3
2094      * lowest-order bits of shift value are used. It is as if the shift value
2095      * were subjected to a bitwise logical AND operator ({@code &}) with the mask value 0x7.
2096      * The shift distance actually used is therefore always in the range 0 to 7, inclusive.
2097      *
2098      * @param s the input scalar; the number of the bits to right shift
2099      * @param m the mask controlling lane selection
2100      * @return the result of logically right shifting this vector by the
2101      * broadcast of an input scalar
2102      */
2103 #end[byte]
2104 #if[short]
2105      /**
2106      * Logically right shifts (or unsigned right shifts) this vector by the
2107      * broadcast of an input scalar, selecting lane elements controlled by a
2108      * mask.
2109      * <p>
2110      * This is a lane-wise binary operation which applies the primitive logical right shift
2111      * operation ({@code >>>}) to each lane to logically right shift the
2112      * element by shift value as specified by the input scalar. Only the 4
2113      * lowest-order bits of shift value are used. It is as if the shift value
2114      * were subjected to a bitwise logical AND operator ({@code &}) with the mask value 0xF.
2115      * The shift distance actually used is therefore always in the range 0 to 15, inclusive.
2116      *
2117      * @param s the input scalar; the number of the bits to right shift
2118      * @param m the mask controlling lane selection
2119      * @return the result of logically right shifting this vector by the
2120      * broadcast of an input scalar
2121      */
2122 #end[short]
2123 #if[intOrLong]
2124     /**
2125      * Logically right shifts (or unsigned right shifts) this vector by the
2126      * broadcast of an input scalar, selecting lane elements controlled by a
2127      * mask.
2128      * <p>
2129      * This is a lane-wise binary operation which applies the primitive logical right shift
2130      * operation ({@code >>>}) to each lane.
2131      *
2132      * @param s the input scalar; the number of the bits to right shift
2133      * @param m the mask controlling lane selection
2134      * @return the result of logically right shifting this vector by the
2135      * broadcast of an input scalar
2136      */
2137 #end[intOrLong]
2138     public abstract $abstractvectortype$ shiftR(int s, VectorMask<$Boxtype$> m);
2139 
2140 #if[intOrLong]
2141     /**
2142      * Logically right shifts (or unsigned right shifts) this vector by an
2143      * input vector.
2144      * <p>
2145      * This is a lane-wise binary operation which applies the primitive logical right shift
2146      * operation ({@code >>>}) to each lane.
2147      *
2148      * @param v the input vector
2149      * @return the result of logically right shifting this vector by the
2150      * input vector
2151      */
2152     public abstract $abstractvectortype$ shiftR(Vector<$Boxtype$> v);
2153 
2154     /**
2155      * Logically right shifts (or unsigned right shifts) this vector by an
2156      * input vector, selecting lane elements controlled by a mask.
2157      * <p>
2158      * This is a lane-wise binary operation which applies the primitive logical right shift
2159      * operation ({@code >>>}) to each lane.
2160      *
2161      * @param v the input vector
2162      * @param m the mask controlling lane selection
2163      * @return the result of logically right shifting this vector by the
2164      * input vector
2165      */
2166     public $abstractvectortype$ shiftR(Vector<$Boxtype$> v, VectorMask<$Boxtype$> m) {
2167         return bOp(v, m, (i, a, b) -> ($type$) (a >>> b));
2168     }
2169 #end[intOrLong]
2170 
2171 #if[byte]
2172     /**
2173      * Arithmetically right shifts (or signed right shifts) this vector by the
2174      * broadcast of an input scalar.
2175      * <p>
2176      * This is a lane-wise binary operation which applies the primitive arithmetic right
2177      * shift operation ({@code >>}) to each lane to arithmetically
2178      * right shift the element by shift value as specified by the input scalar.
2179      * Only the 3 lowest-order bits of shift value are used. It is as if the shift
2180      * value were subjected to a bitwise logical AND operator ({@code &}) with the mask value 0x7.
2181      * The shift distance actually used is therefore always in the range 0 to 7, inclusive.
2182      *
2183      * @param s the input scalar; the number of the bits to right shift
2184      * @return the result of arithmetically right shifting this vector by the
2185      * broadcast of an input scalar
2186      */
2187 #end[byte]
2188 #if[short]
2189     /**
2190      * Arithmetically right shifts (or signed right shifts) this vector by the
2191      * broadcast of an input scalar.
2192      * <p>
2193      * This is a lane-wise binary operation which applies the primitive arithmetic right
2194      * shift operation ({@code >>}) to each lane to arithmetically
2195      * right shift the element by shift value as specified by the input scalar.
2196      * Only the 4 lowest-order bits of shift value are used. It is as if the shift
2197      * value were subjected to a bitwise logical AND operator ({@code &}) with the mask value 0xF.
2198      * The shift distance actually used is therefore always in the range 0 to 15, inclusive.
2199      *
2200      * @param s the input scalar; the number of the bits to right shift
2201      * @return the result of arithmetically right shifting this vector by the
2202      * broadcast of an input scalar
2203      */
2204 #end[short]
2205 #if[intOrLong]
2206     /**
2207      * Arithmetically right shifts (or signed right shifts) this vector by the
2208      * broadcast of an input scalar.
2209      * <p>
2210      * This is a lane-wise binary operation which applies the primitive arithmetic right
2211      * shift operation ({@code >>}) to each lane.
2212      *
2213      * @param s the input scalar; the number of the bits to right shift
2214      * @return the result of arithmetically right shifting this vector by the
2215      * broadcast of an input scalar
2216      */
2217 #end[intOrLong]
2218     public abstract $abstractvectortype$ aShiftR(int s);
2219 
2220 #if[byte]
2221     /**
2222      * Arithmetically right shifts (or signed right shifts) this vector by the
2223      * broadcast of an input scalar, selecting lane elements controlled by a
2224      * mask.
2225      * <p>
2226      * This is a lane-wise binary operation which applies the primitive arithmetic right
2227      * shift operation ({@code >>}) to each lane to arithmetically
2228      * right shift the element by shift value as specified by the input scalar.
2229      * Only the 3 lowest-order bits of shift value are used. It is as if the shift
2230      * value were subjected to a bitwise logical AND operator ({@code &}) with the mask value 0x7.
2231      * The shift distance actually used is therefore always in the range 0 to 7, inclusive.
2232      *
2233      * @param s the input scalar; the number of the bits to right shift
2234      * @param m the mask controlling lane selection
2235      * @return the result of arithmetically right shifting this vector by the
2236      * broadcast of an input scalar
2237      */
2238 #end[byte]
2239 #if[short]
2240     /**
2241      * Arithmetically right shifts (or signed right shifts) this vector by the
2242      * broadcast of an input scalar, selecting lane elements controlled by a
2243      * mask.
2244      * <p>
2245      * This is a lane-wise binary operation which applies the primitive arithmetic right
2246      * shift operation ({@code >>}) to each lane to arithmetically
2247      * right shift the element by shift value as specified by the input scalar.
2248      * Only the 4 lowest-order bits of shift value are used. It is as if the shift
2249      * value were subjected to a bitwise logical AND operator ({@code &}) with the mask value 0xF.
2250      * The shift distance actually used is therefore always in the range 0 to 15, inclusive.
2251      *
2252      * @param s the input scalar; the number of the bits to right shift
2253      * @param m the mask controlling lane selection
2254      * @return the result of arithmetically right shifting this vector by the
2255      * broadcast of an input scalar
2256      */
2257 #end[short]
2258 #if[intOrLong]
2259     /**
2260      * Arithmetically right shifts (or signed right shifts) this vector by the
2261      * broadcast of an input scalar, selecting lane elements controlled by a
2262      * mask.
2263      * <p>
2264      * This is a lane-wise binary operation which applies the primitive arithmetic right
2265      * shift operation ({@code >>}) to each lane.
2266      *
2267      * @param s the input scalar; the number of the bits to right shift
2268      * @param m the mask controlling lane selection
2269      * @return the result of arithmetically right shifting this vector by the
2270      * broadcast of an input scalar
2271      */
2272 #end[intOrLong]
2273     public abstract $abstractvectortype$ aShiftR(int s, VectorMask<$Boxtype$> m);
2274 
2275 #if[intOrLong]
2276     /**
2277      * Arithmetically right shifts (or signed right shifts) this vector by an
2278      * input vector.
2279      * <p>
2280      * This is a lane-wise binary operation which applies the primitive arithmetic right
2281      * shift operation ({@code >>}) to each lane.
2282      *
2283      * @param v the input vector
2284      * @return the result of arithmetically right shifting this vector by the
2285      * input vector
2286      */
2287     public abstract $abstractvectortype$ aShiftR(Vector<$Boxtype$> v);
2288 
2289     /**
2290      * Arithmetically right shifts (or signed right shifts) this vector by an
2291      * input vector, selecting lane elements controlled by a mask.
2292      * <p>
2293      * This is a lane-wise binary operation which applies the primitive arithmetic right
2294      * shift operation ({@code >>}) to each lane.
2295      *
2296      * @param v the input vector
2297      * @param m the mask controlling lane selection
2298      * @return the result of arithmetically right shifting this vector by the
2299      * input vector
2300      */
2301     public $abstractvectortype$ aShiftR(Vector<$Boxtype$> v, VectorMask<$Boxtype$> m) {
2302         return bOp(v, m, (i, a, b) -> ($type$) (a >> b));
2303     }
2304 
2305     /**
2306      * Rotates left this vector by the broadcast of an input scalar.
2307      * <p>
2308      * This is a lane-wise binary operation which applies the operation
2309      * {@link $Wideboxtype$#rotateLeft} to each lane and where
2310      * lane elements of this vector apply to the first argument, and lane
2311      * elements of the broadcast vector apply to the second argument (the
2312      * rotation distance).
2313      *
2314      * @param s the input scalar; the number of the bits to rotate left
2315      * @return the result of rotating left this vector by the broadcast of an
2316      * input scalar
2317      */
2318     @ForceInline
2319     public final $abstractvectortype$ rotateL(int s) {
2320         return shiftL(s).or(shiftR(-s));
2321     }
2322 
2323     /**
2324      * Rotates left this vector by the broadcast of an input scalar, selecting
2325      * lane elements controlled by a mask.
2326      * <p>
2327      * This is a lane-wise binary operation which applies the operation
2328      * {@link $Wideboxtype$#rotateLeft} to each lane and where
2329      * lane elements of this vector apply to the first argument, and lane
2330      * elements of the broadcast vector apply to the second argument (the
2331      * rotation distance).
2332      *
2333      * @param s the input scalar; the number of the bits to rotate left
2334      * @param m the mask controlling lane selection
2335      * @return the result of rotating left this vector by the broadcast of an
2336      * input scalar
2337      */
2338     @ForceInline
2339     public final $abstractvectortype$ rotateL(int s, VectorMask<$Boxtype$> m) {
2340         return shiftL(s, m).or(shiftR(-s, m), m);
2341     }
2342 
2343     /**
2344      * Rotates right this vector by the broadcast of an input scalar.
2345      * <p>
2346      * This is a lane-wise binary operation which applies the operation
2347      * {@link $Wideboxtype$#rotateRight} to each lane and where
2348      * lane elements of this vector apply to the first argument, and lane
2349      * elements of the broadcast vector apply to the second argument (the
2350      * rotation distance).
2351      *
2352      * @param s the input scalar; the number of the bits to rotate right
2353      * @return the result of rotating right this vector by the broadcast of an
2354      * input scalar
2355      */
2356     @ForceInline
2357     public final $abstractvectortype$ rotateR(int s) {
2358         return shiftR(s).or(shiftL(-s));
2359     }
2360 
2361     /**
2362      * Rotates right this vector by the broadcast of an input scalar, selecting
2363      * lane elements controlled by a mask.
2364      * <p>
2365      * This is a lane-wise binary operation which applies the operation
2366      * {@link $Wideboxtype$#rotateRight} to each lane and where
2367      * lane elements of this vector apply to the first argument, and lane
2368      * elements of the broadcast vector apply to the second argument (the
2369      * rotation distance).
2370      *
2371      * @param s the input scalar; the number of the bits to rotate right
2372      * @param m the mask controlling lane selection
2373      * @return the result of rotating right this vector by the broadcast of an
2374      * input scalar
2375      */
2376     @ForceInline
2377     public final $abstractvectortype$ rotateR(int s, VectorMask<$Boxtype$> m) {
2378         return shiftR(s, m).or(shiftL(-s, m), m);
2379     }
2380 #end[intOrLong]
2381 #end[BITWISE]
2382 
2383     /**
2384      * {@inheritDoc}
2385      */
2386     @Override
2387     public abstract void intoByteArray(byte[] a, int ix);
2388 
2389     /**
2390      * {@inheritDoc}
2391      */
2392     @Override
2393     public abstract void intoByteArray(byte[] a, int ix, VectorMask<$Boxtype$> m);
2394 
2395     /**
2396      * {@inheritDoc}
2397      */
2398     @Override
2399     public abstract void intoByteBuffer(ByteBuffer bb, int ix);
2400 
2401     /**
2402      * {@inheritDoc}
2403      */
2404     @Override
2405     public abstract void intoByteBuffer(ByteBuffer bb, int ix, VectorMask<$Boxtype$> m);
2406 
2407 
2408     // Type specific horizontal reductions
2409     /**
2410      * Adds all lane elements of this vector.
2411      * <p>
2412 #if[FP]
2413      * This is a cross-lane reduction operation which applies the addition
2414      * operation ({@code +}) to lane elements,
2415      * and the identity value is {@code 0.0}.
2416      *
2417      * <p>The value of a floating-point sum is a function both of the input values as well
2418      * as the order of addition operations. The order of addition operations of this method
2419      * is intentionally not defined to allow for JVM to generate optimal machine
2420      * code for the underlying platform at runtime. If the platform supports a vector
2421      * instruction to add all values in the vector, or if there is some other efficient machine
2422      * code sequence, then the JVM has the option of generating this machine code. Otherwise,
2423      * the default implementation of adding vectors sequentially from left to right is used.
2424      * For this reason, the output of this method may vary for the same input values.
2425 #else[FP]
2426      * This is an associative cross-lane reduction operation which applies the addition
2427      * operation ({@code +}) to lane elements,
2428      * and the identity value is {@code 0}.
2429 #end[FP]
2430      *
2431      * @return the addition of all the lane elements of this vector
2432      */
2433     public abstract $type$ addAll();
2434 
2435     /**
2436      * Adds all lane elements of this vector, selecting lane elements
2437      * controlled by a mask.
2438      * <p>
2439 #if[FP]
2440      * This is a cross-lane reduction operation which applies the addition
2441      * operation ({@code +}) to lane elements,
2442      * and the identity value is {@code 0.0}.
2443      *
2444      * <p>The value of a floating-point sum is a function both of the input values as well
2445      * as the order of addition operations. The order of addition operations of this method
2446      * is intentionally not defined to allow for JVM to generate optimal machine
2447      * code for the underlying platform at runtime. If the platform supports a vector
2448      * instruction to add all values in the vector, or if there is some other efficient machine
2449      * code sequence, then the JVM has the option of generating this machine code. Otherwise,
2450      * the default implementation of adding vectors sequentially from left to right is used.
2451      * For this reason, the output of this method may vary on the same input values.
2452 #else[FP]
2453      * This is an associative cross-lane reduction operation which applies the addition
2454      * operation ({@code +}) to lane elements,
2455      * and the identity value is {@code 0}.
2456 #end[FP]
2457      *
2458      * @param m the mask controlling lane selection
2459      * @return the addition of the selected lane elements of this vector
2460      */
2461     public abstract $type$ addAll(VectorMask<$Boxtype$> m);
2462 
2463     /**
2464      * Multiplies all lane elements of this vector.
2465      * <p>
2466 #if[FP]
2467      * This is a cross-lane reduction operation which applies the
2468      * multiplication operation ({@code *}) to lane elements,
2469      * and the identity value is {@code 1.0}.
2470      *
2471      * <p>The order of multiplication operations of this method
2472      * is intentionally not defined to allow for JVM to generate optimal machine
2473      * code for the underlying platform at runtime. If the platform supports a vector
2474      * instruction to multiply all values in the vector, or if there is some other efficient machine
2475      * code sequence, then the JVM has the option of generating this machine code. Otherwise,
2476      * the default implementation of multiplying vectors sequentially from left to right is used.
2477      * For this reason, the output of this method may vary on the same input values.
2478 #else[FP]
2479      * This is an associative cross-lane reduction operation which applies the
2480      * multiplication operation ({@code *}) to lane elements,
2481      * and the identity value is {@code 1}.
2482 #end[FP]
2483      *
2484      * @return the multiplication of all the lane elements of this vector
2485      */
2486     public abstract $type$ mulAll();
2487 
2488     /**
2489      * Multiplies all lane elements of this vector, selecting lane elements
2490      * controlled by a mask.
2491      * <p>
2492 #if[FP]
2493      * This is a cross-lane reduction operation which applies the
2494      * multiplication operation ({@code *}) to lane elements,
2495      * and the identity value is {@code 1.0}.
2496      *
2497      * <p>The order of multiplication operations of this method
2498      * is intentionally not defined to allow for JVM to generate optimal machine
2499      * code for the underlying platform at runtime. If the platform supports a vector
2500      * instruction to multiply all values in the vector, or if there is some other efficient machine
2501      * code sequence, then the JVM has the option of generating this machine code. Otherwise,
2502      * the default implementation of multiplying vectors sequentially from left to right is used.
2503      * For this reason, the output of this method may vary on the same input values.
2504 #else[FP]
2505      * This is an associative cross-lane reduction operation which applies the
2506      * multiplication operation ({@code *}) to lane elements,
2507      * and the identity value is {@code 1}.
2508 #end[FP]
2509      *
2510      * @param m the mask controlling lane selection
2511      * @return the multiplication of all the lane elements of this vector
2512      */
2513     public abstract $type$ mulAll(VectorMask<$Boxtype$> m);
2514 
2515     /**
2516      * Returns the minimum 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.min(a, b)} to lane elements,
2520      * and the identity value is
2521 #if[FP]
2522      * {@link $Boxtype$#POSITIVE_INFINITY}.
2523 #else[FP]
2524      * {@link $Boxtype$#MAX_VALUE}.
2525 #end[FP]
2526      *
2527      * @return the minimum lane element of this vector
2528      */
2529     public abstract $type$ minAll();
2530 
2531     /**
2532      * Returns the minimum 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.min(a, b)} to lane elements,
2537      * and the identity value is
2538 #if[FP]
2539      * {@link $Boxtype$#POSITIVE_INFINITY}.
2540 #else[FP]
2541      * {@link $Boxtype$#MAX_VALUE}.
2542 #end[FP]
2543      *
2544      * @param m the mask controlling lane selection
2545      * @return the minimum lane element of this vector
2546      */
2547     public abstract $type$ minAll(VectorMask<$Boxtype$> m);
2548 
2549     /**
2550      * Returns the maximum lane element of this vector.
2551      * <p>
2552      * This is an associative cross-lane reduction operation which applies the operation
2553      * {@code (a, b) -> Math.max(a, b)} to lane elements,
2554      * and the identity value is
2555 #if[FP]
2556      * {@link $Boxtype$#NEGATIVE_INFINITY}.
2557 #else[FP]
2558      * {@link $Boxtype$#MIN_VALUE}.
2559 #end[FP]
2560      *
2561      * @return the maximum lane element of this vector
2562      */
2563     public abstract $type$ maxAll();
2564 
2565     /**
2566      * Returns the maximum lane element of this vector, selecting lane elements
2567      * controlled by a mask.
2568      * <p>
2569      * This is an associative cross-lane reduction operation which applies the operation
2570      * {@code (a, b) -> Math.max(a, b)} to lane elements,
2571      * and the identity value is
2572 #if[FP]
2573      * {@link $Boxtype$#NEGATIVE_INFINITY}.
2574 #else[FP]
2575      * {@link $Boxtype$#MIN_VALUE}.
2576 #end[FP]
2577      *
2578      * @param m the mask controlling lane selection
2579      * @return the maximum lane element of this vector
2580      */
2581     public abstract $type$ maxAll(VectorMask<$Boxtype$> m);
2582 
2583 #if[BITWISE]
2584     /**
2585      * Logically ORs all lane elements of this vector.
2586      * <p>
2587      * This is an associative cross-lane reduction operation which applies the logical OR
2588      * operation ({@code |}) to lane elements,
2589      * and the identity value is {@code 0}.
2590      *
2591      * @return the logical OR all the lane elements of this vector
2592      */
2593     public abstract $type$ orAll();
2594 
2595     /**
2596      * Logically ORs all lane elements of this vector, selecting lane elements
2597      * controlled by a mask.
2598      * <p>
2599      * This is an associative cross-lane reduction operation which applies the logical OR
2600      * operation ({@code |}) to lane elements,
2601      * and the identity value is {@code 0}.
2602      *
2603      * @param m the mask controlling lane selection
2604      * @return the logical OR all the lane elements of this vector
2605      */
2606     public abstract $type$ orAll(VectorMask<$Boxtype$> m);
2607 
2608     /**
2609      * Logically ANDs all lane elements of this vector.
2610      * <p>
2611      * This is an associative cross-lane reduction operation which applies the logical AND
2612      * operation ({@code |}) to lane elements,
2613      * and the identity value is {@code -1}.
2614      *
2615      * @return the logical AND all the lane elements of this vector
2616      */
2617     public abstract $type$ andAll();
2618 
2619     /**
2620      * Logically ANDs all lane elements of this vector, selecting lane elements
2621      * controlled by a mask.
2622      * <p>
2623      * This is an associative cross-lane reduction operation which applies the logical AND
2624      * operation ({@code |}) to lane elements,
2625      * and the identity value is {@code -1}.
2626      *
2627      * @param m the mask controlling lane selection
2628      * @return the logical AND all the lane elements of this vector
2629      */
2630     public abstract $type$ andAll(VectorMask<$Boxtype$> m);
2631 
2632     /**
2633      * Logically XORs all lane elements of this vector.
2634      * <p>
2635      * This is an associative cross-lane reduction operation which applies the logical XOR
2636      * operation ({@code ^}) to lane elements,
2637      * and the identity value is {@code 0}.
2638      *
2639      * @return the logical XOR all the lane elements of this vector
2640      */
2641     public abstract $type$ xorAll();
2642 
2643     /**
2644      * Logically XORs all lane elements of this vector, selecting lane elements
2645      * controlled by a mask.
2646      * <p>
2647      * This is an associative cross-lane reduction operation which applies the logical XOR
2648      * operation ({@code ^}) to lane elements,
2649      * and the identity value is {@code 0}.
2650      *
2651      * @param m the mask controlling lane selection
2652      * @return the logical XOR all the lane elements of this vector
2653      */
2654     public abstract $type$ xorAll(VectorMask<$Boxtype$> m);
2655 #end[BITWISE]
2656 
2657     // Type specific accessors
2658 
2659     /**
2660      * Gets the lane element at lane index {@code i}
2661      *
2662      * @param i the lane index
2663      * @return the lane element at lane index {@code i}
2664      * @throws IllegalArgumentException if the index is is out of range
2665      * ({@code < 0 || >= length()})
2666      */
2667     public abstract $type$ lane(int i);
2668 
2669     /**
2670      * Replaces the lane element of this vector at lane index {@code i} with
2671      * value {@code e}.
2672      * <p>
2673      * This is a cross-lane operation and behaves as if it returns the result
2674      * of blending this vector with an input vector that is the result of
2675      * broadcasting {@code e} and a mask that has only one lane set at lane
2676      * index {@code i}.
2677      *
2678      * @param i the lane index of the lane element to be replaced
2679      * @param e the value to be placed
2680      * @return the result of replacing the lane element of this vector at lane
2681      * index {@code i} with value {@code e}.
2682      * @throws IllegalArgumentException if the index is is out of range
2683      * ({@code < 0 || >= length()})
2684      */
2685     public abstract $abstractvectortype$ with(int i, $type$ e);
2686 
2687     // Type specific extractors
2688 
2689     /**
2690      * Returns an array containing the lane elements of this vector.
2691      * <p>
2692      * This method behaves as if it {@link #intoArray($type$[], int)} stores}
2693      * this vector into an allocated array and returns the array as follows:
2694      * <pre>{@code
2695      *   $type$[] a = new $type$[this.length()];
2696      *   this.intoArray(a, 0);
2697      *   return a;
2698      * }</pre>
2699      *
2700      * @return an array containing the the lane elements of this vector
2701      */
2702     @ForceInline
2703     public final $type$[] toArray() {
2704         $type$[] a = new $type$[species().length()];
2705         intoArray(a, 0);
2706         return a;
2707     }
2708 
2709     /**
2710      * Stores this vector into an array starting at offset.
2711      * <p>
2712      * For each vector lane, where {@code N} is the vector lane index,
2713      * the lane element at index {@code N} is stored into the array at index
2714      * {@code offset + N}.
2715      *
2716      * @param a the array
2717      * @param offset the offset into the array
2718      * @throws IndexOutOfBoundsException if {@code offset < 0}, or
2719      * {@code offset > a.length - this.length()}
2720      */
2721     public abstract void intoArray($type$[] a, int offset);
2722 
2723     /**
2724      * Stores this vector into an array starting at offset and using a mask.
2725      * <p>
2726      * For each vector lane, where {@code N} is the vector lane index,
2727      * if the mask lane at index {@code N} is set then the lane element at
2728      * index {@code N} is stored into the array index {@code offset + N}.
2729      *
2730      * @param a the array
2731      * @param offset the offset into the array
2732      * @param m the mask
2733      * @throws IndexOutOfBoundsException if {@code offset < 0}, or
2734      * for any vector lane index {@code N} where the mask at lane {@code N}
2735      * is set {@code offset >= a.length - N}
2736      */
2737     public abstract void intoArray($type$[] a, int offset, VectorMask<$Boxtype$> m);
2738 
2739     /**
2740      * Stores this vector into an array using indexes obtained from an index
2741      * map.
2742      * <p>
2743      * For each vector lane, where {@code N} is the vector lane index, the
2744      * lane element at index {@code N} is stored into the array at index
2745      * {@code a_offset + indexMap[i_offset + N]}.
2746      *
2747      * @param a the array
2748      * @param a_offset the offset into the array, may be negative if relative
2749      * indexes in the index map compensate to produce a value within the
2750      * array bounds
2751      * @param indexMap the index map
2752      * @param i_offset the offset into the index map
2753      * @throws IndexOutOfBoundsException if {@code i_offset < 0}, or
2754      * {@code i_offset > indexMap.length - this.length()},
2755      * or for any vector lane index {@code N} the result of
2756      * {@code a_offset + indexMap[i_offset + N]} is {@code < 0} or {@code >= a.length}
2757      */
2758 #if[byteOrShort]
2759     public void intoArray($type$[] a, int a_offset, int[] indexMap, int i_offset) {
2760         forEach((n, e) -> a[a_offset + indexMap[i_offset + n]] = e);
2761     }
2762 #else[byteOrShort]
2763     public abstract void intoArray($type$[] a, int a_offset, int[] indexMap, int i_offset);
2764 #end[byteOrShort]
2765 
2766     /**
2767      * Stores this vector into an array using indexes obtained from an index
2768      * map and using a mask.
2769      * <p>
2770      * For each vector lane, where {@code N} is the vector lane index,
2771      * if the mask lane at index {@code N} is set then the lane element at
2772      * index {@code N} is stored into the array at index
2773      * {@code a_offset + indexMap[i_offset + N]}.
2774      *
2775      * @param a the array
2776      * @param a_offset the offset into the array, may be negative if relative
2777      * indexes in the index map compensate to produce a value within the
2778      * array bounds
2779      * @param m the mask
2780      * @param indexMap the index map
2781      * @param i_offset the offset into the index map
2782      * @throws IndexOutOfBoundsException if {@code j < 0}, or
2783      * {@code i_offset > indexMap.length - this.length()},
2784      * or for any vector lane index {@code N} where the mask at lane
2785      * {@code N} is set the result of {@code a_offset + indexMap[i_offset + N]} is
2786      * {@code < 0} or {@code >= a.length}
2787      */
2788 #if[byteOrShort]
2789     public void intoArray($type$[] a, int a_offset, VectorMask<$Boxtype$> m, int[] indexMap, int i_offset) {
2790         forEach(m, (n, e) -> a[a_offset + indexMap[i_offset + n]] = e);
2791     }
2792 #else[byteOrShort]
2793     public abstract void intoArray($type$[] a, int a_offset, VectorMask<$Boxtype$> m, int[] indexMap, int i_offset);
2794 #end[byteOrShort]
2795     // Species
2796 
2797     /**
2798      * {@inheritDoc}
2799      */
2800     @Override
2801     public abstract VectorSpecies<$Boxtype$> species();
2802 
2803     /**
2804      * Class representing {@link $abstractvectortype$}'s of the same {@link VectorShape VectorShape}.
2805      */
2806     static final class $Type$Species extends AbstractSpecies<$Boxtype$> {
2807         final Function<$type$[], $Type$Vector> vectorFactory;
2808 
2809         private $Type$Species(VectorShape shape,
2810                           Class<?> boxType,
2811                           Class<?> maskType,
2812                           Function<$type$[], $Type$Vector> vectorFactory,
2813                           Function<boolean[], VectorMask<$Boxtype$>> maskFactory,
2814                           Function<IntUnaryOperator, VectorShuffle<$Boxtype$>> shuffleFromArrayFactory,
2815                           fShuffleFromArray<$Boxtype$> shuffleFromOpFactory) {
2816             super(shape, $type$.class, $Boxtype$.SIZE, boxType, maskType, maskFactory,
2817                   shuffleFromArrayFactory, shuffleFromOpFactory);
2818             this.vectorFactory = vectorFactory;
2819         }
2820 
2821         interface FOp {
2822             $type$ apply(int i);
2823         }
2824 
2825         $Type$Vector op(FOp f) {
2826             $type$[] res = new $type$[length()];
2827             for (int i = 0; i < length(); i++) {
2828                 res[i] = f.apply(i);
2829             }
2830             return vectorFactory.apply(res);
2831         }
2832 
2833         $Type$Vector op(VectorMask<$Boxtype$> o, FOp f) {
2834             $type$[] res = new $type$[length()];
2835             boolean[] mbits = ((AbstractMask<$Boxtype$>)o).getBits();
2836             for (int i = 0; i < length(); i++) {
2837                 if (mbits[i]) {
2838                     res[i] = f.apply(i);
2839                 }
2840             }
2841             return vectorFactory.apply(res);
2842         }
2843     }
2844 
2845     /**
2846      * Finds the preferred species for an element type of {@code $type$}.
2847      * <p>
2848      * A preferred species is a species chosen by the platform that has a
2849      * shape of maximal bit size.  A preferred species for different element
2850      * types will have the same shape, and therefore vectors, masks, and
2851      * shuffles created from such species will be shape compatible.
2852      *
2853      * @return the preferred species for an element type of {@code $type$}
2854      */
2855     private static $Type$Species preferredSpecies() {
2856         return ($Type$Species) VectorSpecies.ofPreferred($type$.class);
2857     }
2858 
2859     /**
2860      * Finds a species for an element type of {@code $type$} and shape.
2861      *
2862      * @param s the shape
2863      * @return a species for an element type of {@code $type$} and shape
2864      * @throws IllegalArgumentException if no such species exists for the shape
2865      */
2866     static $Type$Species species(VectorShape s) {
2867         Objects.requireNonNull(s);
2868         switch (s) {
2869             case S_64_BIT: return ($Type$Species) SPECIES_64;
2870             case S_128_BIT: return ($Type$Species) SPECIES_128;
2871             case S_256_BIT: return ($Type$Species) SPECIES_256;
2872             case S_512_BIT: return ($Type$Species) SPECIES_512;
2873             case S_Max_BIT: return ($Type$Species) SPECIES_MAX;
2874             default: throw new IllegalArgumentException("Bad shape: " + s);
2875         }
2876     }
2877 
2878     /** Species representing {@link $Type$Vector}s of {@link VectorShape#S_64_BIT VectorShape.S_64_BIT}. */
2879     public static final VectorSpecies<$Boxtype$> SPECIES_64 = new $Type$Species(VectorShape.S_64_BIT, $Type$64Vector.class, $Type$64Vector.$Type$64Mask.class,
2880                                                                      $Type$64Vector::new, $Type$64Vector.$Type$64Mask::new,
2881                                                                      $Type$64Vector.$Type$64Shuffle::new, $Type$64Vector.$Type$64Shuffle::new);
2882 
2883     /** Species representing {@link $Type$Vector}s of {@link VectorShape#S_128_BIT VectorShape.S_128_BIT}. */
2884     public static final VectorSpecies<$Boxtype$> SPECIES_128 = new $Type$Species(VectorShape.S_128_BIT, $Type$128Vector.class, $Type$128Vector.$Type$128Mask.class,
2885                                                                       $Type$128Vector::new, $Type$128Vector.$Type$128Mask::new,
2886                                                                       $Type$128Vector.$Type$128Shuffle::new, $Type$128Vector.$Type$128Shuffle::new);
2887 
2888     /** Species representing {@link $Type$Vector}s of {@link VectorShape#S_256_BIT VectorShape.S_256_BIT}. */
2889     public static final VectorSpecies<$Boxtype$> SPECIES_256 = new $Type$Species(VectorShape.S_256_BIT, $Type$256Vector.class, $Type$256Vector.$Type$256Mask.class,
2890                                                                       $Type$256Vector::new, $Type$256Vector.$Type$256Mask::new,
2891                                                                       $Type$256Vector.$Type$256Shuffle::new, $Type$256Vector.$Type$256Shuffle::new);
2892 
2893     /** Species representing {@link $Type$Vector}s of {@link VectorShape#S_512_BIT VectorShape.S_512_BIT}. */
2894     public static final VectorSpecies<$Boxtype$> SPECIES_512 = new $Type$Species(VectorShape.S_512_BIT, $Type$512Vector.class, $Type$512Vector.$Type$512Mask.class,
2895                                                                       $Type$512Vector::new, $Type$512Vector.$Type$512Mask::new,
2896                                                                       $Type$512Vector.$Type$512Shuffle::new, $Type$512Vector.$Type$512Shuffle::new);
2897 
2898     /** Species representing {@link $Type$Vector}s of {@link VectorShape#S_Max_BIT VectorShape.S_Max_BIT}. */
2899     public static final VectorSpecies<$Boxtype$> SPECIES_MAX = new $Type$Species(VectorShape.S_Max_BIT, $Type$MaxVector.class, $Type$MaxVector.$Type$MaxMask.class,
2900                                                                       $Type$MaxVector::new, $Type$MaxVector.$Type$MaxMask::new,
2901                                                                       $Type$MaxVector.$Type$MaxShuffle::new, $Type$MaxVector.$Type$MaxShuffle::new);
2902 
2903     /**
2904      * Preferred species for {@link $Type$Vector}s.
2905      * A preferred species is a species of maximal bit size for the platform.
2906      */
2907     public static final VectorSpecies<$Boxtype$> SPECIES_PREFERRED = (VectorSpecies<$Boxtype$>) preferredSpecies();
2908 }