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