1 /*
   2  * Copyright (c) 2018, 2020, 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 Double512VectorTests
  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.stream.Collectors;
  51 import java.util.stream.Stream;
  52 
  53 @Test
  54 public class Double512VectorTests extends AbstractVectorTest {
  55 
  56     static final VectorSpecies<Double> SPECIES =
  57                 DoubleVector.SPECIES_512;
  58 
  59     static final int INVOC_COUNT = Integer.getInteger("jdk.incubator.vector.test.loop-iterations", 100);
  60 
  61 
  62     static final int BUFFER_REPS = Integer.getInteger("jdk.incubator.vector.test.buffer-vectors", 25000 / 512);
  63 
  64     static final int BUFFER_SIZE = Integer.getInteger("jdk.incubator.vector.test.buffer-size", BUFFER_REPS * (512 / 8));
  65 
  66     interface FUnOp {
  67         double apply(double a);
  68     }
  69 
  70     static void assertArraysEquals(double[] a, double[] r, FUnOp f) {
  71         int i = 0;
  72         try {
  73             for (; i < a.length; i++) {
  74                 Assert.assertEquals(r[i], f.apply(a[i]));
  75             }
  76         } catch (AssertionError e) {
  77             Assert.assertEquals(r[i], f.apply(a[i]), "at index #" + i + ", input = " + a[i]);
  78         }
  79     }
  80 
  81     interface FUnArrayOp {
  82         double[] apply(double a);
  83     }
  84 
  85     static void assertArraysEquals(double[] a, double[] r, FUnArrayOp f) {
  86         int i = 0;
  87         try {
  88             for (; i < a.length; i += SPECIES.length()) {
  89                 Assert.assertEquals(Arrays.copyOfRange(r, i, i+SPECIES.length()),
  90                   f.apply(a[i]));
  91             }
  92         } catch (AssertionError e) {
  93             double[] ref = f.apply(a[i]);
  94             double[] res = Arrays.copyOfRange(r, i, i+SPECIES.length());
  95             Assert.assertEquals(ref, res, "(ref: " + Arrays.toString(ref)
  96               + ", res: " + Arrays.toString(res)
  97               + "), at index #" + i);
  98         }
  99     }
 100 
 101     static void assertArraysEquals(double[] a, double[] r, boolean[] mask, FUnOp f) {
 102         int i = 0;
 103         try {
 104             for (; i < a.length; i++) {
 105                 Assert.assertEquals(r[i], mask[i % SPECIES.length()] ? f.apply(a[i]) : a[i]);
 106             }
 107         } catch (AssertionError e) {
 108             Assert.assertEquals(r[i], mask[i % SPECIES.length()] ? f.apply(a[i]) : a[i], "at index #" + i + ", input = " + a[i] + ", mask = " + mask[i % SPECIES.length()]);
 109         }
 110     }
 111 
 112     interface FReductionOp {
 113         double apply(double[] a, int idx);
 114     }
 115 
 116     interface FReductionAllOp {
 117         double apply(double[] a);
 118     }
 119 
 120     static void assertReductionArraysEquals(double[] a, double[] b, double c,
 121                                             FReductionOp f, FReductionAllOp fa) {
 122         int i = 0;
 123         try {
 124             Assert.assertEquals(c, fa.apply(a));
 125             for (; i < a.length; i += SPECIES.length()) {
 126                 Assert.assertEquals(b[i], f.apply(a, i));
 127             }
 128         } catch (AssertionError e) {
 129             Assert.assertEquals(c, fa.apply(a), "Final result is incorrect!");
 130             Assert.assertEquals(b[i], f.apply(a, i), "at index #" + i);
 131         }
 132     }
 133 
 134     interface FReductionMaskedOp {
 135         double apply(double[] a, int idx, boolean[] mask);
 136     }
 137 
 138     interface FReductionAllMaskedOp {
 139         double apply(double[] a, boolean[] mask);
 140     }
 141 
 142     static void assertReductionArraysEqualsMasked(double[] a, double[] b, double c, boolean[] mask,
 143                                             FReductionMaskedOp f, FReductionAllMaskedOp fa) {
 144         int i = 0;
 145         try {
 146             Assert.assertEquals(c, fa.apply(a, mask));
 147             for (; i < a.length; i += SPECIES.length()) {
 148                 Assert.assertEquals(b[i], f.apply(a, i, mask));
 149             }
 150         } catch (AssertionError e) {
 151             Assert.assertEquals(c, fa.apply(a, mask), "Final result is incorrect!");
 152             Assert.assertEquals(b[i], f.apply(a, i, mask), "at index #" + i);
 153         }
 154     }
 155 
 156     interface FBoolReductionOp {
 157         boolean apply(boolean[] a, int idx);
 158     }
 159 
 160     static void assertReductionBoolArraysEquals(boolean[] a, boolean[] b, FBoolReductionOp f) {
 161         int i = 0;
 162         try {
 163             for (; i < a.length; i += SPECIES.length()) {
 164                 Assert.assertEquals(b[i], f.apply(a, i));
 165             }
 166         } catch (AssertionError e) {
 167             Assert.assertEquals(b[i], f.apply(a, i), "at index #" + i);
 168         }
 169     }
 170 
 171     static void assertInsertArraysEquals(double[] a, double[] b, double element, int index) {
 172         int i = 0;
 173         try {
 174             for (; i < a.length; i += 1) {
 175                 if(i%SPECIES.length() == index) {
 176                     Assert.assertEquals(b[i], element);
 177                 } else {
 178                     Assert.assertEquals(b[i], a[i]);
 179                 }
 180             }
 181         } catch (AssertionError e) {
 182             if (i%SPECIES.length() == index) {
 183                 Assert.assertEquals(b[i], element, "at index #" + i);
 184             } else {
 185                 Assert.assertEquals(b[i], a[i], "at index #" + i);
 186             }
 187         }
 188     }
 189 
 190     static void assertRearrangeArraysEquals(double[] a, double[] r, int[] order, int vector_len) {
 191         int i = 0, j = 0;
 192         try {
 193             for (; i < a.length; i += vector_len) {
 194                 for (j = 0; j < vector_len; j++) {
 195                     Assert.assertEquals(r[i+j], a[i+order[i+j]]);
 196                 }
 197             }
 198         } catch (AssertionError e) {
 199             int idx = i + j;
 200             Assert.assertEquals(r[i+j], a[i+order[i+j]], "at index #" + idx + ", input = " + a[i+order[i+j]]);
 201         }
 202     }
 203 
 204     static void assertBroadcastArraysEquals(double[]a, double[]r) {
 205         int i = 0;
 206         for (; i < a.length; i += SPECIES.length()) {
 207             int idx = i;
 208             for (int j = idx; j < (idx + SPECIES.length()); j++)
 209                 a[j]=a[idx];
 210         }
 211 
 212         try {
 213             for (i = 0; i < a.length; i++) {
 214                 Assert.assertEquals(r[i], a[i]);
 215             }
 216         } catch (AssertionError e) {
 217             Assert.assertEquals(r[i], a[i], "at index #" + i + ", input = " + a[i]);
 218         }
 219     }
 220 
 221     interface FBinOp {
 222         double apply(double a, double b);
 223     }
 224 
 225     interface FBinMaskOp {
 226         double apply(double a, double b, boolean m);
 227 
 228         static FBinMaskOp lift(FBinOp f) {
 229             return (a, b, m) -> m ? f.apply(a, b) : a;
 230         }
 231     }
 232 
 233     static void assertArraysEquals(double[] a, double[] b, double[] r, FBinOp f) {
 234         int i = 0;
 235         try {
 236             for (; i < a.length; i++) {
 237                 Assert.assertEquals(r[i], f.apply(a[i], b[i]));
 238             }
 239         } catch (AssertionError e) {
 240             Assert.assertEquals(r[i], f.apply(a[i], b[i]), "(" + a[i] + ", " + b[i] + ") at index #" + i);
 241         }
 242     }
 243 
 244     static void assertBroadcastArraysEquals(double[] a, double[] b, double[] r, FBinOp f) {
 245         int i = 0;
 246         try {
 247             for (; i < a.length; i++) {
 248                 Assert.assertEquals(r[i], f.apply(a[i], b[(i / SPECIES.length()) * SPECIES.length()]));
 249             }
 250         } catch (AssertionError e) {
 251             Assert.assertEquals(r[i], f.apply(a[i], b[(i / SPECIES.length()) * SPECIES.length()]),
 252                                 "(" + a[i] + ", " + b[(i / SPECIES.length()) * SPECIES.length()] + ") at index #" + i);
 253         }
 254     }
 255 
 256     static void assertArraysEquals(double[] a, double[] b, double[] r, boolean[] mask, FBinOp f) {
 257         assertArraysEquals(a, b, r, mask, FBinMaskOp.lift(f));
 258     }
 259 
 260     static void assertArraysEquals(double[] a, double[] b, double[] r, boolean[] mask, FBinMaskOp f) {
 261         int i = 0;
 262         try {
 263             for (; i < a.length; i++) {
 264                 Assert.assertEquals(r[i], f.apply(a[i], b[i], mask[i % SPECIES.length()]));
 265             }
 266         } catch (AssertionError err) {
 267             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()]);
 268         }
 269     }
 270 
 271     static void assertBroadcastArraysEquals(double[] a, double[] b, double[] r, boolean[] mask, FBinOp f) {
 272         assertBroadcastArraysEquals(a, b, r, mask, FBinMaskOp.lift(f));
 273     }
 274 
 275     static void assertBroadcastArraysEquals(double[] a, double[] b, double[] r, boolean[] mask, FBinMaskOp f) {
 276         int i = 0;
 277         try {
 278             for (; i < a.length; i++) {
 279                 Assert.assertEquals(r[i], f.apply(a[i], b[(i / SPECIES.length()) * SPECIES.length()], mask[i % SPECIES.length()]));
 280             }
 281         } catch (AssertionError err) {
 282             Assert.assertEquals(r[i], f.apply(a[i], b[(i / SPECIES.length()) * SPECIES.length()], 
 283                                 mask[i % SPECIES.length()]), "at index #" + i + ", input1 = " + a[i] + 
 284                                 ", input2 = " + b[(i / SPECIES.length()) * SPECIES.length()] + ", mask = " +
 285                                 mask[i % SPECIES.length()]);
 286         }
 287     }
 288 
 289     static void assertShiftArraysEquals(double[] a, double[] b, double[] r, FBinOp f) {
 290         int i = 0;
 291         int j = 0;
 292         try {
 293             for (; j < a.length; j += SPECIES.length()) {
 294                 for (i = 0; i < SPECIES.length(); i++) {
 295                     Assert.assertEquals(r[i+j], f.apply(a[i+j], b[j]));
 296                 }
 297             }
 298         } catch (AssertionError e) {
 299             Assert.assertEquals(r[i+j], f.apply(a[i+j], b[j]), "at index #" + i + ", " + j);
 300         }
 301     }
 302 
 303     static void assertShiftArraysEquals(double[] a, double[] b, double[] r, boolean[] mask, FBinOp f) {
 304         assertShiftArraysEquals(a, b, r, mask, FBinMaskOp.lift(f));
 305     }
 306 
 307     static void assertShiftArraysEquals(double[] a, double[] b, double[] r, boolean[] mask, FBinMaskOp f) {
 308         int i = 0;
 309         int j = 0;
 310         try {
 311             for (; j < a.length; j += SPECIES.length()) {
 312                 for (i = 0; i < SPECIES.length(); i++) {
 313                     Assert.assertEquals(r[i+j], f.apply(a[i+j], b[j], mask[i]));
 314                 }
 315             }
 316         } catch (AssertionError err) {
 317             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]);
 318         }
 319     }
 320 
 321     interface FTernOp {
 322         double apply(double a, double b, double c);
 323     }
 324 
 325     interface FTernMaskOp {
 326         double apply(double a, double b, double c, boolean m);
 327 
 328         static FTernMaskOp lift(FTernOp f) {
 329             return (a, b, c, m) -> m ? f.apply(a, b, c) : a;
 330         }
 331     }
 332 
 333     static void assertArraysEquals(double[] a, double[] b, double[] c, double[] r, FTernOp f) {
 334         int i = 0;
 335         try {
 336             for (; i < a.length; i++) {
 337                 Assert.assertEquals(r[i], f.apply(a[i], b[i], c[i]));
 338             }
 339         } catch (AssertionError e) {
 340             Assert.assertEquals(r[i], f.apply(a[i], b[i], c[i]), "at index #" + i + ", input1 = " + a[i] + ", input2 = " + b[i] + ", input3 = " + c[i]);
 341         }
 342     }
 343 
 344     static void assertArraysEquals(double[] a, double[] b, double[] c, double[] r, boolean[] mask, FTernOp f) {
 345         assertArraysEquals(a, b, c, r, mask, FTernMaskOp.lift(f));
 346     }
 347 
 348     static void assertArraysEquals(double[] a, double[] b, double[] c, double[] r, boolean[] mask, FTernMaskOp f) {
 349         int i = 0;
 350         try {
 351             for (; i < a.length; i++) {
 352                 Assert.assertEquals(r[i], f.apply(a[i], b[i], c[i], mask[i % SPECIES.length()]));
 353             }
 354         } catch (AssertionError err) {
 355             Assert.assertEquals(r[i], f.apply(a[i], b[i], c[i], mask[i % SPECIES.length()]), "at index #" + i + ", input1 = " + a[i] + ", input2 = "
 356               + b[i] + ", input3 = " + c[i] + ", mask = " + mask[i % SPECIES.length()]);
 357         }
 358     }
 359 
 360     static boolean isWithin1Ulp(double actual, double expected) {
 361         if (Double.isNaN(expected) && !Double.isNaN(actual)) {
 362             return false;
 363         } else if (!Double.isNaN(expected) && Double.isNaN(actual)) {
 364             return false;
 365         }
 366 
 367         double low = Math.nextDown(expected);
 368         double high = Math.nextUp(expected);
 369 
 370         if (Double.compare(low, expected) > 0) {
 371             return false;
 372         }
 373 
 374         if (Double.compare(high, expected) < 0) {
 375             return false;
 376         }
 377 
 378         return true;
 379     }
 380 
 381     static void assertArraysEqualsWithinOneUlp(double[] a, double[] r, FUnOp mathf, FUnOp strictmathf) {
 382         int i = 0;
 383         try {
 384             // Check that result is within 1 ulp of strict math or equivalent to math implementation.
 385             for (; i < a.length; i++) {
 386                 Assert.assertTrue(Double.compare(r[i], mathf.apply(a[i])) == 0 ||
 387                                     isWithin1Ulp(r[i], strictmathf.apply(a[i])));
 388             }
 389         } catch (AssertionError e) {
 390             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]));
 391             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]));
 392         }
 393     }
 394 
 395     static void assertArraysEqualsWithinOneUlp(double[] a, double[] b, double[] r, FBinOp mathf, FBinOp strictmathf) {
 396         int i = 0;
 397         try {
 398             // Check that result is within 1 ulp of strict math or equivalent to math implementation.
 399             for (; i < a.length; i++) {
 400                 Assert.assertTrue(Double.compare(r[i], mathf.apply(a[i], b[i])) == 0 ||
 401                                     isWithin1Ulp(r[i], strictmathf.apply(a[i], b[i])));
 402             }
 403         } catch (AssertionError e) {
 404             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]));
 405             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]));
 406         }
 407     }
 408 
 409     interface FBinArrayOp {
 410         double apply(double[] a, int b);
 411     }
 412 
 413     static void assertArraysEquals(double[] a, double[] r, FBinArrayOp f) {
 414         int i = 0;
 415         try {
 416             for (; i < a.length; i++) {
 417                 Assert.assertEquals(r[i], f.apply(a, i));
 418             }
 419         } catch (AssertionError e) {
 420             Assert.assertEquals(r[i], f.apply(a,i), "at index #" + i);
 421         }
 422     }
 423 
 424     interface FGatherScatterOp {
 425         double[] apply(double[] a, int ix, int[] b, int iy);
 426     }
 427 
 428     static void assertArraysEquals(double[] a, int[] b, double[] r, FGatherScatterOp f) {
 429         int i = 0;
 430         try {
 431             for (; i < a.length; i += SPECIES.length()) {
 432                 Assert.assertEquals(Arrays.copyOfRange(r, i, i+SPECIES.length()),
 433                   f.apply(a, i, b, i));
 434             }
 435         } catch (AssertionError e) {
 436             double[] ref = f.apply(a, i, b, i);
 437             double[] res = Arrays.copyOfRange(r, i, i+SPECIES.length());
 438             Assert.assertEquals(res, ref,
 439               "(ref: " + Arrays.toString(ref) + ", res: " + Arrays.toString(res) + ", a: "
 440               + Arrays.toString(Arrays.copyOfRange(a, i, i+SPECIES.length()))
 441               + ", b: "
 442               + Arrays.toString(Arrays.copyOfRange(b, i, i+SPECIES.length()))
 443               + " at index #" + i);
 444         }
 445     }
 446 
 447     interface FGatherMaskedOp {
 448         double[] apply(double[] a, int ix, boolean[] mask, int[] b, int iy);
 449     }
 450 
 451     interface FScatterMaskedOp {
 452         double[] apply(double[] r, double[] a, int ix, boolean[] mask, int[] b, int iy);
 453     }
 454 
 455     static void assertArraysEquals(double[] a, int[] b, double[] r, boolean[] mask, FGatherMaskedOp f) {
 456         int i = 0;
 457         try {
 458             for (; i < a.length; i += SPECIES.length()) {
 459                 Assert.assertEquals(Arrays.copyOfRange(r, i, i+SPECIES.length()),
 460                   f.apply(a, i, mask, b, i));
 461             }
 462         } catch (AssertionError e) {
 463             double[] ref = f.apply(a, i, mask, b, i);
 464             double[] res = Arrays.copyOfRange(r, i, i+SPECIES.length());
 465             Assert.assertEquals(ref, res,
 466               "(ref: " + Arrays.toString(ref) + ", res: " + Arrays.toString(res) + ", a: "
 467               + Arrays.toString(Arrays.copyOfRange(a, i, i+SPECIES.length()))
 468               + ", b: "
 469               + Arrays.toString(Arrays.copyOfRange(b, i, i+SPECIES.length()))
 470               + ", mask: "
 471               + Arrays.toString(mask)
 472               + " at index #" + i);
 473         }
 474     }
 475 
 476     static void assertArraysEquals(double[] a, int[] b, double[] r, boolean[] mask, FScatterMaskedOp f) {
 477         int i = 0;
 478         try {
 479             for (; i < a.length; i += SPECIES.length()) {
 480                 Assert.assertEquals(Arrays.copyOfRange(r, i, i+SPECIES.length()),
 481                   f.apply(r, a, i, mask, b, i));
 482             }
 483         } catch (AssertionError e) {
 484             double[] ref = f.apply(r, a, i, mask, b, i);
 485             double[] res = Arrays.copyOfRange(r, i, i+SPECIES.length());
 486             Assert.assertEquals(ref, res,
 487               "(ref: " + Arrays.toString(ref) + ", res: " + Arrays.toString(res) + ", a: "
 488               + Arrays.toString(Arrays.copyOfRange(a, i, i+SPECIES.length()))
 489               + ", b: "
 490               + Arrays.toString(Arrays.copyOfRange(b, i, i+SPECIES.length()))
 491               + ", r: "
 492               + Arrays.toString(Arrays.copyOfRange(r, i, i+SPECIES.length()))
 493               + ", mask: "
 494               + Arrays.toString(mask)
 495               + " at index #" + i);
 496         }
 497     }
 498 
 499     interface FLaneOp {
 500         double[] apply(double[] a, int origin, int idx);
 501     }
 502 
 503     static void assertArraysEquals(double[] a, double[] r, int origin, FLaneOp f) {
 504         int i = 0;
 505         try {
 506             for (; i < a.length; i += SPECIES.length()) {
 507                 Assert.assertEquals(Arrays.copyOfRange(r, i, i+SPECIES.length()),
 508                   f.apply(a, origin, i));
 509             }
 510         } catch (AssertionError e) {
 511             double[] ref = f.apply(a, origin, i);
 512             double[] res = Arrays.copyOfRange(r, i, i+SPECIES.length());
 513             Assert.assertEquals(ref, res, "(ref: " + Arrays.toString(ref)
 514               + ", res: " + Arrays.toString(res)
 515               + "), at index #" + i);
 516         }
 517     }
 518 
 519     interface FLaneBop {
 520         double[] apply(double[] a, double[] b, int origin, int idx);
 521     }
 522 
 523     static void assertArraysEquals(double[] a, double[] b, double[] r, int origin, FLaneBop f) {
 524         int i = 0;
 525         try {
 526             for (; i < a.length; i += SPECIES.length()) {
 527                 Assert.assertEquals(Arrays.copyOfRange(r, i, i+SPECIES.length()),
 528                   f.apply(a, b, origin, i));
 529             }
 530         } catch (AssertionError e) {
 531             double[] ref = f.apply(a, b, origin, i);
 532             double[] res = Arrays.copyOfRange(r, i, i+SPECIES.length());
 533             Assert.assertEquals(ref, res, "(ref: " + Arrays.toString(ref)
 534               + ", res: " + Arrays.toString(res)
 535               + "), at index #" + i
 536               + ", at origin #" + origin);
 537         }
 538     }
 539 
 540     interface FLaneMaskedBop {
 541         double[] apply(double[] a, double[] b, int origin, boolean[] mask, int idx);
 542     }
 543 
 544     static void assertArraysEquals(double[] a, double[] b, double[] r, int origin, boolean[] mask, FLaneMaskedBop f) {
 545         int i = 0;
 546         try {
 547             for (; i < a.length; i += SPECIES.length()) {
 548                 Assert.assertEquals(Arrays.copyOfRange(r, i, i+SPECIES.length()),
 549                   f.apply(a, b, origin, mask, i));
 550             }
 551         } catch (AssertionError e) {
 552             double[] ref = f.apply(a, b, origin, mask, i);
 553             double[] res = Arrays.copyOfRange(r, i, i+SPECIES.length());
 554             Assert.assertEquals(ref, res, "(ref: " + Arrays.toString(ref)
 555               + ", res: " + Arrays.toString(res)
 556               + "), at index #" + i
 557               + ", at origin #" + origin);
 558         }
 559     }
 560 
 561     interface FLanePartBop {
 562         double[] apply(double[] a, double[] b, int origin, int part, int idx);
 563     }
 564 
 565     static void assertArraysEquals(double[] a, double[] b, double[] r, int origin, int part, FLanePartBop f) {
 566         int i = 0;
 567         try {
 568             for (; i < a.length; i += SPECIES.length()) {
 569                 Assert.assertEquals(Arrays.copyOfRange(r, i, i+SPECIES.length()),
 570                   f.apply(a, b, origin, part, i));
 571             }
 572         } catch (AssertionError e) {
 573             double[] ref = f.apply(a, b, origin, part, i);
 574             double[] res = Arrays.copyOfRange(r, i, i+SPECIES.length());
 575             Assert.assertEquals(ref, res, "(ref: " + Arrays.toString(ref)
 576               + ", res: " + Arrays.toString(res)
 577               + "), at index #" + i
 578               + ", at origin #" + origin
 579               + ", with part #" + part);
 580         }
 581     }
 582 
 583     interface FLanePartMaskedBop {
 584         double[] apply(double[] a, double[] b, int origin, int part, boolean[] mask, int idx);
 585     }
 586 
 587     static void assertArraysEquals(double[] a, double[] b, double[] r, int origin, int part, boolean[] mask, FLanePartMaskedBop f) {
 588         int i = 0;
 589         try {
 590             for (; i < a.length; i += SPECIES.length()) {
 591                 Assert.assertEquals(Arrays.copyOfRange(r, i, i+SPECIES.length()),
 592                   f.apply(a, b, origin, part, mask, i));
 593             }
 594         } catch (AssertionError e) {
 595             double[] ref = f.apply(a, b, origin, part, mask, i);
 596             double[] res = Arrays.copyOfRange(r, i, i+SPECIES.length());
 597             Assert.assertEquals(ref, res, "(ref: " + Arrays.toString(ref)
 598               + ", res: " + Arrays.toString(res)
 599               + "), at index #" + i
 600               + ", at origin #" + origin
 601               + ", with part #" + part);
 602         }
 603     }
 604 
 605     static long bits(double e) {
 606         return  Double.doubleToLongBits(e);
 607     }
 608 
 609     static final List<IntFunction<double[]>> DOUBLE_GENERATORS = List.of(
 610             withToString("double[-i * 5]", (int s) -> {
 611                 return fill(s * BUFFER_REPS,
 612                             i -> (double)(-i * 5));
 613             }),
 614             withToString("double[i * 5]", (int s) -> {
 615                 return fill(s * BUFFER_REPS,
 616                             i -> (double)(i * 5));
 617             }),
 618             withToString("double[i + 1]", (int s) -> {
 619                 return fill(s * BUFFER_REPS,
 620                             i -> (((double)(i + 1) == 0) ? 1 : (double)(i + 1)));
 621             }),
 622             withToString("double[cornerCaseValue(i)]", (int s) -> {
 623                 return fill(s * BUFFER_REPS,
 624                             i -> cornerCaseValue(i));
 625             })
 626     );
 627 
 628     // Create combinations of pairs
 629     // @@@ Might be sensitive to order e.g. div by 0
 630     static final List<List<IntFunction<double[]>>> DOUBLE_GENERATOR_PAIRS =
 631         Stream.of(DOUBLE_GENERATORS.get(0)).
 632                 flatMap(fa -> DOUBLE_GENERATORS.stream().skip(1).map(fb -> List.of(fa, fb))).
 633                 collect(Collectors.toList());
 634 
 635     @DataProvider
 636     public Object[][] boolUnaryOpProvider() {
 637         return BOOL_ARRAY_GENERATORS.stream().
 638                 map(f -> new Object[]{f}).
 639                 toArray(Object[][]::new);
 640     }
 641 
 642     static final List<List<IntFunction<double[]>>> DOUBLE_GENERATOR_TRIPLES =
 643         DOUBLE_GENERATOR_PAIRS.stream().
 644                 flatMap(pair -> DOUBLE_GENERATORS.stream().map(f -> List.of(pair.get(0), pair.get(1), f))).
 645                 collect(Collectors.toList());
 646 
 647     @DataProvider
 648     public Object[][] doubleBinaryOpProvider() {
 649         return DOUBLE_GENERATOR_PAIRS.stream().map(List::toArray).
 650                 toArray(Object[][]::new);
 651     }
 652 
 653     @DataProvider
 654     public Object[][] doubleIndexedOpProvider() {
 655         return DOUBLE_GENERATOR_PAIRS.stream().map(List::toArray).
 656                 toArray(Object[][]::new);
 657     }
 658 
 659     @DataProvider
 660     public Object[][] doubleBinaryOpMaskProvider() {
 661         return BOOLEAN_MASK_GENERATORS.stream().
 662                 flatMap(fm -> DOUBLE_GENERATOR_PAIRS.stream().map(lfa -> {
 663                     return Stream.concat(lfa.stream(), Stream.of(fm)).toArray();
 664                 })).
 665                 toArray(Object[][]::new);
 666     }
 667 
 668     @DataProvider
 669     public Object[][] doubleTernaryOpProvider() {
 670         return DOUBLE_GENERATOR_TRIPLES.stream().map(List::toArray).
 671                 toArray(Object[][]::new);
 672     }
 673 
 674     @DataProvider
 675     public Object[][] doubleTernaryOpMaskProvider() {
 676         return BOOLEAN_MASK_GENERATORS.stream().
 677                 flatMap(fm -> DOUBLE_GENERATOR_TRIPLES.stream().map(lfa -> {
 678                     return Stream.concat(lfa.stream(), Stream.of(fm)).toArray();
 679                 })).
 680                 toArray(Object[][]::new);
 681     }
 682 
 683     @DataProvider
 684     public Object[][] doubleUnaryOpProvider() {
 685         return DOUBLE_GENERATORS.stream().
 686                 map(f -> new Object[]{f}).
 687                 toArray(Object[][]::new);
 688     }
 689 
 690     @DataProvider
 691     public Object[][] doubleUnaryOpMaskProvider() {
 692         return BOOLEAN_MASK_GENERATORS.stream().
 693                 flatMap(fm -> DOUBLE_GENERATORS.stream().map(fa -> {
 694                     return new Object[] {fa, fm};
 695                 })).
 696                 toArray(Object[][]::new);
 697     }
 698 
 699     @DataProvider
 700     public Object[][] doubleUnaryOpShuffleProvider() {
 701         return INT_SHUFFLE_GENERATORS.stream().
 702                 flatMap(fs -> DOUBLE_GENERATORS.stream().map(fa -> {
 703                     return new Object[] {fa, fs};
 704                 })).
 705                 toArray(Object[][]::new);
 706     }
 707 
 708     @DataProvider
 709     public Object[][] doubleUnaryOpIndexProvider() {
 710         return INT_INDEX_GENERATORS.stream().
 711                 flatMap(fs -> DOUBLE_GENERATORS.stream().map(fa -> {
 712                     return new Object[] {fa, fs};
 713                 })).
 714                 toArray(Object[][]::new);
 715     }
 716 
 717     @DataProvider
 718     public Object[][] doubleUnaryMaskedOpIndexProvider() {
 719         return BOOLEAN_MASK_GENERATORS.stream().
 720           flatMap(fs -> INT_INDEX_GENERATORS.stream().flatMap(fm ->
 721             DOUBLE_GENERATORS.stream().map(fa -> {
 722                     return new Object[] {fa, fm, fs};
 723             }))).
 724             toArray(Object[][]::new);
 725     }
 726 
 727     @DataProvider
 728     public Object[][] scatterMaskedOpIndexProvider() {
 729         return BOOLEAN_MASK_GENERATORS.stream().
 730           flatMap(fs -> INT_INDEX_GENERATORS.stream().flatMap(fm ->
 731             DOUBLE_GENERATORS.stream().flatMap(fn ->
 732               DOUBLE_GENERATORS.stream().map(fa -> {
 733                     return new Object[] {fa, fn, fm, fs};
 734             })))).
 735             toArray(Object[][]::new);
 736     }
 737 
 738     static final List<IntFunction<double[]>> DOUBLE_COMPARE_GENERATORS = List.of(
 739             withToString("double[i]", (int s) -> {
 740                 return fill(s * BUFFER_REPS,
 741                             i -> (double)i);
 742             }),
 743             withToString("double[i + 1]", (int s) -> {
 744                 return fill(s * BUFFER_REPS,
 745                             i -> (double)(i + 1));
 746             }),
 747             withToString("double[i - 2]", (int s) -> {
 748                 return fill(s * BUFFER_REPS,
 749                             i -> (double)(i - 2));
 750             }),
 751             withToString("double[zigZag(i)]", (int s) -> {
 752                 return fill(s * BUFFER_REPS,
 753                             i -> i%3 == 0 ? (double)i : (i%3 == 1 ? (double)(i + 1) : (double)(i - 2)));
 754             }),
 755             withToString("double[cornerCaseValue(i)]", (int s) -> {
 756                 return fill(s * BUFFER_REPS,
 757                             i -> cornerCaseValue(i));
 758             })
 759     );
 760 
 761     static final List<List<IntFunction<double[]>>> DOUBLE_TEST_GENERATOR_ARGS =
 762         DOUBLE_COMPARE_GENERATORS.stream().
 763                 map(fa -> List.of(fa)).
 764                 collect(Collectors.toList());
 765 
 766     @DataProvider
 767     public Object[][] doubleTestOpProvider() {
 768         return DOUBLE_TEST_GENERATOR_ARGS.stream().map(List::toArray).
 769                 toArray(Object[][]::new);
 770     }
 771 
 772     static final List<List<IntFunction<double[]>>> DOUBLE_COMPARE_GENERATOR_PAIRS =
 773         DOUBLE_COMPARE_GENERATORS.stream().
 774                 flatMap(fa -> DOUBLE_COMPARE_GENERATORS.stream().map(fb -> List.of(fa, fb))).
 775                 collect(Collectors.toList());
 776 
 777     @DataProvider
 778     public Object[][] doubleCompareOpProvider() {
 779         return DOUBLE_COMPARE_GENERATOR_PAIRS.stream().map(List::toArray).
 780                 toArray(Object[][]::new);
 781     }
 782 
 783     interface ToDoubleF {
 784         double apply(int i);
 785     }
 786 
 787     static double[] fill(int s , ToDoubleF f) {
 788         return fill(new double[s], f);
 789     }
 790 
 791     static double[] fill(double[] a, ToDoubleF f) {
 792         for (int i = 0; i < a.length; i++) {
 793             a[i] = f.apply(i);
 794         }
 795         return a;
 796     }
 797 
 798     static double cornerCaseValue(int i) {
 799         switch(i % 7) {
 800             case 0:
 801                 return Double.MAX_VALUE;
 802             case 1:
 803                 return Double.MIN_VALUE;
 804             case 2:
 805                 return Double.NEGATIVE_INFINITY;
 806             case 3:
 807                 return Double.POSITIVE_INFINITY;
 808             case 4:
 809                 return Double.NaN;
 810             case 5:
 811                 return (double)0.0;
 812             default:
 813                 return (double)-0.0;
 814         }
 815     }
 816    static double get(double[] a, int i) {
 817        return (double) a[i];
 818    }
 819 
 820    static final IntFunction<double[]> fr = (vl) -> {
 821         int length = BUFFER_REPS * vl;
 822         return new double[length];
 823     };
 824 
 825     static final IntFunction<boolean[]> fmr = (vl) -> {
 826         int length = BUFFER_REPS * vl;
 827         return new boolean[length];
 828     };
 829 
 830 
 831     @Test
 832     static void smokeTest1() {
 833         DoubleVector three = DoubleVector.broadcast(SPECIES, (byte)-3);
 834         DoubleVector three2 = (DoubleVector) SPECIES.broadcast(-3);
 835         assert(three.eq(three2).allTrue());
 836         DoubleVector three3 = three2.broadcast(1).broadcast(-3);
 837         assert(three.eq(three3).allTrue());
 838         int scale = 2;
 839         Class<?> ETYPE = double.class;
 840         if (ETYPE == double.class || ETYPE == long.class)
 841             scale = 1000000;
 842         else if (ETYPE == byte.class && SPECIES.length() >= 64)
 843             scale = 1;
 844         DoubleVector higher = three.addIndex(scale);
 845         VectorMask<Double> m = three.compare(VectorOperators.LE, higher);
 846         assert(m.allTrue());
 847         m = higher.min((double)-1).test(VectorOperators.IS_NEGATIVE);
 848         assert(m.allTrue());
 849         m = higher.test(VectorOperators.IS_FINITE);
 850         assert(m.allTrue());
 851         double max = higher.reduceLanes(VectorOperators.MAX);
 852         assert(max == -3 + scale * (SPECIES.length()-1));
 853     }
 854 
 855     private static double[]
 856     bothToArray(DoubleVector a, DoubleVector b) {
 857         double[] r = new double[a.length() + b.length()];
 858         a.intoArray(r, 0);
 859         b.intoArray(r, a.length());
 860         return r;
 861     }
 862 
 863     @Test
 864     static void smokeTest2() {
 865         // Do some zipping and shuffling.
 866         DoubleVector io = (DoubleVector) SPECIES.broadcast(0).addIndex(1);
 867         DoubleVector io2 = (DoubleVector) VectorShuffle.iota(SPECIES,0,1,false).toVector();
 868         Assert.assertEquals(io, io2);
 869         DoubleVector a = io.add((double)1); //[1,2]
 870         DoubleVector b = a.neg();  //[-1,-2]
 871         double[] abValues = bothToArray(a,b); //[1,2,-1,-2]
 872         VectorShuffle<Double> zip0 = VectorShuffle.makeZip(SPECIES, 0);
 873         VectorShuffle<Double> zip1 = VectorShuffle.makeZip(SPECIES, 1);
 874         DoubleVector zab0 = a.rearrange(zip0,b); //[1,-1]
 875         DoubleVector zab1 = a.rearrange(zip1,b); //[2,-2]
 876         double[] zabValues = bothToArray(zab0, zab1); //[1,-1,2,-2]
 877         // manually zip
 878         double[] manual = new double[zabValues.length];
 879         for (int i = 0; i < manual.length; i += 2) {
 880             manual[i+0] = abValues[i/2];
 881             manual[i+1] = abValues[a.length() + i/2];
 882         }
 883         Assert.assertEquals(Arrays.toString(zabValues), Arrays.toString(manual));
 884         VectorShuffle<Double> unz0 = VectorShuffle.makeUnzip(SPECIES, 0);
 885         VectorShuffle<Double> unz1 = VectorShuffle.makeUnzip(SPECIES, 1);
 886         DoubleVector uab0 = zab0.rearrange(unz0,zab1);
 887         DoubleVector uab1 = zab0.rearrange(unz1,zab1);
 888         double[] abValues1 = bothToArray(uab0, uab1);
 889         Assert.assertEquals(Arrays.toString(abValues), Arrays.toString(abValues1));
 890     }
 891 
 892     static void iotaShuffle() {
 893         DoubleVector io = (DoubleVector) SPECIES.broadcast(0).addIndex(1);
 894         DoubleVector io2 = (DoubleVector) VectorShuffle.iota(SPECIES, 0 , 1, false).toVector();
 895         Assert.assertEquals(io, io2);
 896     }
 897 
 898     @Test
 899     // Test all shuffle related operations.
 900     static void shuffleTest() {
 901         // To test backend instructions, make sure that C2 is used.
 902         for (int loop = 0; loop < INVOC_COUNT * INVOC_COUNT; loop++) {
 903             iotaShuffle();
 904         }
 905     }
 906 
 907     @Test
 908     void viewAsIntegeralLanesTest() {
 909         Vector<?> asIntegral = SPECIES.zero().viewAsIntegralLanes();
 910         VectorSpecies<?> asIntegralSpecies = asIntegral.species();
 911         Assert.assertNotEquals(asIntegralSpecies.elementType(), SPECIES.elementType());
 912         Assert.assertEquals(asIntegralSpecies.vectorShape(), SPECIES.vectorShape());
 913         Assert.assertEquals(asIntegralSpecies.length(), SPECIES.length());
 914         Assert.assertEquals(asIntegral.viewAsFloatingLanes().species(), SPECIES);
 915     }
 916 
 917     @Test
 918     void viewAsFloatingLanesTest() {
 919         Vector<?> asFloating = SPECIES.zero().viewAsFloatingLanes();
 920         Assert.assertEquals(asFloating.species(), SPECIES);
 921     }
 922 
 923     static double ADD(double a, double b) {
 924         return (double)(a + b);
 925     }
 926 
 927     @Test(dataProvider = "doubleBinaryOpProvider")
 928     static void ADDDouble512VectorTests(IntFunction<double[]> fa, IntFunction<double[]> fb) {
 929         double[] a = fa.apply(SPECIES.length());
 930         double[] b = fb.apply(SPECIES.length());
 931         double[] r = fr.apply(SPECIES.length());
 932 
 933         for (int ic = 0; ic < INVOC_COUNT; ic++) {
 934             for (int i = 0; i < a.length; i += SPECIES.length()) {
 935                 DoubleVector av = DoubleVector.fromArray(SPECIES, a, i);
 936                 DoubleVector bv = DoubleVector.fromArray(SPECIES, b, i);
 937                 av.lanewise(VectorOperators.ADD, bv).intoArray(r, i);
 938             }
 939         }
 940 
 941         assertArraysEquals(a, b, r, Double512VectorTests::ADD);
 942     }
 943     static double add(double a, double b) {
 944         return (double)(a + b);
 945     }
 946 
 947     @Test(dataProvider = "doubleBinaryOpProvider")
 948     static void addDouble512VectorTests(IntFunction<double[]> fa, IntFunction<double[]> fb) {
 949         double[] a = fa.apply(SPECIES.length());
 950         double[] b = fb.apply(SPECIES.length());
 951         double[] r = fr.apply(SPECIES.length());
 952 
 953         for (int ic = 0; ic < INVOC_COUNT; ic++) {
 954             for (int i = 0; i < a.length; i += SPECIES.length()) {
 955                 DoubleVector av = DoubleVector.fromArray(SPECIES, a, i);
 956                 DoubleVector bv = DoubleVector.fromArray(SPECIES, b, i);
 957                 av.add(bv).intoArray(r, i);
 958             }
 959         }
 960 
 961         assertArraysEquals(a, b, r, Double512VectorTests::add);
 962     }
 963 
 964     @Test(dataProvider = "doubleBinaryOpMaskProvider")
 965     static void ADDDouble512VectorTestsMasked(IntFunction<double[]> fa, IntFunction<double[]> fb,
 966                                           IntFunction<boolean[]> fm) {
 967         double[] a = fa.apply(SPECIES.length());
 968         double[] b = fb.apply(SPECIES.length());
 969         double[] r = fr.apply(SPECIES.length());
 970         boolean[] mask = fm.apply(SPECIES.length());
 971         VectorMask<Double> vmask = VectorMask.fromArray(SPECIES, mask, 0);
 972 
 973         for (int ic = 0; ic < INVOC_COUNT; ic++) {
 974             for (int i = 0; i < a.length; i += SPECIES.length()) {
 975                 DoubleVector av = DoubleVector.fromArray(SPECIES, a, i);
 976                 DoubleVector bv = DoubleVector.fromArray(SPECIES, b, i);
 977                 av.lanewise(VectorOperators.ADD, bv, vmask).intoArray(r, i);
 978             }
 979         }
 980 
 981         assertArraysEquals(a, b, r, mask, Double512VectorTests::ADD);
 982     }
 983 
 984     @Test(dataProvider = "doubleBinaryOpMaskProvider")
 985     static void addDouble512VectorTestsMasked(IntFunction<double[]> fa, IntFunction<double[]> fb,
 986                                           IntFunction<boolean[]> fm) {
 987         double[] a = fa.apply(SPECIES.length());
 988         double[] b = fb.apply(SPECIES.length());
 989         double[] r = fr.apply(SPECIES.length());
 990         boolean[] mask = fm.apply(SPECIES.length());
 991         VectorMask<Double> vmask = VectorMask.fromArray(SPECIES, mask, 0);
 992 
 993         for (int ic = 0; ic < INVOC_COUNT; ic++) {
 994             for (int i = 0; i < a.length; i += SPECIES.length()) {
 995                 DoubleVector av = DoubleVector.fromArray(SPECIES, a, i);
 996                 DoubleVector bv = DoubleVector.fromArray(SPECIES, b, i);
 997                 av.add(bv, vmask).intoArray(r, i);
 998             }
 999         }
1000 
1001         assertArraysEquals(a, b, r, mask, Double512VectorTests::add);
1002     }
1003     static double SUB(double a, double b) {
1004         return (double)(a - b);
1005     }
1006 
1007     @Test(dataProvider = "doubleBinaryOpProvider")
1008     static void SUBDouble512VectorTests(IntFunction<double[]> fa, IntFunction<double[]> fb) {
1009         double[] a = fa.apply(SPECIES.length());
1010         double[] b = fb.apply(SPECIES.length());
1011         double[] r = fr.apply(SPECIES.length());
1012 
1013         for (int ic = 0; ic < INVOC_COUNT; ic++) {
1014             for (int i = 0; i < a.length; i += SPECIES.length()) {
1015                 DoubleVector av = DoubleVector.fromArray(SPECIES, a, i);
1016                 DoubleVector bv = DoubleVector.fromArray(SPECIES, b, i);
1017                 av.lanewise(VectorOperators.SUB, bv).intoArray(r, i);
1018             }
1019         }
1020 
1021         assertArraysEquals(a, b, r, Double512VectorTests::SUB);
1022     }
1023     static double sub(double a, double b) {
1024         return (double)(a - b);
1025     }
1026 
1027     @Test(dataProvider = "doubleBinaryOpProvider")
1028     static void subDouble512VectorTests(IntFunction<double[]> fa, IntFunction<double[]> fb) {
1029         double[] a = fa.apply(SPECIES.length());
1030         double[] b = fb.apply(SPECIES.length());
1031         double[] r = fr.apply(SPECIES.length());
1032 
1033         for (int ic = 0; ic < INVOC_COUNT; ic++) {
1034             for (int i = 0; i < a.length; i += SPECIES.length()) {
1035                 DoubleVector av = DoubleVector.fromArray(SPECIES, a, i);
1036                 DoubleVector bv = DoubleVector.fromArray(SPECIES, b, i);
1037                 av.sub(bv).intoArray(r, i);
1038             }
1039         }
1040 
1041         assertArraysEquals(a, b, r, Double512VectorTests::sub);
1042     }
1043 
1044     @Test(dataProvider = "doubleBinaryOpMaskProvider")
1045     static void SUBDouble512VectorTestsMasked(IntFunction<double[]> fa, IntFunction<double[]> fb,
1046                                           IntFunction<boolean[]> fm) {
1047         double[] a = fa.apply(SPECIES.length());
1048         double[] b = fb.apply(SPECIES.length());
1049         double[] r = fr.apply(SPECIES.length());
1050         boolean[] mask = fm.apply(SPECIES.length());
1051         VectorMask<Double> vmask = VectorMask.fromArray(SPECIES, mask, 0);
1052 
1053         for (int ic = 0; ic < INVOC_COUNT; ic++) {
1054             for (int i = 0; i < a.length; i += SPECIES.length()) {
1055                 DoubleVector av = DoubleVector.fromArray(SPECIES, a, i);
1056                 DoubleVector bv = DoubleVector.fromArray(SPECIES, b, i);
1057                 av.lanewise(VectorOperators.SUB, bv, vmask).intoArray(r, i);
1058             }
1059         }
1060 
1061         assertArraysEquals(a, b, r, mask, Double512VectorTests::SUB);
1062     }
1063 
1064     @Test(dataProvider = "doubleBinaryOpMaskProvider")
1065     static void subDouble512VectorTestsMasked(IntFunction<double[]> fa, IntFunction<double[]> fb,
1066                                           IntFunction<boolean[]> fm) {
1067         double[] a = fa.apply(SPECIES.length());
1068         double[] b = fb.apply(SPECIES.length());
1069         double[] r = fr.apply(SPECIES.length());
1070         boolean[] mask = fm.apply(SPECIES.length());
1071         VectorMask<Double> vmask = VectorMask.fromArray(SPECIES, mask, 0);
1072 
1073         for (int ic = 0; ic < INVOC_COUNT; ic++) {
1074             for (int i = 0; i < a.length; i += SPECIES.length()) {
1075                 DoubleVector av = DoubleVector.fromArray(SPECIES, a, i);
1076                 DoubleVector bv = DoubleVector.fromArray(SPECIES, b, i);
1077                 av.sub(bv, vmask).intoArray(r, i);
1078             }
1079         }
1080 
1081         assertArraysEquals(a, b, r, mask, Double512VectorTests::sub);
1082     }
1083     static double MUL(double a, double b) {
1084         return (double)(a * b);
1085     }
1086 
1087     @Test(dataProvider = "doubleBinaryOpProvider")
1088     static void MULDouble512VectorTests(IntFunction<double[]> fa, IntFunction<double[]> fb) {
1089         double[] a = fa.apply(SPECIES.length());
1090         double[] b = fb.apply(SPECIES.length());
1091         double[] r = fr.apply(SPECIES.length());
1092 
1093         for (int ic = 0; ic < INVOC_COUNT; ic++) {
1094             for (int i = 0; i < a.length; i += SPECIES.length()) {
1095                 DoubleVector av = DoubleVector.fromArray(SPECIES, a, i);
1096                 DoubleVector bv = DoubleVector.fromArray(SPECIES, b, i);
1097                 av.lanewise(VectorOperators.MUL, bv).intoArray(r, i);
1098             }
1099         }
1100 
1101         assertArraysEquals(a, b, r, Double512VectorTests::MUL);
1102     }
1103     static double mul(double a, double b) {
1104         return (double)(a * b);
1105     }
1106 
1107     @Test(dataProvider = "doubleBinaryOpProvider")
1108     static void mulDouble512VectorTests(IntFunction<double[]> fa, IntFunction<double[]> fb) {
1109         double[] a = fa.apply(SPECIES.length());
1110         double[] b = fb.apply(SPECIES.length());
1111         double[] r = fr.apply(SPECIES.length());
1112 
1113         for (int ic = 0; ic < INVOC_COUNT; ic++) {
1114             for (int i = 0; i < a.length; i += SPECIES.length()) {
1115                 DoubleVector av = DoubleVector.fromArray(SPECIES, a, i);
1116                 DoubleVector bv = DoubleVector.fromArray(SPECIES, b, i);
1117                 av.mul(bv).intoArray(r, i);
1118             }
1119         }
1120 
1121         assertArraysEquals(a, b, r, Double512VectorTests::mul);
1122     }
1123 
1124     @Test(dataProvider = "doubleBinaryOpMaskProvider")
1125     static void MULDouble512VectorTestsMasked(IntFunction<double[]> fa, IntFunction<double[]> fb,
1126                                           IntFunction<boolean[]> fm) {
1127         double[] a = fa.apply(SPECIES.length());
1128         double[] b = fb.apply(SPECIES.length());
1129         double[] r = fr.apply(SPECIES.length());
1130         boolean[] mask = fm.apply(SPECIES.length());
1131         VectorMask<Double> vmask = VectorMask.fromArray(SPECIES, mask, 0);
1132 
1133         for (int ic = 0; ic < INVOC_COUNT; ic++) {
1134             for (int i = 0; i < a.length; i += SPECIES.length()) {
1135                 DoubleVector av = DoubleVector.fromArray(SPECIES, a, i);
1136                 DoubleVector bv = DoubleVector.fromArray(SPECIES, b, i);
1137                 av.lanewise(VectorOperators.MUL, bv, vmask).intoArray(r, i);
1138             }
1139         }
1140 
1141         assertArraysEquals(a, b, r, mask, Double512VectorTests::MUL);
1142     }
1143 
1144     @Test(dataProvider = "doubleBinaryOpMaskProvider")
1145     static void mulDouble512VectorTestsMasked(IntFunction<double[]> fa, IntFunction<double[]> fb,
1146                                           IntFunction<boolean[]> fm) {
1147         double[] a = fa.apply(SPECIES.length());
1148         double[] b = fb.apply(SPECIES.length());
1149         double[] r = fr.apply(SPECIES.length());
1150         boolean[] mask = fm.apply(SPECIES.length());
1151         VectorMask<Double> vmask = VectorMask.fromArray(SPECIES, mask, 0);
1152 
1153         for (int ic = 0; ic < INVOC_COUNT; ic++) {
1154             for (int i = 0; i < a.length; i += SPECIES.length()) {
1155                 DoubleVector av = DoubleVector.fromArray(SPECIES, a, i);
1156                 DoubleVector bv = DoubleVector.fromArray(SPECIES, b, i);
1157                 av.mul(bv, vmask).intoArray(r, i);
1158             }
1159         }
1160 
1161         assertArraysEquals(a, b, r, mask, Double512VectorTests::mul);
1162     }
1163 
1164     static double DIV(double a, double b) {
1165         return (double)(a / b);
1166     }
1167 
1168     @Test(dataProvider = "doubleBinaryOpProvider")
1169     static void DIVDouble512VectorTests(IntFunction<double[]> fa, IntFunction<double[]> fb) {
1170         double[] a = fa.apply(SPECIES.length());
1171         double[] b = fb.apply(SPECIES.length());
1172         double[] r = fr.apply(SPECIES.length());
1173 
1174         for (int ic = 0; ic < INVOC_COUNT; ic++) {
1175             for (int i = 0; i < a.length; i += SPECIES.length()) {
1176                 DoubleVector av = DoubleVector.fromArray(SPECIES, a, i);
1177                 DoubleVector bv = DoubleVector.fromArray(SPECIES, b, i);
1178                 av.lanewise(VectorOperators.DIV, bv).intoArray(r, i);
1179             }
1180         }
1181 
1182         assertArraysEquals(a, b, r, Double512VectorTests::DIV);
1183     }
1184     static double div(double a, double b) {
1185         return (double)(a / b);
1186     }
1187 
1188     @Test(dataProvider = "doubleBinaryOpProvider")
1189     static void divDouble512VectorTests(IntFunction<double[]> fa, IntFunction<double[]> fb) {
1190         double[] a = fa.apply(SPECIES.length());
1191         double[] b = fb.apply(SPECIES.length());
1192         double[] r = fr.apply(SPECIES.length());
1193 
1194         for (int ic = 0; ic < INVOC_COUNT; ic++) {
1195             for (int i = 0; i < a.length; i += SPECIES.length()) {
1196                 DoubleVector av = DoubleVector.fromArray(SPECIES, a, i);
1197                 DoubleVector bv = DoubleVector.fromArray(SPECIES, b, i);
1198                 av.div(bv).intoArray(r, i);
1199             }
1200         }
1201 
1202         assertArraysEquals(a, b, r, Double512VectorTests::div);
1203     }
1204 
1205 
1206 
1207     @Test(dataProvider = "doubleBinaryOpMaskProvider")
1208     static void DIVDouble512VectorTestsMasked(IntFunction<double[]> fa, IntFunction<double[]> fb,
1209                                           IntFunction<boolean[]> fm) {
1210         double[] a = fa.apply(SPECIES.length());
1211         double[] b = fb.apply(SPECIES.length());
1212         double[] r = fr.apply(SPECIES.length());
1213         boolean[] mask = fm.apply(SPECIES.length());
1214         VectorMask<Double> vmask = VectorMask.fromArray(SPECIES, mask, 0);
1215 
1216         for (int ic = 0; ic < INVOC_COUNT; ic++) {
1217             for (int i = 0; i < a.length; i += SPECIES.length()) {
1218                 DoubleVector av = DoubleVector.fromArray(SPECIES, a, i);
1219                 DoubleVector bv = DoubleVector.fromArray(SPECIES, b, i);
1220                 av.lanewise(VectorOperators.DIV, bv, vmask).intoArray(r, i);
1221             }
1222         }
1223 
1224         assertArraysEquals(a, b, r, mask, Double512VectorTests::DIV);
1225     }
1226 
1227     @Test(dataProvider = "doubleBinaryOpMaskProvider")
1228     static void divDouble512VectorTestsMasked(IntFunction<double[]> fa, IntFunction<double[]> fb,
1229                                           IntFunction<boolean[]> fm) {
1230         double[] a = fa.apply(SPECIES.length());
1231         double[] b = fb.apply(SPECIES.length());
1232         double[] r = fr.apply(SPECIES.length());
1233         boolean[] mask = fm.apply(SPECIES.length());
1234         VectorMask<Double> vmask = VectorMask.fromArray(SPECIES, mask, 0);
1235 
1236         for (int ic = 0; ic < INVOC_COUNT; ic++) {
1237             for (int i = 0; i < a.length; i += SPECIES.length()) {
1238                 DoubleVector av = DoubleVector.fromArray(SPECIES, a, i);
1239                 DoubleVector bv = DoubleVector.fromArray(SPECIES, b, i);
1240                 av.div(bv, vmask).intoArray(r, i);
1241             }
1242         }
1243 
1244         assertArraysEquals(a, b, r, mask, Double512VectorTests::div);
1245     }
1246 
1247 
1248 
1249     static double FIRST_NONZERO(double a, double b) {
1250         return (double)(Double.doubleToLongBits(a)!=0?a:b);
1251     }
1252 
1253     @Test(dataProvider = "doubleBinaryOpProvider")
1254     static void FIRST_NONZERODouble512VectorTests(IntFunction<double[]> fa, IntFunction<double[]> fb) {
1255         double[] a = fa.apply(SPECIES.length());
1256         double[] b = fb.apply(SPECIES.length());
1257         double[] r = fr.apply(SPECIES.length());
1258 
1259         for (int ic = 0; ic < INVOC_COUNT; ic++) {
1260             for (int i = 0; i < a.length; i += SPECIES.length()) {
1261                 DoubleVector av = DoubleVector.fromArray(SPECIES, a, i);
1262                 DoubleVector bv = DoubleVector.fromArray(SPECIES, b, i);
1263                 av.lanewise(VectorOperators.FIRST_NONZERO, bv).intoArray(r, i);
1264             }
1265         }
1266 
1267         assertArraysEquals(a, b, r, Double512VectorTests::FIRST_NONZERO);
1268     }
1269 
1270     @Test(dataProvider = "doubleBinaryOpMaskProvider")
1271     static void FIRST_NONZERODouble512VectorTestsMasked(IntFunction<double[]> fa, IntFunction<double[]> fb,
1272                                           IntFunction<boolean[]> fm) {
1273         double[] a = fa.apply(SPECIES.length());
1274         double[] b = fb.apply(SPECIES.length());
1275         double[] r = fr.apply(SPECIES.length());
1276         boolean[] mask = fm.apply(SPECIES.length());
1277         VectorMask<Double> vmask = VectorMask.fromArray(SPECIES, mask, 0);
1278 
1279         for (int ic = 0; ic < INVOC_COUNT; ic++) {
1280             for (int i = 0; i < a.length; i += SPECIES.length()) {
1281                 DoubleVector av = DoubleVector.fromArray(SPECIES, a, i);
1282                 DoubleVector bv = DoubleVector.fromArray(SPECIES, b, i);
1283                 av.lanewise(VectorOperators.FIRST_NONZERO, bv, vmask).intoArray(r, i);
1284             }
1285         }
1286 
1287         assertArraysEquals(a, b, r, mask, Double512VectorTests::FIRST_NONZERO);
1288     }
1289 
1290 
1291 
1292 
1293 
1294 
1295 
1296 
1297 
1298     @Test(dataProvider = "doubleBinaryOpProvider")
1299     static void addDouble512VectorTestsBroadcastSmokeTest(IntFunction<double[]> fa, IntFunction<double[]> fb) {
1300         double[] a = fa.apply(SPECIES.length());
1301         double[] b = fb.apply(SPECIES.length());
1302         double[] r = fr.apply(SPECIES.length());
1303 
1304         for (int i = 0; i < a.length; i += SPECIES.length()) {
1305             DoubleVector av = DoubleVector.fromArray(SPECIES, a, i);
1306             av.add(b[i]).intoArray(r, i);
1307         }
1308 
1309         assertBroadcastArraysEquals(a, b, r, Double512VectorTests::add);
1310     }
1311 
1312     @Test(dataProvider = "doubleBinaryOpMaskProvider")
1313     static void addDouble512VectorTestsBroadcastMaskedSmokeTest(IntFunction<double[]> fa, IntFunction<double[]> fb,
1314                                           IntFunction<boolean[]> fm) {
1315         double[] a = fa.apply(SPECIES.length());
1316         double[] b = fb.apply(SPECIES.length());
1317         double[] r = fr.apply(SPECIES.length());
1318         boolean[] mask = fm.apply(SPECIES.length());
1319         VectorMask<Double> vmask = VectorMask.fromArray(SPECIES, mask, 0);
1320 
1321         for (int i = 0; i < a.length; i += SPECIES.length()) {
1322             DoubleVector av = DoubleVector.fromArray(SPECIES, a, i);
1323             av.add(b[i], vmask).intoArray(r, i);
1324         }
1325 
1326         assertBroadcastArraysEquals(a, b, r, mask, Double512VectorTests::add);
1327     }
1328 
1329     @Test(dataProvider = "doubleBinaryOpProvider")
1330     static void subDouble512VectorTestsBroadcastSmokeTest(IntFunction<double[]> fa, IntFunction<double[]> fb) {
1331         double[] a = fa.apply(SPECIES.length());
1332         double[] b = fb.apply(SPECIES.length());
1333         double[] r = fr.apply(SPECIES.length());
1334 
1335         for (int i = 0; i < a.length; i += SPECIES.length()) {
1336             DoubleVector av = DoubleVector.fromArray(SPECIES, a, i);
1337             av.sub(b[i]).intoArray(r, i);
1338         }
1339 
1340         assertBroadcastArraysEquals(a, b, r, Double512VectorTests::sub);
1341     }
1342 
1343     @Test(dataProvider = "doubleBinaryOpMaskProvider")
1344     static void subDouble512VectorTestsBroadcastMaskedSmokeTest(IntFunction<double[]> fa, IntFunction<double[]> fb,
1345                                           IntFunction<boolean[]> fm) {
1346         double[] a = fa.apply(SPECIES.length());
1347         double[] b = fb.apply(SPECIES.length());
1348         double[] r = fr.apply(SPECIES.length());
1349         boolean[] mask = fm.apply(SPECIES.length());
1350         VectorMask<Double> vmask = VectorMask.fromArray(SPECIES, mask, 0);
1351 
1352         for (int i = 0; i < a.length; i += SPECIES.length()) {
1353             DoubleVector av = DoubleVector.fromArray(SPECIES, a, i);
1354             av.sub(b[i], vmask).intoArray(r, i);
1355         }
1356 
1357         assertBroadcastArraysEquals(a, b, r, mask, Double512VectorTests::sub);
1358     }
1359 
1360     @Test(dataProvider = "doubleBinaryOpProvider")
1361     static void mulDouble512VectorTestsBroadcastSmokeTest(IntFunction<double[]> fa, IntFunction<double[]> fb) {
1362         double[] a = fa.apply(SPECIES.length());
1363         double[] b = fb.apply(SPECIES.length());
1364         double[] r = fr.apply(SPECIES.length());
1365 
1366         for (int i = 0; i < a.length; i += SPECIES.length()) {
1367             DoubleVector av = DoubleVector.fromArray(SPECIES, a, i);
1368             av.mul(b[i]).intoArray(r, i);
1369         }
1370 
1371         assertBroadcastArraysEquals(a, b, r, Double512VectorTests::mul);
1372     }
1373 
1374     @Test(dataProvider = "doubleBinaryOpMaskProvider")
1375     static void mulDouble512VectorTestsBroadcastMaskedSmokeTest(IntFunction<double[]> fa, IntFunction<double[]> fb,
1376                                           IntFunction<boolean[]> fm) {
1377         double[] a = fa.apply(SPECIES.length());
1378         double[] b = fb.apply(SPECIES.length());
1379         double[] r = fr.apply(SPECIES.length());
1380         boolean[] mask = fm.apply(SPECIES.length());
1381         VectorMask<Double> vmask = VectorMask.fromArray(SPECIES, mask, 0);
1382 
1383         for (int i = 0; i < a.length; i += SPECIES.length()) {
1384             DoubleVector av = DoubleVector.fromArray(SPECIES, a, i);
1385             av.mul(b[i], vmask).intoArray(r, i);
1386         }
1387 
1388         assertBroadcastArraysEquals(a, b, r, mask, Double512VectorTests::mul);
1389     }
1390 
1391 
1392     @Test(dataProvider = "doubleBinaryOpProvider")
1393     static void divDouble512VectorTestsBroadcastSmokeTest(IntFunction<double[]> fa, IntFunction<double[]> fb) {
1394         double[] a = fa.apply(SPECIES.length());
1395         double[] b = fb.apply(SPECIES.length());
1396         double[] r = fr.apply(SPECIES.length());
1397 
1398         for (int i = 0; i < a.length; i += SPECIES.length()) {
1399             DoubleVector av = DoubleVector.fromArray(SPECIES, a, i);
1400             av.div(b[i]).intoArray(r, i);
1401         }
1402 
1403         assertBroadcastArraysEquals(a, b, r, Double512VectorTests::div);
1404     }
1405 
1406 
1407 
1408     @Test(dataProvider = "doubleBinaryOpMaskProvider")
1409     static void divDouble512VectorTestsBroadcastMaskedSmokeTest(IntFunction<double[]> fa, IntFunction<double[]> fb,
1410                                           IntFunction<boolean[]> fm) {
1411         double[] a = fa.apply(SPECIES.length());
1412         double[] b = fb.apply(SPECIES.length());
1413         double[] r = fr.apply(SPECIES.length());
1414         boolean[] mask = fm.apply(SPECIES.length());
1415         VectorMask<Double> vmask = VectorMask.fromArray(SPECIES, mask, 0);
1416 
1417         for (int i = 0; i < a.length; i += SPECIES.length()) {
1418             DoubleVector av = DoubleVector.fromArray(SPECIES, a, i);
1419             av.div(b[i], vmask).intoArray(r, i);
1420         }
1421 
1422         assertBroadcastArraysEquals(a, b, r, mask, Double512VectorTests::div);
1423     }
1424 
1425 
1426 
1427 
1428 
1429 
1430 
1431 
1432 
1433 
1434 
1435 
1436 
1437 
1438 
1439 
1440 
1441 
1442 
1443 
1444 
1445 
1446 
1447 
1448 
1449 
1450 
1451 
1452 
1453 
1454 
1455 
1456 
1457 
1458 
1459 
1460 
1461 
1462 
1463 
1464 
1465     static double MIN(double a, double b) {
1466         return (double)(Math.min(a, b));
1467     }
1468 
1469     @Test(dataProvider = "doubleBinaryOpProvider")
1470     static void MINDouble512VectorTests(IntFunction<double[]> fa, IntFunction<double[]> fb) {
1471         double[] a = fa.apply(SPECIES.length());
1472         double[] b = fb.apply(SPECIES.length());
1473         double[] r = fr.apply(SPECIES.length());
1474 
1475         for (int ic = 0; ic < INVOC_COUNT; ic++) {
1476             for (int i = 0; i < a.length; i += SPECIES.length()) {
1477                 DoubleVector av = DoubleVector.fromArray(SPECIES, a, i);
1478                 DoubleVector bv = DoubleVector.fromArray(SPECIES, b, i);
1479                 av.lanewise(VectorOperators.MIN, bv).intoArray(r, i);
1480             }
1481         }
1482 
1483         assertArraysEquals(a, b, r, Double512VectorTests::MIN);
1484     }
1485     static double min(double a, double b) {
1486         return (double)(Math.min(a, b));
1487     }
1488 
1489     @Test(dataProvider = "doubleBinaryOpProvider")
1490     static void minDouble512VectorTests(IntFunction<double[]> fa, IntFunction<double[]> fb) {
1491         double[] a = fa.apply(SPECIES.length());
1492         double[] b = fb.apply(SPECIES.length());
1493         double[] r = fr.apply(SPECIES.length());
1494 
1495         for (int ic = 0; ic < INVOC_COUNT; ic++) {
1496             for (int i = 0; i < a.length; i += SPECIES.length()) {
1497                 DoubleVector av = DoubleVector.fromArray(SPECIES, a, i);
1498                 DoubleVector bv = DoubleVector.fromArray(SPECIES, b, i);
1499                 av.min(bv).intoArray(r, i);
1500             }
1501         }
1502 
1503         assertArraysEquals(a, b, r, Double512VectorTests::min);
1504     }
1505     static double MAX(double a, double b) {
1506         return (double)(Math.max(a, b));
1507     }
1508 
1509     @Test(dataProvider = "doubleBinaryOpProvider")
1510     static void MAXDouble512VectorTests(IntFunction<double[]> fa, IntFunction<double[]> fb) {
1511         double[] a = fa.apply(SPECIES.length());
1512         double[] b = fb.apply(SPECIES.length());
1513         double[] r = fr.apply(SPECIES.length());
1514 
1515         for (int ic = 0; ic < INVOC_COUNT; ic++) {
1516             for (int i = 0; i < a.length; i += SPECIES.length()) {
1517                 DoubleVector av = DoubleVector.fromArray(SPECIES, a, i);
1518                 DoubleVector bv = DoubleVector.fromArray(SPECIES, b, i);
1519                 av.lanewise(VectorOperators.MAX, bv).intoArray(r, i);
1520             }
1521         }
1522 
1523         assertArraysEquals(a, b, r, Double512VectorTests::MAX);
1524     }
1525     static double max(double a, double b) {
1526         return (double)(Math.max(a, b));
1527     }
1528 
1529     @Test(dataProvider = "doubleBinaryOpProvider")
1530     static void maxDouble512VectorTests(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.max(bv).intoArray(r, i);
1540             }
1541         }
1542 
1543         assertArraysEquals(a, b, r, Double512VectorTests::max);
1544     }
1545 
1546     @Test(dataProvider = "doubleBinaryOpProvider")
1547     static void MINDouble512VectorTestsBroadcastSmokeTest(IntFunction<double[]> fa, IntFunction<double[]> fb) {
1548         double[] a = fa.apply(SPECIES.length());
1549         double[] b = fb.apply(SPECIES.length());
1550         double[] r = fr.apply(SPECIES.length());
1551 
1552         for (int i = 0; i < a.length; i += SPECIES.length()) {
1553             DoubleVector av = DoubleVector.fromArray(SPECIES, a, i);
1554             av.lanewise(VectorOperators.MIN, b[i]).intoArray(r, i);
1555         }
1556 
1557         assertBroadcastArraysEquals(a, b, r, Double512VectorTests::MIN);
1558     }
1559 
1560     @Test(dataProvider = "doubleBinaryOpProvider")
1561     static void minDouble512VectorTestsBroadcastSmokeTest(IntFunction<double[]> fa, IntFunction<double[]> fb) {
1562         double[] a = fa.apply(SPECIES.length());
1563         double[] b = fb.apply(SPECIES.length());
1564         double[] r = fr.apply(SPECIES.length());
1565 
1566         for (int i = 0; i < a.length; i += SPECIES.length()) {
1567             DoubleVector av = DoubleVector.fromArray(SPECIES, a, i);
1568             av.min(b[i]).intoArray(r, i);
1569         }
1570 
1571         assertBroadcastArraysEquals(a, b, r, Double512VectorTests::min);
1572     }
1573 
1574     @Test(dataProvider = "doubleBinaryOpProvider")
1575     static void MAXDouble512VectorTestsBroadcastSmokeTest(IntFunction<double[]> fa, IntFunction<double[]> fb) {
1576         double[] a = fa.apply(SPECIES.length());
1577         double[] b = fb.apply(SPECIES.length());
1578         double[] r = fr.apply(SPECIES.length());
1579 
1580         for (int i = 0; i < a.length; i += SPECIES.length()) {
1581             DoubleVector av = DoubleVector.fromArray(SPECIES, a, i);
1582             av.lanewise(VectorOperators.MAX, b[i]).intoArray(r, i);
1583         }
1584 
1585         assertBroadcastArraysEquals(a, b, r, Double512VectorTests::MAX);
1586     }
1587 
1588     @Test(dataProvider = "doubleBinaryOpProvider")
1589     static void maxDouble512VectorTestsBroadcastSmokeTest(IntFunction<double[]> fa, IntFunction<double[]> fb) {
1590         double[] a = fa.apply(SPECIES.length());
1591         double[] b = fb.apply(SPECIES.length());
1592         double[] r = fr.apply(SPECIES.length());
1593 
1594         for (int i = 0; i < a.length; i += SPECIES.length()) {
1595             DoubleVector av = DoubleVector.fromArray(SPECIES, a, i);
1596             av.max(b[i]).intoArray(r, i);
1597         }
1598 
1599         assertBroadcastArraysEquals(a, b, r, Double512VectorTests::max);
1600     }
1601 
1602 
1603 
1604 
1605 
1606 
1607 
1608 
1609 
1610 
1611 
1612 
1613     static double ADD(double[] a, int idx) {
1614         double res = 0;
1615         for (int i = idx; i < (idx + SPECIES.length()); i++) {
1616             res += a[i];
1617         }
1618 
1619         return res;
1620     }
1621 
1622     static double ADD(double[] a) {
1623         double res = 0;
1624         for (int i = 0; i < a.length; i += SPECIES.length()) {
1625             double tmp = 0;
1626             for (int j = 0; j < SPECIES.length(); j++) {
1627                 tmp += a[i + j];
1628             }
1629             res += tmp;
1630         }
1631 
1632         return res;
1633     }
1634     @Test(dataProvider = "doubleUnaryOpProvider")
1635     static void ADDDouble512VectorTests(IntFunction<double[]> fa) {
1636         double[] a = fa.apply(SPECIES.length());
1637         double[] r = fr.apply(SPECIES.length());
1638         double ra = 0;
1639 
1640         for (int ic = 0; ic < INVOC_COUNT; ic++) {
1641             for (int i = 0; i < a.length; i += SPECIES.length()) {
1642                 DoubleVector av = DoubleVector.fromArray(SPECIES, a, i);
1643                 r[i] = av.reduceLanes(VectorOperators.ADD);
1644             }
1645         }
1646 
1647         for (int ic = 0; ic < INVOC_COUNT; ic++) {
1648             ra = 0;
1649             for (int i = 0; i < a.length; i += SPECIES.length()) {
1650                 DoubleVector av = DoubleVector.fromArray(SPECIES, a, i);
1651                 ra += av.reduceLanes(VectorOperators.ADD);
1652             }
1653         }
1654 
1655         assertReductionArraysEquals(a, r, ra, Double512VectorTests::ADD, Double512VectorTests::ADD);
1656     }
1657     static double ADDMasked(double[] a, int idx, boolean[] mask) {
1658         double res = 0;
1659         for (int i = idx; i < (idx + SPECIES.length()); i++) {
1660             if(mask[i % SPECIES.length()])
1661                 res += a[i];
1662         }
1663 
1664         return res;
1665     }
1666 
1667     static double ADDMasked(double[] a, boolean[] mask) {
1668         double res = 0;
1669         for (int i = 0; i < a.length; i += SPECIES.length()) {
1670             double tmp = 0;
1671             for (int j = 0; j < SPECIES.length(); j++) {
1672                 if(mask[(i + j) % SPECIES.length()])
1673                     tmp += a[i + j];
1674             }
1675             res += tmp;
1676         }
1677 
1678         return res;
1679     }
1680     @Test(dataProvider = "doubleUnaryOpMaskProvider")
1681     static void ADDDouble512VectorTestsMasked(IntFunction<double[]> fa, IntFunction<boolean[]> fm) {
1682         double[] a = fa.apply(SPECIES.length());
1683         double[] r = fr.apply(SPECIES.length());
1684         boolean[] mask = fm.apply(SPECIES.length());
1685         VectorMask<Double> vmask = VectorMask.fromArray(SPECIES, mask, 0);
1686         double ra = 0;
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                 r[i] = av.reduceLanes(VectorOperators.ADD, vmask);
1692             }
1693         }
1694 
1695         for (int ic = 0; ic < INVOC_COUNT; ic++) {
1696             ra = 0;
1697             for (int i = 0; i < a.length; i += SPECIES.length()) {
1698                 DoubleVector av = DoubleVector.fromArray(SPECIES, a, i);
1699                 ra += av.reduceLanes(VectorOperators.ADD, vmask);
1700             }
1701         }
1702 
1703         assertReductionArraysEqualsMasked(a, r, ra, mask, Double512VectorTests::ADDMasked, Double512VectorTests::ADDMasked);
1704     }
1705     static double MUL(double[] a, int idx) {
1706         double res = 1;
1707         for (int i = idx; i < (idx + SPECIES.length()); i++) {
1708             res *= a[i];
1709         }
1710 
1711         return res;
1712     }
1713 
1714     static double MUL(double[] a) {
1715         double res = 1;
1716         for (int i = 0; i < a.length; i += SPECIES.length()) {
1717             double tmp = 1;
1718             for (int j = 0; j < SPECIES.length(); j++) {
1719                 tmp *= a[i + j];
1720             }
1721             res *= tmp;
1722         }
1723 
1724         return res;
1725     }
1726     @Test(dataProvider = "doubleUnaryOpProvider")
1727     static void MULDouble512VectorTests(IntFunction<double[]> fa) {
1728         double[] a = fa.apply(SPECIES.length());
1729         double[] r = fr.apply(SPECIES.length());
1730         double ra = 1;
1731 
1732         for (int ic = 0; ic < INVOC_COUNT; ic++) {
1733             for (int i = 0; i < a.length; i += SPECIES.length()) {
1734                 DoubleVector av = DoubleVector.fromArray(SPECIES, a, i);
1735                 r[i] = av.reduceLanes(VectorOperators.MUL);
1736             }
1737         }
1738 
1739         for (int ic = 0; ic < INVOC_COUNT; ic++) {
1740             ra = 1;
1741             for (int i = 0; i < a.length; i += SPECIES.length()) {
1742                 DoubleVector av = DoubleVector.fromArray(SPECIES, a, i);
1743                 ra *= av.reduceLanes(VectorOperators.MUL);
1744             }
1745         }
1746 
1747         assertReductionArraysEquals(a, r, ra, Double512VectorTests::MUL, Double512VectorTests::MUL);
1748     }
1749     static double MULMasked(double[] a, int idx, boolean[] mask) {
1750         double res = 1;
1751         for (int i = idx; i < (idx + SPECIES.length()); i++) {
1752             if(mask[i % SPECIES.length()])
1753                 res *= a[i];
1754         }
1755 
1756         return res;
1757     }
1758 
1759     static double MULMasked(double[] a, boolean[] mask) {
1760         double res = 1;
1761         for (int i = 0; i < a.length; i += SPECIES.length()) {
1762             double tmp = 1;
1763             for (int j = 0; j < SPECIES.length(); j++) {
1764                 if(mask[(i + j) % SPECIES.length()])
1765                     tmp *= a[i + j];
1766             }
1767             res *= tmp;
1768         }
1769 
1770         return res;
1771     }
1772     @Test(dataProvider = "doubleUnaryOpMaskProvider")
1773     static void MULDouble512VectorTestsMasked(IntFunction<double[]> fa, IntFunction<boolean[]> fm) {
1774         double[] a = fa.apply(SPECIES.length());
1775         double[] r = fr.apply(SPECIES.length());
1776         boolean[] mask = fm.apply(SPECIES.length());
1777         VectorMask<Double> vmask = VectorMask.fromArray(SPECIES, mask, 0);
1778         double ra = 1;
1779 
1780         for (int ic = 0; ic < INVOC_COUNT; ic++) {
1781             for (int i = 0; i < a.length; i += SPECIES.length()) {
1782                 DoubleVector av = DoubleVector.fromArray(SPECIES, a, i);
1783                 r[i] = av.reduceLanes(VectorOperators.MUL, vmask);
1784             }
1785         }
1786 
1787         for (int ic = 0; ic < INVOC_COUNT; ic++) {
1788             ra = 1;
1789             for (int i = 0; i < a.length; i += SPECIES.length()) {
1790                 DoubleVector av = DoubleVector.fromArray(SPECIES, a, i);
1791                 ra *= av.reduceLanes(VectorOperators.MUL, vmask);
1792             }
1793         }
1794 
1795         assertReductionArraysEqualsMasked(a, r, ra, mask, Double512VectorTests::MULMasked, Double512VectorTests::MULMasked);
1796     }
1797     static double MIN(double[] a, int idx) {
1798         double res = Double.POSITIVE_INFINITY;
1799         for (int i = idx; i < (idx + SPECIES.length()); i++) {
1800             res = (double)Math.min(res, a[i]);
1801         }
1802 
1803         return res;
1804     }
1805 
1806     static double MIN(double[] a) {
1807         double res = Double.POSITIVE_INFINITY;
1808         for (int i = 0; i < a.length; i++) {
1809             res = (double)Math.min(res, a[i]);
1810         }
1811 
1812         return res;
1813     }
1814     @Test(dataProvider = "doubleUnaryOpProvider")
1815     static void MINDouble512VectorTests(IntFunction<double[]> fa) {
1816         double[] a = fa.apply(SPECIES.length());
1817         double[] r = fr.apply(SPECIES.length());
1818         double ra = Double.POSITIVE_INFINITY;
1819 
1820         for (int ic = 0; ic < INVOC_COUNT; ic++) {
1821             for (int i = 0; i < a.length; i += SPECIES.length()) {
1822                 DoubleVector av = DoubleVector.fromArray(SPECIES, a, i);
1823                 r[i] = av.reduceLanes(VectorOperators.MIN);
1824             }
1825         }
1826 
1827         for (int ic = 0; ic < INVOC_COUNT; ic++) {
1828             ra = Double.POSITIVE_INFINITY;
1829             for (int i = 0; i < a.length; i += SPECIES.length()) {
1830                 DoubleVector av = DoubleVector.fromArray(SPECIES, a, i);
1831                 ra = (double)Math.min(ra, av.reduceLanes(VectorOperators.MIN));
1832             }
1833         }
1834 
1835         assertReductionArraysEquals(a, r, ra, Double512VectorTests::MIN, Double512VectorTests::MIN);
1836     }
1837     static double MINMasked(double[] a, int idx, boolean[] mask) {
1838         double res = Double.POSITIVE_INFINITY;
1839         for (int i = idx; i < (idx + SPECIES.length()); i++) {
1840             if(mask[i % SPECIES.length()])
1841                 res = (double)Math.min(res, a[i]);
1842         }
1843 
1844         return res;
1845     }
1846 
1847     static double MINMasked(double[] a, boolean[] mask) {
1848         double res = Double.POSITIVE_INFINITY;
1849         for (int i = 0; i < a.length; i++) {
1850             if(mask[i % SPECIES.length()])
1851                 res = (double)Math.min(res, a[i]);
1852         }
1853 
1854         return res;
1855     }
1856     @Test(dataProvider = "doubleUnaryOpMaskProvider")
1857     static void MINDouble512VectorTestsMasked(IntFunction<double[]> fa, IntFunction<boolean[]> fm) {
1858         double[] a = fa.apply(SPECIES.length());
1859         double[] r = fr.apply(SPECIES.length());
1860         boolean[] mask = fm.apply(SPECIES.length());
1861         VectorMask<Double> vmask = VectorMask.fromArray(SPECIES, mask, 0);
1862         double ra = Double.POSITIVE_INFINITY;
1863 
1864         for (int ic = 0; ic < INVOC_COUNT; ic++) {
1865             for (int i = 0; i < a.length; i += SPECIES.length()) {
1866                 DoubleVector av = DoubleVector.fromArray(SPECIES, a, i);
1867                 r[i] = av.reduceLanes(VectorOperators.MIN, vmask);
1868             }
1869         }
1870 
1871         for (int ic = 0; ic < INVOC_COUNT; ic++) {
1872             ra = Double.POSITIVE_INFINITY;
1873             for (int i = 0; i < a.length; i += SPECIES.length()) {
1874                 DoubleVector av = DoubleVector.fromArray(SPECIES, a, i);
1875                 ra = (double)Math.min(ra, av.reduceLanes(VectorOperators.MIN, vmask));
1876             }
1877         }
1878 
1879         assertReductionArraysEqualsMasked(a, r, ra, mask, Double512VectorTests::MINMasked, Double512VectorTests::MINMasked);
1880     }
1881     static double MAX(double[] a, int idx) {
1882         double res = Double.NEGATIVE_INFINITY;
1883         for (int i = idx; i < (idx + SPECIES.length()); i++) {
1884             res = (double)Math.max(res, a[i]);
1885         }
1886 
1887         return res;
1888     }
1889 
1890     static double MAX(double[] a) {
1891         double res = Double.NEGATIVE_INFINITY;
1892         for (int i = 0; i < a.length; i++) {
1893             res = (double)Math.max(res, a[i]);
1894         }
1895 
1896         return res;
1897     }
1898     @Test(dataProvider = "doubleUnaryOpProvider")
1899     static void MAXDouble512VectorTests(IntFunction<double[]> fa) {
1900         double[] a = fa.apply(SPECIES.length());
1901         double[] r = fr.apply(SPECIES.length());
1902         double ra = Double.NEGATIVE_INFINITY;
1903 
1904         for (int ic = 0; ic < INVOC_COUNT; ic++) {
1905             for (int i = 0; i < a.length; i += SPECIES.length()) {
1906                 DoubleVector av = DoubleVector.fromArray(SPECIES, a, i);
1907                 r[i] = av.reduceLanes(VectorOperators.MAX);
1908             }
1909         }
1910 
1911         for (int ic = 0; ic < INVOC_COUNT; ic++) {
1912             ra = Double.NEGATIVE_INFINITY;
1913             for (int i = 0; i < a.length; i += SPECIES.length()) {
1914                 DoubleVector av = DoubleVector.fromArray(SPECIES, a, i);
1915                 ra = (double)Math.max(ra, av.reduceLanes(VectorOperators.MAX));
1916             }
1917         }
1918 
1919         assertReductionArraysEquals(a, r, ra, Double512VectorTests::MAX, Double512VectorTests::MAX);
1920     }
1921     static double MAXMasked(double[] a, int idx, boolean[] mask) {
1922         double res = Double.NEGATIVE_INFINITY;
1923         for (int i = idx; i < (idx + SPECIES.length()); i++) {
1924             if(mask[i % SPECIES.length()])
1925                 res = (double)Math.max(res, a[i]);
1926         }
1927 
1928         return res;
1929     }
1930 
1931     static double MAXMasked(double[] a, boolean[] mask) {
1932         double res = Double.NEGATIVE_INFINITY;
1933         for (int i = 0; i < a.length; i++) {
1934             if(mask[i % SPECIES.length()])
1935                 res = (double)Math.max(res, a[i]);
1936         }
1937 
1938         return res;
1939     }
1940     @Test(dataProvider = "doubleUnaryOpMaskProvider")
1941     static void MAXDouble512VectorTestsMasked(IntFunction<double[]> fa, IntFunction<boolean[]> fm) {
1942         double[] a = fa.apply(SPECIES.length());
1943         double[] r = fr.apply(SPECIES.length());
1944         boolean[] mask = fm.apply(SPECIES.length());
1945         VectorMask<Double> vmask = VectorMask.fromArray(SPECIES, mask, 0);
1946         double ra = Double.NEGATIVE_INFINITY;
1947 
1948         for (int ic = 0; ic < INVOC_COUNT; ic++) {
1949             for (int i = 0; i < a.length; i += SPECIES.length()) {
1950                 DoubleVector av = DoubleVector.fromArray(SPECIES, a, i);
1951                 r[i] = av.reduceLanes(VectorOperators.MAX, vmask);
1952             }
1953         }
1954 
1955         for (int ic = 0; ic < INVOC_COUNT; ic++) {
1956             ra = Double.NEGATIVE_INFINITY;
1957             for (int i = 0; i < a.length; i += SPECIES.length()) {
1958                 DoubleVector av = DoubleVector.fromArray(SPECIES, a, i);
1959                 ra = (double)Math.max(ra, av.reduceLanes(VectorOperators.MAX, vmask));
1960             }
1961         }
1962 
1963         assertReductionArraysEqualsMasked(a, r, ra, mask, Double512VectorTests::MAXMasked, Double512VectorTests::MAXMasked);
1964     }
1965 
1966 
1967 
1968 
1969 
1970     @Test(dataProvider = "doubleUnaryOpProvider")
1971     static void withDouble512VectorTests(IntFunction<double []> fa) {
1972         double[] a = fa.apply(SPECIES.length());
1973         double[] r = fr.apply(SPECIES.length());
1974 
1975         for (int ic = 0; ic < INVOC_COUNT; ic++) {
1976             for (int i = 0; i < a.length; i += SPECIES.length()) {
1977                 DoubleVector av = DoubleVector.fromArray(SPECIES, a, i);
1978                 av.withLane(0, (double)4).intoArray(r, i);
1979             }
1980         }
1981 
1982         assertInsertArraysEquals(a, r, (double)4, 0);
1983     }
1984     static boolean testIS_DEFAULT(double a) {
1985         return bits(a)==0;
1986     }
1987 
1988     @Test(dataProvider = "doubleTestOpProvider")
1989     static void IS_DEFAULTDouble512VectorTests(IntFunction<double[]> fa) {
1990         double[] a = fa.apply(SPECIES.length());
1991 
1992         for (int ic = 0; ic < INVOC_COUNT; ic++) {
1993             for (int i = 0; i < a.length; i += SPECIES.length()) {
1994                 DoubleVector av = DoubleVector.fromArray(SPECIES, a, i);
1995                 VectorMask<Double> mv = av.test(VectorOperators.IS_DEFAULT);
1996 
1997                 // Check results as part of computation.
1998                 for (int j = 0; j < SPECIES.length(); j++) {
1999    
2000                  Assert.assertEquals(mv.laneIsSet(j), testIS_DEFAULT(a[i + j]));
2001                 }
2002             }
2003         }
2004     }
2005 
2006     static boolean testIS_NEGATIVE(double a) {
2007         return bits(a)<0;
2008     }
2009 
2010     @Test(dataProvider = "doubleTestOpProvider")
2011     static void IS_NEGATIVEDouble512VectorTests(IntFunction<double[]> fa) {
2012         double[] a = fa.apply(SPECIES.length());
2013 
2014         for (int ic = 0; ic < INVOC_COUNT; ic++) {
2015             for (int i = 0; i < a.length; i += SPECIES.length()) {
2016                 DoubleVector av = DoubleVector.fromArray(SPECIES, a, i);
2017                 VectorMask<Double> mv = av.test(VectorOperators.IS_NEGATIVE);
2018 
2019                 // Check results as part of computation.
2020                 for (int j = 0; j < SPECIES.length(); j++) {
2021    
2022                  Assert.assertEquals(mv.laneIsSet(j), testIS_NEGATIVE(a[i + j]));
2023                 }
2024             }
2025         }
2026     }
2027 
2028 
2029     static boolean testIS_FINITE(double a) {
2030         return Double.isFinite(a);
2031     }
2032 
2033     @Test(dataProvider = "doubleTestOpProvider")
2034     static void IS_FINITEDouble512VectorTests(IntFunction<double[]> fa) {
2035         double[] a = fa.apply(SPECIES.length());
2036 
2037         for (int ic = 0; ic < INVOC_COUNT; ic++) {
2038             for (int i = 0; i < a.length; i += SPECIES.length()) {
2039                 DoubleVector av = DoubleVector.fromArray(SPECIES, a, i);
2040                 VectorMask<Double> mv = av.test(VectorOperators.IS_FINITE);
2041 
2042                 // Check results as part of computation.
2043                 for (int j = 0; j < SPECIES.length(); j++) {
2044    
2045                  Assert.assertEquals(mv.laneIsSet(j), testIS_FINITE(a[i + j]));
2046                 }
2047             }
2048         }
2049     }
2050 
2051 
2052 
2053     static boolean testIS_NAN(double a) {
2054         return Double.isNaN(a);
2055     }
2056 
2057     @Test(dataProvider = "doubleTestOpProvider")
2058     static void IS_NANDouble512VectorTests(IntFunction<double[]> fa) {
2059         double[] a = fa.apply(SPECIES.length());
2060 
2061         for (int ic = 0; ic < INVOC_COUNT; ic++) {
2062             for (int i = 0; i < a.length; i += SPECIES.length()) {
2063                 DoubleVector av = DoubleVector.fromArray(SPECIES, a, i);
2064                 VectorMask<Double> mv = av.test(VectorOperators.IS_NAN);
2065 
2066                 // Check results as part of computation.
2067                 for (int j = 0; j < SPECIES.length(); j++) {
2068    
2069                  Assert.assertEquals(mv.laneIsSet(j), testIS_NAN(a[i + j]));
2070                 }
2071             }
2072         }
2073     }
2074 
2075 
2076 
2077     static boolean testIS_INFINITE(double a) {
2078         return Double.isInfinite(a);
2079     }
2080 
2081     @Test(dataProvider = "doubleTestOpProvider")
2082     static void IS_INFINITEDouble512VectorTests(IntFunction<double[]> fa) {
2083         double[] a = fa.apply(SPECIES.length());
2084 
2085         for (int ic = 0; ic < INVOC_COUNT; ic++) {
2086             for (int i = 0; i < a.length; i += SPECIES.length()) {
2087                 DoubleVector av = DoubleVector.fromArray(SPECIES, a, i);
2088                 VectorMask<Double> mv = av.test(VectorOperators.IS_INFINITE);
2089 
2090                 // Check results as part of computation.
2091                 for (int j = 0; j < SPECIES.length(); j++) {
2092    
2093                  Assert.assertEquals(mv.laneIsSet(j), testIS_INFINITE(a[i + j]));
2094                 }
2095             }
2096         }
2097     }
2098 
2099 
2100 
2101     @Test(dataProvider = "doubleCompareOpProvider")
2102     static void LTDouble512VectorTests(IntFunction<double[]> fa, IntFunction<double[]> fb) {
2103         double[] a = fa.apply(SPECIES.length());
2104         double[] b = fb.apply(SPECIES.length());
2105 
2106         for (int ic = 0; ic < INVOC_COUNT; ic++) {
2107             for (int i = 0; i < a.length; i += SPECIES.length()) {
2108                 DoubleVector av = DoubleVector.fromArray(SPECIES, a, i);
2109                 DoubleVector bv = DoubleVector.fromArray(SPECIES, b, i);
2110                 VectorMask<Double> mv = av.compare(VectorOperators.LT, bv);
2111 
2112                 // Check results as part of computation.
2113                 for (int j = 0; j < SPECIES.length(); j++) {
2114                     Assert.assertEquals(mv.laneIsSet(j), a[i + j] < b[i + j]);
2115                 }
2116             }
2117         }
2118     }
2119 
2120 
2121     @Test(dataProvider = "doubleCompareOpProvider")
2122     static void ltDouble512VectorTests(IntFunction<double[]> fa, IntFunction<double[]> fb) {
2123         double[] a = fa.apply(SPECIES.length());
2124         double[] b = fb.apply(SPECIES.length());
2125 
2126         for (int ic = 0; ic < INVOC_COUNT; ic++) {
2127             for (int i = 0; i < a.length; i += SPECIES.length()) {
2128                 DoubleVector av = DoubleVector.fromArray(SPECIES, a, i);
2129                 DoubleVector bv = DoubleVector.fromArray(SPECIES, b, i);
2130                 VectorMask<Double> mv = av.lt(bv);
2131 
2132                 // Check results as part of computation.
2133                 for (int j = 0; j < SPECIES.length(); j++) {
2134                     Assert.assertEquals(mv.laneIsSet(j), a[i + j] < b[i + j]);
2135                 }
2136             }
2137         }
2138     }
2139 
2140 
2141     @Test(dataProvider = "doubleCompareOpProvider")
2142     static void GTDouble512VectorTests(IntFunction<double[]> fa, IntFunction<double[]> fb) {
2143         double[] a = fa.apply(SPECIES.length());
2144         double[] b = fb.apply(SPECIES.length());
2145 
2146         for (int ic = 0; ic < INVOC_COUNT; ic++) {
2147             for (int i = 0; i < a.length; i += SPECIES.length()) {
2148                 DoubleVector av = DoubleVector.fromArray(SPECIES, a, i);
2149                 DoubleVector bv = DoubleVector.fromArray(SPECIES, b, i);
2150                 VectorMask<Double> mv = av.compare(VectorOperators.GT, bv);
2151 
2152                 // Check results as part of computation.
2153                 for (int j = 0; j < SPECIES.length(); j++) {
2154                     Assert.assertEquals(mv.laneIsSet(j), a[i + j] > b[i + j]);
2155                 }
2156             }
2157         }
2158     }
2159 
2160 
2161     @Test(dataProvider = "doubleCompareOpProvider")
2162     static void EQDouble512VectorTests(IntFunction<double[]> fa, IntFunction<double[]> fb) {
2163         double[] a = fa.apply(SPECIES.length());
2164         double[] b = fb.apply(SPECIES.length());
2165 
2166         for (int ic = 0; ic < INVOC_COUNT; ic++) {
2167             for (int i = 0; i < a.length; i += SPECIES.length()) {
2168                 DoubleVector av = DoubleVector.fromArray(SPECIES, a, i);
2169                 DoubleVector bv = DoubleVector.fromArray(SPECIES, b, i);
2170                 VectorMask<Double> mv = av.compare(VectorOperators.EQ, bv);
2171 
2172                 // Check results as part of computation.
2173                 for (int j = 0; j < SPECIES.length(); j++) {
2174                     Assert.assertEquals(mv.laneIsSet(j), a[i + j] == b[i + j]);
2175                 }
2176             }
2177         }
2178     }
2179 
2180 
2181     @Test(dataProvider = "doubleCompareOpProvider")
2182     static void eqDouble512VectorTests(IntFunction<double[]> fa, IntFunction<double[]> fb) {
2183         double[] a = fa.apply(SPECIES.length());
2184         double[] b = fb.apply(SPECIES.length());
2185 
2186         for (int ic = 0; ic < INVOC_COUNT; ic++) {
2187             for (int i = 0; i < a.length; i += SPECIES.length()) {
2188                 DoubleVector av = DoubleVector.fromArray(SPECIES, a, i);
2189                 DoubleVector bv = DoubleVector.fromArray(SPECIES, b, i);
2190                 VectorMask<Double> mv = av.eq(bv);
2191 
2192                 // Check results as part of computation.
2193                 for (int j = 0; j < SPECIES.length(); j++) {
2194                     Assert.assertEquals(mv.laneIsSet(j), a[i + j] == b[i + j]);
2195                 }
2196             }
2197         }
2198     }
2199 
2200 
2201     @Test(dataProvider = "doubleCompareOpProvider")
2202     static void NEDouble512VectorTests(IntFunction<double[]> fa, IntFunction<double[]> fb) {
2203         double[] a = fa.apply(SPECIES.length());
2204         double[] b = fb.apply(SPECIES.length());
2205 
2206         for (int ic = 0; ic < INVOC_COUNT; ic++) {
2207             for (int i = 0; i < a.length; i += SPECIES.length()) {
2208                 DoubleVector av = DoubleVector.fromArray(SPECIES, a, i);
2209                 DoubleVector bv = DoubleVector.fromArray(SPECIES, b, i);
2210                 VectorMask<Double> mv = av.compare(VectorOperators.NE, bv);
2211 
2212                 // Check results as part of computation.
2213                 for (int j = 0; j < SPECIES.length(); j++) {
2214                     Assert.assertEquals(mv.laneIsSet(j), a[i + j] != b[i + j]);
2215                 }
2216             }
2217         }
2218     }
2219 
2220 
2221     @Test(dataProvider = "doubleCompareOpProvider")
2222     static void LEDouble512VectorTests(IntFunction<double[]> fa, IntFunction<double[]> fb) {
2223         double[] a = fa.apply(SPECIES.length());
2224         double[] b = fb.apply(SPECIES.length());
2225 
2226         for (int ic = 0; ic < INVOC_COUNT; ic++) {
2227             for (int i = 0; i < a.length; i += SPECIES.length()) {
2228                 DoubleVector av = DoubleVector.fromArray(SPECIES, a, i);
2229                 DoubleVector bv = DoubleVector.fromArray(SPECIES, b, i);
2230                 VectorMask<Double> mv = av.compare(VectorOperators.LE, bv);
2231 
2232                 // Check results as part of computation.
2233                 for (int j = 0; j < SPECIES.length(); j++) {
2234                     Assert.assertEquals(mv.laneIsSet(j), a[i + j] <= b[i + j]);
2235                 }
2236             }
2237         }
2238     }
2239 
2240 
2241     @Test(dataProvider = "doubleCompareOpProvider")
2242     static void GEDouble512VectorTests(IntFunction<double[]> fa, IntFunction<double[]> fb) {
2243         double[] a = fa.apply(SPECIES.length());
2244         double[] b = fb.apply(SPECIES.length());
2245 
2246         for (int ic = 0; ic < INVOC_COUNT; ic++) {
2247             for (int i = 0; i < a.length; i += SPECIES.length()) {
2248                 DoubleVector av = DoubleVector.fromArray(SPECIES, a, i);
2249                 DoubleVector bv = DoubleVector.fromArray(SPECIES, b, i);
2250                 VectorMask<Double> mv = av.compare(VectorOperators.GE, bv);
2251 
2252                 // Check results as part of computation.
2253                 for (int j = 0; j < SPECIES.length(); j++) {
2254                     Assert.assertEquals(mv.laneIsSet(j), a[i + j] >= b[i + j]);
2255                 }
2256             }
2257         }
2258     }
2259 
2260 
2261     static double blend(double a, double b, boolean mask) {
2262         return mask ? b : a;
2263     }
2264 
2265     @Test(dataProvider = "doubleBinaryOpMaskProvider")
2266     static void blendDouble512VectorTests(IntFunction<double[]> fa, IntFunction<double[]> fb,
2267                                           IntFunction<boolean[]> fm) {
2268         double[] a = fa.apply(SPECIES.length());
2269         double[] b = fb.apply(SPECIES.length());
2270         double[] r = fr.apply(SPECIES.length());
2271         boolean[] mask = fm.apply(SPECIES.length());
2272         VectorMask<Double> vmask = VectorMask.fromArray(SPECIES, mask, 0);
2273 
2274         for (int ic = 0; ic < INVOC_COUNT; ic++) {
2275             for (int i = 0; i < a.length; i += SPECIES.length()) {
2276                 DoubleVector av = DoubleVector.fromArray(SPECIES, a, i);
2277                 DoubleVector bv = DoubleVector.fromArray(SPECIES, b, i);
2278                 av.blend(bv, vmask).intoArray(r, i);
2279             }
2280         }
2281 
2282         assertArraysEquals(a, b, r, mask, Double512VectorTests::blend);
2283     }
2284 
2285     @Test(dataProvider = "doubleUnaryOpShuffleProvider")
2286     static void RearrangeDouble512VectorTests(IntFunction<double[]> fa,
2287                                            BiFunction<Integer,Integer,int[]> fs) {
2288         double[] a = fa.apply(SPECIES.length());
2289         int[] order = fs.apply(a.length, SPECIES.length());
2290         double[] r = fr.apply(SPECIES.length());
2291 
2292         for (int ic = 0; ic < INVOC_COUNT; ic++) {
2293             for (int i = 0; i < a.length; i += SPECIES.length()) {
2294                 DoubleVector av = DoubleVector.fromArray(SPECIES, a, i);
2295                 av.rearrange(VectorShuffle.fromArray(SPECIES, order, i)).intoArray(r, i);
2296             }
2297         }
2298 
2299         assertRearrangeArraysEquals(a, r, order, SPECIES.length());
2300     }
2301 
2302 
2303 
2304 
2305     @Test(dataProvider = "doubleUnaryOpProvider")
2306     static void getDouble512VectorTests(IntFunction<double[]> fa) {
2307         double[] a = fa.apply(SPECIES.length());
2308         double[] r = fr.apply(SPECIES.length());
2309 
2310         for (int ic = 0; ic < INVOC_COUNT; ic++) {
2311             for (int i = 0; i < a.length; i += SPECIES.length()) {
2312                 DoubleVector av = DoubleVector.fromArray(SPECIES, a, i);
2313                 int num_lanes = SPECIES.length();
2314                 // Manually unroll because full unroll happens after intrinsification.
2315                 // Unroll is needed because get intrinsic requires for index to be a known constant.
2316                 if (num_lanes == 1) {
2317                     r[i]=av.lane(0);
2318                 } else if (num_lanes == 2) {
2319                     r[i]=av.lane(0);
2320                     r[i+1]=av.lane(1);
2321                 } else if (num_lanes == 4) {
2322                     r[i]=av.lane(0);
2323                     r[i+1]=av.lane(1);
2324                     r[i+2]=av.lane(2);
2325                     r[i+3]=av.lane(3);
2326                 } else if (num_lanes == 8) {
2327                     r[i]=av.lane(0);
2328                     r[i+1]=av.lane(1);
2329                     r[i+2]=av.lane(2);
2330                     r[i+3]=av.lane(3);
2331                     r[i+4]=av.lane(4);
2332                     r[i+5]=av.lane(5);
2333                     r[i+6]=av.lane(6);
2334                     r[i+7]=av.lane(7);
2335                 } else if (num_lanes == 16) {
2336                     r[i]=av.lane(0);
2337                     r[i+1]=av.lane(1);
2338                     r[i+2]=av.lane(2);
2339                     r[i+3]=av.lane(3);
2340                     r[i+4]=av.lane(4);
2341                     r[i+5]=av.lane(5);
2342                     r[i+6]=av.lane(6);
2343                     r[i+7]=av.lane(7);
2344                     r[i+8]=av.lane(8);
2345                     r[i+9]=av.lane(9);
2346                     r[i+10]=av.lane(10);
2347                     r[i+11]=av.lane(11);
2348                     r[i+12]=av.lane(12);
2349                     r[i+13]=av.lane(13);
2350                     r[i+14]=av.lane(14);
2351                     r[i+15]=av.lane(15);
2352                 } else if (num_lanes == 32) {
2353                     r[i]=av.lane(0);
2354                     r[i+1]=av.lane(1);
2355                     r[i+2]=av.lane(2);
2356                     r[i+3]=av.lane(3);
2357                     r[i+4]=av.lane(4);
2358                     r[i+5]=av.lane(5);
2359                     r[i+6]=av.lane(6);
2360                     r[i+7]=av.lane(7);
2361                     r[i+8]=av.lane(8);
2362                     r[i+9]=av.lane(9);
2363                     r[i+10]=av.lane(10);
2364                     r[i+11]=av.lane(11);
2365                     r[i+12]=av.lane(12);
2366                     r[i+13]=av.lane(13);
2367                     r[i+14]=av.lane(14);
2368                     r[i+15]=av.lane(15);
2369                     r[i+16]=av.lane(16);
2370                     r[i+17]=av.lane(17);
2371                     r[i+18]=av.lane(18);
2372                     r[i+19]=av.lane(19);
2373                     r[i+20]=av.lane(20);
2374                     r[i+21]=av.lane(21);
2375                     r[i+22]=av.lane(22);
2376                     r[i+23]=av.lane(23);
2377                     r[i+24]=av.lane(24);
2378                     r[i+25]=av.lane(25);
2379                     r[i+26]=av.lane(26);
2380                     r[i+27]=av.lane(27);
2381                     r[i+28]=av.lane(28);
2382                     r[i+29]=av.lane(29);
2383                     r[i+30]=av.lane(30);
2384                     r[i+31]=av.lane(31);
2385                 } else if (num_lanes == 64) {
2386                     r[i]=av.lane(0);
2387                     r[i+1]=av.lane(1);
2388                     r[i+2]=av.lane(2);
2389                     r[i+3]=av.lane(3);
2390                     r[i+4]=av.lane(4);
2391                     r[i+5]=av.lane(5);
2392                     r[i+6]=av.lane(6);
2393                     r[i+7]=av.lane(7);
2394                     r[i+8]=av.lane(8);
2395                     r[i+9]=av.lane(9);
2396                     r[i+10]=av.lane(10);
2397                     r[i+11]=av.lane(11);
2398                     r[i+12]=av.lane(12);
2399                     r[i+13]=av.lane(13);
2400                     r[i+14]=av.lane(14);
2401                     r[i+15]=av.lane(15);
2402                     r[i+16]=av.lane(16);
2403                     r[i+17]=av.lane(17);
2404                     r[i+18]=av.lane(18);
2405                     r[i+19]=av.lane(19);
2406                     r[i+20]=av.lane(20);
2407                     r[i+21]=av.lane(21);
2408                     r[i+22]=av.lane(22);
2409                     r[i+23]=av.lane(23);
2410                     r[i+24]=av.lane(24);
2411                     r[i+25]=av.lane(25);
2412                     r[i+26]=av.lane(26);
2413                     r[i+27]=av.lane(27);
2414                     r[i+28]=av.lane(28);
2415                     r[i+29]=av.lane(29);
2416                     r[i+30]=av.lane(30);
2417                     r[i+31]=av.lane(31);
2418                     r[i+32]=av.lane(32);
2419                     r[i+33]=av.lane(33);
2420                     r[i+34]=av.lane(34);
2421                     r[i+35]=av.lane(35);
2422                     r[i+36]=av.lane(36);
2423                     r[i+37]=av.lane(37);
2424                     r[i+38]=av.lane(38);
2425                     r[i+39]=av.lane(39);
2426                     r[i+40]=av.lane(40);
2427                     r[i+41]=av.lane(41);
2428                     r[i+42]=av.lane(42);
2429                     r[i+43]=av.lane(43);
2430                     r[i+44]=av.lane(44);
2431                     r[i+45]=av.lane(45);
2432                     r[i+46]=av.lane(46);
2433                     r[i+47]=av.lane(47);
2434                     r[i+48]=av.lane(48);
2435                     r[i+49]=av.lane(49);
2436                     r[i+50]=av.lane(50);
2437                     r[i+51]=av.lane(51);
2438                     r[i+52]=av.lane(52);
2439                     r[i+53]=av.lane(53);
2440                     r[i+54]=av.lane(54);
2441                     r[i+55]=av.lane(55);
2442                     r[i+56]=av.lane(56);
2443                     r[i+57]=av.lane(57);
2444                     r[i+58]=av.lane(58);
2445                     r[i+59]=av.lane(59);
2446                     r[i+60]=av.lane(60);
2447                     r[i+61]=av.lane(61);
2448                     r[i+62]=av.lane(62);
2449                     r[i+63]=av.lane(63);
2450                 } else {
2451                     for (int j = 0; j < SPECIES.length(); j++) {
2452                         r[i+j]=av.lane(j);
2453                     }
2454                 }
2455             }
2456         }
2457 
2458         assertArraysEquals(a, r, Double512VectorTests::get);
2459     }
2460 
2461     @Test(dataProvider = "doubleUnaryOpProvider")
2462     static void BroadcastDouble512VectorTests(IntFunction<double[]> fa) {
2463         double[] a = fa.apply(SPECIES.length());
2464         double[] r = new double[a.length];
2465 
2466         for (int ic = 0; ic < INVOC_COUNT; ic++) {
2467             for (int i = 0; i < a.length; i += SPECIES.length()) {
2468                 DoubleVector.broadcast(SPECIES, a[i]).intoArray(r, i);
2469             }
2470         }
2471 
2472         assertBroadcastArraysEquals(a, r);
2473     }
2474 
2475 
2476 
2477 
2478 
2479     @Test(dataProvider = "doubleUnaryOpProvider")
2480     static void ZeroDouble512VectorTests(IntFunction<double[]> fa) {
2481         double[] a = fa.apply(SPECIES.length());
2482         double[] r = new double[a.length];
2483 
2484         for (int ic = 0; ic < INVOC_COUNT; ic++) {
2485             for (int i = 0; i < a.length; i += SPECIES.length()) {
2486                 DoubleVector.zero(SPECIES).intoArray(a, i);
2487             }
2488         }
2489 
2490         Assert.assertEquals(a, r);
2491     }
2492 
2493 
2494 
2495 
2496     static double[] sliceUnary(double[] a, int origin, int idx) {
2497         double[] res = new double[SPECIES.length()];
2498         for (int i = 0; i < SPECIES.length(); i++){
2499             if(i+origin < SPECIES.length())
2500                 res[i] = a[idx+i+origin];
2501             else
2502                 res[i] = (double)0;
2503         }
2504         return res;
2505     }
2506 
2507     @Test(dataProvider = "doubleUnaryOpProvider")
2508     static void sliceUnaryDouble512VectorTests(IntFunction<double[]> fa) {
2509         double[] a = fa.apply(SPECIES.length());
2510         double[] r = new double[a.length];
2511         int origin = (new java.util.Random()).nextInt(SPECIES.length());
2512         for (int ic = 0; ic < INVOC_COUNT; ic++) {
2513             for (int i = 0; i < a.length; i += SPECIES.length()) {
2514                 DoubleVector av = DoubleVector.fromArray(SPECIES, a, i);
2515                 av.slice(origin).intoArray(r, i);
2516             }
2517         }
2518 
2519         assertArraysEquals(a, r, origin, Double512VectorTests::sliceUnary);
2520     }
2521     static double[] sliceBinary(double[] a, double[] b, int origin, int idx) {
2522         double[] res = new double[SPECIES.length()];
2523         for (int i = 0, j = 0; i < SPECIES.length(); i++){
2524             if(i+origin < SPECIES.length())
2525                 res[i] = a[idx+i+origin];
2526             else {
2527                 res[i] = b[idx+j];
2528                 j++;
2529             }
2530         }
2531         return res;
2532     }
2533 
2534     @Test(dataProvider = "doubleBinaryOpProvider")
2535     static void sliceBinaryDouble512VectorTestsBinary(IntFunction<double[]> fa, IntFunction<double[]> fb) {
2536         double[] a = fa.apply(SPECIES.length());
2537         double[] b = fb.apply(SPECIES.length());
2538         double[] r = new double[a.length];
2539         int origin = (new java.util.Random()).nextInt(SPECIES.length());
2540         for (int ic = 0; ic < INVOC_COUNT; ic++) {
2541             for (int i = 0; i < a.length; i += SPECIES.length()) {
2542                 DoubleVector av = DoubleVector.fromArray(SPECIES, a, i);
2543                 DoubleVector bv = DoubleVector.fromArray(SPECIES, b, i);
2544                 av.slice(origin, bv).intoArray(r, i);
2545             }
2546         }
2547 
2548         assertArraysEquals(a, b, r, origin, Double512VectorTests::sliceBinary);
2549     }
2550     static double[] slice(double[] a, double[] b, int origin, boolean[] mask, int idx) {
2551         double[] res = new double[SPECIES.length()];
2552         for (int i = 0, j = 0; i < SPECIES.length(); i++){
2553             if(i+origin < SPECIES.length())
2554                 res[i] = mask[i] ? a[idx+i+origin] : (double)0;
2555             else {
2556                 res[i] = mask[i] ? b[idx+j] : (double)0;
2557                 j++;
2558             }
2559         }
2560         return res;
2561     }
2562 
2563     @Test(dataProvider = "doubleBinaryOpMaskProvider")
2564     static void sliceDouble512VectorTestsMasked(IntFunction<double[]> fa, IntFunction<double[]> fb,
2565     IntFunction<boolean[]> fm) {
2566         double[] a = fa.apply(SPECIES.length());
2567         double[] b = fb.apply(SPECIES.length());
2568         boolean[] mask = fm.apply(SPECIES.length());
2569         VectorMask<Double> vmask = VectorMask.fromArray(SPECIES, mask, 0);
2570 
2571         double[] r = new double[a.length];
2572         int origin = (new java.util.Random()).nextInt(SPECIES.length());
2573         for (int ic = 0; ic < INVOC_COUNT; ic++) {
2574             for (int i = 0; i < a.length; i += SPECIES.length()) {
2575                 DoubleVector av = DoubleVector.fromArray(SPECIES, a, i);
2576                 DoubleVector bv = DoubleVector.fromArray(SPECIES, b, i);
2577                 av.slice(origin, bv, vmask).intoArray(r, i);
2578             }
2579         }
2580 
2581         assertArraysEquals(a, b, r, origin, mask, Double512VectorTests::slice);
2582     }
2583     static double[] unsliceUnary(double[] a, int origin, int idx) {
2584         double[] res = new double[SPECIES.length()];
2585         for (int i = 0, j = 0; i < SPECIES.length(); i++){
2586             if(i < origin)
2587                 res[i] = (double)0;
2588             else {
2589                 res[i] = a[idx+j];
2590                 j++;
2591             }
2592         }
2593         return res;
2594     }
2595 
2596     @Test(dataProvider = "doubleUnaryOpProvider")
2597     static void unsliceUnaryDouble512VectorTests(IntFunction<double[]> fa) {
2598         double[] a = fa.apply(SPECIES.length());
2599         double[] r = new double[a.length];
2600         int origin = (new java.util.Random()).nextInt(SPECIES.length());
2601         for (int ic = 0; ic < INVOC_COUNT; ic++) {
2602             for (int i = 0; i < a.length; i += SPECIES.length()) {
2603                 DoubleVector av = DoubleVector.fromArray(SPECIES, a, i);
2604                 av.unslice(origin).intoArray(r, i);
2605             }
2606         }
2607 
2608         assertArraysEquals(a, r, origin, Double512VectorTests::unsliceUnary);
2609     }
2610     static double[] unsliceBinary(double[] a, double[] b, int origin, int part, int idx) {
2611         double[] res = new double[SPECIES.length()];
2612         for (int i = 0, j = 0; i < SPECIES.length(); i++){
2613             if (part == 0) {
2614                 if (i < origin)
2615                     res[i] = b[idx+i];
2616                 else {
2617                     res[i] = a[idx+j];
2618                     j++;
2619                 }
2620             } else if (part == 1) {
2621                 if (i < origin)
2622                     res[i] = a[idx+SPECIES.length()-origin+i];
2623                 else {
2624                     res[i] = b[idx+origin+j];
2625                     j++;
2626                 }
2627             }
2628         }
2629         return res;
2630     }
2631 
2632     @Test(dataProvider = "doubleBinaryOpProvider")
2633     static void unsliceBinaryDouble512VectorTestsBinary(IntFunction<double[]> fa, IntFunction<double[]> fb) {
2634         double[] a = fa.apply(SPECIES.length());
2635         double[] b = fb.apply(SPECIES.length());
2636         double[] r = new double[a.length];
2637         int origin = (new java.util.Random()).nextInt(SPECIES.length());
2638         int part = (new java.util.Random()).nextInt(2);
2639         for (int ic = 0; ic < INVOC_COUNT; ic++) {
2640             for (int i = 0; i < a.length; i += SPECIES.length()) {
2641                 DoubleVector av = DoubleVector.fromArray(SPECIES, a, i);
2642                 DoubleVector bv = DoubleVector.fromArray(SPECIES, b, i);
2643                 av.unslice(origin, bv, part).intoArray(r, i);
2644             }
2645         }
2646 
2647         assertArraysEquals(a, b, r, origin, part, Double512VectorTests::unsliceBinary);
2648     }
2649     static double[] unslice(double[] a, double[] b, int origin, int part, boolean[] mask, int idx) {
2650         double[] res = new double[SPECIES.length()];
2651         for (int i = 0, j = 0; i < SPECIES.length(); i++){
2652             if(i+origin < SPECIES.length())
2653                 res[i] = b[idx+i+origin];
2654             else {
2655                 res[i] = b[idx+j];
2656                 j++;
2657             }
2658         }
2659         for (int i = 0; i < SPECIES.length(); i++){
2660             res[i] = mask[i] ? a[idx+i] : res[i];
2661         }
2662         double[] res1 = new double[SPECIES.length()];
2663         if (part == 0) {
2664             for (int i = 0, j = 0; i < SPECIES.length(); i++){
2665                 if (i < origin)
2666                     res1[i] = b[idx+i];
2667                 else {
2668                    res1[i] = res[j];
2669                    j++;
2670                 }
2671             }
2672         } else if (part == 1) {
2673             for (int i = 0, j = 0; i < SPECIES.length(); i++){
2674                 if (i < origin)
2675                     res1[i] = res[SPECIES.length()-origin+i];
2676                 else {
2677                     res1[i] = b[idx+origin+j];
2678                     j++;
2679                 }
2680             }
2681         }
2682         return res1;
2683     }
2684 
2685     @Test(dataProvider = "doubleBinaryOpMaskProvider")
2686     static void unsliceDouble512VectorTestsMasked(IntFunction<double[]> fa, IntFunction<double[]> fb,
2687     IntFunction<boolean[]> fm) {
2688         double[] a = fa.apply(SPECIES.length());
2689         double[] b = fb.apply(SPECIES.length());
2690         boolean[] mask = fm.apply(SPECIES.length());
2691         VectorMask<Double> vmask = VectorMask.fromArray(SPECIES, mask, 0);
2692         double[] r = new double[a.length];
2693         int origin = (new java.util.Random()).nextInt(SPECIES.length());
2694         int part = (new java.util.Random()).nextInt(2);
2695         for (int ic = 0; ic < INVOC_COUNT; ic++) {
2696             for (int i = 0; i < a.length; i += SPECIES.length()) {
2697                 DoubleVector av = DoubleVector.fromArray(SPECIES, a, i);
2698                 DoubleVector bv = DoubleVector.fromArray(SPECIES, b, i);
2699                 av.unslice(origin, bv, part, vmask).intoArray(r, i);
2700             }
2701         }
2702 
2703         assertArraysEquals(a, b, r, origin, part, mask, Double512VectorTests::unslice);
2704     }
2705 
2706     static double SIN(double a) {
2707         return (double)(Math.sin((double)a));
2708     }
2709 
2710     static double strictSIN(double a) {
2711         return (double)(StrictMath.sin((double)a));
2712     }
2713 
2714     @Test(dataProvider = "doubleUnaryOpProvider")
2715     static void SINDouble512VectorTests(IntFunction<double[]> fa) {
2716         double[] a = fa.apply(SPECIES.length());
2717         double[] r = fr.apply(SPECIES.length());
2718 
2719         for (int ic = 0; ic < INVOC_COUNT; ic++) {
2720             for (int i = 0; i < a.length; i += SPECIES.length()) {
2721                 DoubleVector av = DoubleVector.fromArray(SPECIES, a, i);
2722                 av.lanewise(VectorOperators.SIN).intoArray(r, i);
2723             }
2724         }
2725 
2726         assertArraysEqualsWithinOneUlp(a, r, Double512VectorTests::SIN, Double512VectorTests::strictSIN);
2727     }
2728 
2729 
2730     static double EXP(double a) {
2731         return (double)(Math.exp((double)a));
2732     }
2733 
2734     static double strictEXP(double a) {
2735         return (double)(StrictMath.exp((double)a));
2736     }
2737 
2738     @Test(dataProvider = "doubleUnaryOpProvider")
2739     static void EXPDouble512VectorTests(IntFunction<double[]> fa) {
2740         double[] a = fa.apply(SPECIES.length());
2741         double[] r = fr.apply(SPECIES.length());
2742 
2743         for (int ic = 0; ic < INVOC_COUNT; ic++) {
2744             for (int i = 0; i < a.length; i += SPECIES.length()) {
2745                 DoubleVector av = DoubleVector.fromArray(SPECIES, a, i);
2746                 av.lanewise(VectorOperators.EXP).intoArray(r, i);
2747             }
2748         }
2749 
2750         assertArraysEqualsWithinOneUlp(a, r, Double512VectorTests::EXP, Double512VectorTests::strictEXP);
2751     }
2752 
2753 
2754     static double LOG1P(double a) {
2755         return (double)(Math.log1p((double)a));
2756     }
2757 
2758     static double strictLOG1P(double a) {
2759         return (double)(StrictMath.log1p((double)a));
2760     }
2761 
2762     @Test(dataProvider = "doubleUnaryOpProvider")
2763     static void LOG1PDouble512VectorTests(IntFunction<double[]> fa) {
2764         double[] a = fa.apply(SPECIES.length());
2765         double[] r = fr.apply(SPECIES.length());
2766 
2767         for (int ic = 0; ic < INVOC_COUNT; ic++) {
2768             for (int i = 0; i < a.length; i += SPECIES.length()) {
2769                 DoubleVector av = DoubleVector.fromArray(SPECIES, a, i);
2770                 av.lanewise(VectorOperators.LOG1P).intoArray(r, i);
2771             }
2772         }
2773 
2774         assertArraysEqualsWithinOneUlp(a, r, Double512VectorTests::LOG1P, Double512VectorTests::strictLOG1P);
2775     }
2776 
2777 
2778     static double LOG(double a) {
2779         return (double)(Math.log((double)a));
2780     }
2781 
2782     static double strictLOG(double a) {
2783         return (double)(StrictMath.log((double)a));
2784     }
2785 
2786     @Test(dataProvider = "doubleUnaryOpProvider")
2787     static void LOGDouble512VectorTests(IntFunction<double[]> fa) {
2788         double[] a = fa.apply(SPECIES.length());
2789         double[] r = fr.apply(SPECIES.length());
2790 
2791         for (int ic = 0; ic < INVOC_COUNT; ic++) {
2792             for (int i = 0; i < a.length; i += SPECIES.length()) {
2793                 DoubleVector av = DoubleVector.fromArray(SPECIES, a, i);
2794                 av.lanewise(VectorOperators.LOG).intoArray(r, i);
2795             }
2796         }
2797 
2798         assertArraysEqualsWithinOneUlp(a, r, Double512VectorTests::LOG, Double512VectorTests::strictLOG);
2799     }
2800 
2801 
2802     static double LOG10(double a) {
2803         return (double)(Math.log10((double)a));
2804     }
2805 
2806     static double strictLOG10(double a) {
2807         return (double)(StrictMath.log10((double)a));
2808     }
2809 
2810     @Test(dataProvider = "doubleUnaryOpProvider")
2811     static void LOG10Double512VectorTests(IntFunction<double[]> fa) {
2812         double[] a = fa.apply(SPECIES.length());
2813         double[] r = fr.apply(SPECIES.length());
2814 
2815         for (int ic = 0; ic < INVOC_COUNT; ic++) {
2816             for (int i = 0; i < a.length; i += SPECIES.length()) {
2817                 DoubleVector av = DoubleVector.fromArray(SPECIES, a, i);
2818                 av.lanewise(VectorOperators.LOG10).intoArray(r, i);
2819             }
2820         }
2821 
2822         assertArraysEqualsWithinOneUlp(a, r, Double512VectorTests::LOG10, Double512VectorTests::strictLOG10);
2823     }
2824 
2825 
2826     static double EXPM1(double a) {
2827         return (double)(Math.expm1((double)a));
2828     }
2829 
2830     static double strictEXPM1(double a) {
2831         return (double)(StrictMath.expm1((double)a));
2832     }
2833 
2834     @Test(dataProvider = "doubleUnaryOpProvider")
2835     static void EXPM1Double512VectorTests(IntFunction<double[]> fa) {
2836         double[] a = fa.apply(SPECIES.length());
2837         double[] r = fr.apply(SPECIES.length());
2838 
2839         for (int ic = 0; ic < INVOC_COUNT; ic++) {
2840             for (int i = 0; i < a.length; i += SPECIES.length()) {
2841                 DoubleVector av = DoubleVector.fromArray(SPECIES, a, i);
2842                 av.lanewise(VectorOperators.EXPM1).intoArray(r, i);
2843             }
2844         }
2845 
2846         assertArraysEqualsWithinOneUlp(a, r, Double512VectorTests::EXPM1, Double512VectorTests::strictEXPM1);
2847     }
2848 
2849 
2850     static double COS(double a) {
2851         return (double)(Math.cos((double)a));
2852     }
2853 
2854     static double strictCOS(double a) {
2855         return (double)(StrictMath.cos((double)a));
2856     }
2857 
2858     @Test(dataProvider = "doubleUnaryOpProvider")
2859     static void COSDouble512VectorTests(IntFunction<double[]> fa) {
2860         double[] a = fa.apply(SPECIES.length());
2861         double[] r = fr.apply(SPECIES.length());
2862 
2863         for (int ic = 0; ic < INVOC_COUNT; ic++) {
2864             for (int i = 0; i < a.length; i += SPECIES.length()) {
2865                 DoubleVector av = DoubleVector.fromArray(SPECIES, a, i);
2866                 av.lanewise(VectorOperators.COS).intoArray(r, i);
2867             }
2868         }
2869 
2870         assertArraysEqualsWithinOneUlp(a, r, Double512VectorTests::COS, Double512VectorTests::strictCOS);
2871     }
2872 
2873 
2874     static double TAN(double a) {
2875         return (double)(Math.tan((double)a));
2876     }
2877 
2878     static double strictTAN(double a) {
2879         return (double)(StrictMath.tan((double)a));
2880     }
2881 
2882     @Test(dataProvider = "doubleUnaryOpProvider")
2883     static void TANDouble512VectorTests(IntFunction<double[]> fa) {
2884         double[] a = fa.apply(SPECIES.length());
2885         double[] r = fr.apply(SPECIES.length());
2886 
2887         for (int ic = 0; ic < INVOC_COUNT; ic++) {
2888             for (int i = 0; i < a.length; i += SPECIES.length()) {
2889                 DoubleVector av = DoubleVector.fromArray(SPECIES, a, i);
2890                 av.lanewise(VectorOperators.TAN).intoArray(r, i);
2891             }
2892         }
2893 
2894         assertArraysEqualsWithinOneUlp(a, r, Double512VectorTests::TAN, Double512VectorTests::strictTAN);
2895     }
2896 
2897 
2898     static double SINH(double a) {
2899         return (double)(Math.sinh((double)a));
2900     }
2901 
2902     static double strictSINH(double a) {
2903         return (double)(StrictMath.sinh((double)a));
2904     }
2905 
2906     @Test(dataProvider = "doubleUnaryOpProvider")
2907     static void SINHDouble512VectorTests(IntFunction<double[]> fa) {
2908         double[] a = fa.apply(SPECIES.length());
2909         double[] r = fr.apply(SPECIES.length());
2910 
2911         for (int ic = 0; ic < INVOC_COUNT; ic++) {
2912             for (int i = 0; i < a.length; i += SPECIES.length()) {
2913                 DoubleVector av = DoubleVector.fromArray(SPECIES, a, i);
2914                 av.lanewise(VectorOperators.SINH).intoArray(r, i);
2915             }
2916         }
2917 
2918         assertArraysEqualsWithinOneUlp(a, r, Double512VectorTests::SINH, Double512VectorTests::strictSINH);
2919     }
2920 
2921 
2922     static double COSH(double a) {
2923         return (double)(Math.cosh((double)a));
2924     }
2925 
2926     static double strictCOSH(double a) {
2927         return (double)(StrictMath.cosh((double)a));
2928     }
2929 
2930     @Test(dataProvider = "doubleUnaryOpProvider")
2931     static void COSHDouble512VectorTests(IntFunction<double[]> fa) {
2932         double[] a = fa.apply(SPECIES.length());
2933         double[] r = fr.apply(SPECIES.length());
2934 
2935         for (int ic = 0; ic < INVOC_COUNT; ic++) {
2936             for (int i = 0; i < a.length; i += SPECIES.length()) {
2937                 DoubleVector av = DoubleVector.fromArray(SPECIES, a, i);
2938                 av.lanewise(VectorOperators.COSH).intoArray(r, i);
2939             }
2940         }
2941 
2942         assertArraysEqualsWithinOneUlp(a, r, Double512VectorTests::COSH, Double512VectorTests::strictCOSH);
2943     }
2944 
2945 
2946     static double TANH(double a) {
2947         return (double)(Math.tanh((double)a));
2948     }
2949 
2950     static double strictTANH(double a) {
2951         return (double)(StrictMath.tanh((double)a));
2952     }
2953 
2954     @Test(dataProvider = "doubleUnaryOpProvider")
2955     static void TANHDouble512VectorTests(IntFunction<double[]> fa) {
2956         double[] a = fa.apply(SPECIES.length());
2957         double[] r = fr.apply(SPECIES.length());
2958 
2959         for (int ic = 0; ic < INVOC_COUNT; ic++) {
2960             for (int i = 0; i < a.length; i += SPECIES.length()) {
2961                 DoubleVector av = DoubleVector.fromArray(SPECIES, a, i);
2962                 av.lanewise(VectorOperators.TANH).intoArray(r, i);
2963             }
2964         }
2965 
2966         assertArraysEqualsWithinOneUlp(a, r, Double512VectorTests::TANH, Double512VectorTests::strictTANH);
2967     }
2968 
2969 
2970     static double ASIN(double a) {
2971         return (double)(Math.asin((double)a));
2972     }
2973 
2974     static double strictASIN(double a) {
2975         return (double)(StrictMath.asin((double)a));
2976     }
2977 
2978     @Test(dataProvider = "doubleUnaryOpProvider")
2979     static void ASINDouble512VectorTests(IntFunction<double[]> fa) {
2980         double[] a = fa.apply(SPECIES.length());
2981         double[] r = fr.apply(SPECIES.length());
2982 
2983         for (int ic = 0; ic < INVOC_COUNT; ic++) {
2984             for (int i = 0; i < a.length; i += SPECIES.length()) {
2985                 DoubleVector av = DoubleVector.fromArray(SPECIES, a, i);
2986                 av.lanewise(VectorOperators.ASIN).intoArray(r, i);
2987             }
2988         }
2989 
2990         assertArraysEqualsWithinOneUlp(a, r, Double512VectorTests::ASIN, Double512VectorTests::strictASIN);
2991     }
2992 
2993 
2994     static double ACOS(double a) {
2995         return (double)(Math.acos((double)a));
2996     }
2997 
2998     static double strictACOS(double a) {
2999         return (double)(StrictMath.acos((double)a));
3000     }
3001 
3002     @Test(dataProvider = "doubleUnaryOpProvider")
3003     static void ACOSDouble512VectorTests(IntFunction<double[]> fa) {
3004         double[] a = fa.apply(SPECIES.length());
3005         double[] r = fr.apply(SPECIES.length());
3006 
3007         for (int ic = 0; ic < INVOC_COUNT; ic++) {
3008             for (int i = 0; i < a.length; i += SPECIES.length()) {
3009                 DoubleVector av = DoubleVector.fromArray(SPECIES, a, i);
3010                 av.lanewise(VectorOperators.ACOS).intoArray(r, i);
3011             }
3012         }
3013 
3014         assertArraysEqualsWithinOneUlp(a, r, Double512VectorTests::ACOS, Double512VectorTests::strictACOS);
3015     }
3016 
3017 
3018     static double ATAN(double a) {
3019         return (double)(Math.atan((double)a));
3020     }
3021 
3022     static double strictATAN(double a) {
3023         return (double)(StrictMath.atan((double)a));
3024     }
3025 
3026     @Test(dataProvider = "doubleUnaryOpProvider")
3027     static void ATANDouble512VectorTests(IntFunction<double[]> fa) {
3028         double[] a = fa.apply(SPECIES.length());
3029         double[] r = fr.apply(SPECIES.length());
3030 
3031         for (int ic = 0; ic < INVOC_COUNT; ic++) {
3032             for (int i = 0; i < a.length; i += SPECIES.length()) {
3033                 DoubleVector av = DoubleVector.fromArray(SPECIES, a, i);
3034                 av.lanewise(VectorOperators.ATAN).intoArray(r, i);
3035             }
3036         }
3037 
3038         assertArraysEqualsWithinOneUlp(a, r, Double512VectorTests::ATAN, Double512VectorTests::strictATAN);
3039     }
3040 
3041 
3042     static double CBRT(double a) {
3043         return (double)(Math.cbrt((double)a));
3044     }
3045 
3046     static double strictCBRT(double a) {
3047         return (double)(StrictMath.cbrt((double)a));
3048     }
3049 
3050     @Test(dataProvider = "doubleUnaryOpProvider")
3051     static void CBRTDouble512VectorTests(IntFunction<double[]> fa) {
3052         double[] a = fa.apply(SPECIES.length());
3053         double[] r = fr.apply(SPECIES.length());
3054 
3055         for (int ic = 0; ic < INVOC_COUNT; ic++) {
3056             for (int i = 0; i < a.length; i += SPECIES.length()) {
3057                 DoubleVector av = DoubleVector.fromArray(SPECIES, a, i);
3058                 av.lanewise(VectorOperators.CBRT).intoArray(r, i);
3059             }
3060         }
3061 
3062         assertArraysEqualsWithinOneUlp(a, r, Double512VectorTests::CBRT, Double512VectorTests::strictCBRT);
3063     }
3064 
3065 
3066     static double HYPOT(double a, double b) {
3067         return (double)(Math.hypot((double)a, (double)b));
3068     }
3069 
3070     static double strictHYPOT(double a, double b) {
3071         return (double)(StrictMath.hypot((double)a, (double)b));
3072     }
3073 
3074     @Test(dataProvider = "doubleBinaryOpProvider")
3075     static void HYPOTDouble512VectorTests(IntFunction<double[]> fa, IntFunction<double[]> fb) {
3076         double[] a = fa.apply(SPECIES.length());
3077         double[] b = fb.apply(SPECIES.length());
3078         double[] r = fr.apply(SPECIES.length());
3079 
3080         for (int ic = 0; ic < INVOC_COUNT; ic++) {
3081             for (int i = 0; i < a.length; i += SPECIES.length()) {
3082                 DoubleVector av = DoubleVector.fromArray(SPECIES, a, i);
3083                 DoubleVector bv = DoubleVector.fromArray(SPECIES, b, i);
3084                 av.lanewise(VectorOperators.HYPOT, bv).intoArray(r, i);
3085             }
3086         }
3087 
3088         assertArraysEqualsWithinOneUlp(a, b, r, Double512VectorTests::HYPOT, Double512VectorTests::strictHYPOT);
3089     }
3090 
3091 
3092 
3093     static double POW(double a, double b) {
3094         return (double)(Math.pow((double)a, (double)b));
3095     }
3096 
3097     static double strictPOW(double a, double b) {
3098         return (double)(StrictMath.pow((double)a, (double)b));
3099     }
3100 
3101     @Test(dataProvider = "doubleBinaryOpProvider")
3102     static void POWDouble512VectorTests(IntFunction<double[]> fa, IntFunction<double[]> fb) {
3103         double[] a = fa.apply(SPECIES.length());
3104         double[] b = fb.apply(SPECIES.length());
3105         double[] r = fr.apply(SPECIES.length());
3106 
3107         for (int ic = 0; ic < INVOC_COUNT; ic++) {
3108             for (int i = 0; i < a.length; i += SPECIES.length()) {
3109                 DoubleVector av = DoubleVector.fromArray(SPECIES, a, i);
3110                 DoubleVector bv = DoubleVector.fromArray(SPECIES, b, i);
3111                 av.lanewise(VectorOperators.POW, bv).intoArray(r, i);
3112             }
3113         }
3114 
3115         assertArraysEqualsWithinOneUlp(a, b, r, Double512VectorTests::POW, Double512VectorTests::strictPOW);
3116     }
3117 
3118 
3119 
3120     static double ATAN2(double a, double b) {
3121         return (double)(Math.atan2((double)a, (double)b));
3122     }
3123 
3124     static double strictATAN2(double a, double b) {
3125         return (double)(StrictMath.atan2((double)a, (double)b));
3126     }
3127 
3128     @Test(dataProvider = "doubleBinaryOpProvider")
3129     static void ATAN2Double512VectorTests(IntFunction<double[]> fa, IntFunction<double[]> fb) {
3130         double[] a = fa.apply(SPECIES.length());
3131         double[] b = fb.apply(SPECIES.length());
3132         double[] r = fr.apply(SPECIES.length());
3133 
3134         for (int ic = 0; ic < INVOC_COUNT; ic++) {
3135             for (int i = 0; i < a.length; i += SPECIES.length()) {
3136                 DoubleVector av = DoubleVector.fromArray(SPECIES, a, i);
3137                 DoubleVector bv = DoubleVector.fromArray(SPECIES, b, i);
3138                 av.lanewise(VectorOperators.ATAN2, bv).intoArray(r, i);
3139             }
3140         }
3141 
3142         assertArraysEqualsWithinOneUlp(a, b, r, Double512VectorTests::ATAN2, Double512VectorTests::strictATAN2);
3143     }
3144 
3145 
3146 
3147     static double FMA(double a, double b, double c) {
3148         return (double)(Math.fma(a, b, c));
3149     }
3150 
3151 
3152     @Test(dataProvider = "doubleTernaryOpProvider")
3153     static void FMADouble512VectorTests(IntFunction<double[]> fa, IntFunction<double[]> fb, IntFunction<double[]> fc) {
3154         int count = INVOC_COUNT;
3155         switch ("FMA") {
3156         case "fma": case "lanewise_FMA":
3157            // Math.fma uses BigDecimal
3158            count = Math.max(5, count/20); break;
3159         }
3160         final int INVOC_COUNT = count;
3161         double[] a = fa.apply(SPECIES.length());
3162         double[] b = fb.apply(SPECIES.length());
3163         double[] c = fc.apply(SPECIES.length());
3164         double[] r = fr.apply(SPECIES.length());
3165 
3166         for (int ic = 0; ic < INVOC_COUNT; ic++) {
3167             for (int i = 0; i < a.length; i += SPECIES.length()) {
3168                 DoubleVector av = DoubleVector.fromArray(SPECIES, a, i);
3169                 DoubleVector bv = DoubleVector.fromArray(SPECIES, b, i);
3170                 DoubleVector cv = DoubleVector.fromArray(SPECIES, c, i);
3171                 av.lanewise(VectorOperators.FMA, bv, cv).intoArray(r, i);
3172             }
3173         }
3174 
3175         assertArraysEquals(a, b, c, r, Double512VectorTests::FMA);
3176     }
3177 
3178 
3179     @Test(dataProvider = "doubleTernaryOpMaskProvider")
3180     static void FMADouble512VectorTests(IntFunction<double[]> fa, IntFunction<double[]> fb,
3181                                           IntFunction<double[]> fc, IntFunction<boolean[]> fm) {
3182         int count = INVOC_COUNT;
3183         switch ("FMA") {
3184         case "fma": case "lanewise_FMA":
3185            // Math.fma uses BigDecimal
3186            count = Math.max(5, count/20); break;
3187         }
3188         final int INVOC_COUNT = count;
3189         double[] a = fa.apply(SPECIES.length());
3190         double[] b = fb.apply(SPECIES.length());
3191         double[] c = fc.apply(SPECIES.length());
3192         double[] r = fr.apply(SPECIES.length());
3193         boolean[] mask = fm.apply(SPECIES.length());
3194         VectorMask<Double> vmask = VectorMask.fromArray(SPECIES, mask, 0);
3195 
3196         for (int ic = 0; ic < INVOC_COUNT; ic++) {
3197             for (int i = 0; i < a.length; i += SPECIES.length()) {
3198                 DoubleVector av = DoubleVector.fromArray(SPECIES, a, i);
3199                 DoubleVector bv = DoubleVector.fromArray(SPECIES, b, i);
3200                 DoubleVector cv = DoubleVector.fromArray(SPECIES, c, i);
3201                 av.lanewise(VectorOperators.FMA, bv, cv, vmask).intoArray(r, i);
3202             }
3203         }
3204 
3205         assertArraysEquals(a, b, c, r, mask, Double512VectorTests::FMA);
3206     }
3207 
3208 
3209 
3210 
3211 
3212     static double NEG(double a) {
3213         return (double)(-((double)a));
3214     }
3215 
3216     static double neg(double a) {
3217         return (double)(-((double)a));
3218     }
3219 
3220     @Test(dataProvider = "doubleUnaryOpProvider")
3221     static void NEGDouble512VectorTests(IntFunction<double[]> fa) {
3222         double[] a = fa.apply(SPECIES.length());
3223         double[] r = fr.apply(SPECIES.length());
3224 
3225         for (int ic = 0; ic < INVOC_COUNT; ic++) {
3226             for (int i = 0; i < a.length; i += SPECIES.length()) {
3227                 DoubleVector av = DoubleVector.fromArray(SPECIES, a, i);
3228                 av.lanewise(VectorOperators.NEG).intoArray(r, i);
3229             }
3230         }
3231 
3232         assertArraysEquals(a, r, Double512VectorTests::NEG);
3233     }
3234 
3235     @Test(dataProvider = "doubleUnaryOpProvider")
3236     static void negDouble512VectorTests(IntFunction<double[]> fa) {
3237         double[] a = fa.apply(SPECIES.length());
3238         double[] r = fr.apply(SPECIES.length());
3239 
3240         for (int ic = 0; ic < INVOC_COUNT; ic++) {
3241             for (int i = 0; i < a.length; i += SPECIES.length()) {
3242                 DoubleVector av = DoubleVector.fromArray(SPECIES, a, i);
3243                 av.neg().intoArray(r, i);
3244             }
3245         }
3246 
3247         assertArraysEquals(a, r, Double512VectorTests::neg);
3248     }
3249 
3250     @Test(dataProvider = "doubleUnaryOpMaskProvider")
3251     static void NEGMaskedDouble512VectorTests(IntFunction<double[]> fa,
3252                                                 IntFunction<boolean[]> fm) {
3253         double[] a = fa.apply(SPECIES.length());
3254         double[] r = fr.apply(SPECIES.length());
3255         boolean[] mask = fm.apply(SPECIES.length());
3256         VectorMask<Double> vmask = VectorMask.fromArray(SPECIES, mask, 0);
3257 
3258         for (int ic = 0; ic < INVOC_COUNT; ic++) {
3259             for (int i = 0; i < a.length; i += SPECIES.length()) {
3260                 DoubleVector av = DoubleVector.fromArray(SPECIES, a, i);
3261                 av.lanewise(VectorOperators.NEG, vmask).intoArray(r, i);
3262             }
3263         }
3264 
3265         assertArraysEquals(a, r, mask, Double512VectorTests::NEG);
3266     }
3267 
3268     static double ABS(double a) {
3269         return (double)(Math.abs((double)a));
3270     }
3271 
3272     static double abs(double a) {
3273         return (double)(Math.abs((double)a));
3274     }
3275 
3276     @Test(dataProvider = "doubleUnaryOpProvider")
3277     static void ABSDouble512VectorTests(IntFunction<double[]> fa) {
3278         double[] a = fa.apply(SPECIES.length());
3279         double[] r = fr.apply(SPECIES.length());
3280 
3281         for (int ic = 0; ic < INVOC_COUNT; ic++) {
3282             for (int i = 0; i < a.length; i += SPECIES.length()) {
3283                 DoubleVector av = DoubleVector.fromArray(SPECIES, a, i);
3284                 av.lanewise(VectorOperators.ABS).intoArray(r, i);
3285             }
3286         }
3287 
3288         assertArraysEquals(a, r, Double512VectorTests::ABS);
3289     }
3290 
3291     @Test(dataProvider = "doubleUnaryOpProvider")
3292     static void absDouble512VectorTests(IntFunction<double[]> fa) {
3293         double[] a = fa.apply(SPECIES.length());
3294         double[] r = fr.apply(SPECIES.length());
3295 
3296         for (int ic = 0; ic < INVOC_COUNT; ic++) {
3297             for (int i = 0; i < a.length; i += SPECIES.length()) {
3298                 DoubleVector av = DoubleVector.fromArray(SPECIES, a, i);
3299                 av.abs().intoArray(r, i);
3300             }
3301         }
3302 
3303         assertArraysEquals(a, r, Double512VectorTests::abs);
3304     }
3305 
3306     @Test(dataProvider = "doubleUnaryOpMaskProvider")
3307     static void ABSMaskedDouble512VectorTests(IntFunction<double[]> fa,
3308                                                 IntFunction<boolean[]> fm) {
3309         double[] a = fa.apply(SPECIES.length());
3310         double[] r = fr.apply(SPECIES.length());
3311         boolean[] mask = fm.apply(SPECIES.length());
3312         VectorMask<Double> vmask = VectorMask.fromArray(SPECIES, mask, 0);
3313 
3314         for (int ic = 0; ic < INVOC_COUNT; ic++) {
3315             for (int i = 0; i < a.length; i += SPECIES.length()) {
3316                 DoubleVector av = DoubleVector.fromArray(SPECIES, a, i);
3317                 av.lanewise(VectorOperators.ABS, vmask).intoArray(r, i);
3318             }
3319         }
3320 
3321         assertArraysEquals(a, r, mask, Double512VectorTests::ABS);
3322     }
3323 
3324 
3325 
3326 
3327 
3328 
3329 
3330 
3331     static double SQRT(double a) {
3332         return (double)(Math.sqrt((double)a));
3333     }
3334 
3335 
3336 
3337     @Test(dataProvider = "doubleUnaryOpProvider")
3338     static void SQRTDouble512VectorTests(IntFunction<double[]> fa) {
3339         double[] a = fa.apply(SPECIES.length());
3340         double[] r = fr.apply(SPECIES.length());
3341 
3342         for (int ic = 0; ic < INVOC_COUNT; ic++) {
3343             for (int i = 0; i < a.length; i += SPECIES.length()) {
3344                 DoubleVector av = DoubleVector.fromArray(SPECIES, a, i);
3345                 av.lanewise(VectorOperators.SQRT).intoArray(r, i);
3346             }
3347         }
3348 
3349         assertArraysEquals(a, r, Double512VectorTests::SQRT);
3350     }
3351 
3352 
3353 
3354     @Test(dataProvider = "doubleUnaryOpMaskProvider")
3355     static void SQRTMaskedDouble512VectorTests(IntFunction<double[]> fa,
3356                                                 IntFunction<boolean[]> fm) {
3357         double[] a = fa.apply(SPECIES.length());
3358         double[] r = fr.apply(SPECIES.length());
3359         boolean[] mask = fm.apply(SPECIES.length());
3360         VectorMask<Double> vmask = VectorMask.fromArray(SPECIES, mask, 0);
3361 
3362         for (int ic = 0; ic < INVOC_COUNT; ic++) {
3363             for (int i = 0; i < a.length; i += SPECIES.length()) {
3364                 DoubleVector av = DoubleVector.fromArray(SPECIES, a, i);
3365                 av.lanewise(VectorOperators.SQRT, vmask).intoArray(r, i);
3366             }
3367         }
3368 
3369         assertArraysEquals(a, r, mask, Double512VectorTests::SQRT);
3370     }
3371 
3372     static double[] gather(double a[], int ix, int[] b, int iy) {
3373         double[] res = new double[SPECIES.length()];
3374         for (int i = 0; i < SPECIES.length(); i++) {
3375             int bi = iy + i;
3376             res[i] = a[b[bi] + ix];
3377         }
3378         return res;
3379     }
3380 
3381     @Test(dataProvider = "doubleUnaryOpIndexProvider")
3382     static void gatherDouble512VectorTests(IntFunction<double[]> fa, BiFunction<Integer,Integer,int[]> fs) {
3383         double[] a = fa.apply(SPECIES.length());
3384         int[] b    = fs.apply(a.length, SPECIES.length());
3385         double[] r = new double[a.length];
3386 
3387         for (int ic = 0; ic < INVOC_COUNT; ic++) {
3388             for (int i = 0; i < a.length; i += SPECIES.length()) {
3389                 DoubleVector av = DoubleVector.fromArray(SPECIES, a, i, b, i);
3390                 av.intoArray(r, i);
3391             }
3392         }
3393 
3394         assertArraysEquals(a, b, r, Double512VectorTests::gather);
3395     }
3396     static double[] gatherMasked(double a[], int ix, boolean[] mask, int[] b, int iy) {
3397         double[] res = new double[SPECIES.length()];
3398         for (int i = 0; i < SPECIES.length(); i++) {
3399             int bi = iy + i;
3400             if (mask[i]) {
3401               res[i] = a[b[bi] + ix];
3402             }
3403         }
3404         return res;
3405     }
3406 
3407     @Test(dataProvider = "doubleUnaryMaskedOpIndexProvider")
3408     static void gatherMaskedDouble512VectorTests(IntFunction<double[]> fa, BiFunction<Integer,Integer,int[]> fs, IntFunction<boolean[]> fm) {
3409         double[] a = fa.apply(SPECIES.length());
3410         int[] b    = fs.apply(a.length, SPECIES.length());
3411         double[] r = new double[a.length];
3412         boolean[] mask = fm.apply(SPECIES.length());
3413         VectorMask<Double> vmask = VectorMask.fromArray(SPECIES, mask, 0);
3414 
3415         for (int ic = 0; ic < INVOC_COUNT; ic++) {
3416             for (int i = 0; i < a.length; i += SPECIES.length()) {
3417                 DoubleVector av = DoubleVector.fromArray(SPECIES, a, i, b, i, vmask);
3418                 av.intoArray(r, i);
3419             }
3420         }
3421 
3422         assertArraysEquals(a, b, r, mask, Double512VectorTests::gatherMasked);
3423     }
3424 
3425     static double[] scatter(double a[], int ix, int[] b, int iy) {
3426       double[] res = new double[SPECIES.length()];
3427       for (int i = 0; i < SPECIES.length(); i++) {
3428         int bi = iy + i;
3429         res[b[bi]] = a[i + ix];
3430       }
3431       return res;
3432     }
3433 
3434     @Test(dataProvider = "doubleUnaryOpIndexProvider")
3435     static void scatterDouble512VectorTests(IntFunction<double[]> fa, BiFunction<Integer,Integer,int[]> fs) {
3436         double[] a = fa.apply(SPECIES.length());
3437         int[] b = fs.apply(a.length, SPECIES.length());
3438         double[] r = new double[a.length];
3439 
3440         for (int ic = 0; ic < INVOC_COUNT; ic++) {
3441             for (int i = 0; i < a.length; i += SPECIES.length()) {
3442                 DoubleVector av = DoubleVector.fromArray(SPECIES, a, i);
3443                 av.intoArray(r, i, b, i);
3444             }
3445         }
3446 
3447         assertArraysEquals(a, b, r, Double512VectorTests::scatter);
3448     }
3449 
3450     static double[] scatterMasked(double r[], double a[], int ix, boolean[] mask, int[] b, int iy) {
3451       // First, gather r.
3452       double[] oldVal = gather(r, ix, b, iy);
3453       double[] newVal = new double[SPECIES.length()];
3454 
3455       // Second, blending it with a.
3456       for (int i = 0; i < SPECIES.length(); i++) {
3457         newVal[i] = blend(oldVal[i], a[i+ix], mask[i]);
3458       }
3459 
3460       // Third, scatter: copy old value of r, and scatter it manually.
3461       double[] res = Arrays.copyOfRange(r, ix, ix+SPECIES.length());
3462       for (int i = 0; i < SPECIES.length(); i++) {
3463         int bi = iy + i;
3464         res[b[bi]] = newVal[i];
3465       }
3466 
3467       return res;
3468     }
3469 
3470     @Test(dataProvider = "scatterMaskedOpIndexProvider")
3471     static void scatterMaskedDouble512VectorTests(IntFunction<double[]> fa, IntFunction<double[]> fb, BiFunction<Integer,Integer,int[]> fs, IntFunction<boolean[]> fm) {
3472         double[] a = fa.apply(SPECIES.length());
3473         int[] b = fs.apply(a.length, SPECIES.length());
3474         double[] r = fb.apply(SPECIES.length());
3475         boolean[] mask = fm.apply(SPECIES.length());
3476         VectorMask<Double> vmask = VectorMask.fromArray(SPECIES, mask, 0);
3477 
3478         for (int ic = 0; ic < INVOC_COUNT; ic++) {
3479             for (int i = 0; i < a.length; i += SPECIES.length()) {
3480                 DoubleVector av = DoubleVector.fromArray(SPECIES, a, i);
3481                 av.intoArray(r, i, b, i, vmask);
3482             }
3483         }
3484 
3485         assertArraysEquals(a, b, r, mask, Double512VectorTests::scatterMasked);
3486     }
3487 
3488 }
3489