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