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