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