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