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