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