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