1 /*
   2  * Copyright (c) 2018, 2021, 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 any
  21  * questions.
  22  */
  23 
  24 /*
  25  * @test
  26  * @modules jdk.incubator.vector
  27  * @run testng/othervm -ea -esa -Xbatch -XX:-TieredCompilation Double256VectorTests
  28  */
  29 
  30 // -- This file was mechanically generated: Do not edit! -- //
  31 
  32 import jdk.incubator.vector.VectorShape;
  33 import jdk.incubator.vector.VectorSpecies;
  34 import jdk.incubator.vector.VectorShuffle;
  35 import jdk.incubator.vector.VectorMask;
  36 import jdk.incubator.vector.VectorOperators;
  37 import jdk.incubator.vector.Vector;
  38 
  39 import jdk.incubator.vector.DoubleVector;
  40 
  41 import org.testng.Assert;
  42 import org.testng.annotations.DataProvider;
  43 import org.testng.annotations.Test;
  44 
  45 import java.lang.Integer;
  46 import java.util.List;
  47 import java.util.Arrays;
  48 import java.util.function.BiFunction;
  49 import java.util.function.IntFunction;
  50 import java.util.Objects;
  51 import java.util.stream.Collectors;
  52 import java.util.stream.Stream;
  53 
  54 @Test
  55 public class Double256VectorTests extends AbstractVectorTest {
  56 
  57     static final VectorSpecies<Double> SPECIES =
  58                 DoubleVector.SPECIES_256;
  59 
  60     static final int INVOC_COUNT = Integer.getInteger("jdk.incubator.vector.test.loop-iterations", 100);
  61 
  62 
  63     static final int BUFFER_REPS = Integer.getInteger("jdk.incubator.vector.test.buffer-vectors", 25000 / 256);
  64 
  65     interface FUnOp {
  66         double apply(double a);
  67     }
  68 
  69     static void assertArraysEquals(double[] r, double[] a, FUnOp f) {
  70         int i = 0;
  71         try {
  72             for (; i < a.length; i++) {
  73                 Assert.assertEquals(r[i], f.apply(a[i]));
  74             }
  75         } catch (AssertionError e) {
  76             Assert.assertEquals(r[i], f.apply(a[i]), "at index #" + i + ", input = " + a[i]);
  77         }
  78     }
  79 
  80     interface FUnArrayOp {
  81         double[] apply(double a);
  82     }
  83 
  84     static void assertArraysEquals(double[] r, double[] a, FUnArrayOp f) {
  85         int i = 0;
  86         try {
  87             for (; i < a.length; i += SPECIES.length()) {
  88                 Assert.assertEquals(Arrays.copyOfRange(r, i, i+SPECIES.length()),
  89                   f.apply(a[i]));
  90             }
  91         } catch (AssertionError e) {
  92             double[] ref = f.apply(a[i]);
  93             double[] res = Arrays.copyOfRange(r, i, i+SPECIES.length());
  94             Assert.assertEquals(res, ref, "(ref: " + Arrays.toString(ref)
  95               + ", res: " + Arrays.toString(res)
  96               + "), at index #" + i);
  97         }
  98     }
  99 
 100     static void assertArraysEquals(double[] r, double[] a, boolean[] mask, FUnOp f) {
 101         int i = 0;
 102         try {
 103             for (; i < a.length; i++) {
 104                 Assert.assertEquals(r[i], mask[i % SPECIES.length()] ? f.apply(a[i]) : a[i]);
 105             }
 106         } catch (AssertionError e) {
 107             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()]);
 108         }
 109     }
 110 
 111     interface FReductionOp {
 112         double apply(double[] a, int idx);
 113     }
 114 
 115     interface FReductionAllOp {
 116         double apply(double[] a);
 117     }
 118 
 119     static void assertReductionArraysEquals(double[] r, double rc, double[] a,
 120                                             FReductionOp f, FReductionAllOp fa) {
 121         int i = 0;
 122         try {
 123             Assert.assertEquals(rc, fa.apply(a));
 124             for (; i < a.length; i += SPECIES.length()) {
 125                 Assert.assertEquals(r[i], f.apply(a, i));
 126             }
 127         } catch (AssertionError e) {
 128             Assert.assertEquals(rc, fa.apply(a), "Final result is incorrect!");
 129             Assert.assertEquals(r[i], f.apply(a, i), "at index #" + i);
 130         }
 131     }
 132 
 133     interface FReductionMaskedOp {
 134         double apply(double[] a, int idx, boolean[] mask);
 135     }
 136 
 137     interface FReductionAllMaskedOp {
 138         double apply(double[] a, boolean[] mask);
 139     }
 140 
 141     static void assertReductionArraysEqualsMasked(double[] r, double rc, double[] a, boolean[] mask,
 142                                             FReductionMaskedOp f, FReductionAllMaskedOp fa) {
 143         int i = 0;
 144         try {
 145             Assert.assertEquals(rc, fa.apply(a, mask));
 146             for (; i < a.length; i += SPECIES.length()) {
 147                 Assert.assertEquals(r[i], f.apply(a, i, mask));
 148             }
 149         } catch (AssertionError e) {
 150             Assert.assertEquals(rc, fa.apply(a, mask), "Final result is incorrect!");
 151             Assert.assertEquals(r[i], f.apply(a, i, mask), "at index #" + i);
 152         }
 153     }
 154 
 155     interface FReductionOpLong {
 156         long apply(double[] a, int idx);
 157     }
 158 
 159     interface FReductionAllOpLong {
 160         long apply(double[] a);
 161     }
 162 
 163     static void assertReductionLongArraysEquals(long[] r, long rc, double[] a,
 164                                             FReductionOpLong f, FReductionAllOpLong fa) {
 165         int i = 0;
 166         try {
 167             Assert.assertEquals(rc, fa.apply(a));
 168             for (; i < a.length; i += SPECIES.length()) {
 169                 Assert.assertEquals(r[i], f.apply(a, i));
 170             }
 171         } catch (AssertionError e) {
 172             Assert.assertEquals(rc, fa.apply(a), "Final result is incorrect!");
 173             Assert.assertEquals(r[i], f.apply(a, i), "at index #" + i);
 174         }
 175     }
 176 
 177     interface FReductionMaskedOpLong {
 178         long apply(double[] a, int idx, boolean[] mask);
 179     }
 180 
 181     interface FReductionAllMaskedOpLong {
 182         long apply(double[] a, boolean[] mask);
 183     }
 184 
 185     static void assertReductionLongArraysEqualsMasked(long[] r, long rc, double[] a, boolean[] mask,
 186                                             FReductionMaskedOpLong f, FReductionAllMaskedOpLong fa) {
 187         int i = 0;
 188         try {
 189             Assert.assertEquals(rc, fa.apply(a, mask));
 190             for (; i < a.length; i += SPECIES.length()) {
 191                 Assert.assertEquals(r[i], f.apply(a, i, mask));
 192             }
 193         } catch (AssertionError e) {
 194             Assert.assertEquals(rc, fa.apply(a, mask), "Final result is incorrect!");
 195             Assert.assertEquals(r[i], f.apply(a, i, mask), "at index #" + i);
 196         }
 197     }
 198 
 199     interface FBoolReductionOp {
 200         boolean apply(boolean[] a, int idx);
 201     }
 202 
 203     static void assertReductionBoolArraysEquals(boolean[] r, boolean[] a, FBoolReductionOp f) {
 204         int i = 0;
 205         try {
 206             for (; i < a.length; i += SPECIES.length()) {
 207                 Assert.assertEquals(r[i], f.apply(a, i));
 208             }
 209         } catch (AssertionError e) {
 210             Assert.assertEquals(r[i], f.apply(a, i), "at index #" + i);
 211         }
 212     }
 213 
 214     interface FMaskReductionOp {
 215         int apply(boolean[] a, int idx);
 216     }
 217 
 218     static void assertMaskReductionArraysEquals(int[] r, boolean[] a, FMaskReductionOp f) {
 219         int i = 0;
 220         try {
 221             for (; i < a.length; i += SPECIES.length()) {
 222                 Assert.assertEquals(r[i], f.apply(a, i));
 223             }
 224         } catch (AssertionError e) {
 225             Assert.assertEquals(r[i], f.apply(a, i), "at index #" + i);
 226         }
 227     }
 228 
 229     static void assertInsertArraysEquals(double[] r, double[] a, double element, int index) {
 230         int i = 0;
 231         try {
 232             for (; i < a.length; i += 1) {
 233                 if(i%SPECIES.length() == index) {
 234                     Assert.assertEquals(r[i], element);
 235                 } else {
 236                     Assert.assertEquals(r[i], a[i]);
 237                 }
 238             }
 239         } catch (AssertionError e) {
 240             if (i%SPECIES.length() == index) {
 241                 Assert.assertEquals(r[i], element, "at index #" + i);
 242             } else {
 243                 Assert.assertEquals(r[i], a[i], "at index #" + i);
 244             }
 245         }
 246     }
 247 
 248     static void assertRearrangeArraysEquals(double[] r, double[] a, int[] order, int vector_len) {
 249         int i = 0, j = 0;
 250         try {
 251             for (; i < a.length; i += vector_len) {
 252                 for (j = 0; j < vector_len; j++) {
 253                     Assert.assertEquals(r[i+j], a[i+order[i+j]]);
 254                 }
 255             }
 256         } catch (AssertionError e) {
 257             int idx = i + j;
 258             Assert.assertEquals(r[i+j], a[i+order[i+j]], "at index #" + idx + ", input = " + a[i+order[i+j]]);
 259         }
 260     }
 261 
 262     static void assertcompressArraysEquals(double[] r, double[] a, boolean[] m, int vector_len) {
 263         int i = 0, j = 0, k = 0;
 264         try {
 265             for (; i < a.length; i += vector_len) {
 266                 k = 0;
 267                 for (j = 0; j < vector_len; j++) {
 268                     if (m[(i + j) % SPECIES.length()]) {
 269                         Assert.assertEquals(r[i + k], a[i + j]);
 270                         k++;
 271                     }
 272                 }
 273                 for (; k < vector_len; k++) {
 274                     Assert.assertEquals(r[i + k], (double)0);
 275                 }
 276             }
 277         } catch (AssertionError e) {
 278             int idx = i + k;
 279             if (m[(i + j) % SPECIES.length()]) {
 280                 Assert.assertEquals(r[idx], a[i + j], "at index #" + idx);
 281             } else {
 282                 Assert.assertEquals(r[idx], (double)0, "at index #" + idx);
 283             }
 284         }
 285     }
 286 
 287     static void assertexpandArraysEquals(double[] r, double[] a, boolean[] m, int vector_len) {
 288         int i = 0, j = 0, k = 0;
 289         try {
 290             for (; i < a.length; i += vector_len) {
 291                 k = 0;
 292                 for (j = 0; j < vector_len; j++) {
 293                     if (m[(i + j) % SPECIES.length()]) {
 294                         Assert.assertEquals(r[i + j], a[i + k]);
 295                         k++;
 296                     } else {
 297                         Assert.assertEquals(r[i + j], (double)0);
 298                     }
 299                 }
 300             }
 301         } catch (AssertionError e) {
 302             int idx = i + j;
 303             if (m[idx % SPECIES.length()]) {
 304                 Assert.assertEquals(r[idx], a[i + k], "at index #" + idx);
 305             } else {
 306                 Assert.assertEquals(r[idx], (double)0, "at index #" + idx);
 307             }
 308         }
 309     }
 310 
 311     static void assertSelectFromArraysEquals(double[] r, double[] a, double[] order, int vector_len) {
 312         int i = 0, j = 0;
 313         try {
 314             for (; i < a.length; i += vector_len) {
 315                 for (j = 0; j < vector_len; j++) {
 316                     Assert.assertEquals(r[i+j], a[i+(int)order[i+j]]);
 317                 }
 318             }
 319         } catch (AssertionError e) {
 320             int idx = i + j;
 321             Assert.assertEquals(r[i+j], a[i+(int)order[i+j]], "at index #" + idx + ", input = " + a[i+(int)order[i+j]]);
 322         }
 323     }
 324 
 325     static void assertRearrangeArraysEquals(double[] r, double[] a, int[] order, boolean[] mask, int vector_len) {
 326         int i = 0, j = 0;
 327         try {
 328             for (; i < a.length; i += vector_len) {
 329                 for (j = 0; j < vector_len; j++) {
 330                     if (mask[j % SPECIES.length()])
 331                          Assert.assertEquals(r[i+j], a[i+order[i+j]]);
 332                     else
 333                          Assert.assertEquals(r[i+j], (double)0);
 334                 }
 335             }
 336         } catch (AssertionError e) {
 337             int idx = i + j;
 338             if (mask[j % SPECIES.length()])
 339                 Assert.assertEquals(r[i+j], a[i+order[i+j]], "at index #" + idx + ", input = " + a[i+order[i+j]] + ", mask = " + mask[j % SPECIES.length()]);
 340             else
 341                 Assert.assertEquals(r[i+j], (double)0, "at index #" + idx + ", input = " + a[i+order[i+j]] + ", mask = " + mask[j % SPECIES.length()]);
 342         }
 343     }
 344 
 345     static void assertSelectFromArraysEquals(double[] r, double[] a, double[] order, boolean[] mask, int vector_len) {
 346         int i = 0, j = 0;
 347         try {
 348             for (; i < a.length; i += vector_len) {
 349                 for (j = 0; j < vector_len; j++) {
 350                     if (mask[j % SPECIES.length()])
 351                          Assert.assertEquals(r[i+j], a[i+(int)order[i+j]]);
 352                     else
 353                          Assert.assertEquals(r[i+j], (double)0);
 354                 }
 355             }
 356         } catch (AssertionError e) {
 357             int idx = i + j;
 358             if (mask[j % SPECIES.length()])
 359                 Assert.assertEquals(r[i+j], a[i+(int)order[i+j]], "at index #" + idx + ", input = " + a[i+(int)order[i+j]] + ", mask = " + mask[j % SPECIES.length()]);
 360             else
 361                 Assert.assertEquals(r[i+j], (double)0, "at index #" + idx + ", input = " + a[i+(int)order[i+j]] + ", mask = " + mask[j % SPECIES.length()]);
 362         }
 363     }
 364 
 365     static void assertBroadcastArraysEquals(double[] r, double[] a) {
 366         int i = 0;
 367         for (; i < a.length; i += SPECIES.length()) {
 368             int idx = i;
 369             for (int j = idx; j < (idx + SPECIES.length()); j++)
 370                 a[j]=a[idx];
 371         }
 372 
 373         try {
 374             for (i = 0; i < a.length; i++) {
 375                 Assert.assertEquals(r[i], a[i]);
 376             }
 377         } catch (AssertionError e) {
 378             Assert.assertEquals(r[i], a[i], "at index #" + i + ", input = " + a[i]);
 379         }
 380     }
 381 
 382     interface FBinOp {
 383         double apply(double a, double b);
 384     }
 385 
 386     interface FBinMaskOp {
 387         double apply(double a, double b, boolean m);
 388 
 389         static FBinMaskOp lift(FBinOp f) {
 390             return (a, b, m) -> m ? f.apply(a, b) : a;
 391         }
 392     }
 393 
 394     static void assertArraysEquals(double[] r, double[] a, double[] b, FBinOp f) {
 395         int i = 0;
 396         try {
 397             for (; i < a.length; i++) {
 398                 Assert.assertEquals(r[i], f.apply(a[i], b[i]));
 399             }
 400         } catch (AssertionError e) {
 401             Assert.assertEquals(r[i], f.apply(a[i], b[i]), "(" + a[i] + ", " + b[i] + ") at index #" + i);
 402         }
 403     }
 404 
 405     static void assertBroadcastArraysEquals(double[] r, double[] a, double[] b, FBinOp f) {
 406         int i = 0;
 407         try {
 408             for (; i < a.length; i++) {
 409                 Assert.assertEquals(r[i], f.apply(a[i], b[(i / SPECIES.length()) * SPECIES.length()]));
 410             }
 411         } catch (AssertionError e) {
 412             Assert.assertEquals(r[i], f.apply(a[i], b[(i / SPECIES.length()) * SPECIES.length()]),
 413                                 "(" + a[i] + ", " + b[(i / SPECIES.length()) * SPECIES.length()] + ") at index #" + i);
 414         }
 415     }
 416 
 417     static void assertBroadcastLongArraysEquals(double[] r, double[] a, double[] b, FBinOp f) {
 418         int i = 0;
 419         try {
 420             for (; i < a.length; i++) {
 421                 Assert.assertEquals(r[i], f.apply(a[i], (double)((long)b[(i / SPECIES.length()) * SPECIES.length()])));
 422             }
 423         } catch (AssertionError e) {
 424             Assert.assertEquals(r[i], f.apply(a[i], (double)((long)b[(i / SPECIES.length()) * SPECIES.length()])),
 425                                 "(" + a[i] + ", " + b[(i / SPECIES.length()) * SPECIES.length()] + ") at index #" + i);
 426         }
 427     }
 428 
 429     static void assertArraysEquals(double[] r, double[] a, double[] b, boolean[] mask, FBinOp f) {
 430         assertArraysEquals(r, a, b, mask, FBinMaskOp.lift(f));
 431     }
 432 
 433     static void assertArraysEquals(double[] r, double[] a, double[] b, boolean[] mask, FBinMaskOp f) {
 434         int i = 0;
 435         try {
 436             for (; i < a.length; i++) {
 437                 Assert.assertEquals(r[i], f.apply(a[i], b[i], mask[i % SPECIES.length()]));
 438             }
 439         } catch (AssertionError err) {
 440             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()]);
 441         }
 442     }
 443 
 444     static void assertBroadcastArraysEquals(double[] r, double[] a, double[] b, boolean[] mask, FBinOp f) {
 445         assertBroadcastArraysEquals(r, a, b, mask, FBinMaskOp.lift(f));
 446     }
 447 
 448     static void assertBroadcastArraysEquals(double[] r, double[] a, double[] b, boolean[] mask, FBinMaskOp f) {
 449         int i = 0;
 450         try {
 451             for (; i < a.length; i++) {
 452                 Assert.assertEquals(r[i], f.apply(a[i], b[(i / SPECIES.length()) * SPECIES.length()], mask[i % SPECIES.length()]));
 453             }
 454         } catch (AssertionError err) {
 455             Assert.assertEquals(r[i], f.apply(a[i], b[(i / SPECIES.length()) * SPECIES.length()],
 456                                 mask[i % SPECIES.length()]), "at index #" + i + ", input1 = " + a[i] +
 457                                 ", input2 = " + b[(i / SPECIES.length()) * SPECIES.length()] + ", mask = " +
 458                                 mask[i % SPECIES.length()]);
 459         }
 460     }
 461 
 462     static void assertBroadcastLongArraysEquals(double[] r, double[] a, double[] b, boolean[] mask, FBinOp f) {
 463         assertBroadcastLongArraysEquals(r, a, b, mask, FBinMaskOp.lift(f));
 464     }
 465 
 466     static void assertBroadcastLongArraysEquals(double[] r, double[] a, double[] b, boolean[] mask, FBinMaskOp f) {
 467         int i = 0;
 468         try {
 469             for (; i < a.length; i++) {
 470                 Assert.assertEquals(r[i], f.apply(a[i], (double)((long)b[(i / SPECIES.length()) * SPECIES.length()]), mask[i % SPECIES.length()]));
 471             }
 472         } catch (AssertionError err) {
 473             Assert.assertEquals(r[i], f.apply(a[i], (double)((long)b[(i / SPECIES.length()) * SPECIES.length()]),
 474                                 mask[i % SPECIES.length()]), "at index #" + i + ", input1 = " + a[i] +
 475                                 ", input2 = " + b[(i / SPECIES.length()) * SPECIES.length()] + ", mask = " +
 476                                 mask[i % SPECIES.length()]);
 477         }
 478     }
 479 
 480     static void assertShiftArraysEquals(double[] r, double[] a, double[] b, FBinOp f) {
 481         int i = 0;
 482         int j = 0;
 483         try {
 484             for (; j < a.length; j += SPECIES.length()) {
 485                 for (i = 0; i < SPECIES.length(); i++) {
 486                     Assert.assertEquals(r[i+j], f.apply(a[i+j], b[j]));
 487                 }
 488             }
 489         } catch (AssertionError e) {
 490             Assert.assertEquals(r[i+j], f.apply(a[i+j], b[j]), "at index #" + i + ", " + j);
 491         }
 492     }
 493 
 494     static void assertShiftArraysEquals(double[] r, double[] a, double[] b, boolean[] mask, FBinOp f) {
 495         assertShiftArraysEquals(r, a, b, mask, FBinMaskOp.lift(f));
 496     }
 497 
 498     static void assertShiftArraysEquals(double[] r, double[] a, double[] b, boolean[] mask, FBinMaskOp f) {
 499         int i = 0;
 500         int j = 0;
 501         try {
 502             for (; j < a.length; j += SPECIES.length()) {
 503                 for (i = 0; i < SPECIES.length(); i++) {
 504                     Assert.assertEquals(r[i+j], f.apply(a[i+j], b[j], mask[i]));
 505                 }
 506             }
 507         } catch (AssertionError err) {
 508             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]);
 509         }
 510     }
 511 
 512     interface FTernOp {
 513         double apply(double a, double b, double c);
 514     }
 515 
 516     interface FTernMaskOp {
 517         double apply(double a, double b, double c, boolean m);
 518 
 519         static FTernMaskOp lift(FTernOp f) {
 520             return (a, b, c, m) -> m ? f.apply(a, b, c) : a;
 521         }
 522     }
 523 
 524     static void assertArraysEquals(double[] r, double[] a, double[] b, double[] c, FTernOp f) {
 525         int i = 0;
 526         try {
 527             for (; i < a.length; i++) {
 528                 Assert.assertEquals(r[i], f.apply(a[i], b[i], c[i]));
 529             }
 530         } catch (AssertionError e) {
 531             Assert.assertEquals(r[i], f.apply(a[i], b[i], c[i]), "at index #" + i + ", input1 = " + a[i] + ", input2 = " + b[i] + ", input3 = " + c[i]);
 532         }
 533     }
 534 
 535     static void assertArraysEquals(double[] r, double[] a, double[] b, double[] c, boolean[] mask, FTernOp f) {
 536         assertArraysEquals(r, a, b, c, mask, FTernMaskOp.lift(f));
 537     }
 538 
 539     static void assertArraysEquals(double[] r, double[] a, double[] b, double[] c, boolean[] mask, FTernMaskOp f) {
 540         int i = 0;
 541         try {
 542             for (; i < a.length; i++) {
 543                 Assert.assertEquals(r[i], f.apply(a[i], b[i], c[i], mask[i % SPECIES.length()]));
 544             }
 545         } catch (AssertionError err) {
 546             Assert.assertEquals(r[i], f.apply(a[i], b[i], c[i], mask[i % SPECIES.length()]), "at index #" + i + ", input1 = " + a[i] + ", input2 = "
 547               + b[i] + ", input3 = " + c[i] + ", mask = " + mask[i % SPECIES.length()]);
 548         }
 549     }
 550 
 551     static void assertBroadcastArraysEquals(double[] r, double[] a, double[] b, double[] c, FTernOp f) {
 552         int i = 0;
 553         try {
 554             for (; i < a.length; i++) {
 555                 Assert.assertEquals(r[i], f.apply(a[i], b[i], c[(i / SPECIES.length()) * SPECIES.length()]));
 556             }
 557         } catch (AssertionError e) {
 558             Assert.assertEquals(r[i], f.apply(a[i], b[i], c[(i / SPECIES.length()) * SPECIES.length()]), "at index #" +
 559                                 i + ", input1 = " + a[i] + ", input2 = " + b[i] + ", input3 = " +
 560                                 c[(i / SPECIES.length()) * SPECIES.length()]);
 561         }
 562     }
 563 
 564     static void assertAltBroadcastArraysEquals(double[] r, double[] a, double[] b, double[] c, FTernOp f) {
 565         int i = 0;
 566         try {
 567             for (; i < a.length; i++) {
 568                 Assert.assertEquals(r[i], f.apply(a[i], b[(i / SPECIES.length()) * SPECIES.length()], c[i]));
 569             }
 570         } catch (AssertionError e) {
 571             Assert.assertEquals(r[i], f.apply(a[i], b[(i / SPECIES.length()) * SPECIES.length()], c[i]), "at index #" +
 572                                 i + ", input1 = " + a[i] + ", input2 = " +
 573                                 b[(i / SPECIES.length()) * SPECIES.length()] + ",  input3 = " + c[i]);
 574         }
 575     }
 576 
 577     static void assertBroadcastArraysEquals(double[] r, double[] a, double[] b, double[] c, boolean[] mask,
 578                                             FTernOp f) {
 579         assertBroadcastArraysEquals(r, a, b, c, mask, FTernMaskOp.lift(f));
 580     }
 581 
 582     static void assertBroadcastArraysEquals(double[] r, double[] a, double[] b, double[] c, boolean[] mask,
 583                                             FTernMaskOp f) {
 584         int i = 0;
 585         try {
 586             for (; i < a.length; i++) {
 587                 Assert.assertEquals(r[i], f.apply(a[i], b[i], c[(i / SPECIES.length()) * SPECIES.length()],
 588                                     mask[i % SPECIES.length()]));
 589             }
 590         } catch (AssertionError err) {
 591             Assert.assertEquals(r[i], f.apply(a[i], b[i], c[(i / SPECIES.length()) * SPECIES.length()],
 592                                 mask[i % SPECIES.length()]), "at index #" + i + ", input1 = " + a[i] + ", input2 = " +
 593                                 b[i] + ", input3 = " + c[(i / SPECIES.length()) * SPECIES.length()] + ", mask = " +
 594                                 mask[i % SPECIES.length()]);
 595         }
 596     }
 597 
 598     static void assertAltBroadcastArraysEquals(double[] r, double[] a, double[] b, double[] c, boolean[] mask,
 599                                             FTernOp f) {
 600         assertAltBroadcastArraysEquals(r, a, b, c, mask, FTernMaskOp.lift(f));
 601     }
 602 
 603     static void assertAltBroadcastArraysEquals(double[] r, double[] a, double[] b, double[] c, boolean[] mask,
 604                                             FTernMaskOp f) {
 605         int i = 0;
 606         try {
 607             for (; i < a.length; i++) {
 608                 Assert.assertEquals(r[i], f.apply(a[i], b[(i / SPECIES.length()) * SPECIES.length()], c[i],
 609                                     mask[i % SPECIES.length()]));
 610             }
 611         } catch (AssertionError err) {
 612             Assert.assertEquals(r[i], f.apply(a[i], b[(i / SPECIES.length()) * SPECIES.length()], c[i],
 613                                 mask[i % SPECIES.length()]), "at index #" + i + ", input1 = " + a[i] +
 614                                 ", input2 = " + b[(i / SPECIES.length()) * SPECIES.length()] +
 615                                 ", input3 = " + c[i] + ", mask = " + mask[i % SPECIES.length()]);
 616         }
 617     }
 618 
 619     static void assertDoubleBroadcastArraysEquals(double[] r, double[] a, double[] b, double[] c, FTernOp f) {
 620         int i = 0;
 621         try {
 622             for (; i < a.length; i++) {
 623                 Assert.assertEquals(r[i], f.apply(a[i], b[(i / SPECIES.length()) * SPECIES.length()],
 624                                     c[(i / SPECIES.length()) * SPECIES.length()]));
 625             }
 626         } catch (AssertionError e) {
 627             Assert.assertEquals(r[i], f.apply(a[i], b[(i / SPECIES.length()) * SPECIES.length()],
 628                                 c[(i / SPECIES.length()) * SPECIES.length()]), "at index #" + i + ", input1 = " + a[i]
 629                                 + ", input2 = " + b[(i / SPECIES.length()) * SPECIES.length()] + ", input3 = " +
 630                                 c[(i / SPECIES.length()) * SPECIES.length()]);
 631         }
 632     }
 633 
 634     static void assertDoubleBroadcastArraysEquals(double[] r, double[] a, double[] b, double[] c, boolean[] mask,
 635                                                   FTernOp f) {
 636         assertDoubleBroadcastArraysEquals(r, a, b, c, mask, FTernMaskOp.lift(f));
 637     }
 638 
 639     static void assertDoubleBroadcastArraysEquals(double[] r, double[] a, double[] b, double[] c, boolean[] mask,
 640                                                   FTernMaskOp f) {
 641         int i = 0;
 642         try {
 643             for (; i < a.length; i++) {
 644                 Assert.assertEquals(r[i], f.apply(a[i], b[(i / SPECIES.length()) * SPECIES.length()],
 645                                     c[(i / SPECIES.length()) * SPECIES.length()], mask[i % SPECIES.length()]));
 646             }
 647         } catch (AssertionError err) {
 648             Assert.assertEquals(r[i], f.apply(a[i], b[(i / SPECIES.length()) * SPECIES.length()],
 649                                 c[(i / SPECIES.length()) * SPECIES.length()], mask[i % SPECIES.length()]), "at index #"
 650                                 + i + ", input1 = " + a[i] + ", input2 = " + b[(i / SPECIES.length()) * SPECIES.length()] +
 651                                 ", input3 = " + c[(i / SPECIES.length()) * SPECIES.length()] + ", mask = " +
 652                                 mask[i % SPECIES.length()]);
 653         }
 654     }
 655 
 656 
 657     static boolean isWithin1Ulp(double actual, double expected) {
 658         if (Double.isNaN(expected) && !Double.isNaN(actual)) {
 659             return false;
 660         } else if (!Double.isNaN(expected) && Double.isNaN(actual)) {
 661             return false;
 662         }
 663 
 664         double low = Math.nextDown(expected);
 665         double high = Math.nextUp(expected);
 666 
 667         if (Double.compare(low, expected) > 0) {
 668             return false;
 669         }
 670 
 671         if (Double.compare(high, expected) < 0) {
 672             return false;
 673         }
 674 
 675         return true;
 676     }
 677 
 678     static void assertArraysEqualsWithinOneUlp(double[] r, double[] a, FUnOp mathf, FUnOp strictmathf) {
 679         int i = 0;
 680         try {
 681             // Check that result is within 1 ulp of strict math or equivalent to math implementation.
 682             for (; i < a.length; i++) {
 683                 Assert.assertTrue(Double.compare(r[i], mathf.apply(a[i])) == 0 ||
 684                                     isWithin1Ulp(r[i], strictmathf.apply(a[i])));
 685             }
 686         } catch (AssertionError e) {
 687             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]));
 688             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]));
 689         }
 690     }
 691 
 692     static void assertArraysEqualsWithinOneUlp(double[] r, double[] a, double[] b, FBinOp mathf, FBinOp strictmathf) {
 693         int i = 0;
 694         try {
 695             // Check that result is within 1 ulp of strict math or equivalent to math implementation.
 696             for (; i < a.length; i++) {
 697                 Assert.assertTrue(Double.compare(r[i], mathf.apply(a[i], b[i])) == 0 ||
 698                                     isWithin1Ulp(r[i], strictmathf.apply(a[i], b[i])));
 699             }
 700         } catch (AssertionError e) {
 701             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]));
 702             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]));
 703         }
 704     }
 705 
 706     static void assertBroadcastArraysEqualsWithinOneUlp(double[] r, double[] a, double[] b,
 707                                                         FBinOp mathf, FBinOp strictmathf) {
 708         int i = 0;
 709         try {
 710             // Check that result is within 1 ulp of strict math or equivalent to math implementation.
 711             for (; i < a.length; i++) {
 712                 Assert.assertTrue(Double.compare(r[i],
 713                                   mathf.apply(a[i], b[(i / SPECIES.length()) * SPECIES.length()])) == 0 ||
 714                                   isWithin1Ulp(r[i],
 715                                   strictmathf.apply(a[i], b[(i / SPECIES.length()) * SPECIES.length()])));
 716             }
 717         } catch (AssertionError e) {
 718             Assert.assertTrue(Double.compare(r[i],
 719                               mathf.apply(a[i], b[(i / SPECIES.length()) * SPECIES.length()])) == 0,
 720                               "at index #" + i + ", input1 = " + a[i] + ", input2 = " +
 721                               b[(i / SPECIES.length()) * SPECIES.length()] + ", actual = " + r[i] +
 722                               ", expected = " + mathf.apply(a[i], b[(i / SPECIES.length()) * SPECIES.length()]));
 723             Assert.assertTrue(isWithin1Ulp(r[i],
 724                               strictmathf.apply(a[i], b[(i / SPECIES.length()) * SPECIES.length()])),
 725                              "at index #" + i + ", input1 = " + a[i] + ", input2 = " +
 726                              b[(i / SPECIES.length()) * SPECIES.length()] + ", actual = " + r[i] +
 727                              ", expected (within 1 ulp) = " + strictmathf.apply(a[i],
 728                              b[(i / SPECIES.length()) * SPECIES.length()]));
 729         }
 730     }
 731 
 732     interface FBinArrayOp {
 733         double apply(double[] a, int b);
 734     }
 735 
 736     static void assertArraysEquals(double[] r, double[] a, FBinArrayOp f) {
 737         int i = 0;
 738         try {
 739             for (; i < a.length; i++) {
 740                 Assert.assertEquals(r[i], f.apply(a, i));
 741             }
 742         } catch (AssertionError e) {
 743             Assert.assertEquals(r[i], f.apply(a,i), "at index #" + i);
 744         }
 745     }
 746 
 747     interface FGatherScatterOp {
 748         double[] apply(double[] a, int ix, int[] b, int iy);
 749     }
 750 
 751     static void assertArraysEquals(double[] r, double[] a, int[] b, FGatherScatterOp f) {
 752         int i = 0;
 753         try {
 754             for (; i < a.length; i += SPECIES.length()) {
 755                 Assert.assertEquals(Arrays.copyOfRange(r, i, i+SPECIES.length()),
 756                   f.apply(a, i, b, i));
 757             }
 758         } catch (AssertionError e) {
 759             double[] ref = f.apply(a, i, b, i);
 760             double[] res = Arrays.copyOfRange(r, i, i+SPECIES.length());
 761             Assert.assertEquals(res, ref,
 762               "(ref: " + Arrays.toString(ref) + ", res: " + Arrays.toString(res) + ", a: "
 763               + Arrays.toString(Arrays.copyOfRange(a, i, i+SPECIES.length()))
 764               + ", b: "
 765               + Arrays.toString(Arrays.copyOfRange(b, i, i+SPECIES.length()))
 766               + " at index #" + i);
 767         }
 768     }
 769 
 770     interface FGatherMaskedOp {
 771         double[] apply(double[] a, int ix, boolean[] mask, int[] b, int iy);
 772     }
 773 
 774     interface FScatterMaskedOp {
 775         double[] apply(double[] r, double[] a, int ix, boolean[] mask, int[] b, int iy);
 776     }
 777 
 778     static void assertArraysEquals(double[] r, double[] a, int[] b, boolean[] mask, FGatherMaskedOp f) {
 779         int i = 0;
 780         try {
 781             for (; i < a.length; i += SPECIES.length()) {
 782                 Assert.assertEquals(Arrays.copyOfRange(r, i, i+SPECIES.length()),
 783                   f.apply(a, i, mask, b, i));
 784             }
 785         } catch (AssertionError e) {
 786             double[] ref = f.apply(a, i, mask, b, i);
 787             double[] res = Arrays.copyOfRange(r, i, i+SPECIES.length());
 788             Assert.assertEquals(res, ref,
 789               "(ref: " + Arrays.toString(ref) + ", res: " + Arrays.toString(res) + ", a: "
 790               + Arrays.toString(Arrays.copyOfRange(a, i, i+SPECIES.length()))
 791               + ", b: "
 792               + Arrays.toString(Arrays.copyOfRange(b, i, i+SPECIES.length()))
 793               + ", mask: "
 794               + Arrays.toString(mask)
 795               + " at index #" + i);
 796         }
 797     }
 798 
 799     static void assertArraysEquals(double[] r, double[] a, int[] b, boolean[] mask, FScatterMaskedOp f) {
 800         int i = 0;
 801         try {
 802             for (; i < a.length; i += SPECIES.length()) {
 803                 Assert.assertEquals(Arrays.copyOfRange(r, i, i+SPECIES.length()),
 804                   f.apply(r, a, i, mask, b, i));
 805             }
 806         } catch (AssertionError e) {
 807             double[] ref = f.apply(r, a, i, mask, b, i);
 808             double[] res = Arrays.copyOfRange(r, i, i+SPECIES.length());
 809             Assert.assertEquals(res, ref,
 810               "(ref: " + Arrays.toString(ref) + ", res: " + Arrays.toString(res) + ", a: "
 811               + Arrays.toString(Arrays.copyOfRange(a, i, i+SPECIES.length()))
 812               + ", b: "
 813               + Arrays.toString(Arrays.copyOfRange(b, i, i+SPECIES.length()))
 814               + ", r: "
 815               + Arrays.toString(Arrays.copyOfRange(r, i, i+SPECIES.length()))
 816               + ", mask: "
 817               + Arrays.toString(mask)
 818               + " at index #" + i);
 819         }
 820     }
 821 
 822     interface FLaneOp {
 823         double[] apply(double[] a, int origin, int idx);
 824     }
 825 
 826     static void assertArraysEquals(double[] r, double[] a, int origin, FLaneOp f) {
 827         int i = 0;
 828         try {
 829             for (; i < a.length; i += SPECIES.length()) {
 830                 Assert.assertEquals(Arrays.copyOfRange(r, i, i+SPECIES.length()),
 831                   f.apply(a, origin, i));
 832             }
 833         } catch (AssertionError e) {
 834             double[] ref = f.apply(a, origin, i);
 835             double[] res = Arrays.copyOfRange(r, i, i+SPECIES.length());
 836             Assert.assertEquals(res, ref, "(ref: " + Arrays.toString(ref)
 837               + ", res: " + Arrays.toString(res)
 838               + "), at index #" + i);
 839         }
 840     }
 841 
 842     interface FLaneBop {
 843         double[] apply(double[] a, double[] b, int origin, int idx);
 844     }
 845 
 846     static void assertArraysEquals(double[] r, double[] a, double[] b, int origin, FLaneBop f) {
 847         int i = 0;
 848         try {
 849             for (; i < a.length; i += SPECIES.length()) {
 850                 Assert.assertEquals(Arrays.copyOfRange(r, i, i+SPECIES.length()),
 851                   f.apply(a, b, origin, i));
 852             }
 853         } catch (AssertionError e) {
 854             double[] ref = f.apply(a, b, origin, i);
 855             double[] res = Arrays.copyOfRange(r, i, i+SPECIES.length());
 856             Assert.assertEquals(res, ref, "(ref: " + Arrays.toString(ref)
 857               + ", res: " + Arrays.toString(res)
 858               + "), at index #" + i
 859               + ", at origin #" + origin);
 860         }
 861     }
 862 
 863     interface FLaneMaskedBop {
 864         double[] apply(double[] a, double[] b, int origin, boolean[] mask, int idx);
 865     }
 866 
 867     static void assertArraysEquals(double[] r, double[] a, double[] b, int origin, boolean[] mask, FLaneMaskedBop f) {
 868         int i = 0;
 869         try {
 870             for (; i < a.length; i += SPECIES.length()) {
 871                 Assert.assertEquals(Arrays.copyOfRange(r, i, i+SPECIES.length()),
 872                   f.apply(a, b, origin, mask, i));
 873             }
 874         } catch (AssertionError e) {
 875             double[] ref = f.apply(a, b, origin, mask, i);
 876             double[] res = Arrays.copyOfRange(r, i, i+SPECIES.length());
 877             Assert.assertEquals(res, ref, "(ref: " + Arrays.toString(ref)
 878               + ", res: " + Arrays.toString(res)
 879               + "), at index #" + i
 880               + ", at origin #" + origin);
 881         }
 882     }
 883 
 884     interface FLanePartBop {
 885         double[] apply(double[] a, double[] b, int origin, int part, int idx);
 886     }
 887 
 888     static void assertArraysEquals(double[] r, double[] a, double[] b, int origin, int part, FLanePartBop f) {
 889         int i = 0;
 890         try {
 891             for (; i < a.length; i += SPECIES.length()) {
 892                 Assert.assertEquals(Arrays.copyOfRange(r, i, i+SPECIES.length()),
 893                   f.apply(a, b, origin, part, i));
 894             }
 895         } catch (AssertionError e) {
 896             double[] ref = f.apply(a, b, origin, part, i);
 897             double[] res = Arrays.copyOfRange(r, i, i+SPECIES.length());
 898             Assert.assertEquals(res, ref, "(ref: " + Arrays.toString(ref)
 899               + ", res: " + Arrays.toString(res)
 900               + "), at index #" + i
 901               + ", at origin #" + origin
 902               + ", with part #" + part);
 903         }
 904     }
 905 
 906     interface FLanePartMaskedBop {
 907         double[] apply(double[] a, double[] b, int origin, int part, boolean[] mask, int idx);
 908     }
 909 
 910     static void assertArraysEquals(double[] r, double[] a, double[] b, int origin, int part, boolean[] mask, FLanePartMaskedBop f) {
 911         int i = 0;
 912         try {
 913             for (; i < a.length; i += SPECIES.length()) {
 914                 Assert.assertEquals(Arrays.copyOfRange(r, i, i+SPECIES.length()),
 915                   f.apply(a, b, origin, part, mask, i));
 916             }
 917         } catch (AssertionError e) {
 918             double[] ref = f.apply(a, b, origin, part, mask, i);
 919             double[] res = Arrays.copyOfRange(r, i, i+SPECIES.length());
 920             Assert.assertEquals(res, ref, "(ref: " + Arrays.toString(ref)
 921               + ", res: " + Arrays.toString(res)
 922               + "), at index #" + i
 923               + ", at origin #" + origin
 924               + ", with part #" + part);
 925         }
 926     }
 927 
 928     static int intCornerCaseValue(int i) {
 929         switch(i % 5) {
 930             case 0:
 931                 return Integer.MAX_VALUE;
 932             case 1:
 933                 return Integer.MIN_VALUE;
 934             case 2:
 935                 return Integer.MIN_VALUE;
 936             case 3:
 937                 return Integer.MAX_VALUE;
 938             default:
 939                 return (int)0;
 940         }
 941     }
 942 
 943     static final List<IntFunction<double[]>> INT_DOUBLE_GENERATORS = List.of(
 944             withToString("double[-i * 5]", (int s) -> {
 945                 return fill(s * BUFFER_REPS,
 946                             i -> (double)(-i * 5));
 947             }),
 948             withToString("double[i * 5]", (int s) -> {
 949                 return fill(s * BUFFER_REPS,
 950                             i -> (double)(i * 5));
 951             }),
 952             withToString("double[i + 1]", (int s) -> {
 953                 return fill(s * BUFFER_REPS,
 954                             i -> (((double)(i + 1) == 0) ? 1 : (double)(i + 1)));
 955             }),
 956             withToString("double[intCornerCaseValue(i)]", (int s) -> {
 957                 return fill(s * BUFFER_REPS,
 958                             i -> (double)intCornerCaseValue(i));
 959             })
 960     );
 961 
 962     static void assertArraysEquals(int[] r, double[] a, int offs) {
 963         int i = 0;
 964         try {
 965             for (; i < r.length; i++) {
 966                 Assert.assertEquals(r[i], (int)(a[i+offs]));
 967             }
 968         } catch (AssertionError e) {
 969             Assert.assertEquals(r[i], (int)(a[i+offs]), "at index #" + i + ", input = " + a[i+offs]);
 970         }
 971     }
 972 
 973     static long longCornerCaseValue(int i) {
 974         switch(i % 5) {
 975             case 0:
 976                 return Long.MAX_VALUE;
 977             case 1:
 978                 return Long.MIN_VALUE;
 979             case 2:
 980                 return Long.MIN_VALUE;
 981             case 3:
 982                 return Long.MAX_VALUE;
 983             default:
 984                 return (long)0;
 985         }
 986     }
 987 
 988     static final List<IntFunction<double[]>> LONG_DOUBLE_GENERATORS = List.of(
 989             withToString("double[-i * 5]", (int s) -> {
 990                 return fill(s * BUFFER_REPS,
 991                             i -> (double)(-i * 5));
 992             }),
 993             withToString("double[i * 5]", (int s) -> {
 994                 return fill(s * BUFFER_REPS,
 995                             i -> (double)(i * 5));
 996             }),
 997             withToString("double[i + 1]", (int s) -> {
 998                 return fill(s * BUFFER_REPS,
 999                             i -> (((double)(i + 1) == 0) ? 1 : (double)(i + 1)));
1000             }),
1001             withToString("double[cornerCaseValue(i)]", (int s) -> {
1002                 return fill(s * BUFFER_REPS,
1003                             i -> (double)longCornerCaseValue(i));
1004             })
1005     );
1006 
1007 
1008     static void assertArraysEquals(long[] r, double[] a, int offs) {
1009         int i = 0;
1010         try {
1011             for (; i < r.length; i++) {
1012                 Assert.assertEquals(r[i], (long)(a[i+offs]));
1013             }
1014         } catch (AssertionError e) {
1015             Assert.assertEquals(r[i], (long)(a[i+offs]), "at index #" + i + ", input = " + a[i+offs]);
1016         }
1017     }
1018 
1019 
1020 
1021     static long bits(double e) {
1022         return  Double.doubleToLongBits(e);
1023     }
1024 
1025     static final List<IntFunction<double[]>> DOUBLE_GENERATORS = List.of(
1026             withToString("double[-i * 5]", (int s) -> {
1027                 return fill(s * BUFFER_REPS,
1028                             i -> (double)(-i * 5));
1029             }),
1030             withToString("double[i * 5]", (int s) -> {
1031                 return fill(s * BUFFER_REPS,
1032                             i -> (double)(i * 5));
1033             }),
1034             withToString("double[i + 1]", (int s) -> {
1035                 return fill(s * BUFFER_REPS,
1036                             i -> (((double)(i + 1) == 0) ? 1 : (double)(i + 1)));
1037             }),
1038             withToString("double[cornerCaseValue(i)]", (int s) -> {
1039                 return fill(s * BUFFER_REPS,
1040                             i -> cornerCaseValue(i));
1041             })
1042     );
1043 
1044     // Create combinations of pairs
1045     // @@@ Might be sensitive to order e.g. div by 0
1046     static final List<List<IntFunction<double[]>>> DOUBLE_GENERATOR_PAIRS =
1047         Stream.of(DOUBLE_GENERATORS.get(0)).
1048                 flatMap(fa -> DOUBLE_GENERATORS.stream().skip(1).map(fb -> List.of(fa, fb))).
1049                 collect(Collectors.toList());
1050 
1051     @DataProvider
1052     public Object[][] boolUnaryOpProvider() {
1053         return BOOL_ARRAY_GENERATORS.stream().
1054                 map(f -> new Object[]{f}).
1055                 toArray(Object[][]::new);
1056     }
1057 
1058     static final List<List<IntFunction<double[]>>> DOUBLE_GENERATOR_TRIPLES =
1059         DOUBLE_GENERATOR_PAIRS.stream().
1060                 flatMap(pair -> DOUBLE_GENERATORS.stream().map(f -> List.of(pair.get(0), pair.get(1), f))).
1061                 collect(Collectors.toList());
1062 
1063     @DataProvider
1064     public Object[][] doubleBinaryOpProvider() {
1065         return DOUBLE_GENERATOR_PAIRS.stream().map(List::toArray).
1066                 toArray(Object[][]::new);
1067     }
1068 
1069     @DataProvider
1070     public Object[][] doubleIndexedOpProvider() {
1071         return DOUBLE_GENERATOR_PAIRS.stream().map(List::toArray).
1072                 toArray(Object[][]::new);
1073     }
1074 
1075     @DataProvider
1076     public Object[][] doubleBinaryOpMaskProvider() {
1077         return BOOLEAN_MASK_GENERATORS.stream().
1078                 flatMap(fm -> DOUBLE_GENERATOR_PAIRS.stream().map(lfa -> {
1079                     return Stream.concat(lfa.stream(), Stream.of(fm)).toArray();
1080                 })).
1081                 toArray(Object[][]::new);
1082     }
1083 
1084     @DataProvider
1085     public Object[][] doubleTernaryOpProvider() {
1086         return DOUBLE_GENERATOR_TRIPLES.stream().map(List::toArray).
1087                 toArray(Object[][]::new);
1088     }
1089 
1090     @DataProvider
1091     public Object[][] doubleTernaryOpMaskProvider() {
1092         return BOOLEAN_MASK_GENERATORS.stream().
1093                 flatMap(fm -> DOUBLE_GENERATOR_TRIPLES.stream().map(lfa -> {
1094                     return Stream.concat(lfa.stream(), Stream.of(fm)).toArray();
1095                 })).
1096                 toArray(Object[][]::new);
1097     }
1098 
1099     @DataProvider
1100     public Object[][] doubleUnaryOpProvider() {
1101         return DOUBLE_GENERATORS.stream().
1102                 map(f -> new Object[]{f}).
1103                 toArray(Object[][]::new);
1104     }
1105 
1106     @DataProvider
1107     public Object[][] doubleUnaryOpMaskProvider() {
1108         return BOOLEAN_MASK_GENERATORS.stream().
1109                 flatMap(fm -> DOUBLE_GENERATORS.stream().map(fa -> {
1110                     return new Object[] {fa, fm};
1111                 })).
1112                 toArray(Object[][]::new);
1113     }
1114 
1115     @DataProvider
1116     public Object[][] doubletoIntUnaryOpProvider() {
1117         return INT_DOUBLE_GENERATORS.stream().
1118                 map(f -> new Object[]{f}).
1119                 toArray(Object[][]::new);
1120     }
1121 
1122     @DataProvider
1123     public Object[][] doubletoLongUnaryOpProvider() {
1124         return LONG_DOUBLE_GENERATORS.stream().
1125                 map(f -> new Object[]{f}).
1126                 toArray(Object[][]::new);
1127     }
1128 
1129     @DataProvider
1130     public Object[][] maskProvider() {
1131         return BOOLEAN_MASK_GENERATORS.stream().
1132                 map(f -> new Object[]{f}).
1133                 toArray(Object[][]::new);
1134     }
1135 
1136     @DataProvider
1137     public Object[][] maskCompareOpProvider() {
1138         return BOOLEAN_MASK_COMPARE_GENERATOR_PAIRS.stream().map(List::toArray).
1139                 toArray(Object[][]::new);
1140     }
1141 
1142     @DataProvider
1143     public Object[][] shuffleProvider() {
1144         return INT_SHUFFLE_GENERATORS.stream().
1145                 map(f -> new Object[]{f}).
1146                 toArray(Object[][]::new);
1147     }
1148 
1149     @DataProvider
1150     public Object[][] shuffleCompareOpProvider() {
1151         return INT_SHUFFLE_COMPARE_GENERATOR_PAIRS.stream().map(List::toArray).
1152                 toArray(Object[][]::new);
1153     }
1154 
1155     @DataProvider
1156     public Object[][] doubleUnaryOpShuffleProvider() {
1157         return INT_SHUFFLE_GENERATORS.stream().
1158                 flatMap(fs -> DOUBLE_GENERATORS.stream().map(fa -> {
1159                     return new Object[] {fa, fs};
1160                 })).
1161                 toArray(Object[][]::new);
1162     }
1163 
1164     @DataProvider
1165     public Object[][] doubleUnaryOpShuffleMaskProvider() {
1166         return BOOLEAN_MASK_GENERATORS.stream().
1167                 flatMap(fm -> INT_SHUFFLE_GENERATORS.stream().
1168                     flatMap(fs -> DOUBLE_GENERATORS.stream().map(fa -> {
1169                         return new Object[] {fa, fs, fm};
1170                 }))).
1171                 toArray(Object[][]::new);
1172     }
1173 
1174     static final List<BiFunction<Integer,Integer,double[]>> DOUBLE_SHUFFLE_GENERATORS = List.of(
1175             withToStringBi("shuffle[random]", (Integer l, Integer m) -> {
1176                 double[] a = new double[l];
1177                 int upper = m;
1178                 for (int i = 0; i < 1; i++) {
1179                     a[i] = (double)RAND.nextInt(upper);
1180                 }
1181                 return a;
1182             })
1183     );
1184 
1185     @DataProvider
1186     public Object[][] doubleUnaryOpSelectFromProvider() {
1187         return DOUBLE_SHUFFLE_GENERATORS.stream().
1188                 flatMap(fs -> DOUBLE_GENERATORS.stream().map(fa -> {
1189                     return new Object[] {fa, fs};
1190                 })).
1191                 toArray(Object[][]::new);
1192     }
1193 
1194     @DataProvider
1195     public Object[][] doubleUnaryOpSelectFromMaskProvider() {
1196         return BOOLEAN_MASK_GENERATORS.stream().
1197                 flatMap(fm -> DOUBLE_SHUFFLE_GENERATORS.stream().
1198                     flatMap(fs -> DOUBLE_GENERATORS.stream().map(fa -> {
1199                         return new Object[] {fa, fs, fm};
1200                 }))).
1201                 toArray(Object[][]::new);
1202     }
1203 
1204 
1205     static final List<IntFunction<double[]>> DOUBLE_COMPARE_GENERATORS = List.of(
1206             withToString("double[i]", (int s) -> {
1207                 return fill(s * BUFFER_REPS,
1208                             i -> (double)i);
1209             }),
1210             withToString("double[i - length / 2]", (int s) -> {
1211                 return fill(s * BUFFER_REPS,
1212                             i -> (double)(i - (s * BUFFER_REPS / 2)));
1213             }),
1214             withToString("double[i + 1]", (int s) -> {
1215                 return fill(s * BUFFER_REPS,
1216                             i -> (double)(i + 1));
1217             }),
1218             withToString("double[i - 2]", (int s) -> {
1219                 return fill(s * BUFFER_REPS,
1220                             i -> (double)(i - 2));
1221             }),
1222             withToString("double[zigZag(i)]", (int s) -> {
1223                 return fill(s * BUFFER_REPS,
1224                             i -> i%3 == 0 ? (double)i : (i%3 == 1 ? (double)(i + 1) : (double)(i - 2)));
1225             }),
1226             withToString("double[cornerCaseValue(i)]", (int s) -> {
1227                 return fill(s * BUFFER_REPS,
1228                             i -> cornerCaseValue(i));
1229             })
1230     );
1231 
1232     static final List<List<IntFunction<double[]>>> DOUBLE_TEST_GENERATOR_ARGS =
1233         DOUBLE_COMPARE_GENERATORS.stream().
1234                 map(fa -> List.of(fa)).
1235                 collect(Collectors.toList());
1236 
1237     @DataProvider
1238     public Object[][] doubleTestOpProvider() {
1239         return DOUBLE_TEST_GENERATOR_ARGS.stream().map(List::toArray).
1240                 toArray(Object[][]::new);
1241     }
1242 
1243     @DataProvider
1244     public Object[][] doubleTestOpMaskProvider() {
1245         return BOOLEAN_MASK_GENERATORS.stream().
1246                 flatMap(fm -> DOUBLE_TEST_GENERATOR_ARGS.stream().map(lfa -> {
1247                     return Stream.concat(lfa.stream(), Stream.of(fm)).toArray();
1248                 })).
1249                 toArray(Object[][]::new);
1250     }
1251 
1252     static final List<List<IntFunction<double[]>>> DOUBLE_COMPARE_GENERATOR_PAIRS =
1253         DOUBLE_COMPARE_GENERATORS.stream().
1254                 flatMap(fa -> DOUBLE_COMPARE_GENERATORS.stream().map(fb -> List.of(fa, fb))).
1255                 collect(Collectors.toList());
1256 
1257     @DataProvider
1258     public Object[][] doubleCompareOpProvider() {
1259         return DOUBLE_COMPARE_GENERATOR_PAIRS.stream().map(List::toArray).
1260                 toArray(Object[][]::new);
1261     }
1262 
1263     @DataProvider
1264     public Object[][] doubleCompareOpMaskProvider() {
1265         return BOOLEAN_MASK_GENERATORS.stream().
1266                 flatMap(fm -> DOUBLE_COMPARE_GENERATOR_PAIRS.stream().map(lfa -> {
1267                     return Stream.concat(lfa.stream(), Stream.of(fm)).toArray();
1268                 })).
1269                 toArray(Object[][]::new);
1270     }
1271 
1272     interface ToDoubleF {
1273         double apply(int i);
1274     }
1275 
1276     static double[] fill(int s , ToDoubleF f) {
1277         return fill(new double[s], f);
1278     }
1279 
1280     static double[] fill(double[] a, ToDoubleF f) {
1281         for (int i = 0; i < a.length; i++) {
1282             a[i] = f.apply(i);
1283         }
1284         return a;
1285     }
1286 
1287     static double cornerCaseValue(int i) {
1288         switch(i % 7) {
1289             case 0:
1290                 return Double.MAX_VALUE;
1291             case 1:
1292                 return Double.MIN_VALUE;
1293             case 2:
1294                 return Double.NEGATIVE_INFINITY;
1295             case 3:
1296                 return Double.POSITIVE_INFINITY;
1297             case 4:
1298                 return Double.NaN;
1299             case 5:
1300                 return (double)0.0;
1301             default:
1302                 return (double)-0.0;
1303         }
1304     }
1305 
1306     static double get(double[] a, int i) {
1307         return (double) a[i];
1308     }
1309 
1310     static final IntFunction<double[]> fr = (vl) -> {
1311         int length = BUFFER_REPS * vl;
1312         return new double[length];
1313     };
1314 
1315     static final IntFunction<boolean[]> fmr = (vl) -> {
1316         int length = BUFFER_REPS * vl;
1317         return new boolean[length];
1318     };
1319 
1320     static final IntFunction<long[]> lfr = (vl) -> {
1321         int length = BUFFER_REPS * vl;
1322         return new long[length];
1323     };
1324 
1325 
1326     static boolean eq(double a, double b) {
1327         return a == b;
1328     }
1329 
1330     static boolean neq(double a, double b) {
1331         return a != b;
1332     }
1333 
1334     static boolean lt(double a, double b) {
1335         return a < b;
1336     }
1337 
1338     static boolean le(double a, double b) {
1339         return a <= b;
1340     }
1341 
1342     static boolean gt(double a, double b) {
1343         return a > b;
1344     }
1345 
1346     static boolean ge(double a, double b) {
1347         return a >= b;
1348     }
1349 
1350 
1351     @Test
1352     static void smokeTest1() {
1353         DoubleVector three = DoubleVector.broadcast(SPECIES, (byte)-3);
1354         DoubleVector three2 = (DoubleVector) SPECIES.broadcast(-3);
1355         assert(three.eq(three2).allTrue());
1356         DoubleVector three3 = three2.broadcast(1).broadcast(-3);
1357         assert(three.eq(three3).allTrue());
1358         int scale = 2;
1359         Class<?> ETYPE = double.class;
1360         if (ETYPE == double.class || ETYPE == long.class)
1361             scale = 1000000;
1362         else if (ETYPE == byte.class && SPECIES.length() >= 64)
1363             scale = 1;
1364         DoubleVector higher = three.addIndex(scale);
1365         VectorMask<Double> m = three.compare(VectorOperators.LE, higher);
1366         assert(m.allTrue());
1367         m = higher.min((double)-1).test(VectorOperators.IS_NEGATIVE);
1368         assert(m.allTrue());
1369         m = higher.test(VectorOperators.IS_FINITE);
1370         assert(m.allTrue());
1371         double max = higher.reduceLanes(VectorOperators.MAX);
1372         assert(max == -3 + scale * (SPECIES.length()-1));
1373     }
1374 
1375     private static double[]
1376     bothToArray(DoubleVector a, DoubleVector b) {
1377         double[] r = new double[a.length() + b.length()];
1378         a.intoArray(r, 0);
1379         b.intoArray(r, a.length());
1380         return r;
1381     }
1382 
1383     @Test
1384     static void smokeTest2() {
1385         // Do some zipping and shuffling.
1386         DoubleVector io = (DoubleVector) SPECIES.broadcast(0).addIndex(1);
1387         DoubleVector io2 = (DoubleVector) VectorShuffle.iota(SPECIES,0,1,false).toVector();
1388         Assert.assertEquals(io, io2);
1389         DoubleVector a = io.add((double)1); //[1,2]
1390         DoubleVector b = a.neg();  //[-1,-2]
1391         double[] abValues = bothToArray(a,b); //[1,2,-1,-2]
1392         VectorShuffle<Double> zip0 = VectorShuffle.makeZip(SPECIES, 0);
1393         VectorShuffle<Double> zip1 = VectorShuffle.makeZip(SPECIES, 1);
1394         DoubleVector zab0 = a.rearrange(zip0,b); //[1,-1]
1395         DoubleVector zab1 = a.rearrange(zip1,b); //[2,-2]
1396         double[] zabValues = bothToArray(zab0, zab1); //[1,-1,2,-2]
1397         // manually zip
1398         double[] manual = new double[zabValues.length];
1399         for (int i = 0; i < manual.length; i += 2) {
1400             manual[i+0] = abValues[i/2];
1401             manual[i+1] = abValues[a.length() + i/2];
1402         }
1403         Assert.assertEquals(Arrays.toString(zabValues), Arrays.toString(manual));
1404         VectorShuffle<Double> unz0 = VectorShuffle.makeUnzip(SPECIES, 0);
1405         VectorShuffle<Double> unz1 = VectorShuffle.makeUnzip(SPECIES, 1);
1406         DoubleVector uab0 = zab0.rearrange(unz0,zab1);
1407         DoubleVector uab1 = zab0.rearrange(unz1,zab1);
1408         double[] abValues1 = bothToArray(uab0, uab1);
1409         Assert.assertEquals(Arrays.toString(abValues), Arrays.toString(abValues1));
1410     }
1411 
1412     static void iotaShuffle() {
1413         DoubleVector io = (DoubleVector) SPECIES.broadcast(0).addIndex(1);
1414         DoubleVector io2 = (DoubleVector) VectorShuffle.iota(SPECIES, 0 , 1, false).toVector();
1415         Assert.assertEquals(io, io2);
1416     }
1417 
1418     @Test
1419     // Test all shuffle related operations.
1420     static void shuffleTest() {
1421         // To test backend instructions, make sure that C2 is used.
1422         for (int loop = 0; loop < INVOC_COUNT * INVOC_COUNT; loop++) {
1423             iotaShuffle();
1424         }
1425     }
1426 
1427     @Test
1428     void viewAsIntegeralLanesTest() {
1429         Vector<?> asIntegral = SPECIES.zero().viewAsIntegralLanes();
1430         VectorSpecies<?> asIntegralSpecies = asIntegral.species();
1431         Assert.assertNotEquals(asIntegralSpecies.elementType(), SPECIES.elementType());
1432         Assert.assertEquals(asIntegralSpecies.vectorShape(), SPECIES.vectorShape());
1433         Assert.assertEquals(asIntegralSpecies.length(), SPECIES.length());
1434         Assert.assertEquals(asIntegral.viewAsFloatingLanes().species(), SPECIES);
1435     }
1436 
1437     @Test
1438     void viewAsFloatingLanesTest() {
1439         Vector<?> asFloating = SPECIES.zero().viewAsFloatingLanes();
1440         Assert.assertEquals(asFloating.species(), SPECIES);
1441     }
1442 
1443     static double ADD(double a, double b) {
1444         return (double)(a + b);
1445     }
1446 
1447     @Test(dataProvider = "doubleBinaryOpProvider")
1448     static void ADDDouble256VectorTests(IntFunction<double[]> fa, IntFunction<double[]> fb) {
1449         double[] a = fa.apply(SPECIES.length());
1450         double[] b = fb.apply(SPECIES.length());
1451         double[] r = fr.apply(SPECIES.length());
1452 
1453         for (int ic = 0; ic < INVOC_COUNT; ic++) {
1454             for (int i = 0; i < a.length; i += SPECIES.length()) {
1455                 DoubleVector av = DoubleVector.fromArray(SPECIES, a, i);
1456                 DoubleVector bv = DoubleVector.fromArray(SPECIES, b, i);
1457                 av.lanewise(VectorOperators.ADD, bv).intoArray(r, i);
1458             }
1459         }
1460 
1461         assertArraysEquals(r, a, b, Double256VectorTests::ADD);
1462     }
1463     static double add(double a, double b) {
1464         return (double)(a + b);
1465     }
1466 
1467     @Test(dataProvider = "doubleBinaryOpProvider")
1468     static void addDouble256VectorTests(IntFunction<double[]> fa, IntFunction<double[]> fb) {
1469         double[] a = fa.apply(SPECIES.length());
1470         double[] b = fb.apply(SPECIES.length());
1471         double[] r = fr.apply(SPECIES.length());
1472 
1473         for (int i = 0; i < a.length; i += SPECIES.length()) {
1474             DoubleVector av = DoubleVector.fromArray(SPECIES, a, i);
1475             DoubleVector bv = DoubleVector.fromArray(SPECIES, b, i);
1476             av.add(bv).intoArray(r, i);
1477         }
1478 
1479         assertArraysEquals(r, a, b, Double256VectorTests::add);
1480     }
1481 
1482     @Test(dataProvider = "doubleBinaryOpMaskProvider")
1483     static void ADDDouble256VectorTestsMasked(IntFunction<double[]> fa, IntFunction<double[]> fb,
1484                                           IntFunction<boolean[]> fm) {
1485         double[] a = fa.apply(SPECIES.length());
1486         double[] b = fb.apply(SPECIES.length());
1487         double[] r = fr.apply(SPECIES.length());
1488         boolean[] mask = fm.apply(SPECIES.length());
1489         VectorMask<Double> vmask = VectorMask.fromArray(SPECIES, mask, 0);
1490 
1491         for (int ic = 0; ic < INVOC_COUNT; ic++) {
1492             for (int i = 0; i < a.length; i += SPECIES.length()) {
1493                 DoubleVector av = DoubleVector.fromArray(SPECIES, a, i);
1494                 DoubleVector bv = DoubleVector.fromArray(SPECIES, b, i);
1495                 av.lanewise(VectorOperators.ADD, bv, vmask).intoArray(r, i);
1496             }
1497         }
1498 
1499         assertArraysEquals(r, a, b, mask, Double256VectorTests::ADD);
1500     }
1501 
1502     @Test(dataProvider = "doubleBinaryOpMaskProvider")
1503     static void addDouble256VectorTestsMasked(IntFunction<double[]> fa, IntFunction<double[]> fb,
1504                                           IntFunction<boolean[]> fm) {
1505         double[] a = fa.apply(SPECIES.length());
1506         double[] b = fb.apply(SPECIES.length());
1507         double[] r = fr.apply(SPECIES.length());
1508         boolean[] mask = fm.apply(SPECIES.length());
1509         VectorMask<Double> vmask = VectorMask.fromArray(SPECIES, mask, 0);
1510 
1511         for (int i = 0; i < a.length; i += SPECIES.length()) {
1512             DoubleVector av = DoubleVector.fromArray(SPECIES, a, i);
1513             DoubleVector bv = DoubleVector.fromArray(SPECIES, b, i);
1514             av.add(bv, vmask).intoArray(r, i);
1515         }
1516 
1517         assertArraysEquals(r, a, b, mask, Double256VectorTests::add);
1518     }
1519     static double SUB(double a, double b) {
1520         return (double)(a - b);
1521     }
1522 
1523     @Test(dataProvider = "doubleBinaryOpProvider")
1524     static void SUBDouble256VectorTests(IntFunction<double[]> fa, IntFunction<double[]> fb) {
1525         double[] a = fa.apply(SPECIES.length());
1526         double[] b = fb.apply(SPECIES.length());
1527         double[] r = fr.apply(SPECIES.length());
1528 
1529         for (int ic = 0; ic < INVOC_COUNT; ic++) {
1530             for (int i = 0; i < a.length; i += SPECIES.length()) {
1531                 DoubleVector av = DoubleVector.fromArray(SPECIES, a, i);
1532                 DoubleVector bv = DoubleVector.fromArray(SPECIES, b, i);
1533                 av.lanewise(VectorOperators.SUB, bv).intoArray(r, i);
1534             }
1535         }
1536 
1537         assertArraysEquals(r, a, b, Double256VectorTests::SUB);
1538     }
1539     static double sub(double a, double b) {
1540         return (double)(a - b);
1541     }
1542 
1543     @Test(dataProvider = "doubleBinaryOpProvider")
1544     static void subDouble256VectorTests(IntFunction<double[]> fa, IntFunction<double[]> fb) {
1545         double[] a = fa.apply(SPECIES.length());
1546         double[] b = fb.apply(SPECIES.length());
1547         double[] r = fr.apply(SPECIES.length());
1548 
1549         for (int i = 0; i < a.length; i += SPECIES.length()) {
1550             DoubleVector av = DoubleVector.fromArray(SPECIES, a, i);
1551             DoubleVector bv = DoubleVector.fromArray(SPECIES, b, i);
1552             av.sub(bv).intoArray(r, i);
1553         }
1554 
1555         assertArraysEquals(r, a, b, Double256VectorTests::sub);
1556     }
1557 
1558     @Test(dataProvider = "doubleBinaryOpMaskProvider")
1559     static void SUBDouble256VectorTestsMasked(IntFunction<double[]> fa, IntFunction<double[]> fb,
1560                                           IntFunction<boolean[]> fm) {
1561         double[] a = fa.apply(SPECIES.length());
1562         double[] b = fb.apply(SPECIES.length());
1563         double[] r = fr.apply(SPECIES.length());
1564         boolean[] mask = fm.apply(SPECIES.length());
1565         VectorMask<Double> vmask = VectorMask.fromArray(SPECIES, mask, 0);
1566 
1567         for (int ic = 0; ic < INVOC_COUNT; ic++) {
1568             for (int i = 0; i < a.length; i += SPECIES.length()) {
1569                 DoubleVector av = DoubleVector.fromArray(SPECIES, a, i);
1570                 DoubleVector bv = DoubleVector.fromArray(SPECIES, b, i);
1571                 av.lanewise(VectorOperators.SUB, bv, vmask).intoArray(r, i);
1572             }
1573         }
1574 
1575         assertArraysEquals(r, a, b, mask, Double256VectorTests::SUB);
1576     }
1577 
1578     @Test(dataProvider = "doubleBinaryOpMaskProvider")
1579     static void subDouble256VectorTestsMasked(IntFunction<double[]> fa, IntFunction<double[]> fb,
1580                                           IntFunction<boolean[]> fm) {
1581         double[] a = fa.apply(SPECIES.length());
1582         double[] b = fb.apply(SPECIES.length());
1583         double[] r = fr.apply(SPECIES.length());
1584         boolean[] mask = fm.apply(SPECIES.length());
1585         VectorMask<Double> vmask = VectorMask.fromArray(SPECIES, mask, 0);
1586 
1587         for (int i = 0; i < a.length; i += SPECIES.length()) {
1588             DoubleVector av = DoubleVector.fromArray(SPECIES, a, i);
1589             DoubleVector bv = DoubleVector.fromArray(SPECIES, b, i);
1590             av.sub(bv, vmask).intoArray(r, i);
1591         }
1592 
1593         assertArraysEquals(r, a, b, mask, Double256VectorTests::sub);
1594     }
1595     static double MUL(double a, double b) {
1596         return (double)(a * b);
1597     }
1598 
1599     @Test(dataProvider = "doubleBinaryOpProvider")
1600     static void MULDouble256VectorTests(IntFunction<double[]> fa, IntFunction<double[]> fb) {
1601         double[] a = fa.apply(SPECIES.length());
1602         double[] b = fb.apply(SPECIES.length());
1603         double[] r = fr.apply(SPECIES.length());
1604 
1605         for (int ic = 0; ic < INVOC_COUNT; ic++) {
1606             for (int i = 0; i < a.length; i += SPECIES.length()) {
1607                 DoubleVector av = DoubleVector.fromArray(SPECIES, a, i);
1608                 DoubleVector bv = DoubleVector.fromArray(SPECIES, b, i);
1609                 av.lanewise(VectorOperators.MUL, bv).intoArray(r, i);
1610             }
1611         }
1612 
1613         assertArraysEquals(r, a, b, Double256VectorTests::MUL);
1614     }
1615     static double mul(double a, double b) {
1616         return (double)(a * b);
1617     }
1618 
1619     @Test(dataProvider = "doubleBinaryOpProvider")
1620     static void mulDouble256VectorTests(IntFunction<double[]> fa, IntFunction<double[]> fb) {
1621         double[] a = fa.apply(SPECIES.length());
1622         double[] b = fb.apply(SPECIES.length());
1623         double[] r = fr.apply(SPECIES.length());
1624 
1625         for (int i = 0; i < a.length; i += SPECIES.length()) {
1626             DoubleVector av = DoubleVector.fromArray(SPECIES, a, i);
1627             DoubleVector bv = DoubleVector.fromArray(SPECIES, b, i);
1628             av.mul(bv).intoArray(r, i);
1629         }
1630 
1631         assertArraysEquals(r, a, b, Double256VectorTests::mul);
1632     }
1633 
1634     @Test(dataProvider = "doubleBinaryOpMaskProvider")
1635     static void MULDouble256VectorTestsMasked(IntFunction<double[]> fa, IntFunction<double[]> fb,
1636                                           IntFunction<boolean[]> fm) {
1637         double[] a = fa.apply(SPECIES.length());
1638         double[] b = fb.apply(SPECIES.length());
1639         double[] r = fr.apply(SPECIES.length());
1640         boolean[] mask = fm.apply(SPECIES.length());
1641         VectorMask<Double> vmask = VectorMask.fromArray(SPECIES, mask, 0);
1642 
1643         for (int ic = 0; ic < INVOC_COUNT; ic++) {
1644             for (int i = 0; i < a.length; i += SPECIES.length()) {
1645                 DoubleVector av = DoubleVector.fromArray(SPECIES, a, i);
1646                 DoubleVector bv = DoubleVector.fromArray(SPECIES, b, i);
1647                 av.lanewise(VectorOperators.MUL, bv, vmask).intoArray(r, i);
1648             }
1649         }
1650 
1651         assertArraysEquals(r, a, b, mask, Double256VectorTests::MUL);
1652     }
1653 
1654     @Test(dataProvider = "doubleBinaryOpMaskProvider")
1655     static void mulDouble256VectorTestsMasked(IntFunction<double[]> fa, IntFunction<double[]> fb,
1656                                           IntFunction<boolean[]> fm) {
1657         double[] a = fa.apply(SPECIES.length());
1658         double[] b = fb.apply(SPECIES.length());
1659         double[] r = fr.apply(SPECIES.length());
1660         boolean[] mask = fm.apply(SPECIES.length());
1661         VectorMask<Double> vmask = VectorMask.fromArray(SPECIES, mask, 0);
1662 
1663         for (int i = 0; i < a.length; i += SPECIES.length()) {
1664             DoubleVector av = DoubleVector.fromArray(SPECIES, a, i);
1665             DoubleVector bv = DoubleVector.fromArray(SPECIES, b, i);
1666             av.mul(bv, vmask).intoArray(r, i);
1667         }
1668 
1669         assertArraysEquals(r, a, b, mask, Double256VectorTests::mul);
1670     }
1671 
1672     static double DIV(double a, double b) {
1673         return (double)(a / b);
1674     }
1675 
1676     @Test(dataProvider = "doubleBinaryOpProvider")
1677     static void DIVDouble256VectorTests(IntFunction<double[]> fa, IntFunction<double[]> fb) {
1678         double[] a = fa.apply(SPECIES.length());
1679         double[] b = fb.apply(SPECIES.length());
1680         double[] r = fr.apply(SPECIES.length());
1681 
1682         for (int ic = 0; ic < INVOC_COUNT; ic++) {
1683             for (int i = 0; i < a.length; i += SPECIES.length()) {
1684                 DoubleVector av = DoubleVector.fromArray(SPECIES, a, i);
1685                 DoubleVector bv = DoubleVector.fromArray(SPECIES, b, i);
1686                 av.lanewise(VectorOperators.DIV, bv).intoArray(r, i);
1687             }
1688         }
1689 
1690         assertArraysEquals(r, a, b, Double256VectorTests::DIV);
1691     }
1692     static double div(double a, double b) {
1693         return (double)(a / b);
1694     }
1695 
1696     @Test(dataProvider = "doubleBinaryOpProvider")
1697     static void divDouble256VectorTests(IntFunction<double[]> fa, IntFunction<double[]> fb) {
1698         double[] a = fa.apply(SPECIES.length());
1699         double[] b = fb.apply(SPECIES.length());
1700         double[] r = fr.apply(SPECIES.length());
1701 
1702         for (int i = 0; i < a.length; i += SPECIES.length()) {
1703             DoubleVector av = DoubleVector.fromArray(SPECIES, a, i);
1704             DoubleVector bv = DoubleVector.fromArray(SPECIES, b, i);
1705             av.div(bv).intoArray(r, i);
1706         }
1707 
1708         assertArraysEquals(r, a, b, Double256VectorTests::div);
1709     }
1710 
1711 
1712 
1713     @Test(dataProvider = "doubleBinaryOpMaskProvider")
1714     static void DIVDouble256VectorTestsMasked(IntFunction<double[]> fa, IntFunction<double[]> fb,
1715                                           IntFunction<boolean[]> fm) {
1716         double[] a = fa.apply(SPECIES.length());
1717         double[] b = fb.apply(SPECIES.length());
1718         double[] r = fr.apply(SPECIES.length());
1719         boolean[] mask = fm.apply(SPECIES.length());
1720         VectorMask<Double> vmask = VectorMask.fromArray(SPECIES, mask, 0);
1721 
1722         for (int ic = 0; ic < INVOC_COUNT; ic++) {
1723             for (int i = 0; i < a.length; i += SPECIES.length()) {
1724                 DoubleVector av = DoubleVector.fromArray(SPECIES, a, i);
1725                 DoubleVector bv = DoubleVector.fromArray(SPECIES, b, i);
1726                 av.lanewise(VectorOperators.DIV, bv, vmask).intoArray(r, i);
1727             }
1728         }
1729 
1730         assertArraysEquals(r, a, b, mask, Double256VectorTests::DIV);
1731     }
1732 
1733     @Test(dataProvider = "doubleBinaryOpMaskProvider")
1734     static void divDouble256VectorTestsMasked(IntFunction<double[]> fa, IntFunction<double[]> fb,
1735                                           IntFunction<boolean[]> fm) {
1736         double[] a = fa.apply(SPECIES.length());
1737         double[] b = fb.apply(SPECIES.length());
1738         double[] r = fr.apply(SPECIES.length());
1739         boolean[] mask = fm.apply(SPECIES.length());
1740         VectorMask<Double> vmask = VectorMask.fromArray(SPECIES, mask, 0);
1741 
1742         for (int i = 0; i < a.length; i += SPECIES.length()) {
1743             DoubleVector av = DoubleVector.fromArray(SPECIES, a, i);
1744             DoubleVector bv = DoubleVector.fromArray(SPECIES, b, i);
1745             av.div(bv, vmask).intoArray(r, i);
1746         }
1747 
1748         assertArraysEquals(r, a, b, mask, Double256VectorTests::div);
1749     }
1750 
1751 
1752 
1753     static double FIRST_NONZERO(double a, double b) {
1754         return (double)(Double.doubleToLongBits(a)!=0?a:b);
1755     }
1756 
1757     @Test(dataProvider = "doubleBinaryOpProvider")
1758     static void FIRST_NONZERODouble256VectorTests(IntFunction<double[]> fa, IntFunction<double[]> fb) {
1759         double[] a = fa.apply(SPECIES.length());
1760         double[] b = fb.apply(SPECIES.length());
1761         double[] r = fr.apply(SPECIES.length());
1762 
1763         for (int ic = 0; ic < INVOC_COUNT; ic++) {
1764             for (int i = 0; i < a.length; i += SPECIES.length()) {
1765                 DoubleVector av = DoubleVector.fromArray(SPECIES, a, i);
1766                 DoubleVector bv = DoubleVector.fromArray(SPECIES, b, i);
1767                 av.lanewise(VectorOperators.FIRST_NONZERO, bv).intoArray(r, i);
1768             }
1769         }
1770 
1771         assertArraysEquals(r, a, b, Double256VectorTests::FIRST_NONZERO);
1772     }
1773 
1774     @Test(dataProvider = "doubleBinaryOpMaskProvider")
1775     static void FIRST_NONZERODouble256VectorTestsMasked(IntFunction<double[]> fa, IntFunction<double[]> fb,
1776                                           IntFunction<boolean[]> fm) {
1777         double[] a = fa.apply(SPECIES.length());
1778         double[] b = fb.apply(SPECIES.length());
1779         double[] r = fr.apply(SPECIES.length());
1780         boolean[] mask = fm.apply(SPECIES.length());
1781         VectorMask<Double> vmask = VectorMask.fromArray(SPECIES, mask, 0);
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                 DoubleVector bv = DoubleVector.fromArray(SPECIES, b, i);
1787                 av.lanewise(VectorOperators.FIRST_NONZERO, bv, vmask).intoArray(r, i);
1788             }
1789         }
1790 
1791         assertArraysEquals(r, a, b, mask, Double256VectorTests::FIRST_NONZERO);
1792     }
1793 
1794 
1795 
1796 
1797 
1798 
1799 
1800 
1801 
1802     @Test(dataProvider = "doubleBinaryOpProvider")
1803     static void addDouble256VectorTestsBroadcastSmokeTest(IntFunction<double[]> fa, IntFunction<double[]> fb) {
1804         double[] a = fa.apply(SPECIES.length());
1805         double[] b = fb.apply(SPECIES.length());
1806         double[] r = fr.apply(SPECIES.length());
1807 
1808         for (int i = 0; i < a.length; i += SPECIES.length()) {
1809             DoubleVector av = DoubleVector.fromArray(SPECIES, a, i);
1810             av.add(b[i]).intoArray(r, i);
1811         }
1812 
1813         assertBroadcastArraysEquals(r, a, b, Double256VectorTests::add);
1814     }
1815 
1816     @Test(dataProvider = "doubleBinaryOpMaskProvider")
1817     static void addDouble256VectorTestsBroadcastMaskedSmokeTest(IntFunction<double[]> fa, IntFunction<double[]> fb,
1818                                           IntFunction<boolean[]> fm) {
1819         double[] a = fa.apply(SPECIES.length());
1820         double[] b = fb.apply(SPECIES.length());
1821         double[] r = fr.apply(SPECIES.length());
1822         boolean[] mask = fm.apply(SPECIES.length());
1823         VectorMask<Double> vmask = VectorMask.fromArray(SPECIES, mask, 0);
1824 
1825         for (int i = 0; i < a.length; i += SPECIES.length()) {
1826             DoubleVector av = DoubleVector.fromArray(SPECIES, a, i);
1827             av.add(b[i], vmask).intoArray(r, i);
1828         }
1829 
1830         assertBroadcastArraysEquals(r, a, b, mask, Double256VectorTests::add);
1831     }
1832 
1833     @Test(dataProvider = "doubleBinaryOpProvider")
1834     static void subDouble256VectorTestsBroadcastSmokeTest(IntFunction<double[]> fa, IntFunction<double[]> fb) {
1835         double[] a = fa.apply(SPECIES.length());
1836         double[] b = fb.apply(SPECIES.length());
1837         double[] r = fr.apply(SPECIES.length());
1838 
1839         for (int i = 0; i < a.length; i += SPECIES.length()) {
1840             DoubleVector av = DoubleVector.fromArray(SPECIES, a, i);
1841             av.sub(b[i]).intoArray(r, i);
1842         }
1843 
1844         assertBroadcastArraysEquals(r, a, b, Double256VectorTests::sub);
1845     }
1846 
1847     @Test(dataProvider = "doubleBinaryOpMaskProvider")
1848     static void subDouble256VectorTestsBroadcastMaskedSmokeTest(IntFunction<double[]> fa, IntFunction<double[]> fb,
1849                                           IntFunction<boolean[]> fm) {
1850         double[] a = fa.apply(SPECIES.length());
1851         double[] b = fb.apply(SPECIES.length());
1852         double[] r = fr.apply(SPECIES.length());
1853         boolean[] mask = fm.apply(SPECIES.length());
1854         VectorMask<Double> vmask = VectorMask.fromArray(SPECIES, mask, 0);
1855 
1856         for (int i = 0; i < a.length; i += SPECIES.length()) {
1857             DoubleVector av = DoubleVector.fromArray(SPECIES, a, i);
1858             av.sub(b[i], vmask).intoArray(r, i);
1859         }
1860 
1861         assertBroadcastArraysEquals(r, a, b, mask, Double256VectorTests::sub);
1862     }
1863 
1864     @Test(dataProvider = "doubleBinaryOpProvider")
1865     static void mulDouble256VectorTestsBroadcastSmokeTest(IntFunction<double[]> fa, IntFunction<double[]> fb) {
1866         double[] a = fa.apply(SPECIES.length());
1867         double[] b = fb.apply(SPECIES.length());
1868         double[] r = fr.apply(SPECIES.length());
1869 
1870         for (int i = 0; i < a.length; i += SPECIES.length()) {
1871             DoubleVector av = DoubleVector.fromArray(SPECIES, a, i);
1872             av.mul(b[i]).intoArray(r, i);
1873         }
1874 
1875         assertBroadcastArraysEquals(r, a, b, Double256VectorTests::mul);
1876     }
1877 
1878     @Test(dataProvider = "doubleBinaryOpMaskProvider")
1879     static void mulDouble256VectorTestsBroadcastMaskedSmokeTest(IntFunction<double[]> fa, IntFunction<double[]> fb,
1880                                           IntFunction<boolean[]> fm) {
1881         double[] a = fa.apply(SPECIES.length());
1882         double[] b = fb.apply(SPECIES.length());
1883         double[] r = fr.apply(SPECIES.length());
1884         boolean[] mask = fm.apply(SPECIES.length());
1885         VectorMask<Double> vmask = VectorMask.fromArray(SPECIES, mask, 0);
1886 
1887         for (int i = 0; i < a.length; i += SPECIES.length()) {
1888             DoubleVector av = DoubleVector.fromArray(SPECIES, a, i);
1889             av.mul(b[i], vmask).intoArray(r, i);
1890         }
1891 
1892         assertBroadcastArraysEquals(r, a, b, mask, Double256VectorTests::mul);
1893     }
1894 
1895 
1896     @Test(dataProvider = "doubleBinaryOpProvider")
1897     static void divDouble256VectorTestsBroadcastSmokeTest(IntFunction<double[]> fa, IntFunction<double[]> fb) {
1898         double[] a = fa.apply(SPECIES.length());
1899         double[] b = fb.apply(SPECIES.length());
1900         double[] r = fr.apply(SPECIES.length());
1901 
1902         for (int i = 0; i < a.length; i += SPECIES.length()) {
1903             DoubleVector av = DoubleVector.fromArray(SPECIES, a, i);
1904             av.div(b[i]).intoArray(r, i);
1905         }
1906 
1907         assertBroadcastArraysEquals(r, a, b, Double256VectorTests::div);
1908     }
1909 
1910 
1911 
1912     @Test(dataProvider = "doubleBinaryOpMaskProvider")
1913     static void divDouble256VectorTestsBroadcastMaskedSmokeTest(IntFunction<double[]> fa, IntFunction<double[]> fb,
1914                                           IntFunction<boolean[]> fm) {
1915         double[] a = fa.apply(SPECIES.length());
1916         double[] b = fb.apply(SPECIES.length());
1917         double[] r = fr.apply(SPECIES.length());
1918         boolean[] mask = fm.apply(SPECIES.length());
1919         VectorMask<Double> vmask = VectorMask.fromArray(SPECIES, mask, 0);
1920 
1921         for (int i = 0; i < a.length; i += SPECIES.length()) {
1922             DoubleVector av = DoubleVector.fromArray(SPECIES, a, i);
1923             av.div(b[i], vmask).intoArray(r, i);
1924         }
1925 
1926         assertBroadcastArraysEquals(r, a, b, mask, Double256VectorTests::div);
1927     }
1928 
1929 
1930 
1931 
1932 
1933 
1934 
1935 
1936 
1937 
1938     @Test(dataProvider = "doubleBinaryOpProvider")
1939     static void ADDDouble256VectorTestsBroadcastLongSmokeTest(IntFunction<double[]> fa, IntFunction<double[]> fb) {
1940         double[] a = fa.apply(SPECIES.length());
1941         double[] b = fb.apply(SPECIES.length());
1942         double[] r = fr.apply(SPECIES.length());
1943 
1944         for (int i = 0; i < a.length; i += SPECIES.length()) {
1945             DoubleVector av = DoubleVector.fromArray(SPECIES, a, i);
1946             av.lanewise(VectorOperators.ADD, (long)b[i]).intoArray(r, i);
1947         }
1948 
1949         assertBroadcastLongArraysEquals(r, a, b, Double256VectorTests::ADD);
1950     }
1951 
1952     @Test(dataProvider = "doubleBinaryOpMaskProvider")
1953     static void ADDDouble256VectorTestsBroadcastMaskedLongSmokeTest(IntFunction<double[]> fa, IntFunction<double[]> fb,
1954                                           IntFunction<boolean[]> fm) {
1955         double[] a = fa.apply(SPECIES.length());
1956         double[] b = fb.apply(SPECIES.length());
1957         double[] r = fr.apply(SPECIES.length());
1958         boolean[] mask = fm.apply(SPECIES.length());
1959         VectorMask<Double> vmask = VectorMask.fromArray(SPECIES, mask, 0);
1960 
1961         for (int i = 0; i < a.length; i += SPECIES.length()) {
1962             DoubleVector av = DoubleVector.fromArray(SPECIES, a, i);
1963             av.lanewise(VectorOperators.ADD, (long)b[i], vmask).intoArray(r, i);
1964         }
1965 
1966         assertBroadcastLongArraysEquals(r, a, b, mask, Double256VectorTests::ADD);
1967     }
1968 
1969 
1970 
1971 
1972 
1973 
1974 
1975 
1976 
1977 
1978 
1979 
1980 
1981 
1982 
1983 
1984 
1985 
1986 
1987 
1988 
1989 
1990 
1991 
1992 
1993 
1994 
1995 
1996 
1997 
1998 
1999 
2000 
2001 
2002 
2003 
2004 
2005 
2006 
2007 
2008 
2009 
2010 
2011 
2012     static double MIN(double a, double b) {
2013         return (double)(Math.min(a, b));
2014     }
2015 
2016     @Test(dataProvider = "doubleBinaryOpProvider")
2017     static void MINDouble256VectorTests(IntFunction<double[]> fa, IntFunction<double[]> fb) {
2018         double[] a = fa.apply(SPECIES.length());
2019         double[] b = fb.apply(SPECIES.length());
2020         double[] r = fr.apply(SPECIES.length());
2021 
2022         for (int ic = 0; ic < INVOC_COUNT; ic++) {
2023             for (int i = 0; i < a.length; i += SPECIES.length()) {
2024                 DoubleVector av = DoubleVector.fromArray(SPECIES, a, i);
2025                 DoubleVector bv = DoubleVector.fromArray(SPECIES, b, i);
2026                 av.lanewise(VectorOperators.MIN, bv).intoArray(r, i);
2027             }
2028         }
2029 
2030         assertArraysEquals(r, a, b, Double256VectorTests::MIN);
2031     }
2032     static double min(double a, double b) {
2033         return (double)(Math.min(a, b));
2034     }
2035 
2036     @Test(dataProvider = "doubleBinaryOpProvider")
2037     static void minDouble256VectorTests(IntFunction<double[]> fa, IntFunction<double[]> fb) {
2038         double[] a = fa.apply(SPECIES.length());
2039         double[] b = fb.apply(SPECIES.length());
2040         double[] r = fr.apply(SPECIES.length());
2041 
2042         for (int i = 0; i < a.length; i += SPECIES.length()) {
2043             DoubleVector av = DoubleVector.fromArray(SPECIES, a, i);
2044             DoubleVector bv = DoubleVector.fromArray(SPECIES, b, i);
2045             av.min(bv).intoArray(r, i);
2046         }
2047 
2048         assertArraysEquals(r, a, b, Double256VectorTests::min);
2049     }
2050     static double MAX(double a, double b) {
2051         return (double)(Math.max(a, b));
2052     }
2053 
2054     @Test(dataProvider = "doubleBinaryOpProvider")
2055     static void MAXDouble256VectorTests(IntFunction<double[]> fa, IntFunction<double[]> fb) {
2056         double[] a = fa.apply(SPECIES.length());
2057         double[] b = fb.apply(SPECIES.length());
2058         double[] r = fr.apply(SPECIES.length());
2059 
2060         for (int ic = 0; ic < INVOC_COUNT; ic++) {
2061             for (int i = 0; i < a.length; i += SPECIES.length()) {
2062                 DoubleVector av = DoubleVector.fromArray(SPECIES, a, i);
2063                 DoubleVector bv = DoubleVector.fromArray(SPECIES, b, i);
2064                 av.lanewise(VectorOperators.MAX, bv).intoArray(r, i);
2065             }
2066         }
2067 
2068         assertArraysEquals(r, a, b, Double256VectorTests::MAX);
2069     }
2070     static double max(double a, double b) {
2071         return (double)(Math.max(a, b));
2072     }
2073 
2074     @Test(dataProvider = "doubleBinaryOpProvider")
2075     static void maxDouble256VectorTests(IntFunction<double[]> fa, IntFunction<double[]> fb) {
2076         double[] a = fa.apply(SPECIES.length());
2077         double[] b = fb.apply(SPECIES.length());
2078         double[] r = fr.apply(SPECIES.length());
2079 
2080         for (int i = 0; i < a.length; i += SPECIES.length()) {
2081             DoubleVector av = DoubleVector.fromArray(SPECIES, a, i);
2082             DoubleVector bv = DoubleVector.fromArray(SPECIES, b, i);
2083             av.max(bv).intoArray(r, i);
2084         }
2085 
2086         assertArraysEquals(r, a, b, Double256VectorTests::max);
2087     }
2088 
2089     @Test(dataProvider = "doubleBinaryOpProvider")
2090     static void MINDouble256VectorTestsBroadcastSmokeTest(IntFunction<double[]> fa, IntFunction<double[]> fb) {
2091         double[] a = fa.apply(SPECIES.length());
2092         double[] b = fb.apply(SPECIES.length());
2093         double[] r = fr.apply(SPECIES.length());
2094 
2095         for (int i = 0; i < a.length; i += SPECIES.length()) {
2096             DoubleVector av = DoubleVector.fromArray(SPECIES, a, i);
2097             av.lanewise(VectorOperators.MIN, b[i]).intoArray(r, i);
2098         }
2099 
2100         assertBroadcastArraysEquals(r, a, b, Double256VectorTests::MIN);
2101     }
2102 
2103     @Test(dataProvider = "doubleBinaryOpProvider")
2104     static void minDouble256VectorTestsBroadcastSmokeTest(IntFunction<double[]> fa, IntFunction<double[]> fb) {
2105         double[] a = fa.apply(SPECIES.length());
2106         double[] b = fb.apply(SPECIES.length());
2107         double[] r = fr.apply(SPECIES.length());
2108 
2109         for (int i = 0; i < a.length; i += SPECIES.length()) {
2110             DoubleVector av = DoubleVector.fromArray(SPECIES, a, i);
2111             av.min(b[i]).intoArray(r, i);
2112         }
2113 
2114         assertBroadcastArraysEquals(r, a, b, Double256VectorTests::min);
2115     }
2116 
2117     @Test(dataProvider = "doubleBinaryOpProvider")
2118     static void MAXDouble256VectorTestsBroadcastSmokeTest(IntFunction<double[]> fa, IntFunction<double[]> fb) {
2119         double[] a = fa.apply(SPECIES.length());
2120         double[] b = fb.apply(SPECIES.length());
2121         double[] r = fr.apply(SPECIES.length());
2122 
2123         for (int i = 0; i < a.length; i += SPECIES.length()) {
2124             DoubleVector av = DoubleVector.fromArray(SPECIES, a, i);
2125             av.lanewise(VectorOperators.MAX, b[i]).intoArray(r, i);
2126         }
2127 
2128         assertBroadcastArraysEquals(r, a, b, Double256VectorTests::MAX);
2129     }
2130 
2131     @Test(dataProvider = "doubleBinaryOpProvider")
2132     static void maxDouble256VectorTestsBroadcastSmokeTest(IntFunction<double[]> fa, IntFunction<double[]> fb) {
2133         double[] a = fa.apply(SPECIES.length());
2134         double[] b = fb.apply(SPECIES.length());
2135         double[] r = fr.apply(SPECIES.length());
2136 
2137         for (int i = 0; i < a.length; i += SPECIES.length()) {
2138             DoubleVector av = DoubleVector.fromArray(SPECIES, a, i);
2139             av.max(b[i]).intoArray(r, i);
2140         }
2141 
2142         assertBroadcastArraysEquals(r, a, b, Double256VectorTests::max);
2143     }
2144 
2145 
2146 
2147 
2148 
2149 
2150 
2151 
2152 
2153 
2154 
2155 
2156     static double ADDReduce(double[] a, int idx) {
2157         double res = 0;
2158         for (int i = idx; i < (idx + SPECIES.length()); i++) {
2159             res += a[i];
2160         }
2161 
2162         return res;
2163     }
2164 
2165     static double ADDReduceAll(double[] a) {
2166         double res = 0;
2167         for (int i = 0; i < a.length; i += SPECIES.length()) {
2168             res += ADDReduce(a, i);
2169         }
2170 
2171         return res;
2172     }
2173     @Test(dataProvider = "doubleUnaryOpProvider")
2174     static void ADDReduceDouble256VectorTests(IntFunction<double[]> fa) {
2175         double[] a = fa.apply(SPECIES.length());
2176         double[] r = fr.apply(SPECIES.length());
2177         double ra = 0;
2178 
2179         for (int ic = 0; ic < INVOC_COUNT; ic++) {
2180             for (int i = 0; i < a.length; i += SPECIES.length()) {
2181                 DoubleVector av = DoubleVector.fromArray(SPECIES, a, i);
2182                 r[i] = av.reduceLanes(VectorOperators.ADD);
2183             }
2184         }
2185 
2186         for (int ic = 0; ic < INVOC_COUNT; ic++) {
2187             ra = 0;
2188             for (int i = 0; i < a.length; i += SPECIES.length()) {
2189                 DoubleVector av = DoubleVector.fromArray(SPECIES, a, i);
2190                 ra += av.reduceLanes(VectorOperators.ADD);
2191             }
2192         }
2193 
2194         assertReductionArraysEquals(r, ra, a,
2195                 Double256VectorTests::ADDReduce, Double256VectorTests::ADDReduceAll);
2196     }
2197     static double ADDReduceMasked(double[] a, int idx, boolean[] mask) {
2198         double res = 0;
2199         for (int i = idx; i < (idx + SPECIES.length()); i++) {
2200             if (mask[i % SPECIES.length()])
2201                 res += a[i];
2202         }
2203 
2204         return res;
2205     }
2206 
2207     static double ADDReduceAllMasked(double[] a, boolean[] mask) {
2208         double res = 0;
2209         for (int i = 0; i < a.length; i += SPECIES.length()) {
2210             res += ADDReduceMasked(a, i, mask);
2211         }
2212 
2213         return res;
2214     }
2215     @Test(dataProvider = "doubleUnaryOpMaskProvider")
2216     static void ADDReduceDouble256VectorTestsMasked(IntFunction<double[]> fa, IntFunction<boolean[]> fm) {
2217         double[] a = fa.apply(SPECIES.length());
2218         double[] r = fr.apply(SPECIES.length());
2219         boolean[] mask = fm.apply(SPECIES.length());
2220         VectorMask<Double> vmask = VectorMask.fromArray(SPECIES, mask, 0);
2221         double ra = 0;
2222 
2223         for (int ic = 0; ic < INVOC_COUNT; ic++) {
2224             for (int i = 0; i < a.length; i += SPECIES.length()) {
2225                 DoubleVector av = DoubleVector.fromArray(SPECIES, a, i);
2226                 r[i] = av.reduceLanes(VectorOperators.ADD, vmask);
2227             }
2228         }
2229 
2230         for (int ic = 0; ic < INVOC_COUNT; ic++) {
2231             ra = 0;
2232             for (int i = 0; i < a.length; i += SPECIES.length()) {
2233                 DoubleVector av = DoubleVector.fromArray(SPECIES, a, i);
2234                 ra += av.reduceLanes(VectorOperators.ADD, vmask);
2235             }
2236         }
2237 
2238         assertReductionArraysEqualsMasked(r, ra, a, mask,
2239                 Double256VectorTests::ADDReduceMasked, Double256VectorTests::ADDReduceAllMasked);
2240     }
2241     static double MULReduce(double[] a, int idx) {
2242         double res = 1;
2243         for (int i = idx; i < (idx + SPECIES.length()); i++) {
2244             res *= a[i];
2245         }
2246 
2247         return res;
2248     }
2249 
2250     static double MULReduceAll(double[] a) {
2251         double res = 1;
2252         for (int i = 0; i < a.length; i += SPECIES.length()) {
2253             res *= MULReduce(a, i);
2254         }
2255 
2256         return res;
2257     }
2258     @Test(dataProvider = "doubleUnaryOpProvider")
2259     static void MULReduceDouble256VectorTests(IntFunction<double[]> fa) {
2260         double[] a = fa.apply(SPECIES.length());
2261         double[] r = fr.apply(SPECIES.length());
2262         double ra = 1;
2263 
2264         for (int ic = 0; ic < INVOC_COUNT; ic++) {
2265             for (int i = 0; i < a.length; i += SPECIES.length()) {
2266                 DoubleVector av = DoubleVector.fromArray(SPECIES, a, i);
2267                 r[i] = av.reduceLanes(VectorOperators.MUL);
2268             }
2269         }
2270 
2271         for (int ic = 0; ic < INVOC_COUNT; ic++) {
2272             ra = 1;
2273             for (int i = 0; i < a.length; i += SPECIES.length()) {
2274                 DoubleVector av = DoubleVector.fromArray(SPECIES, a, i);
2275                 ra *= av.reduceLanes(VectorOperators.MUL);
2276             }
2277         }
2278 
2279         assertReductionArraysEquals(r, ra, a,
2280                 Double256VectorTests::MULReduce, Double256VectorTests::MULReduceAll);
2281     }
2282     static double MULReduceMasked(double[] a, int idx, boolean[] mask) {
2283         double res = 1;
2284         for (int i = idx; i < (idx + SPECIES.length()); i++) {
2285             if (mask[i % SPECIES.length()])
2286                 res *= a[i];
2287         }
2288 
2289         return res;
2290     }
2291 
2292     static double MULReduceAllMasked(double[] a, boolean[] mask) {
2293         double res = 1;
2294         for (int i = 0; i < a.length; i += SPECIES.length()) {
2295             res *= MULReduceMasked(a, i, mask);
2296         }
2297 
2298         return res;
2299     }
2300     @Test(dataProvider = "doubleUnaryOpMaskProvider")
2301     static void MULReduceDouble256VectorTestsMasked(IntFunction<double[]> fa, IntFunction<boolean[]> fm) {
2302         double[] a = fa.apply(SPECIES.length());
2303         double[] r = fr.apply(SPECIES.length());
2304         boolean[] mask = fm.apply(SPECIES.length());
2305         VectorMask<Double> vmask = VectorMask.fromArray(SPECIES, mask, 0);
2306         double ra = 1;
2307 
2308         for (int ic = 0; ic < INVOC_COUNT; ic++) {
2309             for (int i = 0; i < a.length; i += SPECIES.length()) {
2310                 DoubleVector av = DoubleVector.fromArray(SPECIES, a, i);
2311                 r[i] = av.reduceLanes(VectorOperators.MUL, vmask);
2312             }
2313         }
2314 
2315         for (int ic = 0; ic < INVOC_COUNT; ic++) {
2316             ra = 1;
2317             for (int i = 0; i < a.length; i += SPECIES.length()) {
2318                 DoubleVector av = DoubleVector.fromArray(SPECIES, a, i);
2319                 ra *= av.reduceLanes(VectorOperators.MUL, vmask);
2320             }
2321         }
2322 
2323         assertReductionArraysEqualsMasked(r, ra, a, mask,
2324                 Double256VectorTests::MULReduceMasked, Double256VectorTests::MULReduceAllMasked);
2325     }
2326     static double MINReduce(double[] a, int idx) {
2327         double res = Double.POSITIVE_INFINITY;
2328         for (int i = idx; i < (idx + SPECIES.length()); i++) {
2329             res = (double)Math.min(res, a[i]);
2330         }
2331 
2332         return res;
2333     }
2334 
2335     static double MINReduceAll(double[] a) {
2336         double res = Double.POSITIVE_INFINITY;
2337         for (int i = 0; i < a.length; i++) {
2338             res = (double)Math.min(res, a[i]);
2339         }
2340 
2341         return res;
2342     }
2343     @Test(dataProvider = "doubleUnaryOpProvider")
2344     static void MINReduceDouble256VectorTests(IntFunction<double[]> fa) {
2345         double[] a = fa.apply(SPECIES.length());
2346         double[] r = fr.apply(SPECIES.length());
2347         double ra = Double.POSITIVE_INFINITY;
2348 
2349         for (int ic = 0; ic < INVOC_COUNT; ic++) {
2350             for (int i = 0; i < a.length; i += SPECIES.length()) {
2351                 DoubleVector av = DoubleVector.fromArray(SPECIES, a, i);
2352                 r[i] = av.reduceLanes(VectorOperators.MIN);
2353             }
2354         }
2355 
2356         for (int ic = 0; ic < INVOC_COUNT; ic++) {
2357             ra = Double.POSITIVE_INFINITY;
2358             for (int i = 0; i < a.length; i += SPECIES.length()) {
2359                 DoubleVector av = DoubleVector.fromArray(SPECIES, a, i);
2360                 ra = (double)Math.min(ra, av.reduceLanes(VectorOperators.MIN));
2361             }
2362         }
2363 
2364         assertReductionArraysEquals(r, ra, a,
2365                 Double256VectorTests::MINReduce, Double256VectorTests::MINReduceAll);
2366     }
2367     static double MINReduceMasked(double[] a, int idx, boolean[] mask) {
2368         double res = Double.POSITIVE_INFINITY;
2369         for (int i = idx; i < (idx + SPECIES.length()); i++) {
2370             if(mask[i % SPECIES.length()])
2371                 res = (double)Math.min(res, a[i]);
2372         }
2373 
2374         return res;
2375     }
2376 
2377     static double MINReduceAllMasked(double[] a, boolean[] mask) {
2378         double res = Double.POSITIVE_INFINITY;
2379         for (int i = 0; i < a.length; i++) {
2380             if(mask[i % SPECIES.length()])
2381                 res = (double)Math.min(res, a[i]);
2382         }
2383 
2384         return res;
2385     }
2386     @Test(dataProvider = "doubleUnaryOpMaskProvider")
2387     static void MINReduceDouble256VectorTestsMasked(IntFunction<double[]> fa, IntFunction<boolean[]> fm) {
2388         double[] a = fa.apply(SPECIES.length());
2389         double[] r = fr.apply(SPECIES.length());
2390         boolean[] mask = fm.apply(SPECIES.length());
2391         VectorMask<Double> vmask = VectorMask.fromArray(SPECIES, mask, 0);
2392         double ra = Double.POSITIVE_INFINITY;
2393 
2394         for (int ic = 0; ic < INVOC_COUNT; ic++) {
2395             for (int i = 0; i < a.length; i += SPECIES.length()) {
2396                 DoubleVector av = DoubleVector.fromArray(SPECIES, a, i);
2397                 r[i] = av.reduceLanes(VectorOperators.MIN, vmask);
2398             }
2399         }
2400 
2401         for (int ic = 0; ic < INVOC_COUNT; ic++) {
2402             ra = Double.POSITIVE_INFINITY;
2403             for (int i = 0; i < a.length; i += SPECIES.length()) {
2404                 DoubleVector av = DoubleVector.fromArray(SPECIES, a, i);
2405                 ra = (double)Math.min(ra, av.reduceLanes(VectorOperators.MIN, vmask));
2406             }
2407         }
2408 
2409         assertReductionArraysEqualsMasked(r, ra, a, mask,
2410                 Double256VectorTests::MINReduceMasked, Double256VectorTests::MINReduceAllMasked);
2411     }
2412     static double MAXReduce(double[] a, int idx) {
2413         double res = Double.NEGATIVE_INFINITY;
2414         for (int i = idx; i < (idx + SPECIES.length()); i++) {
2415             res = (double)Math.max(res, a[i]);
2416         }
2417 
2418         return res;
2419     }
2420 
2421     static double MAXReduceAll(double[] a) {
2422         double res = Double.NEGATIVE_INFINITY;
2423         for (int i = 0; i < a.length; i++) {
2424             res = (double)Math.max(res, a[i]);
2425         }
2426 
2427         return res;
2428     }
2429     @Test(dataProvider = "doubleUnaryOpProvider")
2430     static void MAXReduceDouble256VectorTests(IntFunction<double[]> fa) {
2431         double[] a = fa.apply(SPECIES.length());
2432         double[] r = fr.apply(SPECIES.length());
2433         double ra = Double.NEGATIVE_INFINITY;
2434 
2435         for (int ic = 0; ic < INVOC_COUNT; ic++) {
2436             for (int i = 0; i < a.length; i += SPECIES.length()) {
2437                 DoubleVector av = DoubleVector.fromArray(SPECIES, a, i);
2438                 r[i] = av.reduceLanes(VectorOperators.MAX);
2439             }
2440         }
2441 
2442         for (int ic = 0; ic < INVOC_COUNT; ic++) {
2443             ra = Double.NEGATIVE_INFINITY;
2444             for (int i = 0; i < a.length; i += SPECIES.length()) {
2445                 DoubleVector av = DoubleVector.fromArray(SPECIES, a, i);
2446                 ra = (double)Math.max(ra, av.reduceLanes(VectorOperators.MAX));
2447             }
2448         }
2449 
2450         assertReductionArraysEquals(r, ra, a,
2451                 Double256VectorTests::MAXReduce, Double256VectorTests::MAXReduceAll);
2452     }
2453     static double MAXReduceMasked(double[] a, int idx, boolean[] mask) {
2454         double res = Double.NEGATIVE_INFINITY;
2455         for (int i = idx; i < (idx + SPECIES.length()); i++) {
2456             if(mask[i % SPECIES.length()])
2457                 res = (double)Math.max(res, a[i]);
2458         }
2459 
2460         return res;
2461     }
2462 
2463     static double MAXReduceAllMasked(double[] a, boolean[] mask) {
2464         double res = Double.NEGATIVE_INFINITY;
2465         for (int i = 0; i < a.length; i++) {
2466             if(mask[i % SPECIES.length()])
2467                 res = (double)Math.max(res, a[i]);
2468         }
2469 
2470         return res;
2471     }
2472     @Test(dataProvider = "doubleUnaryOpMaskProvider")
2473     static void MAXReduceDouble256VectorTestsMasked(IntFunction<double[]> fa, IntFunction<boolean[]> fm) {
2474         double[] a = fa.apply(SPECIES.length());
2475         double[] r = fr.apply(SPECIES.length());
2476         boolean[] mask = fm.apply(SPECIES.length());
2477         VectorMask<Double> vmask = VectorMask.fromArray(SPECIES, mask, 0);
2478         double ra = Double.NEGATIVE_INFINITY;
2479 
2480         for (int ic = 0; ic < INVOC_COUNT; ic++) {
2481             for (int i = 0; i < a.length; i += SPECIES.length()) {
2482                 DoubleVector av = DoubleVector.fromArray(SPECIES, a, i);
2483                 r[i] = av.reduceLanes(VectorOperators.MAX, vmask);
2484             }
2485         }
2486 
2487         for (int ic = 0; ic < INVOC_COUNT; ic++) {
2488             ra = Double.NEGATIVE_INFINITY;
2489             for (int i = 0; i < a.length; i += SPECIES.length()) {
2490                 DoubleVector av = DoubleVector.fromArray(SPECIES, a, i);
2491                 ra = (double)Math.max(ra, av.reduceLanes(VectorOperators.MAX, vmask));
2492             }
2493         }
2494 
2495         assertReductionArraysEqualsMasked(r, ra, a, mask,
2496                 Double256VectorTests::MAXReduceMasked, Double256VectorTests::MAXReduceAllMasked);
2497     }
2498 
2499 
2500 
2501 
2502 
2503     @Test(dataProvider = "doubleUnaryOpProvider")
2504     static void withDouble256VectorTests(IntFunction<double []> fa) {
2505         double[] a = fa.apply(SPECIES.length());
2506         double[] r = fr.apply(SPECIES.length());
2507 
2508         for (int ic = 0; ic < INVOC_COUNT; ic++) {
2509             for (int i = 0; i < a.length; i += SPECIES.length()) {
2510                 DoubleVector av = DoubleVector.fromArray(SPECIES, a, i);
2511                 av.withLane(0, (double)4).intoArray(r, i);
2512             }
2513         }
2514 
2515         assertInsertArraysEquals(r, a, (double)4, 0);
2516     }
2517     static boolean testIS_DEFAULT(double a) {
2518         return bits(a)==0;
2519     }
2520 
2521     @Test(dataProvider = "doubleTestOpProvider")
2522     static void IS_DEFAULTDouble256VectorTests(IntFunction<double[]> fa) {
2523         double[] a = fa.apply(SPECIES.length());
2524 
2525         for (int ic = 0; ic < INVOC_COUNT; ic++) {
2526             for (int i = 0; i < a.length; i += SPECIES.length()) {
2527                 DoubleVector av = DoubleVector.fromArray(SPECIES, a, i);
2528                 VectorMask<Double> mv = av.test(VectorOperators.IS_DEFAULT);
2529 
2530                 // Check results as part of computation.
2531                 for (int j = 0; j < SPECIES.length(); j++) {
2532                     Assert.assertEquals(mv.laneIsSet(j), testIS_DEFAULT(a[i + j]));
2533                 }
2534             }
2535         }
2536     }
2537 
2538     @Test(dataProvider = "doubleTestOpMaskProvider")
2539     static void IS_DEFAULTMaskedDouble256VectorTestsSmokeTest(IntFunction<double[]> fa,
2540                                           IntFunction<boolean[]> fm) {
2541         double[] a = fa.apply(SPECIES.length());
2542         boolean[] mask = fm.apply(SPECIES.length());
2543         VectorMask<Double> vmask = VectorMask.fromArray(SPECIES, mask, 0);
2544 
2545         for (int i = 0; i < a.length; i += SPECIES.length()) {
2546             DoubleVector av = DoubleVector.fromArray(SPECIES, a, i);
2547             VectorMask<Double> mv = av.test(VectorOperators.IS_DEFAULT, vmask);
2548 
2549             // Check results as part of computation.
2550             for (int j = 0; j < SPECIES.length(); j++) {
2551                 Assert.assertEquals(mv.laneIsSet(j),  vmask.laneIsSet(j) && testIS_DEFAULT(a[i + j]));
2552             }
2553         }
2554     }
2555     static boolean testIS_NEGATIVE(double a) {
2556         return bits(a)<0;
2557     }
2558 
2559     @Test(dataProvider = "doubleTestOpProvider")
2560     static void IS_NEGATIVEDouble256VectorTests(IntFunction<double[]> fa) {
2561         double[] a = fa.apply(SPECIES.length());
2562 
2563         for (int ic = 0; ic < INVOC_COUNT; ic++) {
2564             for (int i = 0; i < a.length; i += SPECIES.length()) {
2565                 DoubleVector av = DoubleVector.fromArray(SPECIES, a, i);
2566                 VectorMask<Double> mv = av.test(VectorOperators.IS_NEGATIVE);
2567 
2568                 // Check results as part of computation.
2569                 for (int j = 0; j < SPECIES.length(); j++) {
2570                     Assert.assertEquals(mv.laneIsSet(j), testIS_NEGATIVE(a[i + j]));
2571                 }
2572             }
2573         }
2574     }
2575 
2576     @Test(dataProvider = "doubleTestOpMaskProvider")
2577     static void IS_NEGATIVEMaskedDouble256VectorTestsSmokeTest(IntFunction<double[]> fa,
2578                                           IntFunction<boolean[]> fm) {
2579         double[] a = fa.apply(SPECIES.length());
2580         boolean[] mask = fm.apply(SPECIES.length());
2581         VectorMask<Double> vmask = VectorMask.fromArray(SPECIES, mask, 0);
2582 
2583         for (int i = 0; i < a.length; i += SPECIES.length()) {
2584             DoubleVector av = DoubleVector.fromArray(SPECIES, a, i);
2585             VectorMask<Double> mv = av.test(VectorOperators.IS_NEGATIVE, vmask);
2586 
2587             // Check results as part of computation.
2588             for (int j = 0; j < SPECIES.length(); j++) {
2589                 Assert.assertEquals(mv.laneIsSet(j),  vmask.laneIsSet(j) && testIS_NEGATIVE(a[i + j]));
2590             }
2591         }
2592     }
2593 
2594     static boolean testIS_FINITE(double a) {
2595         return Double.isFinite(a);
2596     }
2597 
2598     @Test(dataProvider = "doubleTestOpProvider")
2599     static void IS_FINITEDouble256VectorTests(IntFunction<double[]> fa) {
2600         double[] a = fa.apply(SPECIES.length());
2601 
2602         for (int ic = 0; ic < INVOC_COUNT; ic++) {
2603             for (int i = 0; i < a.length; i += SPECIES.length()) {
2604                 DoubleVector av = DoubleVector.fromArray(SPECIES, a, i);
2605                 VectorMask<Double> mv = av.test(VectorOperators.IS_FINITE);
2606 
2607                 // Check results as part of computation.
2608                 for (int j = 0; j < SPECIES.length(); j++) {
2609                     Assert.assertEquals(mv.laneIsSet(j), testIS_FINITE(a[i + j]));
2610                 }
2611             }
2612         }
2613     }
2614 
2615     @Test(dataProvider = "doubleTestOpMaskProvider")
2616     static void IS_FINITEMaskedDouble256VectorTestsSmokeTest(IntFunction<double[]> fa,
2617                                           IntFunction<boolean[]> fm) {
2618         double[] a = fa.apply(SPECIES.length());
2619         boolean[] mask = fm.apply(SPECIES.length());
2620         VectorMask<Double> vmask = VectorMask.fromArray(SPECIES, mask, 0);
2621 
2622         for (int i = 0; i < a.length; i += SPECIES.length()) {
2623             DoubleVector av = DoubleVector.fromArray(SPECIES, a, i);
2624             VectorMask<Double> mv = av.test(VectorOperators.IS_FINITE, vmask);
2625 
2626             // Check results as part of computation.
2627             for (int j = 0; j < SPECIES.length(); j++) {
2628                 Assert.assertEquals(mv.laneIsSet(j),  vmask.laneIsSet(j) && testIS_FINITE(a[i + j]));
2629             }
2630         }
2631     }
2632 
2633 
2634     static boolean testIS_NAN(double a) {
2635         return Double.isNaN(a);
2636     }
2637 
2638     @Test(dataProvider = "doubleTestOpProvider")
2639     static void IS_NANDouble256VectorTests(IntFunction<double[]> fa) {
2640         double[] a = fa.apply(SPECIES.length());
2641 
2642         for (int ic = 0; ic < INVOC_COUNT; ic++) {
2643             for (int i = 0; i < a.length; i += SPECIES.length()) {
2644                 DoubleVector av = DoubleVector.fromArray(SPECIES, a, i);
2645                 VectorMask<Double> mv = av.test(VectorOperators.IS_NAN);
2646 
2647                 // Check results as part of computation.
2648                 for (int j = 0; j < SPECIES.length(); j++) {
2649                     Assert.assertEquals(mv.laneIsSet(j), testIS_NAN(a[i + j]));
2650                 }
2651             }
2652         }
2653     }
2654 
2655     @Test(dataProvider = "doubleTestOpMaskProvider")
2656     static void IS_NANMaskedDouble256VectorTestsSmokeTest(IntFunction<double[]> fa,
2657                                           IntFunction<boolean[]> fm) {
2658         double[] a = fa.apply(SPECIES.length());
2659         boolean[] mask = fm.apply(SPECIES.length());
2660         VectorMask<Double> vmask = VectorMask.fromArray(SPECIES, mask, 0);
2661 
2662         for (int i = 0; i < a.length; i += SPECIES.length()) {
2663             DoubleVector av = DoubleVector.fromArray(SPECIES, a, i);
2664             VectorMask<Double> mv = av.test(VectorOperators.IS_NAN, vmask);
2665 
2666             // Check results as part of computation.
2667             for (int j = 0; j < SPECIES.length(); j++) {
2668                 Assert.assertEquals(mv.laneIsSet(j),  vmask.laneIsSet(j) && testIS_NAN(a[i + j]));
2669             }
2670         }
2671     }
2672 
2673 
2674     static boolean testIS_INFINITE(double a) {
2675         return Double.isInfinite(a);
2676     }
2677 
2678     @Test(dataProvider = "doubleTestOpProvider")
2679     static void IS_INFINITEDouble256VectorTests(IntFunction<double[]> fa) {
2680         double[] a = fa.apply(SPECIES.length());
2681 
2682         for (int ic = 0; ic < INVOC_COUNT; ic++) {
2683             for (int i = 0; i < a.length; i += SPECIES.length()) {
2684                 DoubleVector av = DoubleVector.fromArray(SPECIES, a, i);
2685                 VectorMask<Double> mv = av.test(VectorOperators.IS_INFINITE);
2686 
2687                 // Check results as part of computation.
2688                 for (int j = 0; j < SPECIES.length(); j++) {
2689                     Assert.assertEquals(mv.laneIsSet(j), testIS_INFINITE(a[i + j]));
2690                 }
2691             }
2692         }
2693     }
2694 
2695     @Test(dataProvider = "doubleTestOpMaskProvider")
2696     static void IS_INFINITEMaskedDouble256VectorTestsSmokeTest(IntFunction<double[]> fa,
2697                                           IntFunction<boolean[]> fm) {
2698         double[] a = fa.apply(SPECIES.length());
2699         boolean[] mask = fm.apply(SPECIES.length());
2700         VectorMask<Double> vmask = VectorMask.fromArray(SPECIES, mask, 0);
2701 
2702         for (int i = 0; i < a.length; i += SPECIES.length()) {
2703             DoubleVector av = DoubleVector.fromArray(SPECIES, a, i);
2704             VectorMask<Double> mv = av.test(VectorOperators.IS_INFINITE, vmask);
2705 
2706             // Check results as part of computation.
2707             for (int j = 0; j < SPECIES.length(); j++) {
2708                 Assert.assertEquals(mv.laneIsSet(j),  vmask.laneIsSet(j) && testIS_INFINITE(a[i + j]));
2709             }
2710         }
2711     }
2712 
2713 
2714     @Test(dataProvider = "doubleCompareOpProvider")
2715     static void LTDouble256VectorTests(IntFunction<double[]> fa, IntFunction<double[]> fb) {
2716         double[] a = fa.apply(SPECIES.length());
2717         double[] b = fb.apply(SPECIES.length());
2718 
2719         for (int ic = 0; ic < INVOC_COUNT; ic++) {
2720             for (int i = 0; i < a.length; i += SPECIES.length()) {
2721                 DoubleVector av = DoubleVector.fromArray(SPECIES, a, i);
2722                 DoubleVector bv = DoubleVector.fromArray(SPECIES, b, i);
2723                 VectorMask<Double> mv = av.compare(VectorOperators.LT, bv);
2724 
2725                 // Check results as part of computation.
2726                 for (int j = 0; j < SPECIES.length(); j++) {
2727                     Assert.assertEquals(mv.laneIsSet(j), lt(a[i + j], b[i + j]));
2728                 }
2729             }
2730         }
2731     }
2732 
2733 
2734     @Test(dataProvider = "doubleCompareOpProvider")
2735     static void ltDouble256VectorTests(IntFunction<double[]> fa, IntFunction<double[]> fb) {
2736         double[] a = fa.apply(SPECIES.length());
2737         double[] b = fb.apply(SPECIES.length());
2738 
2739         for (int ic = 0; ic < INVOC_COUNT; ic++) {
2740             for (int i = 0; i < a.length; i += SPECIES.length()) {
2741                 DoubleVector av = DoubleVector.fromArray(SPECIES, a, i);
2742                 DoubleVector bv = DoubleVector.fromArray(SPECIES, b, i);
2743                 VectorMask<Double> mv = av.lt(bv);
2744 
2745                 // Check results as part of computation.
2746                 for (int j = 0; j < SPECIES.length(); j++) {
2747                     Assert.assertEquals(mv.laneIsSet(j), lt(a[i + j], b[i + j]));
2748                 }
2749             }
2750         }
2751     }
2752 
2753     @Test(dataProvider = "doubleCompareOpMaskProvider")
2754     static void LTDouble256VectorTestsMasked(IntFunction<double[]> fa, IntFunction<double[]> fb,
2755                                                 IntFunction<boolean[]> fm) {
2756         double[] a = fa.apply(SPECIES.length());
2757         double[] b = fb.apply(SPECIES.length());
2758         boolean[] mask = fm.apply(SPECIES.length());
2759 
2760         VectorMask<Double> vmask = VectorMask.fromArray(SPECIES, mask, 0);
2761 
2762         for (int ic = 0; ic < INVOC_COUNT; ic++) {
2763             for (int i = 0; i < a.length; i += SPECIES.length()) {
2764                 DoubleVector av = DoubleVector.fromArray(SPECIES, a, i);
2765                 DoubleVector bv = DoubleVector.fromArray(SPECIES, b, i);
2766                 VectorMask<Double> mv = av.compare(VectorOperators.LT, bv, vmask);
2767 
2768                 // Check results as part of computation.
2769                 for (int j = 0; j < SPECIES.length(); j++) {
2770                     Assert.assertEquals(mv.laneIsSet(j), mask[j] && lt(a[i + j], b[i + j]));
2771                 }
2772             }
2773         }
2774     }
2775 
2776 
2777     @Test(dataProvider = "doubleCompareOpProvider")
2778     static void GTDouble256VectorTests(IntFunction<double[]> fa, IntFunction<double[]> fb) {
2779         double[] a = fa.apply(SPECIES.length());
2780         double[] b = fb.apply(SPECIES.length());
2781 
2782         for (int ic = 0; ic < INVOC_COUNT; ic++) {
2783             for (int i = 0; i < a.length; i += SPECIES.length()) {
2784                 DoubleVector av = DoubleVector.fromArray(SPECIES, a, i);
2785                 DoubleVector bv = DoubleVector.fromArray(SPECIES, b, i);
2786                 VectorMask<Double> mv = av.compare(VectorOperators.GT, bv);
2787 
2788                 // Check results as part of computation.
2789                 for (int j = 0; j < SPECIES.length(); j++) {
2790                     Assert.assertEquals(mv.laneIsSet(j), gt(a[i + j], b[i + j]));
2791                 }
2792             }
2793         }
2794     }
2795 
2796     @Test(dataProvider = "doubleCompareOpMaskProvider")
2797     static void GTDouble256VectorTestsMasked(IntFunction<double[]> fa, IntFunction<double[]> fb,
2798                                                 IntFunction<boolean[]> fm) {
2799         double[] a = fa.apply(SPECIES.length());
2800         double[] b = fb.apply(SPECIES.length());
2801         boolean[] mask = fm.apply(SPECIES.length());
2802 
2803         VectorMask<Double> vmask = VectorMask.fromArray(SPECIES, mask, 0);
2804 
2805         for (int ic = 0; ic < INVOC_COUNT; ic++) {
2806             for (int i = 0; i < a.length; i += SPECIES.length()) {
2807                 DoubleVector av = DoubleVector.fromArray(SPECIES, a, i);
2808                 DoubleVector bv = DoubleVector.fromArray(SPECIES, b, i);
2809                 VectorMask<Double> mv = av.compare(VectorOperators.GT, bv, vmask);
2810 
2811                 // Check results as part of computation.
2812                 for (int j = 0; j < SPECIES.length(); j++) {
2813                     Assert.assertEquals(mv.laneIsSet(j), mask[j] && gt(a[i + j], b[i + j]));
2814                 }
2815             }
2816         }
2817     }
2818 
2819 
2820     @Test(dataProvider = "doubleCompareOpProvider")
2821     static void EQDouble256VectorTests(IntFunction<double[]> fa, IntFunction<double[]> fb) {
2822         double[] a = fa.apply(SPECIES.length());
2823         double[] b = fb.apply(SPECIES.length());
2824 
2825         for (int ic = 0; ic < INVOC_COUNT; ic++) {
2826             for (int i = 0; i < a.length; i += SPECIES.length()) {
2827                 DoubleVector av = DoubleVector.fromArray(SPECIES, a, i);
2828                 DoubleVector bv = DoubleVector.fromArray(SPECIES, b, i);
2829                 VectorMask<Double> mv = av.compare(VectorOperators.EQ, bv);
2830 
2831                 // Check results as part of computation.
2832                 for (int j = 0; j < SPECIES.length(); j++) {
2833                     Assert.assertEquals(mv.laneIsSet(j), eq(a[i + j], b[i + j]));
2834                 }
2835             }
2836         }
2837     }
2838 
2839 
2840     @Test(dataProvider = "doubleCompareOpProvider")
2841     static void eqDouble256VectorTests(IntFunction<double[]> fa, IntFunction<double[]> fb) {
2842         double[] a = fa.apply(SPECIES.length());
2843         double[] b = fb.apply(SPECIES.length());
2844 
2845         for (int ic = 0; ic < INVOC_COUNT; ic++) {
2846             for (int i = 0; i < a.length; i += SPECIES.length()) {
2847                 DoubleVector av = DoubleVector.fromArray(SPECIES, a, i);
2848                 DoubleVector bv = DoubleVector.fromArray(SPECIES, b, i);
2849                 VectorMask<Double> mv = av.eq(bv);
2850 
2851                 // Check results as part of computation.
2852                 for (int j = 0; j < SPECIES.length(); j++) {
2853                     Assert.assertEquals(mv.laneIsSet(j), eq(a[i + j], b[i + j]));
2854                 }
2855             }
2856         }
2857     }
2858 
2859     @Test(dataProvider = "doubleCompareOpMaskProvider")
2860     static void EQDouble256VectorTestsMasked(IntFunction<double[]> fa, IntFunction<double[]> fb,
2861                                                 IntFunction<boolean[]> fm) {
2862         double[] a = fa.apply(SPECIES.length());
2863         double[] b = fb.apply(SPECIES.length());
2864         boolean[] mask = fm.apply(SPECIES.length());
2865 
2866         VectorMask<Double> vmask = VectorMask.fromArray(SPECIES, mask, 0);
2867 
2868         for (int ic = 0; ic < INVOC_COUNT; ic++) {
2869             for (int i = 0; i < a.length; i += SPECIES.length()) {
2870                 DoubleVector av = DoubleVector.fromArray(SPECIES, a, i);
2871                 DoubleVector bv = DoubleVector.fromArray(SPECIES, b, i);
2872                 VectorMask<Double> mv = av.compare(VectorOperators.EQ, bv, vmask);
2873 
2874                 // Check results as part of computation.
2875                 for (int j = 0; j < SPECIES.length(); j++) {
2876                     Assert.assertEquals(mv.laneIsSet(j), mask[j] && eq(a[i + j], b[i + j]));
2877                 }
2878             }
2879         }
2880     }
2881 
2882 
2883     @Test(dataProvider = "doubleCompareOpProvider")
2884     static void NEDouble256VectorTests(IntFunction<double[]> fa, IntFunction<double[]> fb) {
2885         double[] a = fa.apply(SPECIES.length());
2886         double[] b = fb.apply(SPECIES.length());
2887 
2888         for (int ic = 0; ic < INVOC_COUNT; ic++) {
2889             for (int i = 0; i < a.length; i += SPECIES.length()) {
2890                 DoubleVector av = DoubleVector.fromArray(SPECIES, a, i);
2891                 DoubleVector bv = DoubleVector.fromArray(SPECIES, b, i);
2892                 VectorMask<Double> mv = av.compare(VectorOperators.NE, bv);
2893 
2894                 // Check results as part of computation.
2895                 for (int j = 0; j < SPECIES.length(); j++) {
2896                     Assert.assertEquals(mv.laneIsSet(j), neq(a[i + j], b[i + j]));
2897                 }
2898             }
2899         }
2900     }
2901 
2902     @Test(dataProvider = "doubleCompareOpMaskProvider")
2903     static void NEDouble256VectorTestsMasked(IntFunction<double[]> fa, IntFunction<double[]> fb,
2904                                                 IntFunction<boolean[]> fm) {
2905         double[] a = fa.apply(SPECIES.length());
2906         double[] b = fb.apply(SPECIES.length());
2907         boolean[] mask = fm.apply(SPECIES.length());
2908 
2909         VectorMask<Double> vmask = VectorMask.fromArray(SPECIES, mask, 0);
2910 
2911         for (int ic = 0; ic < INVOC_COUNT; ic++) {
2912             for (int i = 0; i < a.length; i += SPECIES.length()) {
2913                 DoubleVector av = DoubleVector.fromArray(SPECIES, a, i);
2914                 DoubleVector bv = DoubleVector.fromArray(SPECIES, b, i);
2915                 VectorMask<Double> mv = av.compare(VectorOperators.NE, bv, vmask);
2916 
2917                 // Check results as part of computation.
2918                 for (int j = 0; j < SPECIES.length(); j++) {
2919                     Assert.assertEquals(mv.laneIsSet(j), mask[j] && neq(a[i + j], b[i + j]));
2920                 }
2921             }
2922         }
2923     }
2924 
2925 
2926     @Test(dataProvider = "doubleCompareOpProvider")
2927     static void LEDouble256VectorTests(IntFunction<double[]> fa, IntFunction<double[]> fb) {
2928         double[] a = fa.apply(SPECIES.length());
2929         double[] b = fb.apply(SPECIES.length());
2930 
2931         for (int ic = 0; ic < INVOC_COUNT; ic++) {
2932             for (int i = 0; i < a.length; i += SPECIES.length()) {
2933                 DoubleVector av = DoubleVector.fromArray(SPECIES, a, i);
2934                 DoubleVector bv = DoubleVector.fromArray(SPECIES, b, i);
2935                 VectorMask<Double> mv = av.compare(VectorOperators.LE, bv);
2936 
2937                 // Check results as part of computation.
2938                 for (int j = 0; j < SPECIES.length(); j++) {
2939                     Assert.assertEquals(mv.laneIsSet(j), le(a[i + j], b[i + j]));
2940                 }
2941             }
2942         }
2943     }
2944 
2945     @Test(dataProvider = "doubleCompareOpMaskProvider")
2946     static void LEDouble256VectorTestsMasked(IntFunction<double[]> fa, IntFunction<double[]> fb,
2947                                                 IntFunction<boolean[]> fm) {
2948         double[] a = fa.apply(SPECIES.length());
2949         double[] b = fb.apply(SPECIES.length());
2950         boolean[] mask = fm.apply(SPECIES.length());
2951 
2952         VectorMask<Double> vmask = VectorMask.fromArray(SPECIES, mask, 0);
2953 
2954         for (int ic = 0; ic < INVOC_COUNT; ic++) {
2955             for (int i = 0; i < a.length; i += SPECIES.length()) {
2956                 DoubleVector av = DoubleVector.fromArray(SPECIES, a, i);
2957                 DoubleVector bv = DoubleVector.fromArray(SPECIES, b, i);
2958                 VectorMask<Double> mv = av.compare(VectorOperators.LE, bv, vmask);
2959 
2960                 // Check results as part of computation.
2961                 for (int j = 0; j < SPECIES.length(); j++) {
2962                     Assert.assertEquals(mv.laneIsSet(j), mask[j] && le(a[i + j], b[i + j]));
2963                 }
2964             }
2965         }
2966     }
2967 
2968 
2969     @Test(dataProvider = "doubleCompareOpProvider")
2970     static void GEDouble256VectorTests(IntFunction<double[]> fa, IntFunction<double[]> fb) {
2971         double[] a = fa.apply(SPECIES.length());
2972         double[] b = fb.apply(SPECIES.length());
2973 
2974         for (int ic = 0; ic < INVOC_COUNT; ic++) {
2975             for (int i = 0; i < a.length; i += SPECIES.length()) {
2976                 DoubleVector av = DoubleVector.fromArray(SPECIES, a, i);
2977                 DoubleVector bv = DoubleVector.fromArray(SPECIES, b, i);
2978                 VectorMask<Double> mv = av.compare(VectorOperators.GE, bv);
2979 
2980                 // Check results as part of computation.
2981                 for (int j = 0; j < SPECIES.length(); j++) {
2982                     Assert.assertEquals(mv.laneIsSet(j), ge(a[i + j], b[i + j]));
2983                 }
2984             }
2985         }
2986     }
2987 
2988     @Test(dataProvider = "doubleCompareOpMaskProvider")
2989     static void GEDouble256VectorTestsMasked(IntFunction<double[]> fa, IntFunction<double[]> fb,
2990                                                 IntFunction<boolean[]> fm) {
2991         double[] a = fa.apply(SPECIES.length());
2992         double[] b = fb.apply(SPECIES.length());
2993         boolean[] mask = fm.apply(SPECIES.length());
2994 
2995         VectorMask<Double> vmask = VectorMask.fromArray(SPECIES, mask, 0);
2996 
2997         for (int ic = 0; ic < INVOC_COUNT; ic++) {
2998             for (int i = 0; i < a.length; i += SPECIES.length()) {
2999                 DoubleVector av = DoubleVector.fromArray(SPECIES, a, i);
3000                 DoubleVector bv = DoubleVector.fromArray(SPECIES, b, i);
3001                 VectorMask<Double> mv = av.compare(VectorOperators.GE, bv, vmask);
3002 
3003                 // Check results as part of computation.
3004                 for (int j = 0; j < SPECIES.length(); j++) {
3005                     Assert.assertEquals(mv.laneIsSet(j), mask[j] && ge(a[i + j], b[i + j]));
3006                 }
3007             }
3008         }
3009     }
3010 
3011 
3012 
3013 
3014 
3015 
3016 
3017 
3018 
3019 
3020     @Test(dataProvider = "doubleCompareOpProvider")
3021     static void LTDouble256VectorTestsBroadcastSmokeTest(IntFunction<double[]> fa, IntFunction<double[]> fb) {
3022         double[] a = fa.apply(SPECIES.length());
3023         double[] b = fb.apply(SPECIES.length());
3024 
3025         for (int i = 0; i < a.length; i += SPECIES.length()) {
3026             DoubleVector av = DoubleVector.fromArray(SPECIES, a, i);
3027             VectorMask<Double> mv = av.compare(VectorOperators.LT, b[i]);
3028 
3029             // Check results as part of computation.
3030             for (int j = 0; j < SPECIES.length(); j++) {
3031                 Assert.assertEquals(mv.laneIsSet(j), a[i + j] < b[i]);
3032             }
3033         }
3034     }
3035 
3036 
3037     @Test(dataProvider = "doubleCompareOpMaskProvider")
3038     static void LTDouble256VectorTestsBroadcastMaskedSmokeTest(IntFunction<double[]> fa,
3039                                 IntFunction<double[]> fb, IntFunction<boolean[]> fm) {
3040         double[] a = fa.apply(SPECIES.length());
3041         double[] b = fb.apply(SPECIES.length());
3042         boolean[] mask = fm.apply(SPECIES.length());
3043 
3044         VectorMask<Double> vmask = VectorMask.fromArray(SPECIES, mask, 0);
3045 
3046         for (int i = 0; i < a.length; i += SPECIES.length()) {
3047             DoubleVector av = DoubleVector.fromArray(SPECIES, a, i);
3048             VectorMask<Double> mv = av.compare(VectorOperators.LT, b[i], vmask);
3049 
3050             // Check results as part of computation.
3051             for (int j = 0; j < SPECIES.length(); j++) {
3052                 Assert.assertEquals(mv.laneIsSet(j), mask[j] && (a[i + j] < b[i]));
3053             }
3054         }
3055     }
3056 
3057     @Test(dataProvider = "doubleCompareOpProvider")
3058     static void LTDouble256VectorTestsBroadcastLongSmokeTest(IntFunction<double[]> fa, IntFunction<double[]> fb) {
3059         double[] a = fa.apply(SPECIES.length());
3060         double[] b = fb.apply(SPECIES.length());
3061 
3062         for (int i = 0; i < a.length; i += SPECIES.length()) {
3063             DoubleVector av = DoubleVector.fromArray(SPECIES, a, i);
3064             VectorMask<Double> mv = av.compare(VectorOperators.LT, (long)b[i]);
3065 
3066             // Check results as part of computation.
3067             for (int j = 0; j < SPECIES.length(); j++) {
3068                 Assert.assertEquals(mv.laneIsSet(j), a[i + j] < (double)((long)b[i]));
3069             }
3070         }
3071     }
3072 
3073 
3074     @Test(dataProvider = "doubleCompareOpMaskProvider")
3075     static void LTDouble256VectorTestsBroadcastLongMaskedSmokeTest(IntFunction<double[]> fa,
3076                                 IntFunction<double[]> fb, IntFunction<boolean[]> fm) {
3077         double[] a = fa.apply(SPECIES.length());
3078         double[] b = fb.apply(SPECIES.length());
3079         boolean[] mask = fm.apply(SPECIES.length());
3080 
3081         VectorMask<Double> vmask = VectorMask.fromArray(SPECIES, mask, 0);
3082 
3083         for (int i = 0; i < a.length; i += SPECIES.length()) {
3084             DoubleVector av = DoubleVector.fromArray(SPECIES, a, i);
3085             VectorMask<Double> mv = av.compare(VectorOperators.LT, (long)b[i], vmask);
3086 
3087             // Check results as part of computation.
3088             for (int j = 0; j < SPECIES.length(); j++) {
3089                 Assert.assertEquals(mv.laneIsSet(j), mask[j] && (a[i + j] < (double)((long)b[i])));
3090             }
3091         }
3092     }
3093 
3094     @Test(dataProvider = "doubleCompareOpProvider")
3095     static void EQDouble256VectorTestsBroadcastSmokeTest(IntFunction<double[]> fa, IntFunction<double[]> fb) {
3096         double[] a = fa.apply(SPECIES.length());
3097         double[] b = fb.apply(SPECIES.length());
3098 
3099         for (int i = 0; i < a.length; i += SPECIES.length()) {
3100             DoubleVector av = DoubleVector.fromArray(SPECIES, a, i);
3101             VectorMask<Double> mv = av.compare(VectorOperators.EQ, b[i]);
3102 
3103             // Check results as part of computation.
3104             for (int j = 0; j < SPECIES.length(); j++) {
3105                 Assert.assertEquals(mv.laneIsSet(j), a[i + j] == b[i]);
3106             }
3107         }
3108     }
3109 
3110 
3111     @Test(dataProvider = "doubleCompareOpMaskProvider")
3112     static void EQDouble256VectorTestsBroadcastMaskedSmokeTest(IntFunction<double[]> fa,
3113                                 IntFunction<double[]> fb, IntFunction<boolean[]> fm) {
3114         double[] a = fa.apply(SPECIES.length());
3115         double[] b = fb.apply(SPECIES.length());
3116         boolean[] mask = fm.apply(SPECIES.length());
3117 
3118         VectorMask<Double> vmask = VectorMask.fromArray(SPECIES, mask, 0);
3119 
3120         for (int i = 0; i < a.length; i += SPECIES.length()) {
3121             DoubleVector av = DoubleVector.fromArray(SPECIES, a, i);
3122             VectorMask<Double> mv = av.compare(VectorOperators.EQ, b[i], vmask);
3123 
3124             // Check results as part of computation.
3125             for (int j = 0; j < SPECIES.length(); j++) {
3126                 Assert.assertEquals(mv.laneIsSet(j), mask[j] && (a[i + j] == b[i]));
3127             }
3128         }
3129     }
3130 
3131     @Test(dataProvider = "doubleCompareOpProvider")
3132     static void EQDouble256VectorTestsBroadcastLongSmokeTest(IntFunction<double[]> fa, IntFunction<double[]> fb) {
3133         double[] a = fa.apply(SPECIES.length());
3134         double[] b = fb.apply(SPECIES.length());
3135 
3136         for (int i = 0; i < a.length; i += SPECIES.length()) {
3137             DoubleVector av = DoubleVector.fromArray(SPECIES, a, i);
3138             VectorMask<Double> mv = av.compare(VectorOperators.EQ, (long)b[i]);
3139 
3140             // Check results as part of computation.
3141             for (int j = 0; j < SPECIES.length(); j++) {
3142                 Assert.assertEquals(mv.laneIsSet(j), a[i + j] == (double)((long)b[i]));
3143             }
3144         }
3145     }
3146 
3147 
3148     @Test(dataProvider = "doubleCompareOpMaskProvider")
3149     static void EQDouble256VectorTestsBroadcastLongMaskedSmokeTest(IntFunction<double[]> fa,
3150                                 IntFunction<double[]> fb, IntFunction<boolean[]> fm) {
3151         double[] a = fa.apply(SPECIES.length());
3152         double[] b = fb.apply(SPECIES.length());
3153         boolean[] mask = fm.apply(SPECIES.length());
3154 
3155         VectorMask<Double> vmask = VectorMask.fromArray(SPECIES, mask, 0);
3156 
3157         for (int i = 0; i < a.length; i += SPECIES.length()) {
3158             DoubleVector av = DoubleVector.fromArray(SPECIES, a, i);
3159             VectorMask<Double> mv = av.compare(VectorOperators.EQ, (long)b[i], vmask);
3160 
3161             // Check results as part of computation.
3162             for (int j = 0; j < SPECIES.length(); j++) {
3163                 Assert.assertEquals(mv.laneIsSet(j), mask[j] && (a[i + j] == (double)((long)b[i])));
3164             }
3165         }
3166     }
3167 
3168     static double blend(double a, double b, boolean mask) {
3169         return mask ? b : a;
3170     }
3171 
3172     @Test(dataProvider = "doubleBinaryOpMaskProvider")
3173     static void blendDouble256VectorTests(IntFunction<double[]> fa, IntFunction<double[]> fb,
3174                                           IntFunction<boolean[]> fm) {
3175         double[] a = fa.apply(SPECIES.length());
3176         double[] b = fb.apply(SPECIES.length());
3177         double[] r = fr.apply(SPECIES.length());
3178         boolean[] mask = fm.apply(SPECIES.length());
3179         VectorMask<Double> vmask = VectorMask.fromArray(SPECIES, mask, 0);
3180 
3181         for (int ic = 0; ic < INVOC_COUNT; ic++) {
3182             for (int i = 0; i < a.length; i += SPECIES.length()) {
3183                 DoubleVector av = DoubleVector.fromArray(SPECIES, a, i);
3184                 DoubleVector bv = DoubleVector.fromArray(SPECIES, b, i);
3185                 av.blend(bv, vmask).intoArray(r, i);
3186             }
3187         }
3188 
3189         assertArraysEquals(r, a, b, mask, Double256VectorTests::blend);
3190     }
3191 
3192     @Test(dataProvider = "doubleUnaryOpShuffleProvider")
3193     static void RearrangeDouble256VectorTests(IntFunction<double[]> fa,
3194                                            BiFunction<Integer,Integer,int[]> fs) {
3195         double[] a = fa.apply(SPECIES.length());
3196         int[] order = fs.apply(a.length, SPECIES.length());
3197         double[] r = fr.apply(SPECIES.length());
3198 
3199         for (int ic = 0; ic < INVOC_COUNT; ic++) {
3200             for (int i = 0; i < a.length; i += SPECIES.length()) {
3201                 DoubleVector av = DoubleVector.fromArray(SPECIES, a, i);
3202                 av.rearrange(VectorShuffle.fromArray(SPECIES, order, i)).intoArray(r, i);
3203             }
3204         }
3205 
3206         assertRearrangeArraysEquals(r, a, order, SPECIES.length());
3207     }
3208 
3209     @Test(dataProvider = "doubleUnaryOpShuffleMaskProvider")
3210     static void RearrangeDouble256VectorTestsMaskedSmokeTest(IntFunction<double[]> fa,
3211                                                           BiFunction<Integer,Integer,int[]> fs,
3212                                                           IntFunction<boolean[]> fm) {
3213         double[] a = fa.apply(SPECIES.length());
3214         int[] order = fs.apply(a.length, SPECIES.length());
3215         double[] r = fr.apply(SPECIES.length());
3216         boolean[] mask = fm.apply(SPECIES.length());
3217         VectorMask<Double> vmask = VectorMask.fromArray(SPECIES, mask, 0);
3218 
3219         for (int i = 0; i < a.length; i += SPECIES.length()) {
3220             DoubleVector av = DoubleVector.fromArray(SPECIES, a, i);
3221             av.rearrange(VectorShuffle.fromArray(SPECIES, order, i), vmask).intoArray(r, i);
3222         }
3223 
3224         assertRearrangeArraysEquals(r, a, order, mask, SPECIES.length());
3225     }
3226 
3227     @Test(dataProvider = "doubleUnaryOpMaskProvider")
3228     static void compressDouble256VectorTests(IntFunction<double[]> fa,
3229                                                 IntFunction<boolean[]> fm) {
3230         double[] a = fa.apply(SPECIES.length());
3231         double[] r = fr.apply(SPECIES.length());
3232         boolean[] mask = fm.apply(SPECIES.length());
3233         VectorMask<Double> vmask = VectorMask.fromArray(SPECIES, mask, 0);
3234 
3235         for (int ic = 0; ic < INVOC_COUNT; ic++) {
3236             for (int i = 0; i < a.length; i += SPECIES.length()) {
3237                 DoubleVector av = DoubleVector.fromArray(SPECIES, a, i);
3238                 av.compress(vmask).intoArray(r, i);
3239             }
3240         }
3241 
3242         assertcompressArraysEquals(r, a, mask, SPECIES.length());
3243     }
3244 
3245     @Test(dataProvider = "doubleUnaryOpMaskProvider")
3246     static void expandDouble256VectorTests(IntFunction<double[]> fa,
3247                                                 IntFunction<boolean[]> fm) {
3248         double[] a = fa.apply(SPECIES.length());
3249         double[] r = fr.apply(SPECIES.length());
3250         boolean[] mask = fm.apply(SPECIES.length());
3251         VectorMask<Double> vmask = VectorMask.fromArray(SPECIES, mask, 0);
3252 
3253         for (int ic = 0; ic < INVOC_COUNT; ic++) {
3254             for (int i = 0; i < a.length; i += SPECIES.length()) {
3255                 DoubleVector av = DoubleVector.fromArray(SPECIES, a, i);
3256                 av.expand(vmask).intoArray(r, i);
3257             }
3258         }
3259 
3260         assertexpandArraysEquals(r, a, mask, SPECIES.length());
3261     }
3262     @Test(dataProvider = "doubleUnaryOpProvider")
3263     static void getDouble256VectorTests(IntFunction<double[]> fa) {
3264         double[] a = fa.apply(SPECIES.length());
3265         double[] r = fr.apply(SPECIES.length());
3266 
3267         for (int ic = 0; ic < INVOC_COUNT; ic++) {
3268             for (int i = 0; i < a.length; i += SPECIES.length()) {
3269                 DoubleVector av = DoubleVector.fromArray(SPECIES, a, i);
3270                 int num_lanes = SPECIES.length();
3271                 // Manually unroll because full unroll happens after intrinsification.
3272                 // Unroll is needed because get intrinsic requires for index to be a known constant.
3273                 if (num_lanes == 1) {
3274                     r[i]=av.lane(0);
3275                 } else if (num_lanes == 2) {
3276                     r[i]=av.lane(0);
3277                     r[i+1]=av.lane(1);
3278                 } else if (num_lanes == 4) {
3279                     r[i]=av.lane(0);
3280                     r[i+1]=av.lane(1);
3281                     r[i+2]=av.lane(2);
3282                     r[i+3]=av.lane(3);
3283                 } else if (num_lanes == 8) {
3284                     r[i]=av.lane(0);
3285                     r[i+1]=av.lane(1);
3286                     r[i+2]=av.lane(2);
3287                     r[i+3]=av.lane(3);
3288                     r[i+4]=av.lane(4);
3289                     r[i+5]=av.lane(5);
3290                     r[i+6]=av.lane(6);
3291                     r[i+7]=av.lane(7);
3292                 } else if (num_lanes == 16) {
3293                     r[i]=av.lane(0);
3294                     r[i+1]=av.lane(1);
3295                     r[i+2]=av.lane(2);
3296                     r[i+3]=av.lane(3);
3297                     r[i+4]=av.lane(4);
3298                     r[i+5]=av.lane(5);
3299                     r[i+6]=av.lane(6);
3300                     r[i+7]=av.lane(7);
3301                     r[i+8]=av.lane(8);
3302                     r[i+9]=av.lane(9);
3303                     r[i+10]=av.lane(10);
3304                     r[i+11]=av.lane(11);
3305                     r[i+12]=av.lane(12);
3306                     r[i+13]=av.lane(13);
3307                     r[i+14]=av.lane(14);
3308                     r[i+15]=av.lane(15);
3309                 } else if (num_lanes == 32) {
3310                     r[i]=av.lane(0);
3311                     r[i+1]=av.lane(1);
3312                     r[i+2]=av.lane(2);
3313                     r[i+3]=av.lane(3);
3314                     r[i+4]=av.lane(4);
3315                     r[i+5]=av.lane(5);
3316                     r[i+6]=av.lane(6);
3317                     r[i+7]=av.lane(7);
3318                     r[i+8]=av.lane(8);
3319                     r[i+9]=av.lane(9);
3320                     r[i+10]=av.lane(10);
3321                     r[i+11]=av.lane(11);
3322                     r[i+12]=av.lane(12);
3323                     r[i+13]=av.lane(13);
3324                     r[i+14]=av.lane(14);
3325                     r[i+15]=av.lane(15);
3326                     r[i+16]=av.lane(16);
3327                     r[i+17]=av.lane(17);
3328                     r[i+18]=av.lane(18);
3329                     r[i+19]=av.lane(19);
3330                     r[i+20]=av.lane(20);
3331                     r[i+21]=av.lane(21);
3332                     r[i+22]=av.lane(22);
3333                     r[i+23]=av.lane(23);
3334                     r[i+24]=av.lane(24);
3335                     r[i+25]=av.lane(25);
3336                     r[i+26]=av.lane(26);
3337                     r[i+27]=av.lane(27);
3338                     r[i+28]=av.lane(28);
3339                     r[i+29]=av.lane(29);
3340                     r[i+30]=av.lane(30);
3341                     r[i+31]=av.lane(31);
3342                 } else if (num_lanes == 64) {
3343                     r[i]=av.lane(0);
3344                     r[i+1]=av.lane(1);
3345                     r[i+2]=av.lane(2);
3346                     r[i+3]=av.lane(3);
3347                     r[i+4]=av.lane(4);
3348                     r[i+5]=av.lane(5);
3349                     r[i+6]=av.lane(6);
3350                     r[i+7]=av.lane(7);
3351                     r[i+8]=av.lane(8);
3352                     r[i+9]=av.lane(9);
3353                     r[i+10]=av.lane(10);
3354                     r[i+11]=av.lane(11);
3355                     r[i+12]=av.lane(12);
3356                     r[i+13]=av.lane(13);
3357                     r[i+14]=av.lane(14);
3358                     r[i+15]=av.lane(15);
3359                     r[i+16]=av.lane(16);
3360                     r[i+17]=av.lane(17);
3361                     r[i+18]=av.lane(18);
3362                     r[i+19]=av.lane(19);
3363                     r[i+20]=av.lane(20);
3364                     r[i+21]=av.lane(21);
3365                     r[i+22]=av.lane(22);
3366                     r[i+23]=av.lane(23);
3367                     r[i+24]=av.lane(24);
3368                     r[i+25]=av.lane(25);
3369                     r[i+26]=av.lane(26);
3370                     r[i+27]=av.lane(27);
3371                     r[i+28]=av.lane(28);
3372                     r[i+29]=av.lane(29);
3373                     r[i+30]=av.lane(30);
3374                     r[i+31]=av.lane(31);
3375                     r[i+32]=av.lane(32);
3376                     r[i+33]=av.lane(33);
3377                     r[i+34]=av.lane(34);
3378                     r[i+35]=av.lane(35);
3379                     r[i+36]=av.lane(36);
3380                     r[i+37]=av.lane(37);
3381                     r[i+38]=av.lane(38);
3382                     r[i+39]=av.lane(39);
3383                     r[i+40]=av.lane(40);
3384                     r[i+41]=av.lane(41);
3385                     r[i+42]=av.lane(42);
3386                     r[i+43]=av.lane(43);
3387                     r[i+44]=av.lane(44);
3388                     r[i+45]=av.lane(45);
3389                     r[i+46]=av.lane(46);
3390                     r[i+47]=av.lane(47);
3391                     r[i+48]=av.lane(48);
3392                     r[i+49]=av.lane(49);
3393                     r[i+50]=av.lane(50);
3394                     r[i+51]=av.lane(51);
3395                     r[i+52]=av.lane(52);
3396                     r[i+53]=av.lane(53);
3397                     r[i+54]=av.lane(54);
3398                     r[i+55]=av.lane(55);
3399                     r[i+56]=av.lane(56);
3400                     r[i+57]=av.lane(57);
3401                     r[i+58]=av.lane(58);
3402                     r[i+59]=av.lane(59);
3403                     r[i+60]=av.lane(60);
3404                     r[i+61]=av.lane(61);
3405                     r[i+62]=av.lane(62);
3406                     r[i+63]=av.lane(63);
3407                 } else {
3408                     for (int j = 0; j < SPECIES.length(); j++) {
3409                         r[i+j]=av.lane(j);
3410                     }
3411                 }
3412             }
3413         }
3414 
3415         assertArraysEquals(r, a, Double256VectorTests::get);
3416     }
3417 
3418     @Test(dataProvider = "doubleUnaryOpProvider")
3419     static void BroadcastDouble256VectorTests(IntFunction<double[]> fa) {
3420         double[] a = fa.apply(SPECIES.length());
3421         double[] r = new double[a.length];
3422 
3423         for (int ic = 0; ic < INVOC_COUNT; ic++) {
3424             for (int i = 0; i < a.length; i += SPECIES.length()) {
3425                 DoubleVector.broadcast(SPECIES, a[i]).intoArray(r, i);
3426             }
3427         }
3428 
3429         assertBroadcastArraysEquals(r, a);
3430     }
3431 
3432 
3433 
3434 
3435 
3436     @Test(dataProvider = "doubleUnaryOpProvider")
3437     static void ZeroDouble256VectorTests(IntFunction<double[]> fa) {
3438         double[] a = fa.apply(SPECIES.length());
3439         double[] r = new double[a.length];
3440 
3441         for (int ic = 0; ic < INVOC_COUNT; ic++) {
3442             for (int i = 0; i < a.length; i += SPECIES.length()) {
3443                 DoubleVector.zero(SPECIES).intoArray(a, i);
3444             }
3445         }
3446 
3447         Assert.assertEquals(a, r);
3448     }
3449 
3450 
3451 
3452 
3453     static double[] sliceUnary(double[] a, int origin, int idx) {
3454         double[] res = new double[SPECIES.length()];
3455         for (int i = 0; i < SPECIES.length(); i++){
3456             if(i+origin < SPECIES.length())
3457                 res[i] = a[idx+i+origin];
3458             else
3459                 res[i] = (double)0;
3460         }
3461         return res;
3462     }
3463 
3464     @Test(dataProvider = "doubleUnaryOpProvider")
3465     static void sliceUnaryDouble256VectorTests(IntFunction<double[]> fa) {
3466         double[] a = fa.apply(SPECIES.length());
3467         double[] r = new double[a.length];
3468         int origin = (new java.util.Random()).nextInt(SPECIES.length());
3469         for (int ic = 0; ic < INVOC_COUNT; ic++) {
3470             for (int i = 0; i < a.length; i += SPECIES.length()) {
3471                 DoubleVector av = DoubleVector.fromArray(SPECIES, a, i);
3472                 av.slice(origin).intoArray(r, i);
3473             }
3474         }
3475 
3476         assertArraysEquals(r, a, origin, Double256VectorTests::sliceUnary);
3477     }
3478     static double[] sliceBinary(double[] a, double[] b, int origin, int idx) {
3479         double[] res = new double[SPECIES.length()];
3480         for (int i = 0, j = 0; i < SPECIES.length(); i++){
3481             if(i+origin < SPECIES.length())
3482                 res[i] = a[idx+i+origin];
3483             else {
3484                 res[i] = b[idx+j];
3485                 j++;
3486             }
3487         }
3488         return res;
3489     }
3490 
3491     @Test(dataProvider = "doubleBinaryOpProvider")
3492     static void sliceBinaryDouble256VectorTestsBinary(IntFunction<double[]> fa, IntFunction<double[]> fb) {
3493         double[] a = fa.apply(SPECIES.length());
3494         double[] b = fb.apply(SPECIES.length());
3495         double[] r = new double[a.length];
3496         int origin = (new java.util.Random()).nextInt(SPECIES.length());
3497         for (int ic = 0; ic < INVOC_COUNT; ic++) {
3498             for (int i = 0; i < a.length; i += SPECIES.length()) {
3499                 DoubleVector av = DoubleVector.fromArray(SPECIES, a, i);
3500                 DoubleVector bv = DoubleVector.fromArray(SPECIES, b, i);
3501                 av.slice(origin, bv).intoArray(r, i);
3502             }
3503         }
3504 
3505         assertArraysEquals(r, a, b, origin, Double256VectorTests::sliceBinary);
3506     }
3507     static double[] slice(double[] a, double[] b, int origin, boolean[] mask, int idx) {
3508         double[] res = new double[SPECIES.length()];
3509         for (int i = 0, j = 0; i < SPECIES.length(); i++){
3510             if(i+origin < SPECIES.length())
3511                 res[i] = mask[i] ? a[idx+i+origin] : (double)0;
3512             else {
3513                 res[i] = mask[i] ? b[idx+j] : (double)0;
3514                 j++;
3515             }
3516         }
3517         return res;
3518     }
3519 
3520     @Test(dataProvider = "doubleBinaryOpMaskProvider")
3521     static void sliceDouble256VectorTestsMasked(IntFunction<double[]> fa, IntFunction<double[]> fb,
3522     IntFunction<boolean[]> fm) {
3523         double[] a = fa.apply(SPECIES.length());
3524         double[] b = fb.apply(SPECIES.length());
3525         boolean[] mask = fm.apply(SPECIES.length());
3526         VectorMask<Double> vmask = VectorMask.fromArray(SPECIES, mask, 0);
3527 
3528         double[] r = new double[a.length];
3529         int origin = (new java.util.Random()).nextInt(SPECIES.length());
3530         for (int ic = 0; ic < INVOC_COUNT; ic++) {
3531             for (int i = 0; i < a.length; i += SPECIES.length()) {
3532                 DoubleVector av = DoubleVector.fromArray(SPECIES, a, i);
3533                 DoubleVector bv = DoubleVector.fromArray(SPECIES, b, i);
3534                 av.slice(origin, bv, vmask).intoArray(r, i);
3535             }
3536         }
3537 
3538         assertArraysEquals(r, a, b, origin, mask, Double256VectorTests::slice);
3539     }
3540     static double[] unsliceUnary(double[] a, int origin, int idx) {
3541         double[] res = new double[SPECIES.length()];
3542         for (int i = 0, j = 0; i < SPECIES.length(); i++){
3543             if(i < origin)
3544                 res[i] = (double)0;
3545             else {
3546                 res[i] = a[idx+j];
3547                 j++;
3548             }
3549         }
3550         return res;
3551     }
3552 
3553     @Test(dataProvider = "doubleUnaryOpProvider")
3554     static void unsliceUnaryDouble256VectorTests(IntFunction<double[]> fa) {
3555         double[] a = fa.apply(SPECIES.length());
3556         double[] r = new double[a.length];
3557         int origin = (new java.util.Random()).nextInt(SPECIES.length());
3558         for (int ic = 0; ic < INVOC_COUNT; ic++) {
3559             for (int i = 0; i < a.length; i += SPECIES.length()) {
3560                 DoubleVector av = DoubleVector.fromArray(SPECIES, a, i);
3561                 av.unslice(origin).intoArray(r, i);
3562             }
3563         }
3564 
3565         assertArraysEquals(r, a, origin, Double256VectorTests::unsliceUnary);
3566     }
3567     static double[] unsliceBinary(double[] a, double[] b, int origin, int part, int idx) {
3568         double[] res = new double[SPECIES.length()];
3569         for (int i = 0, j = 0; i < SPECIES.length(); i++){
3570             if (part == 0) {
3571                 if (i < origin)
3572                     res[i] = b[idx+i];
3573                 else {
3574                     res[i] = a[idx+j];
3575                     j++;
3576                 }
3577             } else if (part == 1) {
3578                 if (i < origin)
3579                     res[i] = a[idx+SPECIES.length()-origin+i];
3580                 else {
3581                     res[i] = b[idx+origin+j];
3582                     j++;
3583                 }
3584             }
3585         }
3586         return res;
3587     }
3588 
3589     @Test(dataProvider = "doubleBinaryOpProvider")
3590     static void unsliceBinaryDouble256VectorTestsBinary(IntFunction<double[]> fa, IntFunction<double[]> fb) {
3591         double[] a = fa.apply(SPECIES.length());
3592         double[] b = fb.apply(SPECIES.length());
3593         double[] r = new double[a.length];
3594         int origin = (new java.util.Random()).nextInt(SPECIES.length());
3595         int part = (new java.util.Random()).nextInt(2);
3596         for (int ic = 0; ic < INVOC_COUNT; ic++) {
3597             for (int i = 0; i < a.length; i += SPECIES.length()) {
3598                 DoubleVector av = DoubleVector.fromArray(SPECIES, a, i);
3599                 DoubleVector bv = DoubleVector.fromArray(SPECIES, b, i);
3600                 av.unslice(origin, bv, part).intoArray(r, i);
3601             }
3602         }
3603 
3604         assertArraysEquals(r, a, b, origin, part, Double256VectorTests::unsliceBinary);
3605     }
3606     static double[] unslice(double[] a, double[] b, int origin, int part, boolean[] mask, int idx) {
3607         double[] res = new double[SPECIES.length()];
3608         for (int i = 0, j = 0; i < SPECIES.length(); i++){
3609             if(i+origin < SPECIES.length())
3610                 res[i] = b[idx+i+origin];
3611             else {
3612                 res[i] = b[idx+j];
3613                 j++;
3614             }
3615         }
3616         for (int i = 0; i < SPECIES.length(); i++){
3617             res[i] = mask[i] ? a[idx+i] : res[i];
3618         }
3619         double[] res1 = new double[SPECIES.length()];
3620         if (part == 0) {
3621             for (int i = 0, j = 0; i < SPECIES.length(); i++){
3622                 if (i < origin)
3623                     res1[i] = b[idx+i];
3624                 else {
3625                    res1[i] = res[j];
3626                    j++;
3627                 }
3628             }
3629         } else if (part == 1) {
3630             for (int i = 0, j = 0; i < SPECIES.length(); i++){
3631                 if (i < origin)
3632                     res1[i] = res[SPECIES.length()-origin+i];
3633                 else {
3634                     res1[i] = b[idx+origin+j];
3635                     j++;
3636                 }
3637             }
3638         }
3639         return res1;
3640     }
3641 
3642     @Test(dataProvider = "doubleBinaryOpMaskProvider")
3643     static void unsliceDouble256VectorTestsMasked(IntFunction<double[]> fa, IntFunction<double[]> fb,
3644     IntFunction<boolean[]> fm) {
3645         double[] a = fa.apply(SPECIES.length());
3646         double[] b = fb.apply(SPECIES.length());
3647         boolean[] mask = fm.apply(SPECIES.length());
3648         VectorMask<Double> vmask = VectorMask.fromArray(SPECIES, mask, 0);
3649         double[] r = new double[a.length];
3650         int origin = (new java.util.Random()).nextInt(SPECIES.length());
3651         int part = (new java.util.Random()).nextInt(2);
3652         for (int ic = 0; ic < INVOC_COUNT; ic++) {
3653             for (int i = 0; i < a.length; i += SPECIES.length()) {
3654                 DoubleVector av = DoubleVector.fromArray(SPECIES, a, i);
3655                 DoubleVector bv = DoubleVector.fromArray(SPECIES, b, i);
3656                 av.unslice(origin, bv, part, vmask).intoArray(r, i);
3657             }
3658         }
3659 
3660         assertArraysEquals(r, a, b, origin, part, mask, Double256VectorTests::unslice);
3661     }
3662 
3663     static double SIN(double a) {
3664         return (double)(Math.sin((double)a));
3665     }
3666 
3667     static double strictSIN(double a) {
3668         return (double)(StrictMath.sin((double)a));
3669     }
3670 
3671     @Test(dataProvider = "doubleUnaryOpProvider")
3672     static void SINDouble256VectorTests(IntFunction<double[]> fa) {
3673         double[] a = fa.apply(SPECIES.length());
3674         double[] r = fr.apply(SPECIES.length());
3675 
3676         for (int ic = 0; ic < INVOC_COUNT; ic++) {
3677             for (int i = 0; i < a.length; i += SPECIES.length()) {
3678                 DoubleVector av = DoubleVector.fromArray(SPECIES, a, i);
3679                 av.lanewise(VectorOperators.SIN).intoArray(r, i);
3680             }
3681         }
3682 
3683         assertArraysEqualsWithinOneUlp(r, a, Double256VectorTests::SIN, Double256VectorTests::strictSIN);
3684     }
3685 
3686 
3687     static double EXP(double a) {
3688         return (double)(Math.exp((double)a));
3689     }
3690 
3691     static double strictEXP(double a) {
3692         return (double)(StrictMath.exp((double)a));
3693     }
3694 
3695     @Test(dataProvider = "doubleUnaryOpProvider")
3696     static void EXPDouble256VectorTests(IntFunction<double[]> fa) {
3697         double[] a = fa.apply(SPECIES.length());
3698         double[] r = fr.apply(SPECIES.length());
3699 
3700         for (int ic = 0; ic < INVOC_COUNT; ic++) {
3701             for (int i = 0; i < a.length; i += SPECIES.length()) {
3702                 DoubleVector av = DoubleVector.fromArray(SPECIES, a, i);
3703                 av.lanewise(VectorOperators.EXP).intoArray(r, i);
3704             }
3705         }
3706 
3707         assertArraysEqualsWithinOneUlp(r, a, Double256VectorTests::EXP, Double256VectorTests::strictEXP);
3708     }
3709 
3710 
3711     static double LOG1P(double a) {
3712         return (double)(Math.log1p((double)a));
3713     }
3714 
3715     static double strictLOG1P(double a) {
3716         return (double)(StrictMath.log1p((double)a));
3717     }
3718 
3719     @Test(dataProvider = "doubleUnaryOpProvider")
3720     static void LOG1PDouble256VectorTests(IntFunction<double[]> fa) {
3721         double[] a = fa.apply(SPECIES.length());
3722         double[] r = fr.apply(SPECIES.length());
3723 
3724         for (int ic = 0; ic < INVOC_COUNT; ic++) {
3725             for (int i = 0; i < a.length; i += SPECIES.length()) {
3726                 DoubleVector av = DoubleVector.fromArray(SPECIES, a, i);
3727                 av.lanewise(VectorOperators.LOG1P).intoArray(r, i);
3728             }
3729         }
3730 
3731         assertArraysEqualsWithinOneUlp(r, a, Double256VectorTests::LOG1P, Double256VectorTests::strictLOG1P);
3732     }
3733 
3734 
3735     static double LOG(double a) {
3736         return (double)(Math.log((double)a));
3737     }
3738 
3739     static double strictLOG(double a) {
3740         return (double)(StrictMath.log((double)a));
3741     }
3742 
3743     @Test(dataProvider = "doubleUnaryOpProvider")
3744     static void LOGDouble256VectorTests(IntFunction<double[]> fa) {
3745         double[] a = fa.apply(SPECIES.length());
3746         double[] r = fr.apply(SPECIES.length());
3747 
3748         for (int ic = 0; ic < INVOC_COUNT; ic++) {
3749             for (int i = 0; i < a.length; i += SPECIES.length()) {
3750                 DoubleVector av = DoubleVector.fromArray(SPECIES, a, i);
3751                 av.lanewise(VectorOperators.LOG).intoArray(r, i);
3752             }
3753         }
3754 
3755         assertArraysEqualsWithinOneUlp(r, a, Double256VectorTests::LOG, Double256VectorTests::strictLOG);
3756     }
3757 
3758 
3759     static double LOG10(double a) {
3760         return (double)(Math.log10((double)a));
3761     }
3762 
3763     static double strictLOG10(double a) {
3764         return (double)(StrictMath.log10((double)a));
3765     }
3766 
3767     @Test(dataProvider = "doubleUnaryOpProvider")
3768     static void LOG10Double256VectorTests(IntFunction<double[]> fa) {
3769         double[] a = fa.apply(SPECIES.length());
3770         double[] r = fr.apply(SPECIES.length());
3771 
3772         for (int ic = 0; ic < INVOC_COUNT; ic++) {
3773             for (int i = 0; i < a.length; i += SPECIES.length()) {
3774                 DoubleVector av = DoubleVector.fromArray(SPECIES, a, i);
3775                 av.lanewise(VectorOperators.LOG10).intoArray(r, i);
3776             }
3777         }
3778 
3779         assertArraysEqualsWithinOneUlp(r, a, Double256VectorTests::LOG10, Double256VectorTests::strictLOG10);
3780     }
3781 
3782 
3783     static double EXPM1(double a) {
3784         return (double)(Math.expm1((double)a));
3785     }
3786 
3787     static double strictEXPM1(double a) {
3788         return (double)(StrictMath.expm1((double)a));
3789     }
3790 
3791     @Test(dataProvider = "doubleUnaryOpProvider")
3792     static void EXPM1Double256VectorTests(IntFunction<double[]> fa) {
3793         double[] a = fa.apply(SPECIES.length());
3794         double[] r = fr.apply(SPECIES.length());
3795 
3796         for (int ic = 0; ic < INVOC_COUNT; ic++) {
3797             for (int i = 0; i < a.length; i += SPECIES.length()) {
3798                 DoubleVector av = DoubleVector.fromArray(SPECIES, a, i);
3799                 av.lanewise(VectorOperators.EXPM1).intoArray(r, i);
3800             }
3801         }
3802 
3803         assertArraysEqualsWithinOneUlp(r, a, Double256VectorTests::EXPM1, Double256VectorTests::strictEXPM1);
3804     }
3805 
3806 
3807     static double COS(double a) {
3808         return (double)(Math.cos((double)a));
3809     }
3810 
3811     static double strictCOS(double a) {
3812         return (double)(StrictMath.cos((double)a));
3813     }
3814 
3815     @Test(dataProvider = "doubleUnaryOpProvider")
3816     static void COSDouble256VectorTests(IntFunction<double[]> fa) {
3817         double[] a = fa.apply(SPECIES.length());
3818         double[] r = fr.apply(SPECIES.length());
3819 
3820         for (int ic = 0; ic < INVOC_COUNT; ic++) {
3821             for (int i = 0; i < a.length; i += SPECIES.length()) {
3822                 DoubleVector av = DoubleVector.fromArray(SPECIES, a, i);
3823                 av.lanewise(VectorOperators.COS).intoArray(r, i);
3824             }
3825         }
3826 
3827         assertArraysEqualsWithinOneUlp(r, a, Double256VectorTests::COS, Double256VectorTests::strictCOS);
3828     }
3829 
3830 
3831     static double TAN(double a) {
3832         return (double)(Math.tan((double)a));
3833     }
3834 
3835     static double strictTAN(double a) {
3836         return (double)(StrictMath.tan((double)a));
3837     }
3838 
3839     @Test(dataProvider = "doubleUnaryOpProvider")
3840     static void TANDouble256VectorTests(IntFunction<double[]> fa) {
3841         double[] a = fa.apply(SPECIES.length());
3842         double[] r = fr.apply(SPECIES.length());
3843 
3844         for (int ic = 0; ic < INVOC_COUNT; ic++) {
3845             for (int i = 0; i < a.length; i += SPECIES.length()) {
3846                 DoubleVector av = DoubleVector.fromArray(SPECIES, a, i);
3847                 av.lanewise(VectorOperators.TAN).intoArray(r, i);
3848             }
3849         }
3850 
3851         assertArraysEqualsWithinOneUlp(r, a, Double256VectorTests::TAN, Double256VectorTests::strictTAN);
3852     }
3853 
3854 
3855     static double SINH(double a) {
3856         return (double)(Math.sinh((double)a));
3857     }
3858 
3859     static double strictSINH(double a) {
3860         return (double)(StrictMath.sinh((double)a));
3861     }
3862 
3863     @Test(dataProvider = "doubleUnaryOpProvider")
3864     static void SINHDouble256VectorTests(IntFunction<double[]> fa) {
3865         double[] a = fa.apply(SPECIES.length());
3866         double[] r = fr.apply(SPECIES.length());
3867 
3868         for (int ic = 0; ic < INVOC_COUNT; ic++) {
3869             for (int i = 0; i < a.length; i += SPECIES.length()) {
3870                 DoubleVector av = DoubleVector.fromArray(SPECIES, a, i);
3871                 av.lanewise(VectorOperators.SINH).intoArray(r, i);
3872             }
3873         }
3874 
3875         assertArraysEqualsWithinOneUlp(r, a, Double256VectorTests::SINH, Double256VectorTests::strictSINH);
3876     }
3877 
3878 
3879     static double COSH(double a) {
3880         return (double)(Math.cosh((double)a));
3881     }
3882 
3883     static double strictCOSH(double a) {
3884         return (double)(StrictMath.cosh((double)a));
3885     }
3886 
3887     @Test(dataProvider = "doubleUnaryOpProvider")
3888     static void COSHDouble256VectorTests(IntFunction<double[]> fa) {
3889         double[] a = fa.apply(SPECIES.length());
3890         double[] r = fr.apply(SPECIES.length());
3891 
3892         for (int ic = 0; ic < INVOC_COUNT; ic++) {
3893             for (int i = 0; i < a.length; i += SPECIES.length()) {
3894                 DoubleVector av = DoubleVector.fromArray(SPECIES, a, i);
3895                 av.lanewise(VectorOperators.COSH).intoArray(r, i);
3896             }
3897         }
3898 
3899         assertArraysEqualsWithinOneUlp(r, a, Double256VectorTests::COSH, Double256VectorTests::strictCOSH);
3900     }
3901 
3902 
3903     static double TANH(double a) {
3904         return (double)(Math.tanh((double)a));
3905     }
3906 
3907     static double strictTANH(double a) {
3908         return (double)(StrictMath.tanh((double)a));
3909     }
3910 
3911     @Test(dataProvider = "doubleUnaryOpProvider")
3912     static void TANHDouble256VectorTests(IntFunction<double[]> fa) {
3913         double[] a = fa.apply(SPECIES.length());
3914         double[] r = fr.apply(SPECIES.length());
3915 
3916         for (int ic = 0; ic < INVOC_COUNT; ic++) {
3917             for (int i = 0; i < a.length; i += SPECIES.length()) {
3918                 DoubleVector av = DoubleVector.fromArray(SPECIES, a, i);
3919                 av.lanewise(VectorOperators.TANH).intoArray(r, i);
3920             }
3921         }
3922 
3923         assertArraysEqualsWithinOneUlp(r, a, Double256VectorTests::TANH, Double256VectorTests::strictTANH);
3924     }
3925 
3926 
3927     static double ASIN(double a) {
3928         return (double)(Math.asin((double)a));
3929     }
3930 
3931     static double strictASIN(double a) {
3932         return (double)(StrictMath.asin((double)a));
3933     }
3934 
3935     @Test(dataProvider = "doubleUnaryOpProvider")
3936     static void ASINDouble256VectorTests(IntFunction<double[]> fa) {
3937         double[] a = fa.apply(SPECIES.length());
3938         double[] r = fr.apply(SPECIES.length());
3939 
3940         for (int ic = 0; ic < INVOC_COUNT; ic++) {
3941             for (int i = 0; i < a.length; i += SPECIES.length()) {
3942                 DoubleVector av = DoubleVector.fromArray(SPECIES, a, i);
3943                 av.lanewise(VectorOperators.ASIN).intoArray(r, i);
3944             }
3945         }
3946 
3947         assertArraysEqualsWithinOneUlp(r, a, Double256VectorTests::ASIN, Double256VectorTests::strictASIN);
3948     }
3949 
3950 
3951     static double ACOS(double a) {
3952         return (double)(Math.acos((double)a));
3953     }
3954 
3955     static double strictACOS(double a) {
3956         return (double)(StrictMath.acos((double)a));
3957     }
3958 
3959     @Test(dataProvider = "doubleUnaryOpProvider")
3960     static void ACOSDouble256VectorTests(IntFunction<double[]> fa) {
3961         double[] a = fa.apply(SPECIES.length());
3962         double[] r = fr.apply(SPECIES.length());
3963 
3964         for (int ic = 0; ic < INVOC_COUNT; ic++) {
3965             for (int i = 0; i < a.length; i += SPECIES.length()) {
3966                 DoubleVector av = DoubleVector.fromArray(SPECIES, a, i);
3967                 av.lanewise(VectorOperators.ACOS).intoArray(r, i);
3968             }
3969         }
3970 
3971         assertArraysEqualsWithinOneUlp(r, a, Double256VectorTests::ACOS, Double256VectorTests::strictACOS);
3972     }
3973 
3974 
3975     static double ATAN(double a) {
3976         return (double)(Math.atan((double)a));
3977     }
3978 
3979     static double strictATAN(double a) {
3980         return (double)(StrictMath.atan((double)a));
3981     }
3982 
3983     @Test(dataProvider = "doubleUnaryOpProvider")
3984     static void ATANDouble256VectorTests(IntFunction<double[]> fa) {
3985         double[] a = fa.apply(SPECIES.length());
3986         double[] r = fr.apply(SPECIES.length());
3987 
3988         for (int ic = 0; ic < INVOC_COUNT; ic++) {
3989             for (int i = 0; i < a.length; i += SPECIES.length()) {
3990                 DoubleVector av = DoubleVector.fromArray(SPECIES, a, i);
3991                 av.lanewise(VectorOperators.ATAN).intoArray(r, i);
3992             }
3993         }
3994 
3995         assertArraysEqualsWithinOneUlp(r, a, Double256VectorTests::ATAN, Double256VectorTests::strictATAN);
3996     }
3997 
3998 
3999     static double CBRT(double a) {
4000         return (double)(Math.cbrt((double)a));
4001     }
4002 
4003     static double strictCBRT(double a) {
4004         return (double)(StrictMath.cbrt((double)a));
4005     }
4006 
4007     @Test(dataProvider = "doubleUnaryOpProvider")
4008     static void CBRTDouble256VectorTests(IntFunction<double[]> fa) {
4009         double[] a = fa.apply(SPECIES.length());
4010         double[] r = fr.apply(SPECIES.length());
4011 
4012         for (int ic = 0; ic < INVOC_COUNT; ic++) {
4013             for (int i = 0; i < a.length; i += SPECIES.length()) {
4014                 DoubleVector av = DoubleVector.fromArray(SPECIES, a, i);
4015                 av.lanewise(VectorOperators.CBRT).intoArray(r, i);
4016             }
4017         }
4018 
4019         assertArraysEqualsWithinOneUlp(r, a, Double256VectorTests::CBRT, Double256VectorTests::strictCBRT);
4020     }
4021 
4022 
4023     static double HYPOT(double a, double b) {
4024         return (double)(Math.hypot((double)a, (double)b));
4025     }
4026 
4027     static double strictHYPOT(double a, double b) {
4028         return (double)(StrictMath.hypot((double)a, (double)b));
4029     }
4030 
4031     @Test(dataProvider = "doubleBinaryOpProvider")
4032     static void HYPOTDouble256VectorTests(IntFunction<double[]> fa, IntFunction<double[]> fb) {
4033         double[] a = fa.apply(SPECIES.length());
4034         double[] b = fb.apply(SPECIES.length());
4035         double[] r = fr.apply(SPECIES.length());
4036 
4037         for (int ic = 0; ic < INVOC_COUNT; ic++) {
4038             for (int i = 0; i < a.length; i += SPECIES.length()) {
4039                 DoubleVector av = DoubleVector.fromArray(SPECIES, a, i);
4040                 DoubleVector bv = DoubleVector.fromArray(SPECIES, b, i);
4041                 av.lanewise(VectorOperators.HYPOT, bv).intoArray(r, i);
4042             }
4043         }
4044 
4045         assertArraysEqualsWithinOneUlp(r, a, b, Double256VectorTests::HYPOT, Double256VectorTests::strictHYPOT);
4046     }
4047 
4048 
4049 
4050     static double POW(double a, double b) {
4051         return (double)(Math.pow((double)a, (double)b));
4052     }
4053 
4054     static double strictPOW(double a, double b) {
4055         return (double)(StrictMath.pow((double)a, (double)b));
4056     }
4057 
4058     @Test(dataProvider = "doubleBinaryOpProvider")
4059     static void POWDouble256VectorTests(IntFunction<double[]> fa, IntFunction<double[]> fb) {
4060         double[] a = fa.apply(SPECIES.length());
4061         double[] b = fb.apply(SPECIES.length());
4062         double[] r = fr.apply(SPECIES.length());
4063 
4064         for (int ic = 0; ic < INVOC_COUNT; ic++) {
4065             for (int i = 0; i < a.length; i += SPECIES.length()) {
4066                 DoubleVector av = DoubleVector.fromArray(SPECIES, a, i);
4067                 DoubleVector bv = DoubleVector.fromArray(SPECIES, b, i);
4068                 av.lanewise(VectorOperators.POW, bv).intoArray(r, i);
4069             }
4070         }
4071 
4072         assertArraysEqualsWithinOneUlp(r, a, b, Double256VectorTests::POW, Double256VectorTests::strictPOW);
4073     }
4074 
4075     static double pow(double a, double b) {
4076         return (double)(Math.pow((double)a, (double)b));
4077     }
4078 
4079     static double strictpow(double a, double b) {
4080         return (double)(StrictMath.pow((double)a, (double)b));
4081     }
4082 
4083     @Test(dataProvider = "doubleBinaryOpProvider")
4084     static void powDouble256VectorTests(IntFunction<double[]> fa, IntFunction<double[]> fb) {
4085         double[] a = fa.apply(SPECIES.length());
4086         double[] b = fb.apply(SPECIES.length());
4087         double[] r = fr.apply(SPECIES.length());
4088 
4089         for (int ic = 0; ic < INVOC_COUNT; ic++) {
4090             for (int i = 0; i < a.length; i += SPECIES.length()) {
4091                 DoubleVector av = DoubleVector.fromArray(SPECIES, a, i);
4092                 DoubleVector bv = DoubleVector.fromArray(SPECIES, b, i);
4093                 av.pow(bv).intoArray(r, i);
4094             }
4095         }
4096 
4097         assertArraysEqualsWithinOneUlp(r, a, b, Double256VectorTests::pow, Double256VectorTests::strictpow);
4098     }
4099 
4100 
4101 
4102     static double ATAN2(double a, double b) {
4103         return (double)(Math.atan2((double)a, (double)b));
4104     }
4105 
4106     static double strictATAN2(double a, double b) {
4107         return (double)(StrictMath.atan2((double)a, (double)b));
4108     }
4109 
4110     @Test(dataProvider = "doubleBinaryOpProvider")
4111     static void ATAN2Double256VectorTests(IntFunction<double[]> fa, IntFunction<double[]> fb) {
4112         double[] a = fa.apply(SPECIES.length());
4113         double[] b = fb.apply(SPECIES.length());
4114         double[] r = fr.apply(SPECIES.length());
4115 
4116         for (int ic = 0; ic < INVOC_COUNT; ic++) {
4117             for (int i = 0; i < a.length; i += SPECIES.length()) {
4118                 DoubleVector av = DoubleVector.fromArray(SPECIES, a, i);
4119                 DoubleVector bv = DoubleVector.fromArray(SPECIES, b, i);
4120                 av.lanewise(VectorOperators.ATAN2, bv).intoArray(r, i);
4121             }
4122         }
4123 
4124         assertArraysEqualsWithinOneUlp(r, a, b, Double256VectorTests::ATAN2, Double256VectorTests::strictATAN2);
4125     }
4126 
4127 
4128 
4129     @Test(dataProvider = "doubleBinaryOpProvider")
4130     static void POWDouble256VectorTestsBroadcastSmokeTest(IntFunction<double[]> fa, IntFunction<double[]> fb) {
4131         double[] a = fa.apply(SPECIES.length());
4132         double[] b = fb.apply(SPECIES.length());
4133         double[] r = fr.apply(SPECIES.length());
4134 
4135         for (int i = 0; i < a.length; i += SPECIES.length()) {
4136             DoubleVector av = DoubleVector.fromArray(SPECIES, a, i);
4137             av.lanewise(VectorOperators.POW, b[i]).intoArray(r, i);
4138         }
4139 
4140         assertBroadcastArraysEqualsWithinOneUlp(r, a, b, Double256VectorTests::POW, Double256VectorTests::strictPOW);
4141     }
4142 
4143     @Test(dataProvider = "doubleBinaryOpProvider")
4144     static void powDouble256VectorTestsBroadcastSmokeTest(IntFunction<double[]> fa, IntFunction<double[]> fb) {
4145         double[] a = fa.apply(SPECIES.length());
4146         double[] b = fb.apply(SPECIES.length());
4147         double[] r = fr.apply(SPECIES.length());
4148 
4149         for (int i = 0; i < a.length; i += SPECIES.length()) {
4150             DoubleVector av = DoubleVector.fromArray(SPECIES, a, i);
4151             av.pow(b[i]).intoArray(r, i);
4152         }
4153 
4154         assertBroadcastArraysEqualsWithinOneUlp(r, a, b, Double256VectorTests::pow, Double256VectorTests::strictpow);
4155     }
4156 
4157 
4158 
4159     static double FMA(double a, double b, double c) {
4160         return (double)(Math.fma(a, b, c));
4161     }
4162     static double fma(double a, double b, double c) {
4163         return (double)(Math.fma(a, b, c));
4164     }
4165 
4166 
4167     @Test(dataProvider = "doubleTernaryOpProvider")
4168     static void FMADouble256VectorTests(IntFunction<double[]> fa, IntFunction<double[]> fb, IntFunction<double[]> fc) {
4169         int count = INVOC_COUNT;
4170         switch ("FMA") {
4171         case "fma": case "lanewise_FMA":
4172            // Math.fma uses BigDecimal
4173            count = Math.max(5, count/20); break;
4174         }
4175         final int INVOC_COUNT = count;
4176         double[] a = fa.apply(SPECIES.length());
4177         double[] b = fb.apply(SPECIES.length());
4178         double[] c = fc.apply(SPECIES.length());
4179         double[] r = fr.apply(SPECIES.length());
4180 
4181         for (int ic = 0; ic < INVOC_COUNT; ic++) {
4182             for (int i = 0; i < a.length; i += SPECIES.length()) {
4183                 DoubleVector av = DoubleVector.fromArray(SPECIES, a, i);
4184                 DoubleVector bv = DoubleVector.fromArray(SPECIES, b, i);
4185                 DoubleVector cv = DoubleVector.fromArray(SPECIES, c, i);
4186                 av.lanewise(VectorOperators.FMA, bv, cv).intoArray(r, i);
4187             }
4188         }
4189 
4190         assertArraysEquals(r, a, b, c, Double256VectorTests::FMA);
4191     }
4192     @Test(dataProvider = "doubleTernaryOpProvider")
4193     static void fmaDouble256VectorTests(IntFunction<double[]> fa, IntFunction<double[]> fb, IntFunction<double[]> fc) {
4194         int count = INVOC_COUNT;
4195         switch ("fma") {
4196         case "fma": case "lanewise_FMA":
4197            // Math.fma uses BigDecimal
4198            count = Math.max(5, count/20); break;
4199         }
4200         final int INVOC_COUNT = count;
4201         double[] a = fa.apply(SPECIES.length());
4202         double[] b = fb.apply(SPECIES.length());
4203         double[] c = fc.apply(SPECIES.length());
4204         double[] r = fr.apply(SPECIES.length());
4205 
4206         for (int i = 0; i < a.length; i += SPECIES.length()) {
4207             DoubleVector av = DoubleVector.fromArray(SPECIES, a, i);
4208             DoubleVector bv = DoubleVector.fromArray(SPECIES, b, i);
4209             DoubleVector cv = DoubleVector.fromArray(SPECIES, c, i);
4210             av.fma(bv, cv).intoArray(r, i);
4211         }
4212 
4213         assertArraysEquals(r, a, b, c, Double256VectorTests::fma);
4214     }
4215 
4216 
4217     @Test(dataProvider = "doubleTernaryOpMaskProvider")
4218     static void FMADouble256VectorTestsMasked(IntFunction<double[]> fa, IntFunction<double[]> fb,
4219                                           IntFunction<double[]> fc, IntFunction<boolean[]> fm) {
4220         int count = INVOC_COUNT;
4221         switch ("FMA") {
4222         case "fma": case "lanewise_FMA":
4223            // Math.fma uses BigDecimal
4224            count = Math.max(5, count/20); break;
4225         }
4226         final int INVOC_COUNT = count;
4227         double[] a = fa.apply(SPECIES.length());
4228         double[] b = fb.apply(SPECIES.length());
4229         double[] c = fc.apply(SPECIES.length());
4230         double[] r = fr.apply(SPECIES.length());
4231         boolean[] mask = fm.apply(SPECIES.length());
4232         VectorMask<Double> vmask = VectorMask.fromArray(SPECIES, mask, 0);
4233 
4234         for (int ic = 0; ic < INVOC_COUNT; ic++) {
4235             for (int i = 0; i < a.length; i += SPECIES.length()) {
4236                 DoubleVector av = DoubleVector.fromArray(SPECIES, a, i);
4237                 DoubleVector bv = DoubleVector.fromArray(SPECIES, b, i);
4238                 DoubleVector cv = DoubleVector.fromArray(SPECIES, c, i);
4239                 av.lanewise(VectorOperators.FMA, bv, cv, vmask).intoArray(r, i);
4240             }
4241         }
4242 
4243         assertArraysEquals(r, a, b, c, mask, Double256VectorTests::FMA);
4244     }
4245 
4246 
4247 
4248 
4249 
4250     @Test(dataProvider = "doubleTernaryOpProvider")
4251     static void FMADouble256VectorTestsBroadcastSmokeTest(IntFunction<double[]> fa, IntFunction<double[]> fb, IntFunction<double[]> fc) {
4252         double[] a = fa.apply(SPECIES.length());
4253         double[] b = fb.apply(SPECIES.length());
4254         double[] c = fc.apply(SPECIES.length());
4255         double[] r = fr.apply(SPECIES.length());
4256 
4257         for (int i = 0; i < a.length; i += SPECIES.length()) {
4258             DoubleVector av = DoubleVector.fromArray(SPECIES, a, i);
4259             DoubleVector bv = DoubleVector.fromArray(SPECIES, b, i);
4260             av.lanewise(VectorOperators.FMA, bv, c[i]).intoArray(r, i);
4261         }
4262         assertBroadcastArraysEquals(r, a, b, c, Double256VectorTests::FMA);
4263     }
4264 
4265     @Test(dataProvider = "doubleTernaryOpProvider")
4266     static void FMADouble256VectorTestsAltBroadcastSmokeTest(IntFunction<double[]> fa, IntFunction<double[]> fb, IntFunction<double[]> fc) {
4267         double[] a = fa.apply(SPECIES.length());
4268         double[] b = fb.apply(SPECIES.length());
4269         double[] c = fc.apply(SPECIES.length());
4270         double[] r = fr.apply(SPECIES.length());
4271 
4272         for (int i = 0; i < a.length; i += SPECIES.length()) {
4273             DoubleVector av = DoubleVector.fromArray(SPECIES, a, i);
4274             DoubleVector cv = DoubleVector.fromArray(SPECIES, c, i);
4275             av.lanewise(VectorOperators.FMA, b[i], cv).intoArray(r, i);
4276         }
4277         assertAltBroadcastArraysEquals(r, a, b, c, Double256VectorTests::FMA);
4278     }
4279 
4280 
4281     @Test(dataProvider = "doubleTernaryOpMaskProvider")
4282     static void FMADouble256VectorTestsBroadcastMaskedSmokeTest(IntFunction<double[]> fa, IntFunction<double[]> fb,
4283                                           IntFunction<double[]> fc, IntFunction<boolean[]> fm) {
4284         double[] a = fa.apply(SPECIES.length());
4285         double[] b = fb.apply(SPECIES.length());
4286         double[] c = fc.apply(SPECIES.length());
4287         double[] r = fr.apply(SPECIES.length());
4288         boolean[] mask = fm.apply(SPECIES.length());
4289         VectorMask<Double> vmask = VectorMask.fromArray(SPECIES, mask, 0);
4290 
4291         for (int i = 0; i < a.length; i += SPECIES.length()) {
4292             DoubleVector av = DoubleVector.fromArray(SPECIES, a, i);
4293             DoubleVector bv = DoubleVector.fromArray(SPECIES, b, i);
4294             av.lanewise(VectorOperators.FMA, bv, c[i], vmask).intoArray(r, i);
4295         }
4296 
4297         assertBroadcastArraysEquals(r, a, b, c, mask, Double256VectorTests::FMA);
4298     }
4299 
4300     @Test(dataProvider = "doubleTernaryOpMaskProvider")
4301     static void FMADouble256VectorTestsAltBroadcastMaskedSmokeTest(IntFunction<double[]> fa, IntFunction<double[]> fb,
4302                                           IntFunction<double[]> fc, IntFunction<boolean[]> fm) {
4303         double[] a = fa.apply(SPECIES.length());
4304         double[] b = fb.apply(SPECIES.length());
4305         double[] c = fc.apply(SPECIES.length());
4306         double[] r = fr.apply(SPECIES.length());
4307         boolean[] mask = fm.apply(SPECIES.length());
4308         VectorMask<Double> vmask = VectorMask.fromArray(SPECIES, mask, 0);
4309 
4310         for (int i = 0; i < a.length; i += SPECIES.length()) {
4311             DoubleVector av = DoubleVector.fromArray(SPECIES, a, i);
4312             DoubleVector cv = DoubleVector.fromArray(SPECIES, c, i);
4313             av.lanewise(VectorOperators.FMA, b[i], cv, vmask).intoArray(r, i);
4314         }
4315 
4316         assertAltBroadcastArraysEquals(r, a, b, c, mask, Double256VectorTests::FMA);
4317     }
4318 
4319 
4320 
4321 
4322     @Test(dataProvider = "doubleTernaryOpProvider")
4323     static void FMADouble256VectorTestsDoubleBroadcastSmokeTest(IntFunction<double[]> fa, IntFunction<double[]> fb, IntFunction<double[]> fc) {
4324         int count = INVOC_COUNT;
4325         switch ("FMA") {
4326         case "fma": case "lanewise_FMA":
4327            // Math.fma uses BigDecimal
4328            count = Math.max(5, count/20); break;
4329         }
4330         final int INVOC_COUNT = count;
4331         double[] a = fa.apply(SPECIES.length());
4332         double[] b = fb.apply(SPECIES.length());
4333         double[] c = fc.apply(SPECIES.length());
4334         double[] r = fr.apply(SPECIES.length());
4335 
4336         for (int i = 0; i < a.length; i += SPECIES.length()) {
4337             DoubleVector av = DoubleVector.fromArray(SPECIES, a, i);
4338             av.lanewise(VectorOperators.FMA, b[i], c[i]).intoArray(r, i);
4339         }
4340 
4341         assertDoubleBroadcastArraysEquals(r, a, b, c, Double256VectorTests::FMA);
4342     }
4343     @Test(dataProvider = "doubleTernaryOpProvider")
4344     static void fmaDouble256VectorTestsDoubleBroadcastSmokeTest(IntFunction<double[]> fa, IntFunction<double[]> fb, IntFunction<double[]> fc) {
4345         int count = INVOC_COUNT;
4346         switch ("fma") {
4347         case "fma": case "lanewise_FMA":
4348            // Math.fma uses BigDecimal
4349            count = Math.max(5, count/20); break;
4350         }
4351         final int INVOC_COUNT = count;
4352         double[] a = fa.apply(SPECIES.length());
4353         double[] b = fb.apply(SPECIES.length());
4354         double[] c = fc.apply(SPECIES.length());
4355         double[] r = fr.apply(SPECIES.length());
4356 
4357         for (int i = 0; i < a.length; i += SPECIES.length()) {
4358             DoubleVector av = DoubleVector.fromArray(SPECIES, a, i);
4359             av.fma(b[i], c[i]).intoArray(r, i);
4360         }
4361 
4362         assertDoubleBroadcastArraysEquals(r, a, b, c, Double256VectorTests::fma);
4363     }
4364 
4365 
4366     @Test(dataProvider = "doubleTernaryOpMaskProvider")
4367     static void FMADouble256VectorTestsDoubleBroadcastMaskedSmokeTest(IntFunction<double[]> fa, IntFunction<double[]> fb,
4368                                           IntFunction<double[]> fc, IntFunction<boolean[]> fm) {
4369         int count = INVOC_COUNT;
4370         switch ("FMA") {
4371         case "fma": case "lanewise_FMA":
4372            // Math.fma uses BigDecimal
4373            count = Math.max(5, count/20); break;
4374         }
4375         final int INVOC_COUNT = count;
4376         double[] a = fa.apply(SPECIES.length());
4377         double[] b = fb.apply(SPECIES.length());
4378         double[] c = fc.apply(SPECIES.length());
4379         double[] r = fr.apply(SPECIES.length());
4380         boolean[] mask = fm.apply(SPECIES.length());
4381         VectorMask<Double> vmask = VectorMask.fromArray(SPECIES, mask, 0);
4382 
4383         for (int i = 0; i < a.length; i += SPECIES.length()) {
4384             DoubleVector av = DoubleVector.fromArray(SPECIES, a, i);
4385             av.lanewise(VectorOperators.FMA, b[i], c[i], vmask).intoArray(r, i);
4386         }
4387 
4388         assertDoubleBroadcastArraysEquals(r, a, b, c, mask, Double256VectorTests::FMA);
4389     }
4390 
4391 
4392 
4393 
4394     static double NEG(double a) {
4395         return (double)(-((double)a));
4396     }
4397 
4398     static double neg(double a) {
4399         return (double)(-((double)a));
4400     }
4401 
4402     @Test(dataProvider = "doubleUnaryOpProvider")
4403     static void NEGDouble256VectorTests(IntFunction<double[]> fa) {
4404         double[] a = fa.apply(SPECIES.length());
4405         double[] r = fr.apply(SPECIES.length());
4406 
4407         for (int ic = 0; ic < INVOC_COUNT; ic++) {
4408             for (int i = 0; i < a.length; i += SPECIES.length()) {
4409                 DoubleVector av = DoubleVector.fromArray(SPECIES, a, i);
4410                 av.lanewise(VectorOperators.NEG).intoArray(r, i);
4411             }
4412         }
4413 
4414         assertArraysEquals(r, a, Double256VectorTests::NEG);
4415     }
4416 
4417     @Test(dataProvider = "doubleUnaryOpProvider")
4418     static void negDouble256VectorTests(IntFunction<double[]> fa) {
4419         double[] a = fa.apply(SPECIES.length());
4420         double[] r = fr.apply(SPECIES.length());
4421 
4422         for (int ic = 0; ic < INVOC_COUNT; ic++) {
4423             for (int i = 0; i < a.length; i += SPECIES.length()) {
4424                 DoubleVector av = DoubleVector.fromArray(SPECIES, a, i);
4425                 av.neg().intoArray(r, i);
4426             }
4427         }
4428 
4429         assertArraysEquals(r, a, Double256VectorTests::neg);
4430     }
4431 
4432     @Test(dataProvider = "doubleUnaryOpMaskProvider")
4433     static void NEGMaskedDouble256VectorTests(IntFunction<double[]> fa,
4434                                                 IntFunction<boolean[]> fm) {
4435         double[] a = fa.apply(SPECIES.length());
4436         double[] r = fr.apply(SPECIES.length());
4437         boolean[] mask = fm.apply(SPECIES.length());
4438         VectorMask<Double> vmask = VectorMask.fromArray(SPECIES, mask, 0);
4439 
4440         for (int ic = 0; ic < INVOC_COUNT; ic++) {
4441             for (int i = 0; i < a.length; i += SPECIES.length()) {
4442                 DoubleVector av = DoubleVector.fromArray(SPECIES, a, i);
4443                 av.lanewise(VectorOperators.NEG, vmask).intoArray(r, i);
4444             }
4445         }
4446 
4447         assertArraysEquals(r, a, mask, Double256VectorTests::NEG);
4448     }
4449 
4450     static double ABS(double a) {
4451         return (double)(Math.abs((double)a));
4452     }
4453 
4454     static double abs(double a) {
4455         return (double)(Math.abs((double)a));
4456     }
4457 
4458     @Test(dataProvider = "doubleUnaryOpProvider")
4459     static void ABSDouble256VectorTests(IntFunction<double[]> fa) {
4460         double[] a = fa.apply(SPECIES.length());
4461         double[] r = fr.apply(SPECIES.length());
4462 
4463         for (int ic = 0; ic < INVOC_COUNT; ic++) {
4464             for (int i = 0; i < a.length; i += SPECIES.length()) {
4465                 DoubleVector av = DoubleVector.fromArray(SPECIES, a, i);
4466                 av.lanewise(VectorOperators.ABS).intoArray(r, i);
4467             }
4468         }
4469 
4470         assertArraysEquals(r, a, Double256VectorTests::ABS);
4471     }
4472 
4473     @Test(dataProvider = "doubleUnaryOpProvider")
4474     static void absDouble256VectorTests(IntFunction<double[]> fa) {
4475         double[] a = fa.apply(SPECIES.length());
4476         double[] r = fr.apply(SPECIES.length());
4477 
4478         for (int ic = 0; ic < INVOC_COUNT; ic++) {
4479             for (int i = 0; i < a.length; i += SPECIES.length()) {
4480                 DoubleVector av = DoubleVector.fromArray(SPECIES, a, i);
4481                 av.abs().intoArray(r, i);
4482             }
4483         }
4484 
4485         assertArraysEquals(r, a, Double256VectorTests::abs);
4486     }
4487 
4488     @Test(dataProvider = "doubleUnaryOpMaskProvider")
4489     static void ABSMaskedDouble256VectorTests(IntFunction<double[]> fa,
4490                                                 IntFunction<boolean[]> fm) {
4491         double[] a = fa.apply(SPECIES.length());
4492         double[] r = fr.apply(SPECIES.length());
4493         boolean[] mask = fm.apply(SPECIES.length());
4494         VectorMask<Double> vmask = VectorMask.fromArray(SPECIES, mask, 0);
4495 
4496         for (int ic = 0; ic < INVOC_COUNT; ic++) {
4497             for (int i = 0; i < a.length; i += SPECIES.length()) {
4498                 DoubleVector av = DoubleVector.fromArray(SPECIES, a, i);
4499                 av.lanewise(VectorOperators.ABS, vmask).intoArray(r, i);
4500             }
4501         }
4502 
4503         assertArraysEquals(r, a, mask, Double256VectorTests::ABS);
4504     }
4505 
4506 
4507 
4508 
4509 
4510 
4511 
4512 
4513     static double SQRT(double a) {
4514         return (double)(Math.sqrt((double)a));
4515     }
4516 
4517     static double sqrt(double a) {
4518         return (double)(Math.sqrt((double)a));
4519     }
4520 
4521 
4522 
4523     @Test(dataProvider = "doubleUnaryOpProvider")
4524     static void SQRTDouble256VectorTests(IntFunction<double[]> fa) {
4525         double[] a = fa.apply(SPECIES.length());
4526         double[] r = fr.apply(SPECIES.length());
4527 
4528         for (int ic = 0; ic < INVOC_COUNT; ic++) {
4529             for (int i = 0; i < a.length; i += SPECIES.length()) {
4530                 DoubleVector av = DoubleVector.fromArray(SPECIES, a, i);
4531                 av.lanewise(VectorOperators.SQRT).intoArray(r, i);
4532             }
4533         }
4534 
4535         assertArraysEquals(r, a, Double256VectorTests::SQRT);
4536     }
4537 
4538     @Test(dataProvider = "doubleUnaryOpProvider")
4539     static void sqrtDouble256VectorTests(IntFunction<double[]> fa) {
4540         double[] a = fa.apply(SPECIES.length());
4541         double[] r = fr.apply(SPECIES.length());
4542 
4543         for (int ic = 0; ic < INVOC_COUNT; ic++) {
4544             for (int i = 0; i < a.length; i += SPECIES.length()) {
4545                 DoubleVector av = DoubleVector.fromArray(SPECIES, a, i);
4546                 av.sqrt().intoArray(r, i);
4547             }
4548         }
4549 
4550         assertArraysEquals(r, a, Double256VectorTests::sqrt);
4551     }
4552 
4553 
4554 
4555     @Test(dataProvider = "doubleUnaryOpMaskProvider")
4556     static void SQRTMaskedDouble256VectorTests(IntFunction<double[]> fa,
4557                                                 IntFunction<boolean[]> fm) {
4558         double[] a = fa.apply(SPECIES.length());
4559         double[] r = fr.apply(SPECIES.length());
4560         boolean[] mask = fm.apply(SPECIES.length());
4561         VectorMask<Double> vmask = VectorMask.fromArray(SPECIES, mask, 0);
4562 
4563         for (int ic = 0; ic < INVOC_COUNT; ic++) {
4564             for (int i = 0; i < a.length; i += SPECIES.length()) {
4565                 DoubleVector av = DoubleVector.fromArray(SPECIES, a, i);
4566                 av.lanewise(VectorOperators.SQRT, vmask).intoArray(r, i);
4567             }
4568         }
4569 
4570         assertArraysEquals(r, a, mask, Double256VectorTests::SQRT);
4571     }
4572 
4573 
4574     @Test(dataProvider = "doubleCompareOpProvider")
4575     static void ltDouble256VectorTestsBroadcastSmokeTest(IntFunction<double[]> fa, IntFunction<double[]> fb) {
4576         double[] a = fa.apply(SPECIES.length());
4577         double[] b = fb.apply(SPECIES.length());
4578 
4579         for (int i = 0; i < a.length; i += SPECIES.length()) {
4580             DoubleVector av = DoubleVector.fromArray(SPECIES, a, i);
4581             VectorMask<Double> mv = av.lt(b[i]);
4582 
4583             // Check results as part of computation.
4584             for (int j = 0; j < SPECIES.length(); j++) {
4585                 Assert.assertEquals(mv.laneIsSet(j), a[i + j] < b[i]);
4586             }
4587         }
4588     }
4589 
4590     @Test(dataProvider = "doubleCompareOpProvider")
4591     static void eqDouble256VectorTestsBroadcastMaskedSmokeTest(IntFunction<double[]> fa, IntFunction<double[]> fb) {
4592         double[] a = fa.apply(SPECIES.length());
4593         double[] b = fb.apply(SPECIES.length());
4594 
4595         for (int i = 0; i < a.length; i += SPECIES.length()) {
4596             DoubleVector av = DoubleVector.fromArray(SPECIES, a, i);
4597             VectorMask<Double> mv = av.eq(b[i]);
4598 
4599             // Check results as part of computation.
4600             for (int j = 0; j < SPECIES.length(); j++) {
4601                 Assert.assertEquals(mv.laneIsSet(j), a[i + j] == b[i]);
4602             }
4603         }
4604     }
4605 
4606     @Test(dataProvider = "doubletoIntUnaryOpProvider")
4607     static void toIntArrayDouble256VectorTestsSmokeTest(IntFunction<double[]> fa) {
4608         double[] a = fa.apply(SPECIES.length());
4609 
4610         for (int i = 0; i < a.length; i += SPECIES.length()) {
4611             DoubleVector av = DoubleVector.fromArray(SPECIES, a, i);
4612             int[] r = av.toIntArray();
4613             assertArraysEquals(r, a, i);
4614         }
4615     }
4616 
4617     @Test(dataProvider = "doubletoLongUnaryOpProvider")
4618     static void toLongArrayDouble256VectorTestsSmokeTest(IntFunction<double[]> fa) {
4619         double[] a = fa.apply(SPECIES.length());
4620 
4621         for (int i = 0; i < a.length; i += SPECIES.length()) {
4622             DoubleVector av = DoubleVector.fromArray(SPECIES, a, i);
4623             long[] r = av.toLongArray();
4624             assertArraysEquals(r, a, i);
4625         }
4626     }
4627 
4628 
4629     @Test(dataProvider = "doubleUnaryOpProvider")
4630     static void toStringDouble256VectorTestsSmokeTest(IntFunction<double[]> fa) {
4631         double[] a = fa.apply(SPECIES.length());
4632 
4633         for (int i = 0; i < a.length; i += SPECIES.length()) {
4634             DoubleVector av = DoubleVector.fromArray(SPECIES, a, i);
4635             String str = av.toString();
4636 
4637             double subarr[] = Arrays.copyOfRange(a, i, i + SPECIES.length());
4638             Assert.assertTrue(str.equals(Arrays.toString(subarr)), "at index " + i + ", string should be = " + Arrays.toString(subarr) + ", but is = " + str);
4639         }
4640     }
4641 
4642     @Test(dataProvider = "doubleUnaryOpProvider")
4643     static void hashCodeDouble256VectorTestsSmokeTest(IntFunction<double[]> fa) {
4644         double[] a = fa.apply(SPECIES.length());
4645 
4646         for (int i = 0; i < a.length; i += SPECIES.length()) {
4647             DoubleVector av = DoubleVector.fromArray(SPECIES, a, i);
4648             int hash = av.hashCode();
4649 
4650             double subarr[] = Arrays.copyOfRange(a, i, i + SPECIES.length());
4651             int expectedHash = Objects.hash(SPECIES, Arrays.hashCode(subarr));
4652             Assert.assertTrue(hash == expectedHash, "at index " + i + ", hash should be = " + expectedHash + ", but is = " + hash);
4653         }
4654     }
4655 
4656 
4657     static long ADDReduceLong(double[] a, int idx) {
4658         double res = 0;
4659         for (int i = idx; i < (idx + SPECIES.length()); i++) {
4660             res += a[i];
4661         }
4662 
4663         return (long)res;
4664     }
4665 
4666     static long ADDReduceAllLong(double[] a) {
4667         long res = 0;
4668         for (int i = 0; i < a.length; i += SPECIES.length()) {
4669             res += ADDReduceLong(a, i);
4670         }
4671 
4672         return res;
4673     }
4674 
4675     @Test(dataProvider = "doubleUnaryOpProvider")
4676     static void ADDReduceLongDouble256VectorTests(IntFunction<double[]> fa) {
4677         double[] a = fa.apply(SPECIES.length());
4678         long[] r = lfr.apply(SPECIES.length());
4679         long ra = 0;
4680 
4681         for (int i = 0; i < a.length; i += SPECIES.length()) {
4682             DoubleVector av = DoubleVector.fromArray(SPECIES, a, i);
4683             r[i] = av.reduceLanesToLong(VectorOperators.ADD);
4684         }
4685 
4686         ra = 0;
4687         for (int i = 0; i < a.length; i ++) {
4688             ra += r[i];
4689         }
4690 
4691         assertReductionLongArraysEquals(r, ra, a,
4692                 Double256VectorTests::ADDReduceLong, Double256VectorTests::ADDReduceAllLong);
4693     }
4694 
4695     static long ADDReduceLongMasked(double[] a, int idx, boolean[] mask) {
4696         double res = 0;
4697         for (int i = idx; i < (idx + SPECIES.length()); i++) {
4698             if(mask[i % SPECIES.length()])
4699                 res += a[i];
4700         }
4701 
4702         return (long)res;
4703     }
4704 
4705     static long ADDReduceAllLongMasked(double[] a, boolean[] mask) {
4706         long res = 0;
4707         for (int i = 0; i < a.length; i += SPECIES.length()) {
4708             res += ADDReduceLongMasked(a, i, mask);
4709         }
4710 
4711         return res;
4712     }
4713 
4714     @Test(dataProvider = "doubleUnaryOpMaskProvider")
4715     static void ADDReduceLongDouble256VectorTestsMasked(IntFunction<double[]> fa, IntFunction<boolean[]> fm) {
4716         double[] a = fa.apply(SPECIES.length());
4717         long[] r = lfr.apply(SPECIES.length());
4718         boolean[] mask = fm.apply(SPECIES.length());
4719         VectorMask<Double> vmask = VectorMask.fromArray(SPECIES, mask, 0);
4720         long ra = 0;
4721 
4722         for (int i = 0; i < a.length; i += SPECIES.length()) {
4723             DoubleVector av = DoubleVector.fromArray(SPECIES, a, i);
4724             r[i] = av.reduceLanesToLong(VectorOperators.ADD, vmask);
4725         }
4726 
4727         ra = 0;
4728         for (int i = 0; i < a.length; i ++) {
4729             ra += r[i];
4730         }
4731 
4732         assertReductionLongArraysEqualsMasked(r, ra, a, mask,
4733                 Double256VectorTests::ADDReduceLongMasked, Double256VectorTests::ADDReduceAllLongMasked);
4734     }
4735 
4736     @Test(dataProvider = "doubletoLongUnaryOpProvider")
4737     static void BroadcastLongDouble256VectorTestsSmokeTest(IntFunction<double[]> fa) {
4738         double[] a = fa.apply(SPECIES.length());
4739         double[] r = new double[a.length];
4740 
4741         for (int i = 0; i < a.length; i += SPECIES.length()) {
4742             DoubleVector.broadcast(SPECIES, (long)a[i]).intoArray(r, i);
4743         }
4744         assertBroadcastArraysEquals(r, a);
4745     }
4746 
4747     @Test(dataProvider = "doubleBinaryOpMaskProvider")
4748     static void blendDouble256VectorTestsBroadcastLongSmokeTest(IntFunction<double[]> fa, IntFunction<double[]> fb,
4749                                           IntFunction<boolean[]> fm) {
4750         double[] a = fa.apply(SPECIES.length());
4751         double[] b = fb.apply(SPECIES.length());
4752         double[] r = fr.apply(SPECIES.length());
4753         boolean[] mask = fm.apply(SPECIES.length());
4754         VectorMask<Double> vmask = VectorMask.fromArray(SPECIES, mask, 0);
4755 
4756         for (int ic = 0; ic < INVOC_COUNT; ic++) {
4757             for (int i = 0; i < a.length; i += SPECIES.length()) {
4758                 DoubleVector av = DoubleVector.fromArray(SPECIES, a, i);
4759                 av.blend((long)b[i], vmask).intoArray(r, i);
4760             }
4761         }
4762         assertBroadcastLongArraysEquals(r, a, b, mask, Double256VectorTests::blend);
4763     }
4764 
4765 
4766     @Test(dataProvider = "doubleUnaryOpSelectFromProvider")
4767     static void SelectFromDouble256VectorTests(IntFunction<double[]> fa,
4768                                            BiFunction<Integer,Integer,double[]> fs) {
4769         double[] a = fa.apply(SPECIES.length());
4770         double[] order = fs.apply(a.length, SPECIES.length());
4771         double[] r = fr.apply(SPECIES.length());
4772 
4773         for (int i = 0; i < a.length; i += SPECIES.length()) {
4774             DoubleVector av = DoubleVector.fromArray(SPECIES, a, i);
4775             DoubleVector bv = DoubleVector.fromArray(SPECIES, order, i);
4776             bv.selectFrom(av).intoArray(r, i);
4777         }
4778 
4779         assertSelectFromArraysEquals(r, a, order, SPECIES.length());
4780     }
4781 
4782     @Test(dataProvider = "doubleUnaryOpSelectFromMaskProvider")
4783     static void SelectFromDouble256VectorTestsMaskedSmokeTest(IntFunction<double[]> fa,
4784                                                            BiFunction<Integer,Integer,double[]> fs,
4785                                                            IntFunction<boolean[]> fm) {
4786         double[] a = fa.apply(SPECIES.length());
4787         double[] order = fs.apply(a.length, SPECIES.length());
4788         double[] r = fr.apply(SPECIES.length());
4789         boolean[] mask = fm.apply(SPECIES.length());
4790         VectorMask<Double> vmask = VectorMask.fromArray(SPECIES, mask, 0);
4791 
4792         for (int i = 0; i < a.length; i += SPECIES.length()) {
4793             DoubleVector av = DoubleVector.fromArray(SPECIES, a, i);
4794             DoubleVector bv = DoubleVector.fromArray(SPECIES, order, i);
4795             bv.selectFrom(av, vmask).intoArray(r, i);
4796         }
4797 
4798         assertSelectFromArraysEquals(r, a, order, mask, SPECIES.length());
4799     }
4800 
4801     @Test(dataProvider = "shuffleProvider")
4802     static void shuffleMiscellaneousDouble256VectorTestsSmokeTest(BiFunction<Integer,Integer,int[]> fs) {
4803         int[] a = fs.apply(SPECIES.length() * BUFFER_REPS, SPECIES.length());
4804 
4805         for (int i = 0; i < a.length; i += SPECIES.length()) {
4806             var shuffle = VectorShuffle.fromArray(SPECIES, a, i);
4807             int hash = shuffle.hashCode();
4808             int length = shuffle.length();
4809 
4810             int subarr[] = Arrays.copyOfRange(a, i, i + SPECIES.length());
4811             int expectedHash = Objects.hash(SPECIES, Arrays.hashCode(subarr));
4812             Assert.assertTrue(hash == expectedHash, "at index " + i + ", hash should be = " + expectedHash + ", but is = " + hash);
4813             Assert.assertEquals(length, SPECIES.length());
4814         }
4815     }
4816 
4817     @Test(dataProvider = "shuffleProvider")
4818     static void shuffleToStringDouble256VectorTestsSmokeTest(BiFunction<Integer,Integer,int[]> fs) {
4819         int[] a = fs.apply(SPECIES.length() * BUFFER_REPS, SPECIES.length());
4820 
4821         for (int i = 0; i < a.length; i += SPECIES.length()) {
4822             var shuffle = VectorShuffle.fromArray(SPECIES, a, i);
4823             String str = shuffle.toString();
4824 
4825             int subarr[] = Arrays.copyOfRange(a, i, i + SPECIES.length());
4826             Assert.assertTrue(str.equals("Shuffle" + Arrays.toString(subarr)), "at index " +
4827                 i + ", string should be = " + Arrays.toString(subarr) + ", but is = " + str);
4828         }
4829     }
4830 
4831     @Test(dataProvider = "shuffleCompareOpProvider")
4832     static void shuffleEqualsDouble256VectorTestsSmokeTest(BiFunction<Integer,Integer,int[]> fa, BiFunction<Integer,Integer,int[]> fb) {
4833         int[] a = fa.apply(SPECIES.length() * BUFFER_REPS, SPECIES.length());
4834         int[] b = fb.apply(SPECIES.length() * BUFFER_REPS, SPECIES.length());
4835 
4836         for (int i = 0; i < a.length; i += SPECIES.length()) {
4837             var av = VectorShuffle.fromArray(SPECIES, a, i);
4838             var bv = VectorShuffle.fromArray(SPECIES, b, i);
4839             boolean eq = av.equals(bv);
4840             int to = i + SPECIES.length();
4841             Assert.assertEquals(eq, Arrays.equals(a, i, to, b, i, to));
4842         }
4843     }
4844 
4845     @Test(dataProvider = "maskCompareOpProvider")
4846     static void maskEqualsDouble256VectorTestsSmokeTest(IntFunction<boolean[]> fa, IntFunction<boolean[]> fb) {
4847         boolean[] a = fa.apply(SPECIES.length());
4848         boolean[] b = fb.apply(SPECIES.length());
4849 
4850         for (int i = 0; i < a.length; i += SPECIES.length()) {
4851             var av = SPECIES.loadMask(a, i);
4852             var bv = SPECIES.loadMask(b, i);
4853             boolean equals = av.equals(bv);
4854             int to = i + SPECIES.length();
4855             Assert.assertEquals(equals, Arrays.equals(a, i, to, b, i, to));
4856         }
4857     }
4858 
4859     static boolean beq(boolean a, boolean b) {
4860         return (a == b);
4861     }
4862 
4863     @Test(dataProvider = "maskCompareOpProvider")
4864     static void maskEqDouble256VectorTestsSmokeTest(IntFunction<boolean[]> fa, IntFunction<boolean[]> fb) {
4865         boolean[] a = fa.apply(SPECIES.length());
4866         boolean[] b = fb.apply(SPECIES.length());
4867         boolean[] r = new boolean[a.length];
4868 
4869         for (int i = 0; i < a.length; i += SPECIES.length()) {
4870             var av = SPECIES.loadMask(a, i);
4871             var bv = SPECIES.loadMask(b, i);
4872             var cv = av.eq(bv);
4873             cv.intoArray(r, i);
4874         }
4875         assertArraysEquals(r, a, b, Double256VectorTests::beq);
4876     }
4877 
4878     @Test(dataProvider = "maskProvider")
4879     static void maskHashCodeDouble256VectorTestsSmokeTest(IntFunction<boolean[]> fa) {
4880         boolean[] a = fa.apply(SPECIES.length());
4881 
4882         for (int i = 0; i < a.length; i += SPECIES.length()) {
4883             var vmask = SPECIES.loadMask(a, i);
4884             int hash = vmask.hashCode();
4885 
4886             boolean subarr[] = Arrays.copyOfRange(a, i, i + SPECIES.length());
4887             int expectedHash = Objects.hash(SPECIES, Arrays.hashCode(subarr));
4888             Assert.assertTrue(hash == expectedHash, "at index " + i + ", hash should be = " + expectedHash + ", but is = " + hash);
4889         }
4890     }
4891 
4892     static int maskTrueCount(boolean[] a, int idx) {
4893         int trueCount = 0;
4894         for (int i = idx; i < idx + SPECIES.length(); i++) {
4895             trueCount += a[i] ? 1 : 0;
4896         }
4897         return trueCount;
4898     }
4899 
4900     @Test(dataProvider = "maskProvider")
4901     static void maskTrueCountDouble256VectorTestsSmokeTest(IntFunction<boolean[]> fa) {
4902         boolean[] a = fa.apply(SPECIES.length());
4903         int[] r = new int[a.length];
4904 
4905         for (int ic = 0; ic < INVOC_COUNT * INVOC_COUNT; ic++) {
4906             for (int i = 0; i < a.length; i += SPECIES.length()) {
4907                 var vmask = SPECIES.loadMask(a, i);
4908                 r[i] = vmask.trueCount();
4909             }
4910         }
4911 
4912         assertMaskReductionArraysEquals(r, a, Double256VectorTests::maskTrueCount);
4913     }
4914 
4915     static int maskLastTrue(boolean[] a, int idx) {
4916         int i = idx + SPECIES.length() - 1;
4917         for (; i >= idx; i--) {
4918             if (a[i]) {
4919                 break;
4920             }
4921         }
4922         return i - idx;
4923     }
4924 
4925     @Test(dataProvider = "maskProvider")
4926     static void maskLastTrueDouble256VectorTestsSmokeTest(IntFunction<boolean[]> fa) {
4927         boolean[] a = fa.apply(SPECIES.length());
4928         int[] r = new int[a.length];
4929 
4930         for (int ic = 0; ic < INVOC_COUNT * INVOC_COUNT; ic++) {
4931             for (int i = 0; i < a.length; i += SPECIES.length()) {
4932                 var vmask = SPECIES.loadMask(a, i);
4933                 r[i] = vmask.lastTrue();
4934             }
4935         }
4936 
4937         assertMaskReductionArraysEquals(r, a, Double256VectorTests::maskLastTrue);
4938     }
4939 
4940     static int maskFirstTrue(boolean[] a, int idx) {
4941         int i = idx;
4942         for (; i < idx + SPECIES.length(); i++) {
4943             if (a[i]) {
4944                 break;
4945             }
4946         }
4947         return i - idx;
4948     }
4949 
4950     @Test(dataProvider = "maskProvider")
4951     static void maskFirstTrueDouble256VectorTestsSmokeTest(IntFunction<boolean[]> fa) {
4952         boolean[] a = fa.apply(SPECIES.length());
4953         int[] r = new int[a.length];
4954 
4955         for (int ic = 0; ic < INVOC_COUNT * INVOC_COUNT; ic++) {
4956             for (int i = 0; i < a.length; i += SPECIES.length()) {
4957                 var vmask = SPECIES.loadMask(a, i);
4958                 r[i] = vmask.firstTrue();
4959             }
4960         }
4961 
4962         assertMaskReductionArraysEquals(r, a, Double256VectorTests::maskFirstTrue);
4963     }
4964 
4965     @Test(dataProvider = "maskProvider")
4966     static void maskCompressDouble256VectorTestsSmokeTest(IntFunction<boolean[]> fa) {
4967         int trueCount = 0;
4968         boolean[] a = fa.apply(SPECIES.length());
4969 
4970         for (int ic = 0; ic < INVOC_COUNT * INVOC_COUNT; ic++) {
4971             for (int i = 0; i < a.length; i += SPECIES.length()) {
4972                 var vmask = SPECIES.loadMask(a, i);
4973                 trueCount = vmask.trueCount();
4974                 var rmask = vmask.compress();
4975                 for (int j = 0; j < SPECIES.length(); j++)  {
4976                     Assert.assertEquals(rmask.laneIsSet(j), j < trueCount);
4977                 }
4978             }
4979         }
4980     }
4981 
4982     @DataProvider
4983     public static Object[][] longMaskProvider() {
4984         return new Object[][]{
4985                 {0xFFFFFFFFFFFFFFFFL},
4986                 {0x0000000000000000L},
4987                 {0x5555555555555555L},
4988                 {0x0123456789abcdefL},
4989         };
4990     }
4991 
4992     @Test(dataProvider = "longMaskProvider")
4993     static void maskFromToLongDouble256VectorTestsSmokeTest(long inputLong) {
4994         var vmask = VectorMask.fromLong(SPECIES, inputLong);
4995         long outputLong = vmask.toLong();
4996         Assert.assertEquals(outputLong, inputLong & (((1L << (SPECIES.length() - 1)) << 1) - 1));
4997     }
4998 
4999     @DataProvider
5000     public static Object[][] offsetProvider() {
5001         return new Object[][]{
5002                 {0},
5003                 {-1},
5004                 {+1},
5005                 {+2},
5006                 {-2},
5007         };
5008     }
5009 
5010     @Test(dataProvider = "offsetProvider")
5011     static void indexInRangeDouble256VectorTestsSmokeTest(int offset) {
5012         int limit = SPECIES.length() * BUFFER_REPS;
5013         for (int i = 0; i < limit; i += SPECIES.length()) {
5014             var actualMask = SPECIES.indexInRange(i + offset, limit);
5015             var expectedMask = SPECIES.maskAll(true).indexInRange(i + offset, limit);
5016             assert(actualMask.equals(expectedMask));
5017             for (int j = 0; j < SPECIES.length(); j++)  {
5018                 int index = i + j + offset;
5019                 Assert.assertEquals(actualMask.laneIsSet(j), index >= 0 && index < limit);
5020             }
5021         }
5022     }
5023 
5024     @DataProvider
5025     public static Object[][] lengthProvider() {
5026         return new Object[][]{
5027                 {0},
5028                 {1},
5029                 {32},
5030                 {37},
5031                 {1024},
5032                 {1024+1},
5033                 {1024+5},
5034         };
5035     }
5036 
5037     @Test(dataProvider = "lengthProvider")
5038     static void loopBoundDouble256VectorTestsSmokeTest(int length) {
5039         int actualLoopBound = SPECIES.loopBound(length);
5040         int expectedLoopBound = length - Math.floorMod(length, SPECIES.length());
5041         Assert.assertEquals(actualLoopBound, expectedLoopBound);
5042     }
5043 
5044     @Test
5045     static void ElementSizeDouble256VectorTestsSmokeTest() {
5046         DoubleVector av = DoubleVector.zero(SPECIES);
5047         int elsize = av.elementSize();
5048         Assert.assertEquals(elsize, Double.SIZE);
5049     }
5050 
5051     @Test
5052     static void VectorShapeDouble256VectorTestsSmokeTest() {
5053         DoubleVector av = DoubleVector.zero(SPECIES);
5054         VectorShape vsh = av.shape();
5055         assert(vsh.equals(VectorShape.S_256_BIT));
5056     }
5057 
5058     @Test
5059     static void ShapeWithLanesDouble256VectorTestsSmokeTest() {
5060         DoubleVector av = DoubleVector.zero(SPECIES);
5061         VectorShape vsh = av.shape();
5062         VectorSpecies species = vsh.withLanes(double.class);
5063         assert(species.equals(SPECIES));
5064     }
5065 
5066     @Test
5067     static void ElementTypeDouble256VectorTestsSmokeTest() {
5068         DoubleVector av = DoubleVector.zero(SPECIES);
5069         assert(av.species().elementType() == double.class);
5070     }
5071 
5072     @Test
5073     static void SpeciesElementSizeDouble256VectorTestsSmokeTest() {
5074         DoubleVector av = DoubleVector.zero(SPECIES);
5075         assert(av.species().elementSize() == Double.SIZE);
5076     }
5077 
5078     @Test
5079     static void VectorTypeDouble256VectorTestsSmokeTest() {
5080         DoubleVector av = DoubleVector.zero(SPECIES);
5081         assert(av.species().vectorType() == av.getClass());
5082     }
5083 
5084     @Test
5085     static void WithLanesDouble256VectorTestsSmokeTest() {
5086         DoubleVector av = DoubleVector.zero(SPECIES);
5087         VectorSpecies species = av.species().withLanes(double.class);
5088         assert(species.equals(SPECIES));
5089     }
5090 
5091     @Test
5092     static void WithShapeDouble256VectorTestsSmokeTest() {
5093         DoubleVector av = DoubleVector.zero(SPECIES);
5094         VectorShape vsh = av.shape();
5095         VectorSpecies species = av.species().withShape(vsh);
5096         assert(species.equals(SPECIES));
5097     }
5098 }
5099