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