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