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