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