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