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