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