rev 54658 : refactored mask and shuffle creation methods, moved classes to top-level

   1 /*
   2  * Copyright (c) 2018, 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.
   8  *
   9  * This code is distributed in the hope that it will be useful, but WITHOUT
  10  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  11  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  12  * version 2 for more details (a copy is included in the LICENSE file that
  13  * accompanied this code).
  14  *
  15  * You should have received a copy of the GNU General Public License version
  16  * 2 along with this work; if not, write to the Free Software Foundation,
  17  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  18  *
  19  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  20  * or visit www.oracle.com if you need additional information or have
  21  * questions.
  22  */
  23 
  24 /*
  25  * @test
  26  * @modules jdk.incubator.vector
  27  * @run testng/othervm -ea -esa Double256VectorTests
  28  */
  29 
  30 import jdk.incubator.vector.VectorShape;
  31 import jdk.incubator.vector.VectorSpecies;
  32 import jdk.incubator.vector.VectorShuffle;
  33 import jdk.incubator.vector.VectorMask;
  34 import jdk.incubator.vector.Vector;
  35 
  36 import jdk.incubator.vector.DoubleVector;
  37 
  38 import org.testng.Assert;
  39 import org.testng.annotations.DataProvider;
  40 import org.testng.annotations.Test;
  41 
  42 import java.lang.Integer;
  43 import java.util.List;
  44 import java.util.Arrays;
  45 import java.util.function.BiFunction;
  46 import java.util.function.IntFunction;
  47 import java.util.stream.Collectors;
  48 import java.util.stream.Stream;
  49 
  50 @Test
  51 public class Double256VectorTests extends AbstractVectorTest {
  52 
  53     static final VectorSpecies<Double> SPECIES =
  54                 DoubleVector.SPECIES_256;
  55 
  56     static final int INVOC_COUNT = Integer.getInteger("jdk.incubator.vector.test.loop-iterations", 100);
  57 
  58     interface FUnOp {
  59         double apply(double a);
  60     }
  61 
  62     static void assertArraysEquals(double[] a, double[] r, FUnOp f) {
  63         int i = 0;
  64         try {
  65             for (; i < a.length; i++) {
  66                 Assert.assertEquals(r[i], f.apply(a[i]));
  67             }
  68         } catch (AssertionError e) {
  69             Assert.assertEquals(r[i], f.apply(a[i]), "at index #" + i + ", input = " + a[i]);
  70         }
  71     }
  72 
  73     static void assertArraysEquals(double[] a, double[] r, boolean[] mask, FUnOp f) {
  74         int i = 0;
  75         try {
  76             for (; i < a.length; i++) {
  77                 Assert.assertEquals(r[i], mask[i % SPECIES.length()] ? f.apply(a[i]) : a[i]);
  78             }
  79         } catch (AssertionError e) {
  80             Assert.assertEquals(r[i], mask[i % SPECIES.length()] ? f.apply(a[i]) : a[i], "at index #" + i + ", input = " + a[i] + ", mask = " + mask[i % SPECIES.length()]);
  81         }
  82     }
  83 
  84     interface FReductionOp {
  85         double apply(double[] a, int idx);
  86     }
  87 
  88     interface FReductionAllOp {
  89         double apply(double[] a);
  90     }
  91 
  92     static void assertReductionArraysEquals(double[] a, double[] b, double c,
  93                                             FReductionOp f, FReductionAllOp fa) {
  94         int i = 0;
  95         try {
  96             Assert.assertEquals(c, fa.apply(a));
  97             for (; i < a.length; i += SPECIES.length()) {
  98                 Assert.assertEquals(b[i], f.apply(a, i));
  99             }
 100         } catch (AssertionError e) {
 101             Assert.assertEquals(c, fa.apply(a), "Final result is incorrect!");
 102             Assert.assertEquals(b[i], f.apply(a, i), "at index #" + i);
 103         }
 104     }
 105 
 106     interface FBoolReductionOp {
 107         boolean apply(boolean[] a, int idx);
 108     }
 109 
 110     static void assertReductionBoolArraysEquals(boolean[] a, boolean[] b, FBoolReductionOp f) {
 111         int i = 0;
 112         try {
 113             for (; i < a.length; i += SPECIES.length()) {
 114                 Assert.assertEquals(f.apply(a, i), b[i]);
 115             }
 116         } catch (AssertionError e) {
 117             Assert.assertEquals(f.apply(a, i), b[i], "at index #" + i);
 118         }
 119     }
 120 
 121     static void assertInsertArraysEquals(double[] a, double[] b, double element, int index) {
 122         int i = 0;
 123         try {
 124             for (; i < a.length; i += 1) {
 125                 if(i%SPECIES.length() == index) {
 126                     Assert.assertEquals(b[i], element);
 127                 } else {
 128                     Assert.assertEquals(b[i], a[i]);
 129                 }
 130             }
 131         } catch (AssertionError e) {
 132             if (i%SPECIES.length() == index) {
 133                 Assert.assertEquals(b[i], element, "at index #" + i);
 134             } else {
 135                 Assert.assertEquals(b[i], a[i], "at index #" + i);
 136             }
 137         }
 138     }
 139 
 140     static void assertRearrangeArraysEquals(double[] a, double[] r, int[] order, int vector_len) {
 141         int i = 0, j = 0;
 142         try {
 143             for (; i < a.length; i += vector_len) {
 144                 for (j = 0; j < vector_len; j++) {
 145                     Assert.assertEquals(r[i+j], a[i+order[i+j]]);
 146                 }
 147             }
 148         } catch (AssertionError e) {
 149             int idx = i + j;
 150             Assert.assertEquals(r[i+j], a[i+order[i+j]], "at index #" + idx + ", input = " + a[i+order[i+j]]);
 151         }
 152     }
 153 
 154     interface FBinOp {
 155         double apply(double a, double b);
 156     }
 157 
 158     interface FBinMaskOp {
 159         double apply(double a, double b, boolean m);
 160 
 161         static FBinMaskOp lift(FBinOp f) {
 162             return (a, b, m) -> m ? f.apply(a, b) : a;
 163         }
 164     }
 165 
 166     static void assertArraysEquals(double[] a, double[] b, double[] r, FBinOp f) {
 167         int i = 0;
 168         try {
 169             for (; i < a.length; i++) {
 170                 Assert.assertEquals(r[i], f.apply(a[i], b[i]));
 171             }
 172         } catch (AssertionError e) {
 173             Assert.assertEquals(f.apply(a[i], b[i]), r[i], "(" + a[i] + ", " + b[i] + ") at index #" + i);
 174         }
 175     }
 176 
 177     static void assertArraysEquals(double[] a, double[] b, double[] r, boolean[] mask, FBinOp f) {
 178         assertArraysEquals(a, b, r, mask, FBinMaskOp.lift(f));
 179     }
 180 
 181     static void assertArraysEquals(double[] a, double[] b, double[] r, boolean[] mask, FBinMaskOp f) {
 182         int i = 0;
 183         try {
 184             for (; i < a.length; i++) {
 185                 Assert.assertEquals(r[i], f.apply(a[i], b[i], mask[i % SPECIES.length()]));
 186             }
 187         } catch (AssertionError err) {
 188             Assert.assertEquals(r[i], f.apply(a[i], b[i], mask[i % SPECIES.length()]), "at index #" + i + ", input1 = " + a[i] + ", input2 = " + b[i] + ", mask = " + mask[i % SPECIES.length()]);
 189         }
 190     }
 191 
 192     static void assertShiftArraysEquals(double[] a, double[] b, double[] r, FBinOp f) {
 193         int i = 0;
 194         int j = 0;
 195         try {
 196             for (; j < a.length; j += SPECIES.length()) {
 197                 for (i = 0; i < SPECIES.length(); i++) {
 198                     Assert.assertEquals(f.apply(a[i+j], b[j]), r[i+j]);
 199                 }
 200             }
 201         } catch (AssertionError e) {
 202             Assert.assertEquals(f.apply(a[i+j], b[j]), r[i+j], "at index #" + i + ", " + j);
 203         }
 204     }
 205 
 206     static void assertShiftArraysEquals(double[] a, double[] b, double[] r, boolean[] mask, FBinOp f) {
 207         assertShiftArraysEquals(a, b, r, mask, FBinMaskOp.lift(f));
 208     }
 209 
 210     static void assertShiftArraysEquals(double[] a, double[] b, double[] r, boolean[] mask, FBinMaskOp f) {
 211         int i = 0;
 212         int j = 0;
 213         try {
 214             for (; j < a.length; j += SPECIES.length()) {
 215                 for (i = 0; i < SPECIES.length(); i++) {
 216                     Assert.assertEquals(r[i+j], f.apply(a[i+j], b[j], mask[i]));
 217                 }
 218             }
 219         } catch (AssertionError err) {
 220             Assert.assertEquals(r[i+j], f.apply(a[i+j], b[j], mask[i]), "at index #" + i + ", input1 = " + a[i+j] + ", input2 = " + b[j] + ", mask = " + mask[i]);
 221         }
 222     }
 223 
 224     interface FTernOp {
 225         double apply(double a, double b, double c);
 226     }
 227 
 228     interface FTernMaskOp {
 229         double apply(double a, double b, double c, boolean m);
 230 
 231         static FTernMaskOp lift(FTernOp f) {
 232             return (a, b, c, m) -> m ? f.apply(a, b, c) : a;
 233         }
 234     }
 235 
 236     static void assertArraysEquals(double[] a, double[] b, double[] c, double[] r, FTernOp f) {
 237         int i = 0;
 238         try {
 239             for (; i < a.length; i++) {
 240                 Assert.assertEquals(r[i], f.apply(a[i], b[i], c[i]));
 241             }
 242         } catch (AssertionError e) {
 243             Assert.assertEquals(r[i], f.apply(a[i], b[i], c[i]), "at index #" + i + ", input1 = " + a[i] + ", input2 = " + b[i] + ", input3 = " + c[i]);
 244         }
 245     }
 246 
 247     static void assertArraysEquals(double[] a, double[] b, double[] c, double[] r, boolean[] mask, FTernOp f) {
 248         assertArraysEquals(a, b, c, r, mask, FTernMaskOp.lift(f));
 249     }
 250 
 251     static void assertArraysEquals(double[] a, double[] b, double[] c, double[] r, boolean[] mask, FTernMaskOp f) {
 252         int i = 0;
 253         try {
 254             for (; i < a.length; i++) {
 255                 Assert.assertEquals(r[i], f.apply(a[i], b[i], c[i], mask[i % SPECIES.length()]));
 256             }
 257         } catch (AssertionError err) {
 258             Assert.assertEquals(r[i], f.apply(a[i], b[i], c[i], mask[i % SPECIES.length()]), "at index #" + i + ", input1 = " + a[i] + ", input2 = "
 259               + b[i] + ", input3 = " + c[i] + ", mask = " + mask[i % SPECIES.length()]);
 260         }
 261     }
 262 
 263     static boolean isWithin1Ulp(double actual, double expected) {
 264         if (Double.isNaN(expected) && !Double.isNaN(actual)) {
 265             return false;
 266         } else if (!Double.isNaN(expected) && Double.isNaN(actual)) {
 267             return false;
 268         }
 269 
 270         double low = Math.nextDown(expected);
 271         double high = Math.nextUp(expected);
 272 
 273         if (Double.compare(low, expected) > 0) {
 274             return false;
 275         }
 276 
 277         if (Double.compare(high, expected) < 0) {
 278             return false;
 279         }
 280 
 281         return true;
 282     }
 283 
 284     static void assertArraysEqualsWithinOneUlp(double[] a, double[] r, FUnOp mathf, FUnOp strictmathf) {
 285         int i = 0;
 286         try {
 287             // Check that result is within 1 ulp of strict math or equivalent to math implementation.
 288             for (; i < a.length; i++) {
 289                 Assert.assertTrue(Double.compare(r[i], mathf.apply(a[i])) == 0 ||
 290                                     isWithin1Ulp(r[i], strictmathf.apply(a[i])));
 291             }
 292         } catch (AssertionError e) {
 293             Assert.assertTrue(Double.compare(r[i], mathf.apply(a[i])) == 0, "at index #" + i + ", input = " + a[i] + ", actual = " + r[i] + ", expected = " + mathf.apply(a[i]));
 294             Assert.assertTrue(isWithin1Ulp(r[i], strictmathf.apply(a[i])), "at index #" + i + ", input = " + a[i] + ", actual = " + r[i] + ", expected (within 1 ulp) = " + strictmathf.apply(a[i]));
 295         }
 296     }
 297 
 298     static void assertArraysEqualsWithinOneUlp(double[] a, double[] b, double[] r, FBinOp mathf, FBinOp strictmathf) {
 299         int i = 0;
 300         try {
 301             // Check that result is within 1 ulp of strict math or equivalent to math implementation.
 302             for (; i < a.length; i++) {
 303                 Assert.assertTrue(Double.compare(r[i], mathf.apply(a[i], b[i])) == 0 ||
 304                                     isWithin1Ulp(r[i], strictmathf.apply(a[i], b[i])));
 305             }
 306         } catch (AssertionError e) {
 307             Assert.assertTrue(Double.compare(r[i], mathf.apply(a[i], b[i])) == 0, "at index #" + i + ", input1 = " + a[i] + ", input2 = " + b[i] + ", actual = " + r[i] + ", expected = " + mathf.apply(a[i], b[i]));
 308             Assert.assertTrue(isWithin1Ulp(r[i], strictmathf.apply(a[i], b[i])), "at index #" + i + ", input1 = " + a[i] + ", input2 = " + b[i] + ", actual = " + r[i] + ", expected (within 1 ulp) = " + strictmathf.apply(a[i], b[i]));
 309         }
 310     }
 311 
 312     interface FBinArrayOp {
 313         double apply(double[] a, int b);
 314     }
 315 
 316     static void assertArraysEquals(double[] a, double[] r, FBinArrayOp f) {
 317         int i = 0;
 318         try {
 319             for (; i < a.length; i++) {
 320                 Assert.assertEquals(f.apply(a, i), r[i]);
 321             }
 322         } catch (AssertionError e) {
 323             Assert.assertEquals(f.apply(a,i), r[i], "at index #" + i);
 324         }
 325     }
 326     interface FGatherScatterOp {
 327         double[] apply(double[] a, int ix, int[] b, int iy);
 328     }
 329 
 330     static void assertArraysEquals(double[] a, int[] b, double[] r, FGatherScatterOp f) {
 331         int i = 0;
 332         try {
 333             for (; i < a.length; i += SPECIES.length()) {
 334                 Assert.assertEquals(Arrays.copyOfRange(r, i, i+SPECIES.length()),
 335                   f.apply(a, i, b, i));
 336             }
 337         } catch (AssertionError e) {
 338             double[] ref = f.apply(a, i, b, i);
 339             double[] res = Arrays.copyOfRange(r, i, i+SPECIES.length());
 340             Assert.assertEquals(ref, res,
 341               "(ref: " + Arrays.toString(ref) + ", res: " + Arrays.toString(res) + ", a: "
 342               + Arrays.toString(Arrays.copyOfRange(a, i, i+SPECIES.length()))
 343               + ", b: "
 344               + Arrays.toString(Arrays.copyOfRange(b, i, i+SPECIES.length()))
 345               + " at index #" + i);
 346         }
 347     }
 348 
 349 
 350     static final List<IntFunction<double[]>> DOUBLE_GENERATORS = List.of(
 351             withToString("double[-i * 5]", (int s) -> {
 352                 return fill(s * 1000,
 353                             i -> (double)(-i * 5));
 354             }),
 355             withToString("double[i * 5]", (int s) -> {
 356                 return fill(s * 1000,
 357                             i -> (double)(i * 5));
 358             }),
 359             withToString("double[i + 1]", (int s) -> {
 360                 return fill(s * 1000,
 361                             i -> (((double)(i + 1) == 0) ? 1 : (double)(i + 1)));
 362             }),
 363             withToString("double[cornerCaseValue(i)]", (int s) -> {
 364                 return fill(s * 1000,
 365                             i -> cornerCaseValue(i));
 366             })
 367     );
 368 
 369     // Create combinations of pairs
 370     // @@@ Might be sensitive to order e.g. div by 0
 371     static final List<List<IntFunction<double[]>>> DOUBLE_GENERATOR_PAIRS =
 372         Stream.of(DOUBLE_GENERATORS.get(0)).
 373                 flatMap(fa -> DOUBLE_GENERATORS.stream().skip(1).map(fb -> List.of(fa, fb))).
 374                 collect(Collectors.toList());
 375 
 376     @DataProvider
 377     public Object[][] boolUnaryOpProvider() {
 378         return BOOL_ARRAY_GENERATORS.stream().
 379                 map(f -> new Object[]{f}).
 380                 toArray(Object[][]::new);
 381     }
 382 
 383     static final List<List<IntFunction<double[]>>> DOUBLE_GENERATOR_TRIPLES =
 384         DOUBLE_GENERATOR_PAIRS.stream().
 385                 flatMap(pair -> DOUBLE_GENERATORS.stream().map(f -> List.of(pair.get(0), pair.get(1), f))).
 386                 collect(Collectors.toList());
 387 
 388     @DataProvider
 389     public Object[][] doubleBinaryOpProvider() {
 390         return DOUBLE_GENERATOR_PAIRS.stream().map(List::toArray).
 391                 toArray(Object[][]::new);
 392     }
 393 
 394     @DataProvider
 395     public Object[][] doubleIndexedOpProvider() {
 396         return DOUBLE_GENERATOR_PAIRS.stream().map(List::toArray).
 397                 toArray(Object[][]::new);
 398     }
 399 
 400     @DataProvider
 401     public Object[][] doubleBinaryOpMaskProvider() {
 402         return BOOLEAN_MASK_GENERATORS.stream().
 403                 flatMap(fm -> DOUBLE_GENERATOR_PAIRS.stream().map(lfa -> {
 404                     return Stream.concat(lfa.stream(), Stream.of(fm)).toArray();
 405                 })).
 406                 toArray(Object[][]::new);
 407     }
 408 
 409     @DataProvider
 410     public Object[][] doubleTernaryOpProvider() {
 411         return DOUBLE_GENERATOR_TRIPLES.stream().map(List::toArray).
 412                 toArray(Object[][]::new);
 413     }
 414 
 415     @DataProvider
 416     public Object[][] doubleTernaryOpMaskProvider() {
 417         return BOOLEAN_MASK_GENERATORS.stream().
 418                 flatMap(fm -> DOUBLE_GENERATOR_TRIPLES.stream().map(lfa -> {
 419                     return Stream.concat(lfa.stream(), Stream.of(fm)).toArray();
 420                 })).
 421                 toArray(Object[][]::new);
 422     }
 423 
 424     @DataProvider
 425     public Object[][] doubleUnaryOpProvider() {
 426         return DOUBLE_GENERATORS.stream().
 427                 map(f -> new Object[]{f}).
 428                 toArray(Object[][]::new);
 429     }
 430 
 431     @DataProvider
 432     public Object[][] doubleUnaryOpMaskProvider() {
 433         return BOOLEAN_MASK_GENERATORS.stream().
 434                 flatMap(fm -> DOUBLE_GENERATORS.stream().map(fa -> {
 435                     return new Object[] {fa, fm};
 436                 })).
 437                 toArray(Object[][]::new);
 438     }
 439 
 440     @DataProvider
 441     public Object[][] doubleUnaryOpShuffleProvider() {
 442         return INT_SHUFFLE_GENERATORS.stream().
 443                 flatMap(fs -> DOUBLE_GENERATORS.stream().map(fa -> {
 444                     return new Object[] {fa, fs};
 445                 })).
 446                 toArray(Object[][]::new);
 447     }
 448 
 449     @DataProvider
 450     public Object[][] doubleUnaryOpIndexProvider() {
 451         return INT_INDEX_GENERATORS.stream().
 452                 flatMap(fs -> DOUBLE_GENERATORS.stream().map(fa -> {
 453                     return new Object[] {fa, fs};
 454                 })).
 455                 toArray(Object[][]::new);
 456     }
 457 
 458 
 459     static final List<IntFunction<double[]>> DOUBLE_COMPARE_GENERATORS = List.of(
 460             withToString("double[i]", (int s) -> {
 461                 return fill(s * 1000,
 462                             i -> (double)i);
 463             }),
 464             withToString("double[i + 1]", (int s) -> {
 465                 return fill(s * 1000,
 466                             i -> (double)(i + 1));
 467             }),
 468             withToString("double[i - 2]", (int s) -> {
 469                 return fill(s * 1000,
 470                             i -> (double)(i - 2));
 471             }),
 472             withToString("double[zigZag(i)]", (int s) -> {
 473                 return fill(s * 1000,
 474                             i -> i%3 == 0 ? (double)i : (i%3 == 1 ? (double)(i + 1) : (double)(i - 2)));
 475             }),
 476             withToString("double[cornerCaseValue(i)]", (int s) -> {
 477                 return fill(s * 1000,
 478                             i -> cornerCaseValue(i));
 479             })
 480     );
 481 
 482     static final List<List<IntFunction<double[]>>> DOUBLE_COMPARE_GENERATOR_PAIRS =
 483         DOUBLE_COMPARE_GENERATORS.stream().
 484                 flatMap(fa -> DOUBLE_COMPARE_GENERATORS.stream().map(fb -> List.of(fa, fb))).
 485                 collect(Collectors.toList());
 486 
 487     @DataProvider
 488     public Object[][] doubleCompareOpProvider() {
 489         return DOUBLE_COMPARE_GENERATOR_PAIRS.stream().map(List::toArray).
 490                 toArray(Object[][]::new);
 491     }
 492 
 493     interface ToDoubleF {
 494         double apply(int i);
 495     }
 496 
 497     static double[] fill(int s , ToDoubleF f) {
 498         return fill(new double[s], f);
 499     }
 500 
 501     static double[] fill(double[] a, ToDoubleF f) {
 502         for (int i = 0; i < a.length; i++) {
 503             a[i] = f.apply(i);
 504         }
 505         return a;
 506     }
 507 
 508     static double cornerCaseValue(int i) {
 509         switch(i % 7) {
 510             case 0:
 511                 return Double.MAX_VALUE;
 512             case 1:
 513                 return Double.MIN_VALUE;
 514             case 2:
 515                 return Double.NEGATIVE_INFINITY;
 516             case 3:
 517                 return Double.POSITIVE_INFINITY;
 518             case 4:
 519                 return Double.NaN;
 520             case 5:
 521                 return (double)0.0;
 522             default:
 523                 return (double)-0.0;
 524         }
 525     }
 526    static double get(double[] a, int i) {
 527        return (double) a[i];
 528    }
 529 
 530    static final IntFunction<double[]> fr = (vl) -> {
 531         int length = 1000 * vl;
 532         return new double[length];
 533     };
 534 
 535     static final IntFunction<boolean[]> fmr = (vl) -> {
 536         int length = 1000 * vl;
 537         return new boolean[length];
 538     };
 539     static double add(double a, double b) {
 540         return (double)(a + b);
 541     }
 542 
 543     @Test(dataProvider = "doubleBinaryOpProvider")
 544     static void addDouble256VectorTests(IntFunction<double[]> fa, IntFunction<double[]> fb) {
 545         double[] a = fa.apply(SPECIES.length());
 546         double[] b = fb.apply(SPECIES.length());
 547         double[] r = fr.apply(SPECIES.length());
 548 
 549         for (int ic = 0; ic < INVOC_COUNT; ic++) {
 550             for (int i = 0; i < a.length; i += SPECIES.length()) {
 551                 DoubleVector av = DoubleVector.fromArray(SPECIES, a, i);
 552                 DoubleVector bv = DoubleVector.fromArray(SPECIES, b, i);
 553                 av.add(bv).intoArray(r, i);
 554             }
 555         }
 556 
 557         assertArraysEquals(a, b, r, Double256VectorTests::add);
 558     }
 559 
 560     @Test(dataProvider = "doubleBinaryOpMaskProvider")
 561     static void addDouble256VectorTests(IntFunction<double[]> fa, IntFunction<double[]> fb,
 562                                           IntFunction<boolean[]> fm) {
 563         double[] a = fa.apply(SPECIES.length());
 564         double[] b = fb.apply(SPECIES.length());
 565         double[] r = fr.apply(SPECIES.length());
 566         boolean[] mask = fm.apply(SPECIES.length());
 567         VectorMask<Double> vmask = VectorMask.fromValues(SPECIES, mask);
 568 
 569         for (int ic = 0; ic < INVOC_COUNT; ic++) {
 570             for (int i = 0; i < a.length; i += SPECIES.length()) {
 571                 DoubleVector av = DoubleVector.fromArray(SPECIES, a, i);
 572                 DoubleVector bv = DoubleVector.fromArray(SPECIES, b, i);
 573                 av.add(bv, vmask).intoArray(r, i);
 574             }
 575         }
 576 
 577         assertArraysEquals(a, b, r, mask, Double256VectorTests::add);
 578     }
 579     static double sub(double a, double b) {
 580         return (double)(a - b);
 581     }
 582 
 583     @Test(dataProvider = "doubleBinaryOpProvider")
 584     static void subDouble256VectorTests(IntFunction<double[]> fa, IntFunction<double[]> fb) {
 585         double[] a = fa.apply(SPECIES.length());
 586         double[] b = fb.apply(SPECIES.length());
 587         double[] r = fr.apply(SPECIES.length());
 588 
 589         for (int ic = 0; ic < INVOC_COUNT; ic++) {
 590             for (int i = 0; i < a.length; i += SPECIES.length()) {
 591                 DoubleVector av = DoubleVector.fromArray(SPECIES, a, i);
 592                 DoubleVector bv = DoubleVector.fromArray(SPECIES, b, i);
 593                 av.sub(bv).intoArray(r, i);
 594             }
 595         }
 596 
 597         assertArraysEquals(a, b, r, Double256VectorTests::sub);
 598     }
 599 
 600     @Test(dataProvider = "doubleBinaryOpMaskProvider")
 601     static void subDouble256VectorTests(IntFunction<double[]> fa, IntFunction<double[]> fb,
 602                                           IntFunction<boolean[]> fm) {
 603         double[] a = fa.apply(SPECIES.length());
 604         double[] b = fb.apply(SPECIES.length());
 605         double[] r = fr.apply(SPECIES.length());
 606         boolean[] mask = fm.apply(SPECIES.length());
 607         VectorMask<Double> vmask = VectorMask.fromValues(SPECIES, mask);
 608 
 609         for (int ic = 0; ic < INVOC_COUNT; ic++) {
 610             for (int i = 0; i < a.length; i += SPECIES.length()) {
 611                 DoubleVector av = DoubleVector.fromArray(SPECIES, a, i);
 612                 DoubleVector bv = DoubleVector.fromArray(SPECIES, b, i);
 613                 av.sub(bv, vmask).intoArray(r, i);
 614             }
 615         }
 616 
 617         assertArraysEquals(a, b, r, mask, Double256VectorTests::sub);
 618     }
 619 
 620     static double div(double a, double b) {
 621         return (double)(a / b);
 622     }
 623 
 624     @Test(dataProvider = "doubleBinaryOpProvider")
 625     static void divDouble256VectorTests(IntFunction<double[]> fa, IntFunction<double[]> fb) {
 626         double[] a = fa.apply(SPECIES.length());
 627         double[] b = fb.apply(SPECIES.length());
 628         double[] r = fr.apply(SPECIES.length());
 629 
 630         for (int ic = 0; ic < INVOC_COUNT; ic++) {
 631             for (int i = 0; i < a.length; i += SPECIES.length()) {
 632                 DoubleVector av = DoubleVector.fromArray(SPECIES, a, i);
 633                 DoubleVector bv = DoubleVector.fromArray(SPECIES, b, i);
 634                 av.div(bv).intoArray(r, i);
 635             }
 636         }
 637 
 638         assertArraysEquals(a, b, r, Double256VectorTests::div);
 639     }
 640 
 641 
 642 
 643     @Test(dataProvider = "doubleBinaryOpMaskProvider")
 644     static void divDouble256VectorTests(IntFunction<double[]> fa, IntFunction<double[]> fb,
 645                                           IntFunction<boolean[]> fm) {
 646         double[] a = fa.apply(SPECIES.length());
 647         double[] b = fb.apply(SPECIES.length());
 648         double[] r = fr.apply(SPECIES.length());
 649         boolean[] mask = fm.apply(SPECIES.length());
 650         VectorMask<Double> vmask = VectorMask.fromValues(SPECIES, mask);
 651 
 652         for (int ic = 0; ic < INVOC_COUNT; ic++) {
 653             for (int i = 0; i < a.length; i += SPECIES.length()) {
 654                 DoubleVector av = DoubleVector.fromArray(SPECIES, a, i);
 655                 DoubleVector bv = DoubleVector.fromArray(SPECIES, b, i);
 656                 av.div(bv, vmask).intoArray(r, i);
 657             }
 658         }
 659 
 660         assertArraysEquals(a, b, r, mask, Double256VectorTests::div);
 661     }
 662 
 663     static double mul(double a, double b) {
 664         return (double)(a * b);
 665     }
 666 
 667     @Test(dataProvider = "doubleBinaryOpProvider")
 668     static void mulDouble256VectorTests(IntFunction<double[]> fa, IntFunction<double[]> fb) {
 669         double[] a = fa.apply(SPECIES.length());
 670         double[] b = fb.apply(SPECIES.length());
 671         double[] r = fr.apply(SPECIES.length());
 672 
 673         for (int ic = 0; ic < INVOC_COUNT; ic++) {
 674             for (int i = 0; i < a.length; i += SPECIES.length()) {
 675                 DoubleVector av = DoubleVector.fromArray(SPECIES, a, i);
 676                 DoubleVector bv = DoubleVector.fromArray(SPECIES, b, i);
 677                 av.mul(bv).intoArray(r, i);
 678             }
 679         }
 680 
 681         assertArraysEquals(a, b, r, Double256VectorTests::mul);
 682     }
 683 
 684     @Test(dataProvider = "doubleBinaryOpMaskProvider")
 685     static void mulDouble256VectorTests(IntFunction<double[]> fa, IntFunction<double[]> fb,
 686                                           IntFunction<boolean[]> fm) {
 687         double[] a = fa.apply(SPECIES.length());
 688         double[] b = fb.apply(SPECIES.length());
 689         double[] r = fr.apply(SPECIES.length());
 690         boolean[] mask = fm.apply(SPECIES.length());
 691         VectorMask<Double> vmask = VectorMask.fromValues(SPECIES, mask);
 692 
 693         for (int ic = 0; ic < INVOC_COUNT; ic++) {
 694             for (int i = 0; i < a.length; i += SPECIES.length()) {
 695                 DoubleVector av = DoubleVector.fromArray(SPECIES, a, i);
 696                 DoubleVector bv = DoubleVector.fromArray(SPECIES, b, i);
 697                 av.mul(bv, vmask).intoArray(r, i);
 698             }
 699         }
 700 
 701         assertArraysEquals(a, b, r, mask, Double256VectorTests::mul);
 702     }
 703 
 704 
 705 
 706 
 707 
 708 
 709 
 710 
 711 
 712 
 713 
 714 
 715 
 716 
 717 
 718 
 719 
 720 
 721 
 722 
 723 
 724 
 725 
 726 
 727 
 728 
 729 
 730 
 731 
 732 
 733     static double max(double a, double b) {
 734         return (double)(Math.max(a, b));
 735     }
 736 
 737     @Test(dataProvider = "doubleBinaryOpProvider")
 738     static void maxDouble256VectorTests(IntFunction<double[]> fa, IntFunction<double[]> fb) {
 739         double[] a = fa.apply(SPECIES.length());
 740         double[] b = fb.apply(SPECIES.length());
 741         double[] r = fr.apply(SPECIES.length());
 742 
 743         for (int ic = 0; ic < INVOC_COUNT; ic++) {
 744             for (int i = 0; i < a.length; i += SPECIES.length()) {
 745                 DoubleVector av = DoubleVector.fromArray(SPECIES, a, i);
 746                 DoubleVector bv = DoubleVector.fromArray(SPECIES, b, i);
 747                 av.max(bv).intoArray(r, i);
 748             }
 749         }
 750 
 751         assertArraysEquals(a, b, r, Double256VectorTests::max);
 752     }
 753     static double min(double a, double b) {
 754         return (double)(Math.min(a, b));
 755     }
 756 
 757     @Test(dataProvider = "doubleBinaryOpProvider")
 758     static void minDouble256VectorTests(IntFunction<double[]> fa, IntFunction<double[]> fb) {
 759         double[] a = fa.apply(SPECIES.length());
 760         double[] b = fb.apply(SPECIES.length());
 761         double[] r = fr.apply(SPECIES.length());
 762 
 763         for (int ic = 0; ic < INVOC_COUNT; ic++) {
 764             for (int i = 0; i < a.length; i += SPECIES.length()) {
 765                 DoubleVector av = DoubleVector.fromArray(SPECIES, a, i);
 766                 DoubleVector bv = DoubleVector.fromArray(SPECIES, b, i);
 767                 av.min(bv).intoArray(r, i);
 768             }
 769         }
 770 
 771         assertArraysEquals(a, b, r, Double256VectorTests::min);
 772     }
 773 
 774 
 775 
 776 
 777 
 778 
 779     static double addAll(double[] a, int idx) {
 780         double res = 0;
 781         for (int i = idx; i < (idx + SPECIES.length()); i++) {
 782             res += a[i];
 783         }
 784 
 785         return res;
 786     }
 787 
 788     static double addAll(double[] a) {
 789         double res = 0;
 790         for (int i = 0; i < a.length; i += SPECIES.length()) {
 791             double tmp = 0;
 792             for (int j = 0; j < SPECIES.length(); j++) {
 793                 tmp += a[i + j];
 794             }
 795             res += tmp;
 796         }
 797 
 798         return res;
 799     }
 800     @Test(dataProvider = "doubleUnaryOpProvider")
 801     static void addAllDouble256VectorTests(IntFunction<double[]> fa) {
 802         double[] a = fa.apply(SPECIES.length());
 803         double[] r = fr.apply(SPECIES.length());
 804         double ra = 0;
 805 
 806         for (int ic = 0; ic < INVOC_COUNT; ic++) {
 807             for (int i = 0; i < a.length; i += SPECIES.length()) {
 808                 DoubleVector av = DoubleVector.fromArray(SPECIES, a, i);
 809                 r[i] = av.addAll();
 810             }
 811         }
 812 
 813         for (int ic = 0; ic < INVOC_COUNT; ic++) {
 814             ra = 0;
 815             for (int i = 0; i < a.length; i += SPECIES.length()) {
 816                 DoubleVector av = DoubleVector.fromArray(SPECIES, a, i);
 817                 ra += av.addAll();
 818             }
 819         }
 820 
 821         assertReductionArraysEquals(a, r, ra, Double256VectorTests::addAll, Double256VectorTests::addAll);
 822     }
 823     static double mulAll(double[] a, int idx) {
 824         double res = 1;
 825         for (int i = idx; i < (idx + SPECIES.length()); i++) {
 826             res *= a[i];
 827         }
 828 
 829         return res;
 830     }
 831 
 832     static double mulAll(double[] a) {
 833         double res = 1;
 834         for (int i = 0; i < a.length; i += SPECIES.length()) {
 835             double tmp = 1;
 836             for (int j = 0; j < SPECIES.length(); j++) {
 837                 tmp *= a[i + j];
 838             }
 839             res *= tmp;
 840         }
 841 
 842         return res;
 843     }
 844     @Test(dataProvider = "doubleUnaryOpProvider")
 845     static void mulAllDouble256VectorTests(IntFunction<double[]> fa) {
 846         double[] a = fa.apply(SPECIES.length());
 847         double[] r = fr.apply(SPECIES.length());
 848         double ra = 1;
 849 
 850         for (int ic = 0; ic < INVOC_COUNT; ic++) {
 851             for (int i = 0; i < a.length; i += SPECIES.length()) {
 852                 DoubleVector av = DoubleVector.fromArray(SPECIES, a, i);
 853                 r[i] = av.mulAll();
 854             }
 855         }
 856 
 857         for (int ic = 0; ic < INVOC_COUNT; ic++) {
 858             ra = 1;
 859             for (int i = 0; i < a.length; i += SPECIES.length()) {
 860                 DoubleVector av = DoubleVector.fromArray(SPECIES, a, i);
 861                 ra *= av.mulAll();
 862             }
 863         }
 864 
 865         assertReductionArraysEquals(a, r, ra, Double256VectorTests::mulAll, Double256VectorTests::mulAll);
 866     }
 867     static double minAll(double[] a, int idx) {
 868         double res = Double.POSITIVE_INFINITY;
 869         for (int i = idx; i < (idx + SPECIES.length()); i++) {
 870             res = (double)Math.min(res, a[i]);
 871         }
 872 
 873         return res;
 874     }
 875 
 876     static double minAll(double[] a) {
 877         double res = Double.POSITIVE_INFINITY;
 878         for (int i = 0; i < a.length; i++) {
 879             res = (double)Math.min(res, a[i]);
 880         }
 881 
 882         return res;
 883     }
 884     @Test(dataProvider = "doubleUnaryOpProvider")
 885     static void minAllDouble256VectorTests(IntFunction<double[]> fa) {
 886         double[] a = fa.apply(SPECIES.length());
 887         double[] r = fr.apply(SPECIES.length());
 888         double ra = Double.POSITIVE_INFINITY;
 889 
 890         for (int ic = 0; ic < INVOC_COUNT; ic++) {
 891             for (int i = 0; i < a.length; i += SPECIES.length()) {
 892                 DoubleVector av = DoubleVector.fromArray(SPECIES, a, i);
 893                 r[i] = av.minAll();
 894             }
 895         }
 896 
 897         for (int ic = 0; ic < INVOC_COUNT; ic++) {
 898             ra = Double.POSITIVE_INFINITY;
 899             for (int i = 0; i < a.length; i += SPECIES.length()) {
 900                 DoubleVector av = DoubleVector.fromArray(SPECIES, a, i);
 901                 ra = (double)Math.min(ra, av.minAll());
 902             }
 903         }
 904 
 905         assertReductionArraysEquals(a, r, ra, Double256VectorTests::minAll, Double256VectorTests::minAll);
 906     }
 907     static double maxAll(double[] a, int idx) {
 908         double res = Double.NEGATIVE_INFINITY;
 909         for (int i = idx; i < (idx + SPECIES.length()); i++) {
 910             res = (double)Math.max(res, a[i]);
 911         }
 912 
 913         return res;
 914     }
 915 
 916     static double maxAll(double[] a) {
 917         double res = Double.NEGATIVE_INFINITY;
 918         for (int i = 0; i < a.length; i++) {
 919             res = (double)Math.max(res, a[i]);
 920         }
 921 
 922         return res;
 923     }
 924     @Test(dataProvider = "doubleUnaryOpProvider")
 925     static void maxAllDouble256VectorTests(IntFunction<double[]> fa) {
 926         double[] a = fa.apply(SPECIES.length());
 927         double[] r = fr.apply(SPECIES.length());
 928         double ra = Double.NEGATIVE_INFINITY;
 929 
 930         for (int ic = 0; ic < INVOC_COUNT; ic++) {
 931             for (int i = 0; i < a.length; i += SPECIES.length()) {
 932                 DoubleVector av = DoubleVector.fromArray(SPECIES, a, i);
 933                 r[i] = av.maxAll();
 934             }
 935         }
 936 
 937         for (int ic = 0; ic < INVOC_COUNT; ic++) {
 938             ra = Double.NEGATIVE_INFINITY;
 939             for (int i = 0; i < a.length; i += SPECIES.length()) {
 940                 DoubleVector av = DoubleVector.fromArray(SPECIES, a, i);
 941                 ra = (double)Math.max(ra, av.maxAll());
 942             }
 943         }
 944 
 945         assertReductionArraysEquals(a, r, ra, Double256VectorTests::maxAll, Double256VectorTests::maxAll);
 946     }
 947 
 948 
 949 
 950 
 951 
 952     @Test(dataProvider = "doubleUnaryOpProvider")
 953     static void withDouble256VectorTests(IntFunction<double []> fa) {
 954         double[] a = fa.apply(SPECIES.length());
 955         double[] r = fr.apply(SPECIES.length());
 956 
 957         for (int ic = 0; ic < INVOC_COUNT; ic++) {
 958             for (int i = 0; i < a.length; i += SPECIES.length()) {
 959                 DoubleVector av = DoubleVector.fromArray(SPECIES, a, i);
 960                 av.with(0, (double)4).intoArray(r, i);
 961             }
 962         }
 963 
 964         assertInsertArraysEquals(a, r, (double)4, 0);
 965     }
 966 
 967     @Test(dataProvider = "doubleCompareOpProvider")
 968     static void lessThanDouble256VectorTests(IntFunction<double[]> fa, IntFunction<double[]> fb) {
 969         double[] a = fa.apply(SPECIES.length());
 970         double[] b = fb.apply(SPECIES.length());
 971 
 972         for (int ic = 0; ic < INVOC_COUNT; ic++) {
 973             for (int i = 0; i < a.length; i += SPECIES.length()) {
 974                 DoubleVector av = DoubleVector.fromArray(SPECIES, a, i);
 975                 DoubleVector bv = DoubleVector.fromArray(SPECIES, b, i);
 976                 VectorMask<Double> mv = av.lessThan(bv);
 977 
 978                 // Check results as part of computation.
 979                 for (int j = 0; j < SPECIES.length(); j++) {
 980                     Assert.assertEquals(mv.getElement(j), a[i + j] < b[i + j]);
 981                 }
 982             }
 983         }
 984     }
 985 
 986 
 987     @Test(dataProvider = "doubleCompareOpProvider")
 988     static void greaterThanDouble256VectorTests(IntFunction<double[]> fa, IntFunction<double[]> fb) {
 989         double[] a = fa.apply(SPECIES.length());
 990         double[] b = fb.apply(SPECIES.length());
 991 
 992         for (int ic = 0; ic < INVOC_COUNT; ic++) {
 993             for (int i = 0; i < a.length; i += SPECIES.length()) {
 994                 DoubleVector av = DoubleVector.fromArray(SPECIES, a, i);
 995                 DoubleVector bv = DoubleVector.fromArray(SPECIES, b, i);
 996                 VectorMask<Double> mv = av.greaterThan(bv);
 997 
 998                 // Check results as part of computation.
 999                 for (int j = 0; j < SPECIES.length(); j++) {
1000                     Assert.assertEquals(mv.getElement(j), a[i + j] > b[i + j]);
1001                 }
1002             }
1003         }
1004     }
1005 
1006 
1007     @Test(dataProvider = "doubleCompareOpProvider")
1008     static void equalDouble256VectorTests(IntFunction<double[]> fa, IntFunction<double[]> fb) {
1009         double[] a = fa.apply(SPECIES.length());
1010         double[] b = fb.apply(SPECIES.length());
1011 
1012         for (int ic = 0; ic < INVOC_COUNT; ic++) {
1013             for (int i = 0; i < a.length; i += SPECIES.length()) {
1014                 DoubleVector av = DoubleVector.fromArray(SPECIES, a, i);
1015                 DoubleVector bv = DoubleVector.fromArray(SPECIES, b, i);
1016                 VectorMask<Double> mv = av.equal(bv);
1017 
1018                 // Check results as part of computation.
1019                 for (int j = 0; j < SPECIES.length(); j++) {
1020                     Assert.assertEquals(mv.getElement(j), a[i + j] == b[i + j]);
1021                 }
1022             }
1023         }
1024     }
1025 
1026 
1027     @Test(dataProvider = "doubleCompareOpProvider")
1028     static void notEqualDouble256VectorTests(IntFunction<double[]> fa, IntFunction<double[]> fb) {
1029         double[] a = fa.apply(SPECIES.length());
1030         double[] b = fb.apply(SPECIES.length());
1031 
1032         for (int ic = 0; ic < INVOC_COUNT; ic++) {
1033             for (int i = 0; i < a.length; i += SPECIES.length()) {
1034                 DoubleVector av = DoubleVector.fromArray(SPECIES, a, i);
1035                 DoubleVector bv = DoubleVector.fromArray(SPECIES, b, i);
1036                 VectorMask<Double> mv = av.notEqual(bv);
1037 
1038                 // Check results as part of computation.
1039                 for (int j = 0; j < SPECIES.length(); j++) {
1040                     Assert.assertEquals(mv.getElement(j), a[i + j] != b[i + j]);
1041                 }
1042             }
1043         }
1044     }
1045 
1046 
1047     @Test(dataProvider = "doubleCompareOpProvider")
1048     static void lessThanEqDouble256VectorTests(IntFunction<double[]> fa, IntFunction<double[]> fb) {
1049         double[] a = fa.apply(SPECIES.length());
1050         double[] b = fb.apply(SPECIES.length());
1051 
1052         for (int ic = 0; ic < INVOC_COUNT; ic++) {
1053             for (int i = 0; i < a.length; i += SPECIES.length()) {
1054                 DoubleVector av = DoubleVector.fromArray(SPECIES, a, i);
1055                 DoubleVector bv = DoubleVector.fromArray(SPECIES, b, i);
1056                 VectorMask<Double> mv = av.lessThanEq(bv);
1057 
1058                 // Check results as part of computation.
1059                 for (int j = 0; j < SPECIES.length(); j++) {
1060                     Assert.assertEquals(mv.getElement(j), a[i + j] <= b[i + j]);
1061                 }
1062             }
1063         }
1064     }
1065 
1066 
1067     @Test(dataProvider = "doubleCompareOpProvider")
1068     static void greaterThanEqDouble256VectorTests(IntFunction<double[]> fa, IntFunction<double[]> fb) {
1069         double[] a = fa.apply(SPECIES.length());
1070         double[] b = fb.apply(SPECIES.length());
1071 
1072         for (int ic = 0; ic < INVOC_COUNT; ic++) {
1073             for (int i = 0; i < a.length; i += SPECIES.length()) {
1074                 DoubleVector av = DoubleVector.fromArray(SPECIES, a, i);
1075                 DoubleVector bv = DoubleVector.fromArray(SPECIES, b, i);
1076                 VectorMask<Double> mv = av.greaterThanEq(bv);
1077 
1078                 // Check results as part of computation.
1079                 for (int j = 0; j < SPECIES.length(); j++) {
1080                     Assert.assertEquals(mv.getElement(j), a[i + j] >= b[i + j]);
1081                 }
1082             }
1083         }
1084     }
1085 
1086 
1087     static double blend(double a, double b, boolean mask) {
1088         return mask ? b : a;
1089     }
1090 
1091     @Test(dataProvider = "doubleBinaryOpMaskProvider")
1092     static void blendDouble256VectorTests(IntFunction<double[]> fa, IntFunction<double[]> fb,
1093                                           IntFunction<boolean[]> fm) {
1094         double[] a = fa.apply(SPECIES.length());
1095         double[] b = fb.apply(SPECIES.length());
1096         double[] r = fr.apply(SPECIES.length());
1097         boolean[] mask = fm.apply(SPECIES.length());
1098         VectorMask<Double> vmask = VectorMask.fromValues(SPECIES, mask);
1099 
1100         for (int ic = 0; ic < INVOC_COUNT; ic++) {
1101             for (int i = 0; i < a.length; i += SPECIES.length()) {
1102                 DoubleVector av = DoubleVector.fromArray(SPECIES, a, i);
1103                 DoubleVector bv = DoubleVector.fromArray(SPECIES, b, i);
1104                 av.blend(bv, vmask).intoArray(r, i);
1105             }
1106         }
1107 
1108         assertArraysEquals(a, b, r, mask, Double256VectorTests::blend);
1109     }
1110 
1111     @Test(dataProvider = "doubleUnaryOpShuffleProvider")
1112     static void RearrangeDouble256VectorTests(IntFunction<double[]> fa,
1113                                            BiFunction<Integer,Integer,int[]> fs) {
1114         double[] a = fa.apply(SPECIES.length());
1115         int[] order = fs.apply(a.length, SPECIES.length());
1116         double[] r = fr.apply(SPECIES.length());
1117 
1118         for (int ic = 0; ic < INVOC_COUNT; ic++) {
1119             for (int i = 0; i < a.length; i += SPECIES.length()) {
1120                 DoubleVector av = DoubleVector.fromArray(SPECIES, a, i);
1121                 av.rearrange(VectorShuffle.fromArray(SPECIES, order, i)).intoArray(r, i);
1122             }
1123         }
1124 
1125         assertRearrangeArraysEquals(a, r, order, SPECIES.length());
1126     }
1127 
1128 
1129 
1130 
1131     @Test(dataProvider = "doubleUnaryOpProvider")
1132     static void getDouble256VectorTests(IntFunction<double[]> fa) {
1133         double[] a = fa.apply(SPECIES.length());
1134         double[] r = fr.apply(SPECIES.length());
1135 
1136         for (int ic = 0; ic < INVOC_COUNT; ic++) {
1137             for (int i = 0; i < a.length; i += SPECIES.length()) {
1138                 DoubleVector av = DoubleVector.fromArray(SPECIES, a, i);
1139                 int num_lanes = SPECIES.length();
1140                 // Manually unroll because full unroll happens after intrinsification.
1141                 // Unroll is needed because get intrinsic requires for index to be a known constant.
1142                 if (num_lanes == 1) {
1143                     r[i]=av.get(0);
1144                 } else if (num_lanes == 2) {
1145                     r[i]=av.get(0);
1146                     r[i+1]=av.get(1);
1147                 } else if (num_lanes == 4) {
1148                     r[i]=av.get(0);
1149                     r[i+1]=av.get(1);
1150                     r[i+2]=av.get(2);
1151                     r[i+3]=av.get(3);
1152                 } else if (num_lanes == 8) {
1153                     r[i]=av.get(0);
1154                     r[i+1]=av.get(1);
1155                     r[i+2]=av.get(2);
1156                     r[i+3]=av.get(3);
1157                     r[i+4]=av.get(4);
1158                     r[i+5]=av.get(5);
1159                     r[i+6]=av.get(6);
1160                     r[i+7]=av.get(7);
1161                 } else if (num_lanes == 16) {
1162                     r[i]=av.get(0);
1163                     r[i+1]=av.get(1);
1164                     r[i+2]=av.get(2);
1165                     r[i+3]=av.get(3);
1166                     r[i+4]=av.get(4);
1167                     r[i+5]=av.get(5);
1168                     r[i+6]=av.get(6);
1169                     r[i+7]=av.get(7);
1170                     r[i+8]=av.get(8);
1171                     r[i+9]=av.get(9);
1172                     r[i+10]=av.get(10);
1173                     r[i+11]=av.get(11);
1174                     r[i+12]=av.get(12);
1175                     r[i+13]=av.get(13);
1176                     r[i+14]=av.get(14);
1177                     r[i+15]=av.get(15);
1178                 } else if (num_lanes == 32) {
1179                     r[i]=av.get(0);
1180                     r[i+1]=av.get(1);
1181                     r[i+2]=av.get(2);
1182                     r[i+3]=av.get(3);
1183                     r[i+4]=av.get(4);
1184                     r[i+5]=av.get(5);
1185                     r[i+6]=av.get(6);
1186                     r[i+7]=av.get(7);
1187                     r[i+8]=av.get(8);
1188                     r[i+9]=av.get(9);
1189                     r[i+10]=av.get(10);
1190                     r[i+11]=av.get(11);
1191                     r[i+12]=av.get(12);
1192                     r[i+13]=av.get(13);
1193                     r[i+14]=av.get(14);
1194                     r[i+15]=av.get(15);
1195                     r[i+16]=av.get(16);
1196                     r[i+17]=av.get(17);
1197                     r[i+18]=av.get(18);
1198                     r[i+19]=av.get(19);
1199                     r[i+20]=av.get(20);
1200                     r[i+21]=av.get(21);
1201                     r[i+22]=av.get(22);
1202                     r[i+23]=av.get(23);
1203                     r[i+24]=av.get(24);
1204                     r[i+25]=av.get(25);
1205                     r[i+26]=av.get(26);
1206                     r[i+27]=av.get(27);
1207                     r[i+28]=av.get(28);
1208                     r[i+29]=av.get(29);
1209                     r[i+30]=av.get(30);
1210                     r[i+31]=av.get(31);
1211                 } else if (num_lanes == 64) {
1212                     r[i]=av.get(0);
1213                     r[i+1]=av.get(1);
1214                     r[i+2]=av.get(2);
1215                     r[i+3]=av.get(3);
1216                     r[i+4]=av.get(4);
1217                     r[i+5]=av.get(5);
1218                     r[i+6]=av.get(6);
1219                     r[i+7]=av.get(7);
1220                     r[i+8]=av.get(8);
1221                     r[i+9]=av.get(9);
1222                     r[i+10]=av.get(10);
1223                     r[i+11]=av.get(11);
1224                     r[i+12]=av.get(12);
1225                     r[i+13]=av.get(13);
1226                     r[i+14]=av.get(14);
1227                     r[i+15]=av.get(15);
1228                     r[i+16]=av.get(16);
1229                     r[i+17]=av.get(17);
1230                     r[i+18]=av.get(18);
1231                     r[i+19]=av.get(19);
1232                     r[i+20]=av.get(20);
1233                     r[i+21]=av.get(21);
1234                     r[i+22]=av.get(22);
1235                     r[i+23]=av.get(23);
1236                     r[i+24]=av.get(24);
1237                     r[i+25]=av.get(25);
1238                     r[i+26]=av.get(26);
1239                     r[i+27]=av.get(27);
1240                     r[i+28]=av.get(28);
1241                     r[i+29]=av.get(29);
1242                     r[i+30]=av.get(30);
1243                     r[i+31]=av.get(31);
1244                     r[i+32]=av.get(32);
1245                     r[i+33]=av.get(33);
1246                     r[i+34]=av.get(34);
1247                     r[i+35]=av.get(35);
1248                     r[i+36]=av.get(36);
1249                     r[i+37]=av.get(37);
1250                     r[i+38]=av.get(38);
1251                     r[i+39]=av.get(39);
1252                     r[i+40]=av.get(40);
1253                     r[i+41]=av.get(41);
1254                     r[i+42]=av.get(42);
1255                     r[i+43]=av.get(43);
1256                     r[i+44]=av.get(44);
1257                     r[i+45]=av.get(45);
1258                     r[i+46]=av.get(46);
1259                     r[i+47]=av.get(47);
1260                     r[i+48]=av.get(48);
1261                     r[i+49]=av.get(49);
1262                     r[i+50]=av.get(50);
1263                     r[i+51]=av.get(51);
1264                     r[i+52]=av.get(52);
1265                     r[i+53]=av.get(53);
1266                     r[i+54]=av.get(54);
1267                     r[i+55]=av.get(55);
1268                     r[i+56]=av.get(56);
1269                     r[i+57]=av.get(57);
1270                     r[i+58]=av.get(58);
1271                     r[i+59]=av.get(59);
1272                     r[i+60]=av.get(60);
1273                     r[i+61]=av.get(61);
1274                     r[i+62]=av.get(62);
1275                     r[i+63]=av.get(63);
1276                 } else {
1277                     for (int j = 0; j < SPECIES.length(); j++) {
1278                         r[i+j]=av.get(j);
1279                     }
1280                 }
1281             }
1282         }
1283 
1284         assertArraysEquals(a, r, Double256VectorTests::get);
1285     }
1286 
1287     static double sin(double a) {
1288         return (double)(Math.sin((double)a));
1289     }
1290 
1291     static double strictsin(double a) {
1292         return (double)(StrictMath.sin((double)a));
1293     }
1294 
1295     @Test(dataProvider = "doubleUnaryOpProvider")
1296     static void sinDouble256VectorTests(IntFunction<double[]> fa) {
1297         double[] a = fa.apply(SPECIES.length());
1298         double[] r = fr.apply(SPECIES.length());
1299 
1300         for (int ic = 0; ic < INVOC_COUNT; ic++) {
1301             for (int i = 0; i < a.length; i += SPECIES.length()) {
1302                 DoubleVector av = DoubleVector.fromArray(SPECIES, a, i);
1303                 av.sin().intoArray(r, i);
1304             }
1305         }
1306 
1307         assertArraysEqualsWithinOneUlp(a, r, Double256VectorTests::sin, Double256VectorTests::strictsin);
1308     }
1309 
1310 
1311     static double exp(double a) {
1312         return (double)(Math.exp((double)a));
1313     }
1314 
1315     static double strictexp(double a) {
1316         return (double)(StrictMath.exp((double)a));
1317     }
1318 
1319     @Test(dataProvider = "doubleUnaryOpProvider")
1320     static void expDouble256VectorTests(IntFunction<double[]> fa) {
1321         double[] a = fa.apply(SPECIES.length());
1322         double[] r = fr.apply(SPECIES.length());
1323 
1324         for (int ic = 0; ic < INVOC_COUNT; ic++) {
1325             for (int i = 0; i < a.length; i += SPECIES.length()) {
1326                 DoubleVector av = DoubleVector.fromArray(SPECIES, a, i);
1327                 av.exp().intoArray(r, i);
1328             }
1329         }
1330 
1331         assertArraysEqualsWithinOneUlp(a, r, Double256VectorTests::exp, Double256VectorTests::strictexp);
1332     }
1333 
1334 
1335     static double log1p(double a) {
1336         return (double)(Math.log1p((double)a));
1337     }
1338 
1339     static double strictlog1p(double a) {
1340         return (double)(StrictMath.log1p((double)a));
1341     }
1342 
1343     @Test(dataProvider = "doubleUnaryOpProvider")
1344     static void log1pDouble256VectorTests(IntFunction<double[]> fa) {
1345         double[] a = fa.apply(SPECIES.length());
1346         double[] r = fr.apply(SPECIES.length());
1347 
1348         for (int ic = 0; ic < INVOC_COUNT; ic++) {
1349             for (int i = 0; i < a.length; i += SPECIES.length()) {
1350                 DoubleVector av = DoubleVector.fromArray(SPECIES, a, i);
1351                 av.log1p().intoArray(r, i);
1352             }
1353         }
1354 
1355         assertArraysEqualsWithinOneUlp(a, r, Double256VectorTests::log1p, Double256VectorTests::strictlog1p);
1356     }
1357 
1358 
1359     static double log(double a) {
1360         return (double)(Math.log((double)a));
1361     }
1362 
1363     static double strictlog(double a) {
1364         return (double)(StrictMath.log((double)a));
1365     }
1366 
1367     @Test(dataProvider = "doubleUnaryOpProvider")
1368     static void logDouble256VectorTests(IntFunction<double[]> fa) {
1369         double[] a = fa.apply(SPECIES.length());
1370         double[] r = fr.apply(SPECIES.length());
1371 
1372         for (int ic = 0; ic < INVOC_COUNT; ic++) {
1373             for (int i = 0; i < a.length; i += SPECIES.length()) {
1374                 DoubleVector av = DoubleVector.fromArray(SPECIES, a, i);
1375                 av.log().intoArray(r, i);
1376             }
1377         }
1378 
1379         assertArraysEqualsWithinOneUlp(a, r, Double256VectorTests::log, Double256VectorTests::strictlog);
1380     }
1381 
1382 
1383     static double log10(double a) {
1384         return (double)(Math.log10((double)a));
1385     }
1386 
1387     static double strictlog10(double a) {
1388         return (double)(StrictMath.log10((double)a));
1389     }
1390 
1391     @Test(dataProvider = "doubleUnaryOpProvider")
1392     static void log10Double256VectorTests(IntFunction<double[]> fa) {
1393         double[] a = fa.apply(SPECIES.length());
1394         double[] r = fr.apply(SPECIES.length());
1395 
1396         for (int ic = 0; ic < INVOC_COUNT; ic++) {
1397             for (int i = 0; i < a.length; i += SPECIES.length()) {
1398                 DoubleVector av = DoubleVector.fromArray(SPECIES, a, i);
1399                 av.log10().intoArray(r, i);
1400             }
1401         }
1402 
1403         assertArraysEqualsWithinOneUlp(a, r, Double256VectorTests::log10, Double256VectorTests::strictlog10);
1404     }
1405 
1406 
1407     static double expm1(double a) {
1408         return (double)(Math.expm1((double)a));
1409     }
1410 
1411     static double strictexpm1(double a) {
1412         return (double)(StrictMath.expm1((double)a));
1413     }
1414 
1415     @Test(dataProvider = "doubleUnaryOpProvider")
1416     static void expm1Double256VectorTests(IntFunction<double[]> fa) {
1417         double[] a = fa.apply(SPECIES.length());
1418         double[] r = fr.apply(SPECIES.length());
1419 
1420         for (int ic = 0; ic < INVOC_COUNT; ic++) {
1421             for (int i = 0; i < a.length; i += SPECIES.length()) {
1422                 DoubleVector av = DoubleVector.fromArray(SPECIES, a, i);
1423                 av.expm1().intoArray(r, i);
1424             }
1425         }
1426 
1427         assertArraysEqualsWithinOneUlp(a, r, Double256VectorTests::expm1, Double256VectorTests::strictexpm1);
1428     }
1429 
1430 
1431     static double cos(double a) {
1432         return (double)(Math.cos((double)a));
1433     }
1434 
1435     static double strictcos(double a) {
1436         return (double)(StrictMath.cos((double)a));
1437     }
1438 
1439     @Test(dataProvider = "doubleUnaryOpProvider")
1440     static void cosDouble256VectorTests(IntFunction<double[]> fa) {
1441         double[] a = fa.apply(SPECIES.length());
1442         double[] r = fr.apply(SPECIES.length());
1443 
1444         for (int ic = 0; ic < INVOC_COUNT; ic++) {
1445             for (int i = 0; i < a.length; i += SPECIES.length()) {
1446                 DoubleVector av = DoubleVector.fromArray(SPECIES, a, i);
1447                 av.cos().intoArray(r, i);
1448             }
1449         }
1450 
1451         assertArraysEqualsWithinOneUlp(a, r, Double256VectorTests::cos, Double256VectorTests::strictcos);
1452     }
1453 
1454 
1455     static double tan(double a) {
1456         return (double)(Math.tan((double)a));
1457     }
1458 
1459     static double stricttan(double a) {
1460         return (double)(StrictMath.tan((double)a));
1461     }
1462 
1463     @Test(dataProvider = "doubleUnaryOpProvider")
1464     static void tanDouble256VectorTests(IntFunction<double[]> fa) {
1465         double[] a = fa.apply(SPECIES.length());
1466         double[] r = fr.apply(SPECIES.length());
1467 
1468         for (int ic = 0; ic < INVOC_COUNT; ic++) {
1469             for (int i = 0; i < a.length; i += SPECIES.length()) {
1470                 DoubleVector av = DoubleVector.fromArray(SPECIES, a, i);
1471                 av.tan().intoArray(r, i);
1472             }
1473         }
1474 
1475         assertArraysEqualsWithinOneUlp(a, r, Double256VectorTests::tan, Double256VectorTests::stricttan);
1476     }
1477 
1478 
1479     static double sinh(double a) {
1480         return (double)(Math.sinh((double)a));
1481     }
1482 
1483     static double strictsinh(double a) {
1484         return (double)(StrictMath.sinh((double)a));
1485     }
1486 
1487     @Test(dataProvider = "doubleUnaryOpProvider")
1488     static void sinhDouble256VectorTests(IntFunction<double[]> fa) {
1489         double[] a = fa.apply(SPECIES.length());
1490         double[] r = fr.apply(SPECIES.length());
1491 
1492         for (int ic = 0; ic < INVOC_COUNT; ic++) {
1493             for (int i = 0; i < a.length; i += SPECIES.length()) {
1494                 DoubleVector av = DoubleVector.fromArray(SPECIES, a, i);
1495                 av.sinh().intoArray(r, i);
1496             }
1497         }
1498 
1499         assertArraysEqualsWithinOneUlp(a, r, Double256VectorTests::sinh, Double256VectorTests::strictsinh);
1500     }
1501 
1502 
1503     static double cosh(double a) {
1504         return (double)(Math.cosh((double)a));
1505     }
1506 
1507     static double strictcosh(double a) {
1508         return (double)(StrictMath.cosh((double)a));
1509     }
1510 
1511     @Test(dataProvider = "doubleUnaryOpProvider")
1512     static void coshDouble256VectorTests(IntFunction<double[]> fa) {
1513         double[] a = fa.apply(SPECIES.length());
1514         double[] r = fr.apply(SPECIES.length());
1515 
1516         for (int ic = 0; ic < INVOC_COUNT; ic++) {
1517             for (int i = 0; i < a.length; i += SPECIES.length()) {
1518                 DoubleVector av = DoubleVector.fromArray(SPECIES, a, i);
1519                 av.cosh().intoArray(r, i);
1520             }
1521         }
1522 
1523         assertArraysEqualsWithinOneUlp(a, r, Double256VectorTests::cosh, Double256VectorTests::strictcosh);
1524     }
1525 
1526 
1527     static double tanh(double a) {
1528         return (double)(Math.tanh((double)a));
1529     }
1530 
1531     static double stricttanh(double a) {
1532         return (double)(StrictMath.tanh((double)a));
1533     }
1534 
1535     @Test(dataProvider = "doubleUnaryOpProvider")
1536     static void tanhDouble256VectorTests(IntFunction<double[]> fa) {
1537         double[] a = fa.apply(SPECIES.length());
1538         double[] r = fr.apply(SPECIES.length());
1539 
1540         for (int ic = 0; ic < INVOC_COUNT; ic++) {
1541             for (int i = 0; i < a.length; i += SPECIES.length()) {
1542                 DoubleVector av = DoubleVector.fromArray(SPECIES, a, i);
1543                 av.tanh().intoArray(r, i);
1544             }
1545         }
1546 
1547         assertArraysEqualsWithinOneUlp(a, r, Double256VectorTests::tanh, Double256VectorTests::stricttanh);
1548     }
1549 
1550 
1551     static double asin(double a) {
1552         return (double)(Math.asin((double)a));
1553     }
1554 
1555     static double strictasin(double a) {
1556         return (double)(StrictMath.asin((double)a));
1557     }
1558 
1559     @Test(dataProvider = "doubleUnaryOpProvider")
1560     static void asinDouble256VectorTests(IntFunction<double[]> fa) {
1561         double[] a = fa.apply(SPECIES.length());
1562         double[] r = fr.apply(SPECIES.length());
1563 
1564         for (int ic = 0; ic < INVOC_COUNT; ic++) {
1565             for (int i = 0; i < a.length; i += SPECIES.length()) {
1566                 DoubleVector av = DoubleVector.fromArray(SPECIES, a, i);
1567                 av.asin().intoArray(r, i);
1568             }
1569         }
1570 
1571         assertArraysEqualsWithinOneUlp(a, r, Double256VectorTests::asin, Double256VectorTests::strictasin);
1572     }
1573 
1574 
1575     static double acos(double a) {
1576         return (double)(Math.acos((double)a));
1577     }
1578 
1579     static double strictacos(double a) {
1580         return (double)(StrictMath.acos((double)a));
1581     }
1582 
1583     @Test(dataProvider = "doubleUnaryOpProvider")
1584     static void acosDouble256VectorTests(IntFunction<double[]> fa) {
1585         double[] a = fa.apply(SPECIES.length());
1586         double[] r = fr.apply(SPECIES.length());
1587 
1588         for (int ic = 0; ic < INVOC_COUNT; ic++) {
1589             for (int i = 0; i < a.length; i += SPECIES.length()) {
1590                 DoubleVector av = DoubleVector.fromArray(SPECIES, a, i);
1591                 av.acos().intoArray(r, i);
1592             }
1593         }
1594 
1595         assertArraysEqualsWithinOneUlp(a, r, Double256VectorTests::acos, Double256VectorTests::strictacos);
1596     }
1597 
1598 
1599     static double atan(double a) {
1600         return (double)(Math.atan((double)a));
1601     }
1602 
1603     static double strictatan(double a) {
1604         return (double)(StrictMath.atan((double)a));
1605     }
1606 
1607     @Test(dataProvider = "doubleUnaryOpProvider")
1608     static void atanDouble256VectorTests(IntFunction<double[]> fa) {
1609         double[] a = fa.apply(SPECIES.length());
1610         double[] r = fr.apply(SPECIES.length());
1611 
1612         for (int ic = 0; ic < INVOC_COUNT; ic++) {
1613             for (int i = 0; i < a.length; i += SPECIES.length()) {
1614                 DoubleVector av = DoubleVector.fromArray(SPECIES, a, i);
1615                 av.atan().intoArray(r, i);
1616             }
1617         }
1618 
1619         assertArraysEqualsWithinOneUlp(a, r, Double256VectorTests::atan, Double256VectorTests::strictatan);
1620     }
1621 
1622 
1623     static double cbrt(double a) {
1624         return (double)(Math.cbrt((double)a));
1625     }
1626 
1627     static double strictcbrt(double a) {
1628         return (double)(StrictMath.cbrt((double)a));
1629     }
1630 
1631     @Test(dataProvider = "doubleUnaryOpProvider")
1632     static void cbrtDouble256VectorTests(IntFunction<double[]> fa) {
1633         double[] a = fa.apply(SPECIES.length());
1634         double[] r = fr.apply(SPECIES.length());
1635 
1636         for (int ic = 0; ic < INVOC_COUNT; ic++) {
1637             for (int i = 0; i < a.length; i += SPECIES.length()) {
1638                 DoubleVector av = DoubleVector.fromArray(SPECIES, a, i);
1639                 av.cbrt().intoArray(r, i);
1640             }
1641         }
1642 
1643         assertArraysEqualsWithinOneUlp(a, r, Double256VectorTests::cbrt, Double256VectorTests::strictcbrt);
1644     }
1645 
1646 
1647     static double hypot(double a, double b) {
1648         return (double)(Math.hypot((double)a, (double)b));
1649     }
1650 
1651     static double stricthypot(double a, double b) {
1652         return (double)(StrictMath.hypot((double)a, (double)b));
1653     }
1654 
1655     @Test(dataProvider = "doubleBinaryOpProvider")
1656     static void hypotDouble256VectorTests(IntFunction<double[]> fa, IntFunction<double[]> fb) {
1657         double[] a = fa.apply(SPECIES.length());
1658         double[] b = fb.apply(SPECIES.length());
1659         double[] r = fr.apply(SPECIES.length());
1660 
1661         for (int ic = 0; ic < INVOC_COUNT; ic++) {
1662             for (int i = 0; i < a.length; i += SPECIES.length()) {
1663                 DoubleVector av = DoubleVector.fromArray(SPECIES, a, i);
1664                 DoubleVector bv = DoubleVector.fromArray(SPECIES, b, i);
1665                 av.hypot(bv).intoArray(r, i);
1666             }
1667         }
1668 
1669         assertArraysEqualsWithinOneUlp(a, b, r, Double256VectorTests::hypot, Double256VectorTests::stricthypot);
1670     }
1671 
1672 
1673 
1674     static double pow(double a, double b) {
1675         return (double)(Math.pow((double)a, (double)b));
1676     }
1677 
1678     static double strictpow(double a, double b) {
1679         return (double)(StrictMath.pow((double)a, (double)b));
1680     }
1681 
1682     @Test(dataProvider = "doubleBinaryOpProvider")
1683     static void powDouble256VectorTests(IntFunction<double[]> fa, IntFunction<double[]> fb) {
1684         double[] a = fa.apply(SPECIES.length());
1685         double[] b = fb.apply(SPECIES.length());
1686         double[] r = fr.apply(SPECIES.length());
1687 
1688         for (int ic = 0; ic < INVOC_COUNT; ic++) {
1689             for (int i = 0; i < a.length; i += SPECIES.length()) {
1690                 DoubleVector av = DoubleVector.fromArray(SPECIES, a, i);
1691                 DoubleVector bv = DoubleVector.fromArray(SPECIES, b, i);
1692                 av.pow(bv).intoArray(r, i);
1693             }
1694         }
1695 
1696         assertArraysEqualsWithinOneUlp(a, b, r, Double256VectorTests::pow, Double256VectorTests::strictpow);
1697     }
1698 
1699 
1700 
1701     static double atan2(double a, double b) {
1702         return (double)(Math.atan2((double)a, (double)b));
1703     }
1704 
1705     static double strictatan2(double a, double b) {
1706         return (double)(StrictMath.atan2((double)a, (double)b));
1707     }
1708 
1709     @Test(dataProvider = "doubleBinaryOpProvider")
1710     static void atan2Double256VectorTests(IntFunction<double[]> fa, IntFunction<double[]> fb) {
1711         double[] a = fa.apply(SPECIES.length());
1712         double[] b = fb.apply(SPECIES.length());
1713         double[] r = fr.apply(SPECIES.length());
1714 
1715         for (int ic = 0; ic < INVOC_COUNT; ic++) {
1716             for (int i = 0; i < a.length; i += SPECIES.length()) {
1717                 DoubleVector av = DoubleVector.fromArray(SPECIES, a, i);
1718                 DoubleVector bv = DoubleVector.fromArray(SPECIES, b, i);
1719                 av.atan2(bv).intoArray(r, i);
1720             }
1721         }
1722 
1723         assertArraysEqualsWithinOneUlp(a, b, r, Double256VectorTests::atan2, Double256VectorTests::strictatan2);
1724     }
1725 
1726 
1727 
1728     static double fma(double a, double b, double c) {
1729         return (double)(Math.fma(a, b, c));
1730     }
1731 
1732 
1733     @Test(dataProvider = "doubleTernaryOpProvider")
1734     static void fmaDouble256VectorTests(IntFunction<double[]> fa, IntFunction<double[]> fb, IntFunction<double[]> fc) {
1735         double[] a = fa.apply(SPECIES.length());
1736         double[] b = fb.apply(SPECIES.length());
1737         double[] c = fc.apply(SPECIES.length());
1738         double[] r = fr.apply(SPECIES.length());
1739 
1740         for (int ic = 0; ic < INVOC_COUNT; ic++) {
1741             for (int i = 0; i < a.length; i += SPECIES.length()) {
1742                 DoubleVector av = DoubleVector.fromArray(SPECIES, a, i);
1743                 DoubleVector bv = DoubleVector.fromArray(SPECIES, b, i);
1744                 DoubleVector cv = DoubleVector.fromArray(SPECIES, c, i);
1745                 av.fma(bv, cv).intoArray(r, i);
1746             }
1747         }
1748 
1749         assertArraysEquals(a, b, c, r, Double256VectorTests::fma);
1750     }
1751 
1752 
1753     @Test(dataProvider = "doubleTernaryOpMaskProvider")
1754     static void fmaDouble256VectorTests(IntFunction<double[]> fa, IntFunction<double[]> fb,
1755                                           IntFunction<double[]> fc, IntFunction<boolean[]> fm) {
1756         double[] a = fa.apply(SPECIES.length());
1757         double[] b = fb.apply(SPECIES.length());
1758         double[] c = fc.apply(SPECIES.length());
1759         double[] r = fr.apply(SPECIES.length());
1760         boolean[] mask = fm.apply(SPECIES.length());
1761         VectorMask<Double> vmask = VectorMask.fromValues(SPECIES, mask);
1762 
1763         for (int ic = 0; ic < INVOC_COUNT; ic++) {
1764             for (int i = 0; i < a.length; i += SPECIES.length()) {
1765                 DoubleVector av = DoubleVector.fromArray(SPECIES, a, i);
1766                 DoubleVector bv = DoubleVector.fromArray(SPECIES, b, i);
1767                 DoubleVector cv = DoubleVector.fromArray(SPECIES, c, i);
1768                 av.fma(bv, cv, vmask).intoArray(r, i);
1769             }
1770         }
1771 
1772         assertArraysEquals(a, b, c, r, mask, Double256VectorTests::fma);
1773     }
1774 
1775 
1776     static double neg(double a) {
1777         return (double)(-((double)a));
1778     }
1779 
1780     @Test(dataProvider = "doubleUnaryOpProvider")
1781     static void negDouble256VectorTests(IntFunction<double[]> fa) {
1782         double[] a = fa.apply(SPECIES.length());
1783         double[] r = fr.apply(SPECIES.length());
1784 
1785         for (int ic = 0; ic < INVOC_COUNT; ic++) {
1786             for (int i = 0; i < a.length; i += SPECIES.length()) {
1787                 DoubleVector av = DoubleVector.fromArray(SPECIES, a, i);
1788                 av.neg().intoArray(r, i);
1789             }
1790         }
1791 
1792         assertArraysEquals(a, r, Double256VectorTests::neg);
1793     }
1794 
1795     @Test(dataProvider = "doubleUnaryOpMaskProvider")
1796     static void negMaskedDouble256VectorTests(IntFunction<double[]> fa,
1797                                                 IntFunction<boolean[]> fm) {
1798         double[] a = fa.apply(SPECIES.length());
1799         double[] r = fr.apply(SPECIES.length());
1800         boolean[] mask = fm.apply(SPECIES.length());
1801         VectorMask<Double> vmask = VectorMask.fromValues(SPECIES, mask);
1802 
1803         for (int ic = 0; ic < INVOC_COUNT; ic++) {
1804             for (int i = 0; i < a.length; i += SPECIES.length()) {
1805                 DoubleVector av = DoubleVector.fromArray(SPECIES, a, i);
1806                 av.neg(vmask).intoArray(r, i);
1807             }
1808         }
1809 
1810         assertArraysEquals(a, r, mask, Double256VectorTests::neg);
1811     }
1812 
1813     static double abs(double a) {
1814         return (double)(Math.abs((double)a));
1815     }
1816 
1817     @Test(dataProvider = "doubleUnaryOpProvider")
1818     static void absDouble256VectorTests(IntFunction<double[]> fa) {
1819         double[] a = fa.apply(SPECIES.length());
1820         double[] r = fr.apply(SPECIES.length());
1821 
1822         for (int ic = 0; ic < INVOC_COUNT; ic++) {
1823             for (int i = 0; i < a.length; i += SPECIES.length()) {
1824                 DoubleVector av = DoubleVector.fromArray(SPECIES, a, i);
1825                 av.abs().intoArray(r, i);
1826             }
1827         }
1828 
1829         assertArraysEquals(a, r, Double256VectorTests::abs);
1830     }
1831 
1832     @Test(dataProvider = "doubleUnaryOpMaskProvider")
1833     static void absMaskedDouble256VectorTests(IntFunction<double[]> fa,
1834                                                 IntFunction<boolean[]> fm) {
1835         double[] a = fa.apply(SPECIES.length());
1836         double[] r = fr.apply(SPECIES.length());
1837         boolean[] mask = fm.apply(SPECIES.length());
1838         VectorMask<Double> vmask = VectorMask.fromValues(SPECIES, mask);
1839 
1840         for (int ic = 0; ic < INVOC_COUNT; ic++) {
1841             for (int i = 0; i < a.length; i += SPECIES.length()) {
1842                 DoubleVector av = DoubleVector.fromArray(SPECIES, a, i);
1843                 av.abs(vmask).intoArray(r, i);
1844             }
1845         }
1846 
1847         assertArraysEquals(a, r, mask, Double256VectorTests::abs);
1848     }
1849 
1850 
1851 
1852 
1853 
1854     static double sqrt(double a) {
1855         return (double)(Math.sqrt((double)a));
1856     }
1857 
1858 
1859 
1860     @Test(dataProvider = "doubleUnaryOpProvider")
1861     static void sqrtDouble256VectorTests(IntFunction<double[]> fa) {
1862         double[] a = fa.apply(SPECIES.length());
1863         double[] r = fr.apply(SPECIES.length());
1864 
1865         for (int ic = 0; ic < INVOC_COUNT; ic++) {
1866             for (int i = 0; i < a.length; i += SPECIES.length()) {
1867                 DoubleVector av = DoubleVector.fromArray(SPECIES, a, i);
1868                 av.sqrt().intoArray(r, i);
1869             }
1870         }
1871 
1872         assertArraysEquals(a, r, Double256VectorTests::sqrt);
1873     }
1874 
1875 
1876 
1877     @Test(dataProvider = "doubleUnaryOpMaskProvider")
1878     static void sqrtMaskedDouble256VectorTests(IntFunction<double[]> fa,
1879                                                 IntFunction<boolean[]> fm) {
1880         double[] a = fa.apply(SPECIES.length());
1881         double[] r = fr.apply(SPECIES.length());
1882         boolean[] mask = fm.apply(SPECIES.length());
1883         VectorMask<Double> vmask = VectorMask.fromValues(SPECIES, mask);
1884 
1885         for (int ic = 0; ic < INVOC_COUNT; ic++) {
1886             for (int i = 0; i < a.length; i += SPECIES.length()) {
1887                 DoubleVector av = DoubleVector.fromArray(SPECIES, a, i);
1888                 av.sqrt(vmask).intoArray(r, i);
1889             }
1890         }
1891 
1892         assertArraysEquals(a, r, mask, Double256VectorTests::sqrt);
1893     }
1894 
1895 
1896     static double[] gather(double a[], int ix, int[] b, int iy) {
1897         double[] res = new double[SPECIES.length()];
1898         for (int i = 0; i < SPECIES.length(); i++) {
1899             int bi = iy + i;
1900             res[i] = a[b[bi] + ix];
1901         }
1902         return res;
1903     }
1904 
1905     @Test(dataProvider = "doubleUnaryOpIndexProvider")
1906     static void gatherDouble256VectorTests(IntFunction<double[]> fa, BiFunction<Integer,Integer,int[]> fs) {
1907         double[] a = fa.apply(SPECIES.length());
1908         int[] b    = fs.apply(a.length, SPECIES.length());
1909         double[] r = new double[a.length];
1910 
1911         for (int ic = 0; ic < INVOC_COUNT; ic++) {
1912             for (int i = 0; i < a.length; i += SPECIES.length()) {
1913                 DoubleVector av = DoubleVector.fromArray(SPECIES, a, i, b, i);
1914                 av.intoArray(r, i);
1915             }
1916         }
1917 
1918         assertArraysEquals(a, b, r, Double256VectorTests::gather);
1919     }
1920 
1921 
1922     static double[] scatter(double a[], int ix, int[] b, int iy) {
1923       double[] res = new double[SPECIES.length()];
1924       for (int i = 0; i < SPECIES.length(); i++) {
1925         int bi = iy + i;
1926         res[b[bi]] = a[i + ix];
1927       }
1928       return res;
1929     }
1930 
1931     @Test(dataProvider = "doubleUnaryOpIndexProvider")
1932     static void scatterDouble256VectorTests(IntFunction<double[]> fa, BiFunction<Integer,Integer,int[]> fs) {
1933         double[] a = fa.apply(SPECIES.length());
1934         int[] b = fs.apply(a.length, SPECIES.length());
1935         double[] r = new double[a.length];
1936 
1937         for (int ic = 0; ic < INVOC_COUNT; ic++) {
1938             for (int i = 0; i < a.length; i += SPECIES.length()) {
1939                 DoubleVector av = DoubleVector.fromArray(SPECIES, a, i);
1940                 av.intoArray(r, i, b, i);
1941             }
1942         }
1943 
1944         assertArraysEquals(a, b, r, Double256VectorTests::scatter);
1945     }
1946 
1947 }
1948 
--- EOF ---