< prev index next >

test/jdk/jdk/incubator/vector/DoubleMaxVectorTests.java

Print this page

  48 import java.util.function.BiFunction;
  49 import java.util.function.IntFunction;
  50 import java.util.Objects;
  51 import java.util.stream.Collectors;
  52 import java.util.stream.Stream;
  53 
  54 @Test
  55 public class DoubleMaxVectorTests extends AbstractVectorTest {
  56 
  57     static final VectorSpecies<Double> SPECIES =
  58                 DoubleVector.SPECIES_MAX;
  59 
  60     static final int INVOC_COUNT = Integer.getInteger("jdk.incubator.vector.test.loop-iterations", 100);
  61 
  62     static VectorShape getMaxBit() {
  63         return VectorShape.S_Max_BIT;
  64     }
  65 
  66     private static final int Max = 256;  // juts so we can do N/Max
  67 
  68     private static final double CONST_SHIFT = Double.SIZE / 2;
  69 
  70     static final int BUFFER_REPS = Integer.getInteger("jdk.incubator.vector.test.buffer-vectors", 25000 / Max);
  71 
  72     interface FUnOp {
  73         double apply(double a);
  74     }
  75 
  76     static void assertArraysEquals(double[] r, double[] a, FUnOp f) {
  77         int i = 0;
  78         try {
  79             for (; i < a.length; i++) {
  80                 Assert.assertEquals(r[i], f.apply(a[i]));
  81             }
  82         } catch (AssertionError e) {
  83             Assert.assertEquals(r[i], f.apply(a[i]), "at index #" + i + ", input = " + a[i]);
  84         }
  85     }
  86 
  87     interface FUnArrayOp {
  88         double[] apply(double a);

 249             } else {
 250                 Assert.assertEquals(r[i], a[i], "at index #" + i);
 251             }
 252         }
 253     }
 254 
 255     static void assertRearrangeArraysEquals(double[] r, double[] a, int[] order, int vector_len) {
 256         int i = 0, j = 0;
 257         try {
 258             for (; i < a.length; i += vector_len) {
 259                 for (j = 0; j < vector_len; j++) {
 260                     Assert.assertEquals(r[i+j], a[i+order[i+j]]);
 261                 }
 262             }
 263         } catch (AssertionError e) {
 264             int idx = i + j;
 265             Assert.assertEquals(r[i+j], a[i+order[i+j]], "at index #" + idx + ", input = " + a[i+order[i+j]]);
 266         }
 267     }
 268 

















































 269     static void assertSelectFromArraysEquals(double[] r, double[] a, double[] order, int vector_len) {
 270         int i = 0, j = 0;
 271         try {
 272             for (; i < a.length; i += vector_len) {
 273                 for (j = 0; j < vector_len; j++) {
 274                     Assert.assertEquals(r[i+j], a[i+(int)order[i+j]]);
 275                 }
 276             }
 277         } catch (AssertionError e) {
 278             int idx = i + j;
 279             Assert.assertEquals(r[i+j], a[i+(int)order[i+j]], "at index #" + idx + ", input = " + a[i+(int)order[i+j]]);
 280         }
 281     }
 282 
 283     static void assertRearrangeArraysEquals(double[] r, double[] a, int[] order, boolean[] mask, int vector_len) {
 284         int i = 0, j = 0;
 285         try {
 286             for (; i < a.length; i += vector_len) {
 287                 for (j = 0; j < vector_len; j++) {
 288                     if (mask[j % SPECIES.length()])

1001                             i -> (((double)(i + 1) == 0) ? 1 : (double)(i + 1)));
1002             }),
1003             withToString("double[cornerCaseValue(i)]", (int s) -> {
1004                 return fill(s * BUFFER_REPS,
1005                             i -> (double)longCornerCaseValue(i));
1006             })
1007     );
1008 
1009 
1010     static void assertArraysEquals(long[] r, double[] a, int offs) {
1011         int i = 0;
1012         try {
1013             for (; i < r.length; i++) {
1014                 Assert.assertEquals(r[i], (long)(a[i+offs]));
1015             }
1016         } catch (AssertionError e) {
1017             Assert.assertEquals(r[i], (long)(a[i+offs]), "at index #" + i + ", input = " + a[i+offs]);
1018         }
1019     }
1020 
1021 
1022 
1023     static long bits(double e) {
1024         return  Double.doubleToLongBits(e);
1025     }
1026 
1027     static final List<IntFunction<double[]>> DOUBLE_GENERATORS = List.of(
1028             withToString("double[-i * 5]", (int s) -> {
1029                 return fill(s * BUFFER_REPS,
1030                             i -> (double)(-i * 5));
1031             }),
1032             withToString("double[i * 5]", (int s) -> {
1033                 return fill(s * BUFFER_REPS,
1034                             i -> (double)(i * 5));
1035             }),
1036             withToString("double[i + 1]", (int s) -> {
1037                 return fill(s * BUFFER_REPS,
1038                             i -> (((double)(i + 1) == 0) ? 1 : (double)(i + 1)));
1039             }),
1040             withToString("double[cornerCaseValue(i)]", (int s) -> {
1041                 return fill(s * BUFFER_REPS,
1042                             i -> cornerCaseValue(i));

1186 
1187     @DataProvider
1188     public Object[][] doubleUnaryOpSelectFromProvider() {
1189         return DOUBLE_SHUFFLE_GENERATORS.stream().
1190                 flatMap(fs -> DOUBLE_GENERATORS.stream().map(fa -> {
1191                     return new Object[] {fa, fs};
1192                 })).
1193                 toArray(Object[][]::new);
1194     }
1195 
1196     @DataProvider
1197     public Object[][] doubleUnaryOpSelectFromMaskProvider() {
1198         return BOOLEAN_MASK_GENERATORS.stream().
1199                 flatMap(fm -> DOUBLE_SHUFFLE_GENERATORS.stream().
1200                     flatMap(fs -> DOUBLE_GENERATORS.stream().map(fa -> {
1201                         return new Object[] {fa, fs, fm};
1202                 }))).
1203                 toArray(Object[][]::new);
1204     }
1205 
1206 
1207     static final List<IntFunction<double[]>> DOUBLE_COMPARE_GENERATORS = List.of(
1208             withToString("double[i]", (int s) -> {
1209                 return fill(s * BUFFER_REPS,
1210                             i -> (double)i);
1211             }),
1212             withToString("double[i - length / 2]", (int s) -> {
1213                 return fill(s * BUFFER_REPS,
1214                             i -> (double)(i - (s * BUFFER_REPS / 2)));
1215             }),
1216             withToString("double[i + 1]", (int s) -> {
1217                 return fill(s * BUFFER_REPS,
1218                             i -> (double)(i + 1));
1219             }),
1220             withToString("double[i - 2]", (int s) -> {
1221                 return fill(s * BUFFER_REPS,
1222                             i -> (double)(i - 2));
1223             }),
1224             withToString("double[zigZag(i)]", (int s) -> {
1225                 return fill(s * BUFFER_REPS,
1226                             i -> i%3 == 0 ? (double)i : (i%3 == 1 ? (double)(i + 1) : (double)(i - 2)));

1307 
1308     static double get(double[] a, int i) {
1309         return (double) a[i];
1310     }
1311 
1312     static final IntFunction<double[]> fr = (vl) -> {
1313         int length = BUFFER_REPS * vl;
1314         return new double[length];
1315     };
1316 
1317     static final IntFunction<boolean[]> fmr = (vl) -> {
1318         int length = BUFFER_REPS * vl;
1319         return new boolean[length];
1320     };
1321 
1322     static final IntFunction<long[]> lfr = (vl) -> {
1323         int length = BUFFER_REPS * vl;
1324         return new long[length];
1325     };
1326 
1327 
1328     static boolean eq(double a, double b) {
1329         return a == b;
1330     }
1331 
1332     static boolean neq(double a, double b) {
1333         return a != b;
1334     }
1335 
1336     static boolean lt(double a, double b) {
1337         return a < b;
1338     }
1339 
1340     static boolean le(double a, double b) {
1341         return a <= b;
1342     }
1343 
1344     static boolean gt(double a, double b) {
1345         return a > b;
1346     }
1347 
1348     static boolean ge(double a, double b) {
1349         return a >= b;
1350     }
1351 
1352 
1353     static double firstNonZero(double a, double b) {
1354         return Double.compare(a, (double) 0) != 0 ? a : b;
1355     }
1356 
1357     @Test
1358     static void smokeTest1() {
1359         DoubleVector three = DoubleVector.broadcast(SPECIES, (byte)-3);
1360         DoubleVector three2 = (DoubleVector) SPECIES.broadcast(-3);
1361         assert(three.eq(three2).allTrue());
1362         DoubleVector three3 = three2.broadcast(1).broadcast(-3);
1363         assert(three.eq(three3).allTrue());
1364         int scale = 2;
1365         Class<?> ETYPE = double.class;
1366         if (ETYPE == double.class || ETYPE == long.class)
1367             scale = 1000000;
1368         else if (ETYPE == byte.class && SPECIES.length() >= 64)
1369             scale = 1;
1370         DoubleVector higher = three.addIndex(scale);
1371         VectorMask<Double> m = three.compare(VectorOperators.LE, higher);
1372         assert(m.allTrue());

1449     static double ADD(double a, double b) {
1450         return (double)(a + b);
1451     }
1452 
1453     @Test(dataProvider = "doubleBinaryOpProvider")
1454     static void ADDDoubleMaxVectorTests(IntFunction<double[]> fa, IntFunction<double[]> fb) {
1455         double[] a = fa.apply(SPECIES.length());
1456         double[] b = fb.apply(SPECIES.length());
1457         double[] r = fr.apply(SPECIES.length());
1458 
1459         for (int ic = 0; ic < INVOC_COUNT; ic++) {
1460             for (int i = 0; i < a.length; i += SPECIES.length()) {
1461                 DoubleVector av = DoubleVector.fromArray(SPECIES, a, i);
1462                 DoubleVector bv = DoubleVector.fromArray(SPECIES, b, i);
1463                 av.lanewise(VectorOperators.ADD, bv).intoArray(r, i);
1464             }
1465         }
1466 
1467         assertArraysEquals(r, a, b, DoubleMaxVectorTests::ADD);
1468     }

1469     static double add(double a, double b) {
1470         return (double)(a + b);
1471     }
1472 
1473     @Test(dataProvider = "doubleBinaryOpProvider")
1474     static void addDoubleMaxVectorTests(IntFunction<double[]> fa, IntFunction<double[]> fb) {
1475         double[] a = fa.apply(SPECIES.length());
1476         double[] b = fb.apply(SPECIES.length());
1477         double[] r = fr.apply(SPECIES.length());
1478 
1479         for (int i = 0; i < a.length; i += SPECIES.length()) {
1480             DoubleVector av = DoubleVector.fromArray(SPECIES, a, i);
1481             DoubleVector bv = DoubleVector.fromArray(SPECIES, b, i);
1482             av.add(bv).intoArray(r, i);
1483         }
1484 
1485         assertArraysEquals(r, a, b, DoubleMaxVectorTests::add);
1486     }
1487 
1488     @Test(dataProvider = "doubleBinaryOpMaskProvider")

1505         assertArraysEquals(r, a, b, mask, DoubleMaxVectorTests::ADD);
1506     }
1507 
1508     @Test(dataProvider = "doubleBinaryOpMaskProvider")
1509     static void addDoubleMaxVectorTestsMasked(IntFunction<double[]> fa, IntFunction<double[]> fb,
1510                                           IntFunction<boolean[]> fm) {
1511         double[] a = fa.apply(SPECIES.length());
1512         double[] b = fb.apply(SPECIES.length());
1513         double[] r = fr.apply(SPECIES.length());
1514         boolean[] mask = fm.apply(SPECIES.length());
1515         VectorMask<Double> vmask = VectorMask.fromArray(SPECIES, mask, 0);
1516 
1517         for (int i = 0; i < a.length; i += SPECIES.length()) {
1518             DoubleVector av = DoubleVector.fromArray(SPECIES, a, i);
1519             DoubleVector bv = DoubleVector.fromArray(SPECIES, b, i);
1520             av.add(bv, vmask).intoArray(r, i);
1521         }
1522 
1523         assertArraysEquals(r, a, b, mask, DoubleMaxVectorTests::add);
1524     }

1525     static double SUB(double a, double b) {
1526         return (double)(a - b);
1527     }
1528 
1529     @Test(dataProvider = "doubleBinaryOpProvider")
1530     static void SUBDoubleMaxVectorTests(IntFunction<double[]> fa, IntFunction<double[]> fb) {
1531         double[] a = fa.apply(SPECIES.length());
1532         double[] b = fb.apply(SPECIES.length());
1533         double[] r = fr.apply(SPECIES.length());
1534 
1535         for (int ic = 0; ic < INVOC_COUNT; ic++) {
1536             for (int i = 0; i < a.length; i += SPECIES.length()) {
1537                 DoubleVector av = DoubleVector.fromArray(SPECIES, a, i);
1538                 DoubleVector bv = DoubleVector.fromArray(SPECIES, b, i);
1539                 av.lanewise(VectorOperators.SUB, bv).intoArray(r, i);
1540             }
1541         }
1542 
1543         assertArraysEquals(r, a, b, DoubleMaxVectorTests::SUB);
1544     }

1545     static double sub(double a, double b) {
1546         return (double)(a - b);
1547     }
1548 
1549     @Test(dataProvider = "doubleBinaryOpProvider")
1550     static void subDoubleMaxVectorTests(IntFunction<double[]> fa, IntFunction<double[]> fb) {
1551         double[] a = fa.apply(SPECIES.length());
1552         double[] b = fb.apply(SPECIES.length());
1553         double[] r = fr.apply(SPECIES.length());
1554 
1555         for (int i = 0; i < a.length; i += SPECIES.length()) {
1556             DoubleVector av = DoubleVector.fromArray(SPECIES, a, i);
1557             DoubleVector bv = DoubleVector.fromArray(SPECIES, b, i);
1558             av.sub(bv).intoArray(r, i);
1559         }
1560 
1561         assertArraysEquals(r, a, b, DoubleMaxVectorTests::sub);
1562     }
1563 
1564     @Test(dataProvider = "doubleBinaryOpMaskProvider")

1581         assertArraysEquals(r, a, b, mask, DoubleMaxVectorTests::SUB);
1582     }
1583 
1584     @Test(dataProvider = "doubleBinaryOpMaskProvider")
1585     static void subDoubleMaxVectorTestsMasked(IntFunction<double[]> fa, IntFunction<double[]> fb,
1586                                           IntFunction<boolean[]> fm) {
1587         double[] a = fa.apply(SPECIES.length());
1588         double[] b = fb.apply(SPECIES.length());
1589         double[] r = fr.apply(SPECIES.length());
1590         boolean[] mask = fm.apply(SPECIES.length());
1591         VectorMask<Double> vmask = VectorMask.fromArray(SPECIES, mask, 0);
1592 
1593         for (int i = 0; i < a.length; i += SPECIES.length()) {
1594             DoubleVector av = DoubleVector.fromArray(SPECIES, a, i);
1595             DoubleVector bv = DoubleVector.fromArray(SPECIES, b, i);
1596             av.sub(bv, vmask).intoArray(r, i);
1597         }
1598 
1599         assertArraysEquals(r, a, b, mask, DoubleMaxVectorTests::sub);
1600     }

1601     static double MUL(double a, double b) {
1602         return (double)(a * b);
1603     }
1604 
1605     @Test(dataProvider = "doubleBinaryOpProvider")
1606     static void MULDoubleMaxVectorTests(IntFunction<double[]> fa, IntFunction<double[]> fb) {
1607         double[] a = fa.apply(SPECIES.length());
1608         double[] b = fb.apply(SPECIES.length());
1609         double[] r = fr.apply(SPECIES.length());
1610 
1611         for (int ic = 0; ic < INVOC_COUNT; ic++) {
1612             for (int i = 0; i < a.length; i += SPECIES.length()) {
1613                 DoubleVector av = DoubleVector.fromArray(SPECIES, a, i);
1614                 DoubleVector bv = DoubleVector.fromArray(SPECIES, b, i);
1615                 av.lanewise(VectorOperators.MUL, bv).intoArray(r, i);
1616             }
1617         }
1618 
1619         assertArraysEquals(r, a, b, DoubleMaxVectorTests::MUL);
1620     }

1621     static double mul(double a, double b) {
1622         return (double)(a * b);
1623     }
1624 
1625     @Test(dataProvider = "doubleBinaryOpProvider")
1626     static void mulDoubleMaxVectorTests(IntFunction<double[]> fa, IntFunction<double[]> fb) {
1627         double[] a = fa.apply(SPECIES.length());
1628         double[] b = fb.apply(SPECIES.length());
1629         double[] r = fr.apply(SPECIES.length());
1630 
1631         for (int i = 0; i < a.length; i += SPECIES.length()) {
1632             DoubleVector av = DoubleVector.fromArray(SPECIES, a, i);
1633             DoubleVector bv = DoubleVector.fromArray(SPECIES, b, i);
1634             av.mul(bv).intoArray(r, i);
1635         }
1636 
1637         assertArraysEquals(r, a, b, DoubleMaxVectorTests::mul);
1638     }
1639 
1640     @Test(dataProvider = "doubleBinaryOpMaskProvider")

1678     static double DIV(double a, double b) {
1679         return (double)(a / b);
1680     }
1681 
1682     @Test(dataProvider = "doubleBinaryOpProvider")
1683     static void DIVDoubleMaxVectorTests(IntFunction<double[]> fa, IntFunction<double[]> fb) {
1684         double[] a = fa.apply(SPECIES.length());
1685         double[] b = fb.apply(SPECIES.length());
1686         double[] r = fr.apply(SPECIES.length());
1687 
1688         for (int ic = 0; ic < INVOC_COUNT; ic++) {
1689             for (int i = 0; i < a.length; i += SPECIES.length()) {
1690                 DoubleVector av = DoubleVector.fromArray(SPECIES, a, i);
1691                 DoubleVector bv = DoubleVector.fromArray(SPECIES, b, i);
1692                 av.lanewise(VectorOperators.DIV, bv).intoArray(r, i);
1693             }
1694         }
1695 
1696         assertArraysEquals(r, a, b, DoubleMaxVectorTests::DIV);
1697     }

1698     static double div(double a, double b) {
1699         return (double)(a / b);
1700     }
1701 
1702     @Test(dataProvider = "doubleBinaryOpProvider")
1703     static void divDoubleMaxVectorTests(IntFunction<double[]> fa, IntFunction<double[]> fb) {
1704         double[] a = fa.apply(SPECIES.length());
1705         double[] b = fb.apply(SPECIES.length());
1706         double[] r = fr.apply(SPECIES.length());
1707 
1708         for (int i = 0; i < a.length; i += SPECIES.length()) {
1709             DoubleVector av = DoubleVector.fromArray(SPECIES, a, i);
1710             DoubleVector bv = DoubleVector.fromArray(SPECIES, b, i);
1711             av.div(bv).intoArray(r, i);
1712         }
1713 
1714         assertArraysEquals(r, a, b, DoubleMaxVectorTests::div);
1715     }
1716 
1717 
1718 
1719     @Test(dataProvider = "doubleBinaryOpMaskProvider")
1720     static void DIVDoubleMaxVectorTestsMasked(IntFunction<double[]> fa, IntFunction<double[]> fb,
1721                                           IntFunction<boolean[]> fm) {
1722         double[] a = fa.apply(SPECIES.length());
1723         double[] b = fb.apply(SPECIES.length());
1724         double[] r = fr.apply(SPECIES.length());
1725         boolean[] mask = fm.apply(SPECIES.length());
1726         VectorMask<Double> vmask = VectorMask.fromArray(SPECIES, mask, 0);
1727 
1728         for (int ic = 0; ic < INVOC_COUNT; ic++) {
1729             for (int i = 0; i < a.length; i += SPECIES.length()) {
1730                 DoubleVector av = DoubleVector.fromArray(SPECIES, a, i);
1731                 DoubleVector bv = DoubleVector.fromArray(SPECIES, b, i);
1732                 av.lanewise(VectorOperators.DIV, bv, vmask).intoArray(r, i);
1733             }
1734         }
1735 
1736         assertArraysEquals(r, a, b, mask, DoubleMaxVectorTests::DIV);
1737     }
1738 
1739     @Test(dataProvider = "doubleBinaryOpMaskProvider")
1740     static void divDoubleMaxVectorTestsMasked(IntFunction<double[]> fa, IntFunction<double[]> fb,
1741                                           IntFunction<boolean[]> fm) {
1742         double[] a = fa.apply(SPECIES.length());
1743         double[] b = fb.apply(SPECIES.length());
1744         double[] r = fr.apply(SPECIES.length());
1745         boolean[] mask = fm.apply(SPECIES.length());
1746         VectorMask<Double> vmask = VectorMask.fromArray(SPECIES, mask, 0);
1747 
1748         for (int i = 0; i < a.length; i += SPECIES.length()) {
1749             DoubleVector av = DoubleVector.fromArray(SPECIES, a, i);
1750             DoubleVector bv = DoubleVector.fromArray(SPECIES, b, i);
1751             av.div(bv, vmask).intoArray(r, i);
1752         }
1753 
1754         assertArraysEquals(r, a, b, mask, DoubleMaxVectorTests::div);
1755     }
1756 
1757 
1758 
1759     static double FIRST_NONZERO(double a, double b) {
1760         return (double)(Double.doubleToLongBits(a)!=0?a:b);
1761     }
1762 
1763     @Test(dataProvider = "doubleBinaryOpProvider")
1764     static void FIRST_NONZERODoubleMaxVectorTests(IntFunction<double[]> fa, IntFunction<double[]> fb) {
1765         double[] a = fa.apply(SPECIES.length());
1766         double[] b = fb.apply(SPECIES.length());
1767         double[] r = fr.apply(SPECIES.length());
1768 
1769         for (int ic = 0; ic < INVOC_COUNT; ic++) {
1770             for (int i = 0; i < a.length; i += SPECIES.length()) {
1771                 DoubleVector av = DoubleVector.fromArray(SPECIES, a, i);
1772                 DoubleVector bv = DoubleVector.fromArray(SPECIES, b, i);
1773                 av.lanewise(VectorOperators.FIRST_NONZERO, bv).intoArray(r, i);
1774             }
1775         }
1776 
1777         assertArraysEquals(r, a, b, DoubleMaxVectorTests::FIRST_NONZERO);
1778     }

1780     @Test(dataProvider = "doubleBinaryOpMaskProvider")
1781     static void FIRST_NONZERODoubleMaxVectorTestsMasked(IntFunction<double[]> fa, IntFunction<double[]> fb,
1782                                           IntFunction<boolean[]> fm) {
1783         double[] a = fa.apply(SPECIES.length());
1784         double[] b = fb.apply(SPECIES.length());
1785         double[] r = fr.apply(SPECIES.length());
1786         boolean[] mask = fm.apply(SPECIES.length());
1787         VectorMask<Double> vmask = VectorMask.fromArray(SPECIES, mask, 0);
1788 
1789         for (int ic = 0; ic < INVOC_COUNT; ic++) {
1790             for (int i = 0; i < a.length; i += SPECIES.length()) {
1791                 DoubleVector av = DoubleVector.fromArray(SPECIES, a, i);
1792                 DoubleVector bv = DoubleVector.fromArray(SPECIES, b, i);
1793                 av.lanewise(VectorOperators.FIRST_NONZERO, bv, vmask).intoArray(r, i);
1794             }
1795         }
1796 
1797         assertArraysEquals(r, a, b, mask, DoubleMaxVectorTests::FIRST_NONZERO);
1798     }
1799 
1800 
1801 
1802 
1803 
1804 
1805 
1806 
1807 
1808     @Test(dataProvider = "doubleBinaryOpProvider")
1809     static void addDoubleMaxVectorTestsBroadcastSmokeTest(IntFunction<double[]> fa, IntFunction<double[]> fb) {
1810         double[] a = fa.apply(SPECIES.length());
1811         double[] b = fb.apply(SPECIES.length());
1812         double[] r = fr.apply(SPECIES.length());
1813 
1814         for (int i = 0; i < a.length; i += SPECIES.length()) {
1815             DoubleVector av = DoubleVector.fromArray(SPECIES, a, i);
1816             av.add(b[i]).intoArray(r, i);
1817         }
1818 
1819         assertBroadcastArraysEquals(r, a, b, DoubleMaxVectorTests::add);
1820     }
1821 
1822     @Test(dataProvider = "doubleBinaryOpMaskProvider")
1823     static void addDoubleMaxVectorTestsBroadcastMaskedSmokeTest(IntFunction<double[]> fa, IntFunction<double[]> fb,
1824                                           IntFunction<boolean[]> fm) {
1825         double[] a = fa.apply(SPECIES.length());
1826         double[] b = fb.apply(SPECIES.length());
1827         double[] r = fr.apply(SPECIES.length());

1881         assertBroadcastArraysEquals(r, a, b, DoubleMaxVectorTests::mul);
1882     }
1883 
1884     @Test(dataProvider = "doubleBinaryOpMaskProvider")
1885     static void mulDoubleMaxVectorTestsBroadcastMaskedSmokeTest(IntFunction<double[]> fa, IntFunction<double[]> fb,
1886                                           IntFunction<boolean[]> fm) {
1887         double[] a = fa.apply(SPECIES.length());
1888         double[] b = fb.apply(SPECIES.length());
1889         double[] r = fr.apply(SPECIES.length());
1890         boolean[] mask = fm.apply(SPECIES.length());
1891         VectorMask<Double> vmask = VectorMask.fromArray(SPECIES, mask, 0);
1892 
1893         for (int i = 0; i < a.length; i += SPECIES.length()) {
1894             DoubleVector av = DoubleVector.fromArray(SPECIES, a, i);
1895             av.mul(b[i], vmask).intoArray(r, i);
1896         }
1897 
1898         assertBroadcastArraysEquals(r, a, b, mask, DoubleMaxVectorTests::mul);
1899     }
1900 
1901 
1902     @Test(dataProvider = "doubleBinaryOpProvider")
1903     static void divDoubleMaxVectorTestsBroadcastSmokeTest(IntFunction<double[]> fa, IntFunction<double[]> fb) {
1904         double[] a = fa.apply(SPECIES.length());
1905         double[] b = fb.apply(SPECIES.length());
1906         double[] r = fr.apply(SPECIES.length());
1907 
1908         for (int i = 0; i < a.length; i += SPECIES.length()) {
1909             DoubleVector av = DoubleVector.fromArray(SPECIES, a, i);
1910             av.div(b[i]).intoArray(r, i);
1911         }
1912 
1913         assertBroadcastArraysEquals(r, a, b, DoubleMaxVectorTests::div);
1914     }
1915 
1916 
1917 
1918     @Test(dataProvider = "doubleBinaryOpMaskProvider")
1919     static void divDoubleMaxVectorTestsBroadcastMaskedSmokeTest(IntFunction<double[]> fa, IntFunction<double[]> fb,
1920                                           IntFunction<boolean[]> fm) {
1921         double[] a = fa.apply(SPECIES.length());
1922         double[] b = fb.apply(SPECIES.length());
1923         double[] r = fr.apply(SPECIES.length());
1924         boolean[] mask = fm.apply(SPECIES.length());
1925         VectorMask<Double> vmask = VectorMask.fromArray(SPECIES, mask, 0);
1926 
1927         for (int i = 0; i < a.length; i += SPECIES.length()) {
1928             DoubleVector av = DoubleVector.fromArray(SPECIES, a, i);
1929             av.div(b[i], vmask).intoArray(r, i);
1930         }
1931 
1932         assertBroadcastArraysEquals(r, a, b, mask, DoubleMaxVectorTests::div);
1933     }
1934 
1935 
1936 
1937 
1938 
1939 
1940 
1941 
1942 
1943 
1944     @Test(dataProvider = "doubleBinaryOpProvider")
1945     static void ADDDoubleMaxVectorTestsBroadcastLongSmokeTest(IntFunction<double[]> fa, IntFunction<double[]> fb) {
1946         double[] a = fa.apply(SPECIES.length());
1947         double[] b = fb.apply(SPECIES.length());
1948         double[] r = fr.apply(SPECIES.length());
1949 
1950         for (int i = 0; i < a.length; i += SPECIES.length()) {
1951             DoubleVector av = DoubleVector.fromArray(SPECIES, a, i);
1952             av.lanewise(VectorOperators.ADD, (long)b[i]).intoArray(r, i);
1953         }
1954 
1955         assertBroadcastLongArraysEquals(r, a, b, DoubleMaxVectorTests::ADD);
1956     }
1957 
1958     @Test(dataProvider = "doubleBinaryOpMaskProvider")
1959     static void ADDDoubleMaxVectorTestsBroadcastMaskedLongSmokeTest(IntFunction<double[]> fa, IntFunction<double[]> fb,
1960                                           IntFunction<boolean[]> fm) {
1961         double[] a = fa.apply(SPECIES.length());
1962         double[] b = fb.apply(SPECIES.length());
1963         double[] r = fr.apply(SPECIES.length());
1964         boolean[] mask = fm.apply(SPECIES.length());
1965         VectorMask<Double> vmask = VectorMask.fromArray(SPECIES, mask, 0);
1966 
1967         for (int i = 0; i < a.length; i += SPECIES.length()) {
1968             DoubleVector av = DoubleVector.fromArray(SPECIES, a, i);
1969             av.lanewise(VectorOperators.ADD, (long)b[i], vmask).intoArray(r, i);
1970         }
1971 
1972         assertBroadcastLongArraysEquals(r, a, b, mask, DoubleMaxVectorTests::ADD);
1973     }
1974 
1975 
1976 
1977 
1978 
1979 
1980 
1981 
1982 
1983 
1984 
1985 
1986 
1987 
1988 
1989 
1990 
1991 
1992 
1993 
1994 
1995 
1996 
1997 
1998 
1999 
2000 
2001 
2002 
2003 
2004 
2005 
2006 
2007 
2008 
2009 
2010 
2011 
2012 
2013 
2014 
2015 
2016 
2017 
2018 
2019 
2020 
2021 
2022 
2023 
2024 
2025 
2026 
2027 
2028 
2029 
2030 
2031 
2032     static double MIN(double a, double b) {
2033         return (double)(Math.min(a, b));
2034     }
2035 
2036     @Test(dataProvider = "doubleBinaryOpProvider")
2037     static void MINDoubleMaxVectorTests(IntFunction<double[]> fa, IntFunction<double[]> fb) {
2038         double[] a = fa.apply(SPECIES.length());
2039         double[] b = fb.apply(SPECIES.length());
2040         double[] r = fr.apply(SPECIES.length());
2041 
2042         for (int ic = 0; ic < INVOC_COUNT; ic++) {
2043             for (int i = 0; i < a.length; i += SPECIES.length()) {
2044                 DoubleVector av = DoubleVector.fromArray(SPECIES, a, i);
2045                 DoubleVector bv = DoubleVector.fromArray(SPECIES, b, i);
2046                 av.lanewise(VectorOperators.MIN, bv).intoArray(r, i);
2047             }
2048         }
2049 
2050         assertArraysEquals(r, a, b, DoubleMaxVectorTests::MIN);
2051     }

2052     static double min(double a, double b) {
2053         return (double)(Math.min(a, b));
2054     }
2055 
2056     @Test(dataProvider = "doubleBinaryOpProvider")
2057     static void minDoubleMaxVectorTests(IntFunction<double[]> fa, IntFunction<double[]> fb) {
2058         double[] a = fa.apply(SPECIES.length());
2059         double[] b = fb.apply(SPECIES.length());
2060         double[] r = fr.apply(SPECIES.length());
2061 
2062         for (int i = 0; i < a.length; i += SPECIES.length()) {
2063             DoubleVector av = DoubleVector.fromArray(SPECIES, a, i);
2064             DoubleVector bv = DoubleVector.fromArray(SPECIES, b, i);
2065             av.min(bv).intoArray(r, i);
2066         }
2067 
2068         assertArraysEquals(r, a, b, DoubleMaxVectorTests::min);
2069     }

2070     static double MAX(double a, double b) {
2071         return (double)(Math.max(a, b));
2072     }
2073 
2074     @Test(dataProvider = "doubleBinaryOpProvider")
2075     static void MAXDoubleMaxVectorTests(IntFunction<double[]> fa, IntFunction<double[]> fb) {
2076         double[] a = fa.apply(SPECIES.length());
2077         double[] b = fb.apply(SPECIES.length());
2078         double[] r = fr.apply(SPECIES.length());
2079 
2080         for (int ic = 0; ic < INVOC_COUNT; ic++) {
2081             for (int i = 0; i < a.length; i += SPECIES.length()) {
2082                 DoubleVector av = DoubleVector.fromArray(SPECIES, a, i);
2083                 DoubleVector bv = DoubleVector.fromArray(SPECIES, b, i);
2084                 av.lanewise(VectorOperators.MAX, bv).intoArray(r, i);
2085             }
2086         }
2087 
2088         assertArraysEquals(r, a, b, DoubleMaxVectorTests::MAX);
2089     }

2090     static double max(double a, double b) {
2091         return (double)(Math.max(a, b));
2092     }
2093 
2094     @Test(dataProvider = "doubleBinaryOpProvider")
2095     static void maxDoubleMaxVectorTests(IntFunction<double[]> fa, IntFunction<double[]> fb) {
2096         double[] a = fa.apply(SPECIES.length());
2097         double[] b = fb.apply(SPECIES.length());
2098         double[] r = fr.apply(SPECIES.length());
2099 
2100         for (int i = 0; i < a.length; i += SPECIES.length()) {
2101             DoubleVector av = DoubleVector.fromArray(SPECIES, a, i);
2102             DoubleVector bv = DoubleVector.fromArray(SPECIES, b, i);
2103             av.max(bv).intoArray(r, i);
2104         }
2105 
2106         assertArraysEquals(r, a, b, DoubleMaxVectorTests::max);
2107     }
2108 
2109     @Test(dataProvider = "doubleBinaryOpProvider")

2145             av.lanewise(VectorOperators.MAX, b[i]).intoArray(r, i);
2146         }
2147 
2148         assertBroadcastArraysEquals(r, a, b, DoubleMaxVectorTests::MAX);
2149     }
2150 
2151     @Test(dataProvider = "doubleBinaryOpProvider")
2152     static void maxDoubleMaxVectorTestsBroadcastSmokeTest(IntFunction<double[]> fa, IntFunction<double[]> fb) {
2153         double[] a = fa.apply(SPECIES.length());
2154         double[] b = fb.apply(SPECIES.length());
2155         double[] r = fr.apply(SPECIES.length());
2156 
2157         for (int i = 0; i < a.length; i += SPECIES.length()) {
2158             DoubleVector av = DoubleVector.fromArray(SPECIES, a, i);
2159             av.max(b[i]).intoArray(r, i);
2160         }
2161 
2162         assertBroadcastArraysEquals(r, a, b, DoubleMaxVectorTests::max);
2163     }
2164 
2165 
2166 
2167 
2168 
2169 
2170 
2171 
2172 
2173 
2174 
2175 
2176     static double ADDReduce(double[] a, int idx) {
2177         double res = 0;
2178         for (int i = idx; i < (idx + SPECIES.length()); i++) {
2179             res += a[i];
2180         }
2181 
2182         return res;
2183     }
2184 
2185     static double ADDReduceAll(double[] a) {
2186         double res = 0;
2187         for (int i = 0; i < a.length; i += SPECIES.length()) {
2188             res += ADDReduce(a, i);
2189         }
2190 
2191         return res;
2192     }

2193     @Test(dataProvider = "doubleUnaryOpProvider")
2194     static void ADDReduceDoubleMaxVectorTests(IntFunction<double[]> fa) {
2195         double[] a = fa.apply(SPECIES.length());
2196         double[] r = fr.apply(SPECIES.length());
2197         double ra = 0;
2198 
2199         for (int ic = 0; ic < INVOC_COUNT; ic++) {
2200             for (int i = 0; i < a.length; i += SPECIES.length()) {
2201                 DoubleVector av = DoubleVector.fromArray(SPECIES, a, i);
2202                 r[i] = av.reduceLanes(VectorOperators.ADD);
2203             }
2204         }
2205 
2206         for (int ic = 0; ic < INVOC_COUNT; ic++) {
2207             ra = 0;
2208             for (int i = 0; i < a.length; i += SPECIES.length()) {
2209                 DoubleVector av = DoubleVector.fromArray(SPECIES, a, i);
2210                 ra += av.reduceLanes(VectorOperators.ADD);
2211             }
2212         }
2213 
2214         assertReductionArraysEquals(r, ra, a,
2215                 DoubleMaxVectorTests::ADDReduce, DoubleMaxVectorTests::ADDReduceAll);
2216     }

2217     static double ADDReduceMasked(double[] a, int idx, boolean[] mask) {
2218         double res = 0;
2219         for (int i = idx; i < (idx + SPECIES.length()); i++) {
2220             if (mask[i % SPECIES.length()])
2221                 res += a[i];
2222         }
2223 
2224         return res;
2225     }
2226 
2227     static double ADDReduceAllMasked(double[] a, boolean[] mask) {
2228         double res = 0;
2229         for (int i = 0; i < a.length; i += SPECIES.length()) {
2230             res += ADDReduceMasked(a, i, mask);
2231         }
2232 
2233         return res;
2234     }

2235     @Test(dataProvider = "doubleUnaryOpMaskProvider")
2236     static void ADDReduceDoubleMaxVectorTestsMasked(IntFunction<double[]> fa, IntFunction<boolean[]> fm) {
2237         double[] a = fa.apply(SPECIES.length());
2238         double[] r = fr.apply(SPECIES.length());
2239         boolean[] mask = fm.apply(SPECIES.length());
2240         VectorMask<Double> vmask = VectorMask.fromArray(SPECIES, mask, 0);
2241         double ra = 0;
2242 
2243         for (int ic = 0; ic < INVOC_COUNT; ic++) {
2244             for (int i = 0; i < a.length; i += SPECIES.length()) {
2245                 DoubleVector av = DoubleVector.fromArray(SPECIES, a, i);
2246                 r[i] = av.reduceLanes(VectorOperators.ADD, vmask);
2247             }
2248         }
2249 
2250         for (int ic = 0; ic < INVOC_COUNT; ic++) {
2251             ra = 0;
2252             for (int i = 0; i < a.length; i += SPECIES.length()) {
2253                 DoubleVector av = DoubleVector.fromArray(SPECIES, a, i);
2254                 ra += av.reduceLanes(VectorOperators.ADD, vmask);
2255             }
2256         }
2257 
2258         assertReductionArraysEqualsMasked(r, ra, a, mask,
2259                 DoubleMaxVectorTests::ADDReduceMasked, DoubleMaxVectorTests::ADDReduceAllMasked);
2260     }

2261     static double MULReduce(double[] a, int idx) {
2262         double res = 1;
2263         for (int i = idx; i < (idx + SPECIES.length()); i++) {
2264             res *= a[i];
2265         }
2266 
2267         return res;
2268     }
2269 
2270     static double MULReduceAll(double[] a) {
2271         double res = 1;
2272         for (int i = 0; i < a.length; i += SPECIES.length()) {
2273             res *= MULReduce(a, i);
2274         }
2275 
2276         return res;
2277     }

2278     @Test(dataProvider = "doubleUnaryOpProvider")
2279     static void MULReduceDoubleMaxVectorTests(IntFunction<double[]> fa) {
2280         double[] a = fa.apply(SPECIES.length());
2281         double[] r = fr.apply(SPECIES.length());
2282         double ra = 1;
2283 
2284         for (int ic = 0; ic < INVOC_COUNT; ic++) {
2285             for (int i = 0; i < a.length; i += SPECIES.length()) {
2286                 DoubleVector av = DoubleVector.fromArray(SPECIES, a, i);
2287                 r[i] = av.reduceLanes(VectorOperators.MUL);
2288             }
2289         }
2290 
2291         for (int ic = 0; ic < INVOC_COUNT; ic++) {
2292             ra = 1;
2293             for (int i = 0; i < a.length; i += SPECIES.length()) {
2294                 DoubleVector av = DoubleVector.fromArray(SPECIES, a, i);
2295                 ra *= av.reduceLanes(VectorOperators.MUL);
2296             }
2297         }
2298 
2299         assertReductionArraysEquals(r, ra, a,
2300                 DoubleMaxVectorTests::MULReduce, DoubleMaxVectorTests::MULReduceAll);
2301     }

2302     static double MULReduceMasked(double[] a, int idx, boolean[] mask) {
2303         double res = 1;
2304         for (int i = idx; i < (idx + SPECIES.length()); i++) {
2305             if (mask[i % SPECIES.length()])
2306                 res *= a[i];
2307         }
2308 
2309         return res;
2310     }
2311 
2312     static double MULReduceAllMasked(double[] a, boolean[] mask) {
2313         double res = 1;
2314         for (int i = 0; i < a.length; i += SPECIES.length()) {
2315             res *= MULReduceMasked(a, i, mask);
2316         }
2317 
2318         return res;
2319     }

2320     @Test(dataProvider = "doubleUnaryOpMaskProvider")
2321     static void MULReduceDoubleMaxVectorTestsMasked(IntFunction<double[]> fa, IntFunction<boolean[]> fm) {
2322         double[] a = fa.apply(SPECIES.length());
2323         double[] r = fr.apply(SPECIES.length());
2324         boolean[] mask = fm.apply(SPECIES.length());
2325         VectorMask<Double> vmask = VectorMask.fromArray(SPECIES, mask, 0);
2326         double ra = 1;
2327 
2328         for (int ic = 0; ic < INVOC_COUNT; ic++) {
2329             for (int i = 0; i < a.length; i += SPECIES.length()) {
2330                 DoubleVector av = DoubleVector.fromArray(SPECIES, a, i);
2331                 r[i] = av.reduceLanes(VectorOperators.MUL, vmask);
2332             }
2333         }
2334 
2335         for (int ic = 0; ic < INVOC_COUNT; ic++) {
2336             ra = 1;
2337             for (int i = 0; i < a.length; i += SPECIES.length()) {
2338                 DoubleVector av = DoubleVector.fromArray(SPECIES, a, i);
2339                 ra *= av.reduceLanes(VectorOperators.MUL, vmask);
2340             }
2341         }
2342 
2343         assertReductionArraysEqualsMasked(r, ra, a, mask,
2344                 DoubleMaxVectorTests::MULReduceMasked, DoubleMaxVectorTests::MULReduceAllMasked);
2345     }

2346     static double MINReduce(double[] a, int idx) {
2347         double res = Double.POSITIVE_INFINITY;
2348         for (int i = idx; i < (idx + SPECIES.length()); i++) {
2349             res = (double) Math.min(res, a[i]);
2350         }
2351 
2352         return res;
2353     }
2354 
2355     static double MINReduceAll(double[] a) {
2356         double res = Double.POSITIVE_INFINITY;
2357         for (int i = 0; i < a.length; i += SPECIES.length()) {
2358             res = (double) Math.min(res, MINReduce(a, i));
2359         }
2360 
2361         return res;
2362     }

2363     @Test(dataProvider = "doubleUnaryOpProvider")
2364     static void MINReduceDoubleMaxVectorTests(IntFunction<double[]> fa) {
2365         double[] a = fa.apply(SPECIES.length());
2366         double[] r = fr.apply(SPECIES.length());
2367         double ra = Double.POSITIVE_INFINITY;
2368 
2369         for (int ic = 0; ic < INVOC_COUNT; ic++) {
2370             for (int i = 0; i < a.length; i += SPECIES.length()) {
2371                 DoubleVector av = DoubleVector.fromArray(SPECIES, a, i);
2372                 r[i] = av.reduceLanes(VectorOperators.MIN);
2373             }
2374         }
2375 
2376         for (int ic = 0; ic < INVOC_COUNT; ic++) {
2377             ra = Double.POSITIVE_INFINITY;
2378             for (int i = 0; i < a.length; i += SPECIES.length()) {
2379                 DoubleVector av = DoubleVector.fromArray(SPECIES, a, i);
2380                 ra = (double) Math.min(ra, av.reduceLanes(VectorOperators.MIN));
2381             }
2382         }
2383 
2384         assertReductionArraysEquals(r, ra, a,
2385                 DoubleMaxVectorTests::MINReduce, DoubleMaxVectorTests::MINReduceAll);
2386     }

2387     static double MINReduceMasked(double[] a, int idx, boolean[] mask) {
2388         double res = Double.POSITIVE_INFINITY;
2389         for (int i = idx; i < (idx + SPECIES.length()); i++) {
2390             if (mask[i % SPECIES.length()])
2391                 res = (double) Math.min(res, a[i]);
2392         }
2393 
2394         return res;
2395     }
2396 
2397     static double MINReduceAllMasked(double[] a, boolean[] mask) {
2398         double res = Double.POSITIVE_INFINITY;
2399         for (int i = 0; i < a.length; i += SPECIES.length()) {
2400             res = (double) Math.min(res, MINReduceMasked(a, i, mask));
2401         }
2402 
2403         return res;
2404     }

2405     @Test(dataProvider = "doubleUnaryOpMaskProvider")
2406     static void MINReduceDoubleMaxVectorTestsMasked(IntFunction<double[]> fa, IntFunction<boolean[]> fm) {
2407         double[] a = fa.apply(SPECIES.length());
2408         double[] r = fr.apply(SPECIES.length());
2409         boolean[] mask = fm.apply(SPECIES.length());
2410         VectorMask<Double> vmask = VectorMask.fromArray(SPECIES, mask, 0);
2411         double ra = Double.POSITIVE_INFINITY;
2412 
2413         for (int ic = 0; ic < INVOC_COUNT; ic++) {
2414             for (int i = 0; i < a.length; i += SPECIES.length()) {
2415                 DoubleVector av = DoubleVector.fromArray(SPECIES, a, i);
2416                 r[i] = av.reduceLanes(VectorOperators.MIN, vmask);
2417             }
2418         }
2419 
2420         for (int ic = 0; ic < INVOC_COUNT; ic++) {
2421             ra = Double.POSITIVE_INFINITY;
2422             for (int i = 0; i < a.length; i += SPECIES.length()) {
2423                 DoubleVector av = DoubleVector.fromArray(SPECIES, a, i);
2424                 ra = (double) Math.min(ra, av.reduceLanes(VectorOperators.MIN, vmask));
2425             }
2426         }
2427 
2428         assertReductionArraysEqualsMasked(r, ra, a, mask,
2429                 DoubleMaxVectorTests::MINReduceMasked, DoubleMaxVectorTests::MINReduceAllMasked);
2430     }

2431     static double MAXReduce(double[] a, int idx) {
2432         double res = Double.NEGATIVE_INFINITY;
2433         for (int i = idx; i < (idx + SPECIES.length()); i++) {
2434             res = (double) Math.max(res, a[i]);
2435         }
2436 
2437         return res;
2438     }
2439 
2440     static double MAXReduceAll(double[] a) {
2441         double res = Double.NEGATIVE_INFINITY;
2442         for (int i = 0; i < a.length; i += SPECIES.length()) {
2443             res = (double) Math.max(res, MAXReduce(a, i));
2444         }
2445 
2446         return res;
2447     }

2448     @Test(dataProvider = "doubleUnaryOpProvider")
2449     static void MAXReduceDoubleMaxVectorTests(IntFunction<double[]> fa) {
2450         double[] a = fa.apply(SPECIES.length());
2451         double[] r = fr.apply(SPECIES.length());
2452         double ra = Double.NEGATIVE_INFINITY;
2453 
2454         for (int ic = 0; ic < INVOC_COUNT; ic++) {
2455             for (int i = 0; i < a.length; i += SPECIES.length()) {
2456                 DoubleVector av = DoubleVector.fromArray(SPECIES, a, i);
2457                 r[i] = av.reduceLanes(VectorOperators.MAX);
2458             }
2459         }
2460 
2461         for (int ic = 0; ic < INVOC_COUNT; ic++) {
2462             ra = Double.NEGATIVE_INFINITY;
2463             for (int i = 0; i < a.length; i += SPECIES.length()) {
2464                 DoubleVector av = DoubleVector.fromArray(SPECIES, a, i);
2465                 ra = (double) Math.max(ra, av.reduceLanes(VectorOperators.MAX));
2466             }
2467         }
2468 
2469         assertReductionArraysEquals(r, ra, a,
2470                 DoubleMaxVectorTests::MAXReduce, DoubleMaxVectorTests::MAXReduceAll);
2471     }

2472     static double MAXReduceMasked(double[] a, int idx, boolean[] mask) {
2473         double res = Double.NEGATIVE_INFINITY;
2474         for (int i = idx; i < (idx + SPECIES.length()); i++) {
2475             if (mask[i % SPECIES.length()])
2476                 res = (double) Math.max(res, a[i]);
2477         }
2478 
2479         return res;
2480     }
2481 
2482     static double MAXReduceAllMasked(double[] a, boolean[] mask) {
2483         double res = Double.NEGATIVE_INFINITY;
2484         for (int i = 0; i < a.length; i += SPECIES.length()) {
2485             res = (double) Math.max(res, MAXReduceMasked(a, i, mask));
2486         }
2487 
2488         return res;
2489     }

2490     @Test(dataProvider = "doubleUnaryOpMaskProvider")
2491     static void MAXReduceDoubleMaxVectorTestsMasked(IntFunction<double[]> fa, IntFunction<boolean[]> fm) {
2492         double[] a = fa.apply(SPECIES.length());
2493         double[] r = fr.apply(SPECIES.length());
2494         boolean[] mask = fm.apply(SPECIES.length());
2495         VectorMask<Double> vmask = VectorMask.fromArray(SPECIES, mask, 0);
2496         double ra = Double.NEGATIVE_INFINITY;
2497 
2498         for (int ic = 0; ic < INVOC_COUNT; ic++) {
2499             for (int i = 0; i < a.length; i += SPECIES.length()) {
2500                 DoubleVector av = DoubleVector.fromArray(SPECIES, a, i);
2501                 r[i] = av.reduceLanes(VectorOperators.MAX, vmask);
2502             }
2503         }
2504 
2505         for (int ic = 0; ic < INVOC_COUNT; ic++) {
2506             ra = Double.NEGATIVE_INFINITY;
2507             for (int i = 0; i < a.length; i += SPECIES.length()) {
2508                 DoubleVector av = DoubleVector.fromArray(SPECIES, a, i);
2509                 ra = (double) Math.max(ra, av.reduceLanes(VectorOperators.MAX, vmask));
2510             }
2511         }
2512 
2513         assertReductionArraysEqualsMasked(r, ra, a, mask,
2514                 DoubleMaxVectorTests::MAXReduceMasked, DoubleMaxVectorTests::MAXReduceAllMasked);
2515     }

2516     static double FIRST_NONZEROReduce(double[] a, int idx) {
2517         double res = (double) 0;
2518         for (int i = idx; i < (idx + SPECIES.length()); i++) {
2519             res = firstNonZero(res, a[i]);
2520         }
2521 
2522         return res;
2523     }
2524 
2525     static double FIRST_NONZEROReduceAll(double[] a) {
2526         double res = (double) 0;
2527         for (int i = 0; i < a.length; i += SPECIES.length()) {
2528             res = firstNonZero(res, FIRST_NONZEROReduce(a, i));
2529         }
2530 
2531         return res;
2532     }

2533     @Test(dataProvider = "doubleUnaryOpProvider")
2534     static void FIRST_NONZEROReduceDoubleMaxVectorTests(IntFunction<double[]> fa) {
2535         double[] a = fa.apply(SPECIES.length());
2536         double[] r = fr.apply(SPECIES.length());
2537         double ra = (double) 0;
2538 
2539         for (int ic = 0; ic < INVOC_COUNT; ic++) {
2540             for (int i = 0; i < a.length; i += SPECIES.length()) {
2541                 DoubleVector av = DoubleVector.fromArray(SPECIES, a, i);
2542                 r[i] = av.reduceLanes(VectorOperators.FIRST_NONZERO);
2543             }
2544         }
2545 
2546         for (int ic = 0; ic < INVOC_COUNT; ic++) {
2547             ra = (double) 0;
2548             for (int i = 0; i < a.length; i += SPECIES.length()) {
2549                 DoubleVector av = DoubleVector.fromArray(SPECIES, a, i);
2550                 ra = firstNonZero(ra, av.reduceLanes(VectorOperators.FIRST_NONZERO));
2551             }
2552         }
2553 
2554         assertReductionArraysEquals(r, ra, a,
2555                 DoubleMaxVectorTests::FIRST_NONZEROReduce, DoubleMaxVectorTests::FIRST_NONZEROReduceAll);
2556     }

2557     static double FIRST_NONZEROReduceMasked(double[] a, int idx, boolean[] mask) {
2558         double res = (double) 0;
2559         for (int i = idx; i < (idx + SPECIES.length()); i++) {
2560             if (mask[i % SPECIES.length()])
2561                 res = firstNonZero(res, a[i]);
2562         }
2563 
2564         return res;
2565     }
2566 
2567     static double FIRST_NONZEROReduceAllMasked(double[] a, boolean[] mask) {
2568         double res = (double) 0;
2569         for (int i = 0; i < a.length; i += SPECIES.length()) {
2570             res = firstNonZero(res, FIRST_NONZEROReduceMasked(a, i, mask));
2571         }
2572 
2573         return res;
2574     }

2575     @Test(dataProvider = "doubleUnaryOpMaskProvider")
2576     static void FIRST_NONZEROReduceDoubleMaxVectorTestsMasked(IntFunction<double[]> fa, IntFunction<boolean[]> fm) {
2577         double[] a = fa.apply(SPECIES.length());
2578         double[] r = fr.apply(SPECIES.length());
2579         boolean[] mask = fm.apply(SPECIES.length());
2580         VectorMask<Double> vmask = VectorMask.fromArray(SPECIES, mask, 0);
2581         double ra = (double) 0;
2582 
2583         for (int ic = 0; ic < INVOC_COUNT; ic++) {
2584             for (int i = 0; i < a.length; i += SPECIES.length()) {
2585                 DoubleVector av = DoubleVector.fromArray(SPECIES, a, i);
2586                 r[i] = av.reduceLanes(VectorOperators.FIRST_NONZERO, vmask);
2587             }
2588         }
2589 
2590         for (int ic = 0; ic < INVOC_COUNT; ic++) {
2591             ra = (double) 0;
2592             for (int i = 0; i < a.length; i += SPECIES.length()) {
2593                 DoubleVector av = DoubleVector.fromArray(SPECIES, a, i);
2594                 ra = firstNonZero(ra, av.reduceLanes(VectorOperators.FIRST_NONZERO, vmask));
2595             }
2596         }
2597 
2598         assertReductionArraysEqualsMasked(r, ra, a, mask,
2599                 DoubleMaxVectorTests::FIRST_NONZEROReduceMasked, DoubleMaxVectorTests::FIRST_NONZEROReduceAllMasked);
2600     }
2601 
2602 
2603 
2604 
2605 
2606     @Test(dataProvider = "doubleUnaryOpProvider")
2607     static void withDoubleMaxVectorTests(IntFunction<double []> fa) {
2608         double[] a = fa.apply(SPECIES.length());
2609         double[] r = fr.apply(SPECIES.length());
2610 
2611         for (int ic = 0; ic < INVOC_COUNT; ic++) {
2612             for (int i = 0, j = 0; i < a.length; i += SPECIES.length()) {
2613                 DoubleVector av = DoubleVector.fromArray(SPECIES, a, i);
2614                 av.withLane((j++ & (SPECIES.length()-1)), (double)(65535+i)).intoArray(r, i);
2615             }
2616         }
2617 
2618 
2619         for (int i = 0, j = 0; i < a.length; i += SPECIES.length()) {
2620             assertInsertArraysEquals(r, a, (double)(65535+i), (j++ & (SPECIES.length()-1)), i , i + SPECIES.length());
2621         }
2622     }

2623     static boolean testIS_DEFAULT(double a) {
2624         return bits(a)==0;
2625     }
2626 
2627     @Test(dataProvider = "doubleTestOpProvider")
2628     static void IS_DEFAULTDoubleMaxVectorTests(IntFunction<double[]> fa) {
2629         double[] a = fa.apply(SPECIES.length());
2630 
2631         for (int ic = 0; ic < INVOC_COUNT; ic++) {
2632             for (int i = 0; i < a.length; i += SPECIES.length()) {
2633                 DoubleVector av = DoubleVector.fromArray(SPECIES, a, i);
2634                 VectorMask<Double> mv = av.test(VectorOperators.IS_DEFAULT);
2635 
2636                 // Check results as part of computation.
2637                 for (int j = 0; j < SPECIES.length(); j++) {
2638                     Assert.assertEquals(mv.laneIsSet(j), testIS_DEFAULT(a[i + j]));
2639                 }
2640             }
2641         }
2642     }
2643 
2644     @Test(dataProvider = "doubleTestOpMaskProvider")
2645     static void IS_DEFAULTMaskedDoubleMaxVectorTests(IntFunction<double[]> fa,
2646                                           IntFunction<boolean[]> fm) {
2647         double[] a = fa.apply(SPECIES.length());
2648         boolean[] mask = fm.apply(SPECIES.length());
2649         VectorMask<Double> vmask = VectorMask.fromArray(SPECIES, mask, 0);
2650 
2651         for (int ic = 0; ic < INVOC_COUNT; ic++) {
2652             for (int i = 0; i < a.length; i += SPECIES.length()) {
2653                 DoubleVector av = DoubleVector.fromArray(SPECIES, a, i);
2654                 VectorMask<Double> mv = av.test(VectorOperators.IS_DEFAULT, vmask);
2655 
2656                 // Check results as part of computation.
2657                 for (int j = 0; j < SPECIES.length(); j++) {
2658                     Assert.assertEquals(mv.laneIsSet(j),  vmask.laneIsSet(j) && testIS_DEFAULT(a[i + j]));
2659                 }
2660             }
2661         }
2662     }

2663     static boolean testIS_NEGATIVE(double a) {
2664         return bits(a)<0;
2665     }
2666 
2667     @Test(dataProvider = "doubleTestOpProvider")
2668     static void IS_NEGATIVEDoubleMaxVectorTests(IntFunction<double[]> fa) {
2669         double[] a = fa.apply(SPECIES.length());
2670 
2671         for (int ic = 0; ic < INVOC_COUNT; ic++) {
2672             for (int i = 0; i < a.length; i += SPECIES.length()) {
2673                 DoubleVector av = DoubleVector.fromArray(SPECIES, a, i);
2674                 VectorMask<Double> mv = av.test(VectorOperators.IS_NEGATIVE);
2675 
2676                 // Check results as part of computation.
2677                 for (int j = 0; j < SPECIES.length(); j++) {
2678                     Assert.assertEquals(mv.laneIsSet(j), testIS_NEGATIVE(a[i + j]));
2679                 }
2680             }
2681         }
2682     }

2725     @Test(dataProvider = "doubleTestOpMaskProvider")
2726     static void IS_FINITEMaskedDoubleMaxVectorTests(IntFunction<double[]> fa,
2727                                           IntFunction<boolean[]> fm) {
2728         double[] a = fa.apply(SPECIES.length());
2729         boolean[] mask = fm.apply(SPECIES.length());
2730         VectorMask<Double> vmask = VectorMask.fromArray(SPECIES, mask, 0);
2731 
2732         for (int ic = 0; ic < INVOC_COUNT; ic++) {
2733             for (int i = 0; i < a.length; i += SPECIES.length()) {
2734                 DoubleVector av = DoubleVector.fromArray(SPECIES, a, i);
2735                 VectorMask<Double> mv = av.test(VectorOperators.IS_FINITE, vmask);
2736 
2737                 // Check results as part of computation.
2738                 for (int j = 0; j < SPECIES.length(); j++) {
2739                     Assert.assertEquals(mv.laneIsSet(j),  vmask.laneIsSet(j) && testIS_FINITE(a[i + j]));
2740                 }
2741             }
2742         }
2743     }
2744 
2745 
2746     static boolean testIS_NAN(double a) {
2747         return Double.isNaN(a);
2748     }
2749 
2750     @Test(dataProvider = "doubleTestOpProvider")
2751     static void IS_NANDoubleMaxVectorTests(IntFunction<double[]> fa) {
2752         double[] a = fa.apply(SPECIES.length());
2753 
2754         for (int ic = 0; ic < INVOC_COUNT; ic++) {
2755             for (int i = 0; i < a.length; i += SPECIES.length()) {
2756                 DoubleVector av = DoubleVector.fromArray(SPECIES, a, i);
2757                 VectorMask<Double> mv = av.test(VectorOperators.IS_NAN);
2758 
2759                 // Check results as part of computation.
2760                 for (int j = 0; j < SPECIES.length(); j++) {
2761                     Assert.assertEquals(mv.laneIsSet(j), testIS_NAN(a[i + j]));
2762                 }
2763             }
2764         }
2765     }

2767     @Test(dataProvider = "doubleTestOpMaskProvider")
2768     static void IS_NANMaskedDoubleMaxVectorTests(IntFunction<double[]> fa,
2769                                           IntFunction<boolean[]> fm) {
2770         double[] a = fa.apply(SPECIES.length());
2771         boolean[] mask = fm.apply(SPECIES.length());
2772         VectorMask<Double> vmask = VectorMask.fromArray(SPECIES, mask, 0);
2773 
2774         for (int ic = 0; ic < INVOC_COUNT; ic++) {
2775             for (int i = 0; i < a.length; i += SPECIES.length()) {
2776                 DoubleVector av = DoubleVector.fromArray(SPECIES, a, i);
2777                 VectorMask<Double> mv = av.test(VectorOperators.IS_NAN, vmask);
2778 
2779                 // Check results as part of computation.
2780                 for (int j = 0; j < SPECIES.length(); j++) {
2781                     Assert.assertEquals(mv.laneIsSet(j),  vmask.laneIsSet(j) && testIS_NAN(a[i + j]));
2782                 }
2783             }
2784         }
2785     }
2786 
2787 
2788     static boolean testIS_INFINITE(double a) {
2789         return Double.isInfinite(a);
2790     }
2791 
2792     @Test(dataProvider = "doubleTestOpProvider")
2793     static void IS_INFINITEDoubleMaxVectorTests(IntFunction<double[]> fa) {
2794         double[] a = fa.apply(SPECIES.length());
2795 
2796         for (int ic = 0; ic < INVOC_COUNT; ic++) {
2797             for (int i = 0; i < a.length; i += SPECIES.length()) {
2798                 DoubleVector av = DoubleVector.fromArray(SPECIES, a, i);
2799                 VectorMask<Double> mv = av.test(VectorOperators.IS_INFINITE);
2800 
2801                 // Check results as part of computation.
2802                 for (int j = 0; j < SPECIES.length(); j++) {
2803                     Assert.assertEquals(mv.laneIsSet(j), testIS_INFINITE(a[i + j]));
2804                 }
2805             }
2806         }
2807     }

2809     @Test(dataProvider = "doubleTestOpMaskProvider")
2810     static void IS_INFINITEMaskedDoubleMaxVectorTests(IntFunction<double[]> fa,
2811                                           IntFunction<boolean[]> fm) {
2812         double[] a = fa.apply(SPECIES.length());
2813         boolean[] mask = fm.apply(SPECIES.length());
2814         VectorMask<Double> vmask = VectorMask.fromArray(SPECIES, mask, 0);
2815 
2816         for (int ic = 0; ic < INVOC_COUNT; ic++) {
2817             for (int i = 0; i < a.length; i += SPECIES.length()) {
2818                 DoubleVector av = DoubleVector.fromArray(SPECIES, a, i);
2819                 VectorMask<Double> mv = av.test(VectorOperators.IS_INFINITE, vmask);
2820 
2821                 // Check results as part of computation.
2822                 for (int j = 0; j < SPECIES.length(); j++) {
2823                     Assert.assertEquals(mv.laneIsSet(j),  vmask.laneIsSet(j) && testIS_INFINITE(a[i + j]));
2824                 }
2825             }
2826         }
2827     }
2828 
2829 
2830     @Test(dataProvider = "doubleCompareOpProvider")
2831     static void LTDoubleMaxVectorTests(IntFunction<double[]> fa, IntFunction<double[]> fb) {
2832         double[] a = fa.apply(SPECIES.length());
2833         double[] b = fb.apply(SPECIES.length());
2834 
2835         for (int ic = 0; ic < INVOC_COUNT; ic++) {
2836             for (int i = 0; i < a.length; i += SPECIES.length()) {
2837                 DoubleVector av = DoubleVector.fromArray(SPECIES, a, i);
2838                 DoubleVector bv = DoubleVector.fromArray(SPECIES, b, i);
2839                 VectorMask<Double> mv = av.compare(VectorOperators.LT, bv);
2840 
2841                 // Check results as part of computation.
2842                 for (int j = 0; j < SPECIES.length(); j++) {
2843                     Assert.assertEquals(mv.laneIsSet(j), lt(a[i + j], b[i + j]));
2844                 }
2845             }
2846         }
2847     }
2848 
2849 
2850     @Test(dataProvider = "doubleCompareOpProvider")
2851     static void ltDoubleMaxVectorTests(IntFunction<double[]> fa, IntFunction<double[]> fb) {
2852         double[] a = fa.apply(SPECIES.length());
2853         double[] b = fb.apply(SPECIES.length());
2854 
2855         for (int ic = 0; ic < INVOC_COUNT; ic++) {
2856             for (int i = 0; i < a.length; i += SPECIES.length()) {
2857                 DoubleVector av = DoubleVector.fromArray(SPECIES, a, i);
2858                 DoubleVector bv = DoubleVector.fromArray(SPECIES, b, i);
2859                 VectorMask<Double> mv = av.lt(bv);
2860 
2861                 // Check results as part of computation.
2862                 for (int j = 0; j < SPECIES.length(); j++) {
2863                     Assert.assertEquals(mv.laneIsSet(j), lt(a[i + j], b[i + j]));
2864                 }
2865             }
2866         }
2867     }
2868 
2869     @Test(dataProvider = "doubleCompareOpMaskProvider")

2872         double[] a = fa.apply(SPECIES.length());
2873         double[] b = fb.apply(SPECIES.length());
2874         boolean[] mask = fm.apply(SPECIES.length());
2875 
2876         VectorMask<Double> vmask = VectorMask.fromArray(SPECIES, mask, 0);
2877 
2878         for (int ic = 0; ic < INVOC_COUNT; ic++) {
2879             for (int i = 0; i < a.length; i += SPECIES.length()) {
2880                 DoubleVector av = DoubleVector.fromArray(SPECIES, a, i);
2881                 DoubleVector bv = DoubleVector.fromArray(SPECIES, b, i);
2882                 VectorMask<Double> mv = av.compare(VectorOperators.LT, bv, vmask);
2883 
2884                 // Check results as part of computation.
2885                 for (int j = 0; j < SPECIES.length(); j++) {
2886                     Assert.assertEquals(mv.laneIsSet(j), mask[j] && lt(a[i + j], b[i + j]));
2887                 }
2888             }
2889         }
2890     }
2891 
2892 
2893     @Test(dataProvider = "doubleCompareOpProvider")
2894     static void GTDoubleMaxVectorTests(IntFunction<double[]> fa, IntFunction<double[]> fb) {
2895         double[] a = fa.apply(SPECIES.length());
2896         double[] b = fb.apply(SPECIES.length());
2897 
2898         for (int ic = 0; ic < INVOC_COUNT; ic++) {
2899             for (int i = 0; i < a.length; i += SPECIES.length()) {
2900                 DoubleVector av = DoubleVector.fromArray(SPECIES, a, i);
2901                 DoubleVector bv = DoubleVector.fromArray(SPECIES, b, i);
2902                 VectorMask<Double> mv = av.compare(VectorOperators.GT, bv);
2903 
2904                 // Check results as part of computation.
2905                 for (int j = 0; j < SPECIES.length(); j++) {
2906                     Assert.assertEquals(mv.laneIsSet(j), gt(a[i + j], b[i + j]));
2907                 }
2908             }
2909         }
2910     }
2911 
2912     @Test(dataProvider = "doubleCompareOpMaskProvider")

2915         double[] a = fa.apply(SPECIES.length());
2916         double[] b = fb.apply(SPECIES.length());
2917         boolean[] mask = fm.apply(SPECIES.length());
2918 
2919         VectorMask<Double> vmask = VectorMask.fromArray(SPECIES, mask, 0);
2920 
2921         for (int ic = 0; ic < INVOC_COUNT; ic++) {
2922             for (int i = 0; i < a.length; i += SPECIES.length()) {
2923                 DoubleVector av = DoubleVector.fromArray(SPECIES, a, i);
2924                 DoubleVector bv = DoubleVector.fromArray(SPECIES, b, i);
2925                 VectorMask<Double> mv = av.compare(VectorOperators.GT, bv, vmask);
2926 
2927                 // Check results as part of computation.
2928                 for (int j = 0; j < SPECIES.length(); j++) {
2929                     Assert.assertEquals(mv.laneIsSet(j), mask[j] && gt(a[i + j], b[i + j]));
2930                 }
2931             }
2932         }
2933     }
2934 
2935 
2936     @Test(dataProvider = "doubleCompareOpProvider")
2937     static void EQDoubleMaxVectorTests(IntFunction<double[]> fa, IntFunction<double[]> fb) {
2938         double[] a = fa.apply(SPECIES.length());
2939         double[] b = fb.apply(SPECIES.length());
2940 
2941         for (int ic = 0; ic < INVOC_COUNT; ic++) {
2942             for (int i = 0; i < a.length; i += SPECIES.length()) {
2943                 DoubleVector av = DoubleVector.fromArray(SPECIES, a, i);
2944                 DoubleVector bv = DoubleVector.fromArray(SPECIES, b, i);
2945                 VectorMask<Double> mv = av.compare(VectorOperators.EQ, bv);
2946 
2947                 // Check results as part of computation.
2948                 for (int j = 0; j < SPECIES.length(); j++) {
2949                     Assert.assertEquals(mv.laneIsSet(j), eq(a[i + j], b[i + j]));
2950                 }
2951             }
2952         }
2953     }
2954 
2955 
2956     @Test(dataProvider = "doubleCompareOpProvider")
2957     static void eqDoubleMaxVectorTests(IntFunction<double[]> fa, IntFunction<double[]> fb) {
2958         double[] a = fa.apply(SPECIES.length());
2959         double[] b = fb.apply(SPECIES.length());
2960 
2961         for (int ic = 0; ic < INVOC_COUNT; ic++) {
2962             for (int i = 0; i < a.length; i += SPECIES.length()) {
2963                 DoubleVector av = DoubleVector.fromArray(SPECIES, a, i);
2964                 DoubleVector bv = DoubleVector.fromArray(SPECIES, b, i);
2965                 VectorMask<Double> mv = av.eq(bv);
2966 
2967                 // Check results as part of computation.
2968                 for (int j = 0; j < SPECIES.length(); j++) {
2969                     Assert.assertEquals(mv.laneIsSet(j), eq(a[i + j], b[i + j]));
2970                 }
2971             }
2972         }
2973     }
2974 
2975     @Test(dataProvider = "doubleCompareOpMaskProvider")

2978         double[] a = fa.apply(SPECIES.length());
2979         double[] b = fb.apply(SPECIES.length());
2980         boolean[] mask = fm.apply(SPECIES.length());
2981 
2982         VectorMask<Double> vmask = VectorMask.fromArray(SPECIES, mask, 0);
2983 
2984         for (int ic = 0; ic < INVOC_COUNT; ic++) {
2985             for (int i = 0; i < a.length; i += SPECIES.length()) {
2986                 DoubleVector av = DoubleVector.fromArray(SPECIES, a, i);
2987                 DoubleVector bv = DoubleVector.fromArray(SPECIES, b, i);
2988                 VectorMask<Double> mv = av.compare(VectorOperators.EQ, bv, vmask);
2989 
2990                 // Check results as part of computation.
2991                 for (int j = 0; j < SPECIES.length(); j++) {
2992                     Assert.assertEquals(mv.laneIsSet(j), mask[j] && eq(a[i + j], b[i + j]));
2993                 }
2994             }
2995         }
2996     }
2997 
2998 
2999     @Test(dataProvider = "doubleCompareOpProvider")
3000     static void NEDoubleMaxVectorTests(IntFunction<double[]> fa, IntFunction<double[]> fb) {
3001         double[] a = fa.apply(SPECIES.length());
3002         double[] b = fb.apply(SPECIES.length());
3003 
3004         for (int ic = 0; ic < INVOC_COUNT; ic++) {
3005             for (int i = 0; i < a.length; i += SPECIES.length()) {
3006                 DoubleVector av = DoubleVector.fromArray(SPECIES, a, i);
3007                 DoubleVector bv = DoubleVector.fromArray(SPECIES, b, i);
3008                 VectorMask<Double> mv = av.compare(VectorOperators.NE, bv);
3009 
3010                 // Check results as part of computation.
3011                 for (int j = 0; j < SPECIES.length(); j++) {
3012                     Assert.assertEquals(mv.laneIsSet(j), neq(a[i + j], b[i + j]));
3013                 }
3014             }
3015         }
3016     }
3017 
3018     @Test(dataProvider = "doubleCompareOpMaskProvider")

3021         double[] a = fa.apply(SPECIES.length());
3022         double[] b = fb.apply(SPECIES.length());
3023         boolean[] mask = fm.apply(SPECIES.length());
3024 
3025         VectorMask<Double> vmask = VectorMask.fromArray(SPECIES, mask, 0);
3026 
3027         for (int ic = 0; ic < INVOC_COUNT; ic++) {
3028             for (int i = 0; i < a.length; i += SPECIES.length()) {
3029                 DoubleVector av = DoubleVector.fromArray(SPECIES, a, i);
3030                 DoubleVector bv = DoubleVector.fromArray(SPECIES, b, i);
3031                 VectorMask<Double> mv = av.compare(VectorOperators.NE, bv, vmask);
3032 
3033                 // Check results as part of computation.
3034                 for (int j = 0; j < SPECIES.length(); j++) {
3035                     Assert.assertEquals(mv.laneIsSet(j), mask[j] && neq(a[i + j], b[i + j]));
3036                 }
3037             }
3038         }
3039     }
3040 
3041 
3042     @Test(dataProvider = "doubleCompareOpProvider")
3043     static void LEDoubleMaxVectorTests(IntFunction<double[]> fa, IntFunction<double[]> fb) {
3044         double[] a = fa.apply(SPECIES.length());
3045         double[] b = fb.apply(SPECIES.length());
3046 
3047         for (int ic = 0; ic < INVOC_COUNT; ic++) {
3048             for (int i = 0; i < a.length; i += SPECIES.length()) {
3049                 DoubleVector av = DoubleVector.fromArray(SPECIES, a, i);
3050                 DoubleVector bv = DoubleVector.fromArray(SPECIES, b, i);
3051                 VectorMask<Double> mv = av.compare(VectorOperators.LE, bv);
3052 
3053                 // Check results as part of computation.
3054                 for (int j = 0; j < SPECIES.length(); j++) {
3055                     Assert.assertEquals(mv.laneIsSet(j), le(a[i + j], b[i + j]));
3056                 }
3057             }
3058         }
3059     }
3060 
3061     @Test(dataProvider = "doubleCompareOpMaskProvider")

3064         double[] a = fa.apply(SPECIES.length());
3065         double[] b = fb.apply(SPECIES.length());
3066         boolean[] mask = fm.apply(SPECIES.length());
3067 
3068         VectorMask<Double> vmask = VectorMask.fromArray(SPECIES, mask, 0);
3069 
3070         for (int ic = 0; ic < INVOC_COUNT; ic++) {
3071             for (int i = 0; i < a.length; i += SPECIES.length()) {
3072                 DoubleVector av = DoubleVector.fromArray(SPECIES, a, i);
3073                 DoubleVector bv = DoubleVector.fromArray(SPECIES, b, i);
3074                 VectorMask<Double> mv = av.compare(VectorOperators.LE, bv, vmask);
3075 
3076                 // Check results as part of computation.
3077                 for (int j = 0; j < SPECIES.length(); j++) {
3078                     Assert.assertEquals(mv.laneIsSet(j), mask[j] && le(a[i + j], b[i + j]));
3079                 }
3080             }
3081         }
3082     }
3083 
3084 
3085     @Test(dataProvider = "doubleCompareOpProvider")
3086     static void GEDoubleMaxVectorTests(IntFunction<double[]> fa, IntFunction<double[]> fb) {
3087         double[] a = fa.apply(SPECIES.length());
3088         double[] b = fb.apply(SPECIES.length());
3089 
3090         for (int ic = 0; ic < INVOC_COUNT; ic++) {
3091             for (int i = 0; i < a.length; i += SPECIES.length()) {
3092                 DoubleVector av = DoubleVector.fromArray(SPECIES, a, i);
3093                 DoubleVector bv = DoubleVector.fromArray(SPECIES, b, i);
3094                 VectorMask<Double> mv = av.compare(VectorOperators.GE, bv);
3095 
3096                 // Check results as part of computation.
3097                 for (int j = 0; j < SPECIES.length(); j++) {
3098                     Assert.assertEquals(mv.laneIsSet(j), ge(a[i + j], b[i + j]));
3099                 }
3100             }
3101         }
3102     }
3103 
3104     @Test(dataProvider = "doubleCompareOpMaskProvider")

3107         double[] a = fa.apply(SPECIES.length());
3108         double[] b = fb.apply(SPECIES.length());
3109         boolean[] mask = fm.apply(SPECIES.length());
3110 
3111         VectorMask<Double> vmask = VectorMask.fromArray(SPECIES, mask, 0);
3112 
3113         for (int ic = 0; ic < INVOC_COUNT; ic++) {
3114             for (int i = 0; i < a.length; i += SPECIES.length()) {
3115                 DoubleVector av = DoubleVector.fromArray(SPECIES, a, i);
3116                 DoubleVector bv = DoubleVector.fromArray(SPECIES, b, i);
3117                 VectorMask<Double> mv = av.compare(VectorOperators.GE, bv, vmask);
3118 
3119                 // Check results as part of computation.
3120                 for (int j = 0; j < SPECIES.length(); j++) {
3121                     Assert.assertEquals(mv.laneIsSet(j), mask[j] && ge(a[i + j], b[i + j]));
3122                 }
3123             }
3124         }
3125     }
3126 
3127 
3128 
3129 
3130 
3131 
3132 
3133 
3134 
3135 
3136     @Test(dataProvider = "doubleCompareOpProvider")
3137     static void LTDoubleMaxVectorTestsBroadcastSmokeTest(IntFunction<double[]> fa, IntFunction<double[]> fb) {
3138         double[] a = fa.apply(SPECIES.length());
3139         double[] b = fb.apply(SPECIES.length());
3140 
3141         for (int i = 0; i < a.length; i += SPECIES.length()) {
3142             DoubleVector av = DoubleVector.fromArray(SPECIES, a, i);
3143             VectorMask<Double> mv = av.compare(VectorOperators.LT, b[i]);
3144 
3145             // Check results as part of computation.
3146             for (int j = 0; j < SPECIES.length(); j++) {
3147                 Assert.assertEquals(mv.laneIsSet(j), a[i + j] < b[i]);
3148             }
3149         }
3150     }
3151 
3152 
3153     @Test(dataProvider = "doubleCompareOpMaskProvider")
3154     static void LTDoubleMaxVectorTestsBroadcastMaskedSmokeTest(IntFunction<double[]> fa,
3155                                 IntFunction<double[]> fb, IntFunction<boolean[]> fm) {
3156         double[] a = fa.apply(SPECIES.length());
3157         double[] b = fb.apply(SPECIES.length());
3158         boolean[] mask = fm.apply(SPECIES.length());
3159 
3160         VectorMask<Double> vmask = VectorMask.fromArray(SPECIES, mask, 0);
3161 
3162         for (int i = 0; i < a.length; i += SPECIES.length()) {
3163             DoubleVector av = DoubleVector.fromArray(SPECIES, a, i);
3164             VectorMask<Double> mv = av.compare(VectorOperators.LT, b[i], vmask);
3165 
3166             // Check results as part of computation.
3167             for (int j = 0; j < SPECIES.length(); j++) {
3168                 Assert.assertEquals(mv.laneIsSet(j), mask[j] && (a[i + j] < b[i]));
3169             }
3170         }
3171     }
3172 
3173     @Test(dataProvider = "doubleCompareOpProvider")
3174     static void LTDoubleMaxVectorTestsBroadcastLongSmokeTest(IntFunction<double[]> fa, IntFunction<double[]> fb) {
3175         double[] a = fa.apply(SPECIES.length());
3176         double[] b = fb.apply(SPECIES.length());
3177 
3178         for (int i = 0; i < a.length; i += SPECIES.length()) {
3179             DoubleVector av = DoubleVector.fromArray(SPECIES, a, i);
3180             VectorMask<Double> mv = av.compare(VectorOperators.LT, (long)b[i]);
3181 
3182             // Check results as part of computation.
3183             for (int j = 0; j < SPECIES.length(); j++) {
3184                 Assert.assertEquals(mv.laneIsSet(j), a[i + j] < (double)((long)b[i]));
3185             }
3186         }
3187     }
3188 
3189 
3190     @Test(dataProvider = "doubleCompareOpMaskProvider")
3191     static void LTDoubleMaxVectorTestsBroadcastLongMaskedSmokeTest(IntFunction<double[]> fa,
3192                                 IntFunction<double[]> fb, IntFunction<boolean[]> fm) {
3193         double[] a = fa.apply(SPECIES.length());
3194         double[] b = fb.apply(SPECIES.length());
3195         boolean[] mask = fm.apply(SPECIES.length());
3196 
3197         VectorMask<Double> vmask = VectorMask.fromArray(SPECIES, mask, 0);
3198 
3199         for (int i = 0; i < a.length; i += SPECIES.length()) {
3200             DoubleVector av = DoubleVector.fromArray(SPECIES, a, i);
3201             VectorMask<Double> mv = av.compare(VectorOperators.LT, (long)b[i], vmask);
3202 
3203             // Check results as part of computation.
3204             for (int j = 0; j < SPECIES.length(); j++) {
3205                 Assert.assertEquals(mv.laneIsSet(j), mask[j] && (a[i + j] < (double)((long)b[i])));
3206             }
3207         }
3208     }
3209 
3210     @Test(dataProvider = "doubleCompareOpProvider")
3211     static void EQDoubleMaxVectorTestsBroadcastSmokeTest(IntFunction<double[]> fa, IntFunction<double[]> fb) {
3212         double[] a = fa.apply(SPECIES.length());
3213         double[] b = fb.apply(SPECIES.length());
3214 
3215         for (int i = 0; i < a.length; i += SPECIES.length()) {
3216             DoubleVector av = DoubleVector.fromArray(SPECIES, a, i);
3217             VectorMask<Double> mv = av.compare(VectorOperators.EQ, b[i]);
3218 
3219             // Check results as part of computation.
3220             for (int j = 0; j < SPECIES.length(); j++) {
3221                 Assert.assertEquals(mv.laneIsSet(j), a[i + j] == b[i]);
3222             }
3223         }
3224     }
3225 
3226 
3227     @Test(dataProvider = "doubleCompareOpMaskProvider")
3228     static void EQDoubleMaxVectorTestsBroadcastMaskedSmokeTest(IntFunction<double[]> fa,
3229                                 IntFunction<double[]> fb, IntFunction<boolean[]> fm) {
3230         double[] a = fa.apply(SPECIES.length());
3231         double[] b = fb.apply(SPECIES.length());
3232         boolean[] mask = fm.apply(SPECIES.length());
3233 
3234         VectorMask<Double> vmask = VectorMask.fromArray(SPECIES, mask, 0);
3235 
3236         for (int i = 0; i < a.length; i += SPECIES.length()) {
3237             DoubleVector av = DoubleVector.fromArray(SPECIES, a, i);
3238             VectorMask<Double> mv = av.compare(VectorOperators.EQ, b[i], vmask);
3239 
3240             // Check results as part of computation.
3241             for (int j = 0; j < SPECIES.length(); j++) {
3242                 Assert.assertEquals(mv.laneIsSet(j), mask[j] && (a[i + j] == b[i]));
3243             }
3244         }
3245     }
3246 
3247     @Test(dataProvider = "doubleCompareOpProvider")
3248     static void EQDoubleMaxVectorTestsBroadcastLongSmokeTest(IntFunction<double[]> fa, IntFunction<double[]> fb) {
3249         double[] a = fa.apply(SPECIES.length());
3250         double[] b = fb.apply(SPECIES.length());
3251 
3252         for (int i = 0; i < a.length; i += SPECIES.length()) {
3253             DoubleVector av = DoubleVector.fromArray(SPECIES, a, i);
3254             VectorMask<Double> mv = av.compare(VectorOperators.EQ, (long)b[i]);
3255 
3256             // Check results as part of computation.
3257             for (int j = 0; j < SPECIES.length(); j++) {
3258                 Assert.assertEquals(mv.laneIsSet(j), a[i + j] == (double)((long)b[i]));
3259             }
3260         }
3261     }
3262 
3263 
3264     @Test(dataProvider = "doubleCompareOpMaskProvider")
3265     static void EQDoubleMaxVectorTestsBroadcastLongMaskedSmokeTest(IntFunction<double[]> fa,
3266                                 IntFunction<double[]> fb, IntFunction<boolean[]> fm) {
3267         double[] a = fa.apply(SPECIES.length());
3268         double[] b = fb.apply(SPECIES.length());
3269         boolean[] mask = fm.apply(SPECIES.length());
3270 
3271         VectorMask<Double> vmask = VectorMask.fromArray(SPECIES, mask, 0);
3272 
3273         for (int i = 0; i < a.length; i += SPECIES.length()) {
3274             DoubleVector av = DoubleVector.fromArray(SPECIES, a, i);
3275             VectorMask<Double> mv = av.compare(VectorOperators.EQ, (long)b[i], vmask);
3276 
3277             // Check results as part of computation.
3278             for (int j = 0; j < SPECIES.length(); j++) {
3279                 Assert.assertEquals(mv.laneIsSet(j), mask[j] && (a[i + j] == (double)((long)b[i])));
3280             }
3281         }
3282     }
3283 

3322         assertRearrangeArraysEquals(r, a, order, SPECIES.length());
3323     }
3324 
3325     @Test(dataProvider = "doubleUnaryOpShuffleMaskProvider")
3326     static void RearrangeDoubleMaxVectorTestsMaskedSmokeTest(IntFunction<double[]> fa,
3327                                                           BiFunction<Integer,Integer,int[]> fs,
3328                                                           IntFunction<boolean[]> fm) {
3329         double[] a = fa.apply(SPECIES.length());
3330         int[] order = fs.apply(a.length, SPECIES.length());
3331         double[] r = fr.apply(SPECIES.length());
3332         boolean[] mask = fm.apply(SPECIES.length());
3333         VectorMask<Double> vmask = VectorMask.fromArray(SPECIES, mask, 0);
3334 
3335         for (int i = 0; i < a.length; i += SPECIES.length()) {
3336             DoubleVector av = DoubleVector.fromArray(SPECIES, a, i);
3337             av.rearrange(VectorShuffle.fromArray(SPECIES, order, i), vmask).intoArray(r, i);
3338         }
3339 
3340         assertRearrangeArraysEquals(r, a, order, mask, SPECIES.length());
3341     }





































3342     @Test(dataProvider = "doubleUnaryOpProvider")
3343     static void getDoubleMaxVectorTests(IntFunction<double[]> fa) {
3344         double[] a = fa.apply(SPECIES.length());
3345         double[] r = fr.apply(SPECIES.length());
3346 
3347         for (int ic = 0; ic < INVOC_COUNT; ic++) {
3348             for (int i = 0; i < a.length; i += SPECIES.length()) {
3349                 DoubleVector av = DoubleVector.fromArray(SPECIES, a, i);
3350                 int num_lanes = SPECIES.length();
3351                 // Manually unroll because full unroll happens after intrinsification.
3352                 // Unroll is needed because get intrinsic requires for index to be a known constant.
3353                 if (num_lanes == 1) {
3354                     r[i]=av.lane(0);
3355                 } else if (num_lanes == 2) {
3356                     r[i]=av.lane(0);
3357                     r[i+1]=av.lane(1);
3358                 } else if (num_lanes == 4) {
3359                     r[i]=av.lane(0);
3360                     r[i+1]=av.lane(1);
3361                     r[i+2]=av.lane(2);

3492             }
3493         }
3494 
3495         assertArraysEquals(r, a, DoubleMaxVectorTests::get);
3496     }
3497 
3498     @Test(dataProvider = "doubleUnaryOpProvider")
3499     static void BroadcastDoubleMaxVectorTests(IntFunction<double[]> fa) {
3500         double[] a = fa.apply(SPECIES.length());
3501         double[] r = new double[a.length];
3502 
3503         for (int ic = 0; ic < INVOC_COUNT; ic++) {
3504             for (int i = 0; i < a.length; i += SPECIES.length()) {
3505                 DoubleVector.broadcast(SPECIES, a[i]).intoArray(r, i);
3506             }
3507         }
3508 
3509         assertBroadcastArraysEquals(r, a);
3510     }
3511 
3512 
3513 
3514 
3515 
3516     @Test(dataProvider = "doubleUnaryOpProvider")
3517     static void ZeroDoubleMaxVectorTests(IntFunction<double[]> fa) {
3518         double[] a = fa.apply(SPECIES.length());
3519         double[] r = new double[a.length];
3520 
3521         for (int ic = 0; ic < INVOC_COUNT; ic++) {
3522             for (int i = 0; i < a.length; i += SPECIES.length()) {
3523                 DoubleVector.zero(SPECIES).intoArray(a, i);
3524             }
3525         }
3526 
3527         Assert.assertEquals(a, r);
3528     }
3529 
3530 
3531 
3532 
3533     static double[] sliceUnary(double[] a, int origin, int idx) {
3534         double[] res = new double[SPECIES.length()];
3535         for (int i = 0; i < SPECIES.length(); i++){
3536             if(i+origin < SPECIES.length())
3537                 res[i] = a[idx+i+origin];
3538             else
3539                 res[i] = (double)0;
3540         }
3541         return res;
3542     }
3543 
3544     @Test(dataProvider = "doubleUnaryOpProvider")
3545     static void sliceUnaryDoubleMaxVectorTests(IntFunction<double[]> fa) {
3546         double[] a = fa.apply(SPECIES.length());
3547         double[] r = new double[a.length];
3548         int origin = (new java.util.Random()).nextInt(SPECIES.length());
3549         for (int ic = 0; ic < INVOC_COUNT; ic++) {
3550             for (int i = 0; i < a.length; i += SPECIES.length()) {
3551                 DoubleVector av = DoubleVector.fromArray(SPECIES, a, i);
3552                 av.slice(origin).intoArray(r, i);
3553             }
3554         }
3555 
3556         assertArraysEquals(r, a, origin, DoubleMaxVectorTests::sliceUnary);
3557     }

3558     static double[] sliceBinary(double[] a, double[] b, int origin, int idx) {
3559         double[] res = new double[SPECIES.length()];
3560         for (int i = 0, j = 0; i < SPECIES.length(); i++){
3561             if(i+origin < SPECIES.length())
3562                 res[i] = a[idx+i+origin];
3563             else {
3564                 res[i] = b[idx+j];
3565                 j++;
3566             }
3567         }
3568         return res;
3569     }
3570 
3571     @Test(dataProvider = "doubleBinaryOpProvider")
3572     static void sliceBinaryDoubleMaxVectorTestsBinary(IntFunction<double[]> fa, IntFunction<double[]> fb) {
3573         double[] a = fa.apply(SPECIES.length());
3574         double[] b = fb.apply(SPECIES.length());
3575         double[] r = new double[a.length];
3576         int origin = (new java.util.Random()).nextInt(SPECIES.length());
3577         for (int ic = 0; ic < INVOC_COUNT; ic++) {
3578             for (int i = 0; i < a.length; i += SPECIES.length()) {
3579                 DoubleVector av = DoubleVector.fromArray(SPECIES, a, i);
3580                 DoubleVector bv = DoubleVector.fromArray(SPECIES, b, i);
3581                 av.slice(origin, bv).intoArray(r, i);
3582             }
3583         }
3584 
3585         assertArraysEquals(r, a, b, origin, DoubleMaxVectorTests::sliceBinary);
3586     }

3587     static double[] slice(double[] a, double[] b, int origin, boolean[] mask, int idx) {
3588         double[] res = new double[SPECIES.length()];
3589         for (int i = 0, j = 0; i < SPECIES.length(); i++){
3590             if(i+origin < SPECIES.length())
3591                 res[i] = mask[i] ? a[idx+i+origin] : (double)0;
3592             else {
3593                 res[i] = mask[i] ? b[idx+j] : (double)0;
3594                 j++;
3595             }
3596         }
3597         return res;
3598     }
3599 
3600     @Test(dataProvider = "doubleBinaryOpMaskProvider")
3601     static void sliceDoubleMaxVectorTestsMasked(IntFunction<double[]> fa, IntFunction<double[]> fb,
3602     IntFunction<boolean[]> fm) {
3603         double[] a = fa.apply(SPECIES.length());
3604         double[] b = fb.apply(SPECIES.length());
3605         boolean[] mask = fm.apply(SPECIES.length());
3606         VectorMask<Double> vmask = VectorMask.fromArray(SPECIES, mask, 0);
3607 
3608         double[] r = new double[a.length];
3609         int origin = (new java.util.Random()).nextInt(SPECIES.length());
3610         for (int ic = 0; ic < INVOC_COUNT; ic++) {
3611             for (int i = 0; i < a.length; i += SPECIES.length()) {
3612                 DoubleVector av = DoubleVector.fromArray(SPECIES, a, i);
3613                 DoubleVector bv = DoubleVector.fromArray(SPECIES, b, i);
3614                 av.slice(origin, bv, vmask).intoArray(r, i);
3615             }
3616         }
3617 
3618         assertArraysEquals(r, a, b, origin, mask, DoubleMaxVectorTests::slice);
3619     }

3620     static double[] unsliceUnary(double[] a, int origin, int idx) {
3621         double[] res = new double[SPECIES.length()];
3622         for (int i = 0, j = 0; i < SPECIES.length(); i++){
3623             if(i < origin)
3624                 res[i] = (double)0;
3625             else {
3626                 res[i] = a[idx+j];
3627                 j++;
3628             }
3629         }
3630         return res;
3631     }
3632 
3633     @Test(dataProvider = "doubleUnaryOpProvider")
3634     static void unsliceUnaryDoubleMaxVectorTests(IntFunction<double[]> fa) {
3635         double[] a = fa.apply(SPECIES.length());
3636         double[] r = new double[a.length];
3637         int origin = (new java.util.Random()).nextInt(SPECIES.length());
3638         for (int ic = 0; ic < INVOC_COUNT; ic++) {
3639             for (int i = 0; i < a.length; i += SPECIES.length()) {
3640                 DoubleVector av = DoubleVector.fromArray(SPECIES, a, i);
3641                 av.unslice(origin).intoArray(r, i);
3642             }
3643         }
3644 
3645         assertArraysEquals(r, a, origin, DoubleMaxVectorTests::unsliceUnary);
3646     }

3647     static double[] unsliceBinary(double[] a, double[] b, int origin, int part, int idx) {
3648         double[] res = new double[SPECIES.length()];
3649         for (int i = 0, j = 0; i < SPECIES.length(); i++){
3650             if (part == 0) {
3651                 if (i < origin)
3652                     res[i] = b[idx+i];
3653                 else {
3654                     res[i] = a[idx+j];
3655                     j++;
3656                 }
3657             } else if (part == 1) {
3658                 if (i < origin)
3659                     res[i] = a[idx+SPECIES.length()-origin+i];
3660                 else {
3661                     res[i] = b[idx+origin+j];
3662                     j++;
3663                 }
3664             }
3665         }
3666         return res;
3667     }
3668 
3669     @Test(dataProvider = "doubleBinaryOpProvider")
3670     static void unsliceBinaryDoubleMaxVectorTestsBinary(IntFunction<double[]> fa, IntFunction<double[]> fb) {
3671         double[] a = fa.apply(SPECIES.length());
3672         double[] b = fb.apply(SPECIES.length());
3673         double[] r = new double[a.length];
3674         int origin = (new java.util.Random()).nextInt(SPECIES.length());
3675         int part = (new java.util.Random()).nextInt(2);
3676         for (int ic = 0; ic < INVOC_COUNT; ic++) {
3677             for (int i = 0; i < a.length; i += SPECIES.length()) {
3678                 DoubleVector av = DoubleVector.fromArray(SPECIES, a, i);
3679                 DoubleVector bv = DoubleVector.fromArray(SPECIES, b, i);
3680                 av.unslice(origin, bv, part).intoArray(r, i);
3681             }
3682         }
3683 
3684         assertArraysEquals(r, a, b, origin, part, DoubleMaxVectorTests::unsliceBinary);
3685     }

3686     static double[] unslice(double[] a, double[] b, int origin, int part, boolean[] mask, int idx) {
3687         double[] res = new double[SPECIES.length()];
3688         for (int i = 0, j = 0; i < SPECIES.length(); i++){
3689             if(i+origin < SPECIES.length())
3690                 res[i] = b[idx+i+origin];
3691             else {
3692                 res[i] = b[idx+j];
3693                 j++;
3694             }
3695         }
3696         for (int i = 0; i < SPECIES.length(); i++){
3697             res[i] = mask[i] ? a[idx+i] : res[i];
3698         }
3699         double[] res1 = new double[SPECIES.length()];
3700         if (part == 0) {
3701             for (int i = 0, j = 0; i < SPECIES.length(); i++){
3702                 if (i < origin)
3703                     res1[i] = b[idx+i];
3704                 else {
3705                    res1[i] = res[j];

3746 
3747     static double strictSIN(double a) {
3748         return (double)(StrictMath.sin((double)a));
3749     }
3750 
3751     @Test(dataProvider = "doubleUnaryOpProvider")
3752     static void SINDoubleMaxVectorTests(IntFunction<double[]> fa) {
3753         double[] a = fa.apply(SPECIES.length());
3754         double[] r = fr.apply(SPECIES.length());
3755 
3756         for (int ic = 0; ic < INVOC_COUNT; ic++) {
3757             for (int i = 0; i < a.length; i += SPECIES.length()) {
3758                 DoubleVector av = DoubleVector.fromArray(SPECIES, a, i);
3759                 av.lanewise(VectorOperators.SIN).intoArray(r, i);
3760             }
3761         }
3762 
3763         assertArraysEqualsWithinOneUlp(r, a, DoubleMaxVectorTests::SIN, DoubleMaxVectorTests::strictSIN);
3764     }
3765 
3766 
3767     static double EXP(double a) {
3768         return (double)(Math.exp((double)a));
3769     }
3770 
3771     static double strictEXP(double a) {
3772         return (double)(StrictMath.exp((double)a));
3773     }
3774 
3775     @Test(dataProvider = "doubleUnaryOpProvider")
3776     static void EXPDoubleMaxVectorTests(IntFunction<double[]> fa) {
3777         double[] a = fa.apply(SPECIES.length());
3778         double[] r = fr.apply(SPECIES.length());
3779 
3780         for (int ic = 0; ic < INVOC_COUNT; ic++) {
3781             for (int i = 0; i < a.length; i += SPECIES.length()) {
3782                 DoubleVector av = DoubleVector.fromArray(SPECIES, a, i);
3783                 av.lanewise(VectorOperators.EXP).intoArray(r, i);
3784             }
3785         }
3786 
3787         assertArraysEqualsWithinOneUlp(r, a, DoubleMaxVectorTests::EXP, DoubleMaxVectorTests::strictEXP);
3788     }
3789 
3790 
3791     static double LOG1P(double a) {
3792         return (double)(Math.log1p((double)a));
3793     }
3794 
3795     static double strictLOG1P(double a) {
3796         return (double)(StrictMath.log1p((double)a));
3797     }
3798 
3799     @Test(dataProvider = "doubleUnaryOpProvider")
3800     static void LOG1PDoubleMaxVectorTests(IntFunction<double[]> fa) {
3801         double[] a = fa.apply(SPECIES.length());
3802         double[] r = fr.apply(SPECIES.length());
3803 
3804         for (int ic = 0; ic < INVOC_COUNT; ic++) {
3805             for (int i = 0; i < a.length; i += SPECIES.length()) {
3806                 DoubleVector av = DoubleVector.fromArray(SPECIES, a, i);
3807                 av.lanewise(VectorOperators.LOG1P).intoArray(r, i);
3808             }
3809         }
3810 
3811         assertArraysEqualsWithinOneUlp(r, a, DoubleMaxVectorTests::LOG1P, DoubleMaxVectorTests::strictLOG1P);
3812     }
3813 
3814 
3815     static double LOG(double a) {
3816         return (double)(Math.log((double)a));
3817     }
3818 
3819     static double strictLOG(double a) {
3820         return (double)(StrictMath.log((double)a));
3821     }
3822 
3823     @Test(dataProvider = "doubleUnaryOpProvider")
3824     static void LOGDoubleMaxVectorTests(IntFunction<double[]> fa) {
3825         double[] a = fa.apply(SPECIES.length());
3826         double[] r = fr.apply(SPECIES.length());
3827 
3828         for (int ic = 0; ic < INVOC_COUNT; ic++) {
3829             for (int i = 0; i < a.length; i += SPECIES.length()) {
3830                 DoubleVector av = DoubleVector.fromArray(SPECIES, a, i);
3831                 av.lanewise(VectorOperators.LOG).intoArray(r, i);
3832             }
3833         }
3834 
3835         assertArraysEqualsWithinOneUlp(r, a, DoubleMaxVectorTests::LOG, DoubleMaxVectorTests::strictLOG);
3836     }
3837 
3838 
3839     static double LOG10(double a) {
3840         return (double)(Math.log10((double)a));
3841     }
3842 
3843     static double strictLOG10(double a) {
3844         return (double)(StrictMath.log10((double)a));
3845     }
3846 
3847     @Test(dataProvider = "doubleUnaryOpProvider")
3848     static void LOG10DoubleMaxVectorTests(IntFunction<double[]> fa) {
3849         double[] a = fa.apply(SPECIES.length());
3850         double[] r = fr.apply(SPECIES.length());
3851 
3852         for (int ic = 0; ic < INVOC_COUNT; ic++) {
3853             for (int i = 0; i < a.length; i += SPECIES.length()) {
3854                 DoubleVector av = DoubleVector.fromArray(SPECIES, a, i);
3855                 av.lanewise(VectorOperators.LOG10).intoArray(r, i);
3856             }
3857         }
3858 
3859         assertArraysEqualsWithinOneUlp(r, a, DoubleMaxVectorTests::LOG10, DoubleMaxVectorTests::strictLOG10);
3860     }
3861 
3862 
3863     static double EXPM1(double a) {
3864         return (double)(Math.expm1((double)a));
3865     }
3866 
3867     static double strictEXPM1(double a) {
3868         return (double)(StrictMath.expm1((double)a));
3869     }
3870 
3871     @Test(dataProvider = "doubleUnaryOpProvider")
3872     static void EXPM1DoubleMaxVectorTests(IntFunction<double[]> fa) {
3873         double[] a = fa.apply(SPECIES.length());
3874         double[] r = fr.apply(SPECIES.length());
3875 
3876         for (int ic = 0; ic < INVOC_COUNT; ic++) {
3877             for (int i = 0; i < a.length; i += SPECIES.length()) {
3878                 DoubleVector av = DoubleVector.fromArray(SPECIES, a, i);
3879                 av.lanewise(VectorOperators.EXPM1).intoArray(r, i);
3880             }
3881         }
3882 
3883         assertArraysEqualsWithinOneUlp(r, a, DoubleMaxVectorTests::EXPM1, DoubleMaxVectorTests::strictEXPM1);
3884     }
3885 
3886 
3887     static double COS(double a) {
3888         return (double)(Math.cos((double)a));
3889     }
3890 
3891     static double strictCOS(double a) {
3892         return (double)(StrictMath.cos((double)a));
3893     }
3894 
3895     @Test(dataProvider = "doubleUnaryOpProvider")
3896     static void COSDoubleMaxVectorTests(IntFunction<double[]> fa) {
3897         double[] a = fa.apply(SPECIES.length());
3898         double[] r = fr.apply(SPECIES.length());
3899 
3900         for (int ic = 0; ic < INVOC_COUNT; ic++) {
3901             for (int i = 0; i < a.length; i += SPECIES.length()) {
3902                 DoubleVector av = DoubleVector.fromArray(SPECIES, a, i);
3903                 av.lanewise(VectorOperators.COS).intoArray(r, i);
3904             }
3905         }
3906 
3907         assertArraysEqualsWithinOneUlp(r, a, DoubleMaxVectorTests::COS, DoubleMaxVectorTests::strictCOS);
3908     }
3909 
3910 
3911     static double TAN(double a) {
3912         return (double)(Math.tan((double)a));
3913     }
3914 
3915     static double strictTAN(double a) {
3916         return (double)(StrictMath.tan((double)a));
3917     }
3918 
3919     @Test(dataProvider = "doubleUnaryOpProvider")
3920     static void TANDoubleMaxVectorTests(IntFunction<double[]> fa) {
3921         double[] a = fa.apply(SPECIES.length());
3922         double[] r = fr.apply(SPECIES.length());
3923 
3924         for (int ic = 0; ic < INVOC_COUNT; ic++) {
3925             for (int i = 0; i < a.length; i += SPECIES.length()) {
3926                 DoubleVector av = DoubleVector.fromArray(SPECIES, a, i);
3927                 av.lanewise(VectorOperators.TAN).intoArray(r, i);
3928             }
3929         }
3930 
3931         assertArraysEqualsWithinOneUlp(r, a, DoubleMaxVectorTests::TAN, DoubleMaxVectorTests::strictTAN);
3932     }
3933 
3934 
3935     static double SINH(double a) {
3936         return (double)(Math.sinh((double)a));
3937     }
3938 
3939     static double strictSINH(double a) {
3940         return (double)(StrictMath.sinh((double)a));
3941     }
3942 
3943     @Test(dataProvider = "doubleUnaryOpProvider")
3944     static void SINHDoubleMaxVectorTests(IntFunction<double[]> fa) {
3945         double[] a = fa.apply(SPECIES.length());
3946         double[] r = fr.apply(SPECIES.length());
3947 
3948         for (int ic = 0; ic < INVOC_COUNT; ic++) {
3949             for (int i = 0; i < a.length; i += SPECIES.length()) {
3950                 DoubleVector av = DoubleVector.fromArray(SPECIES, a, i);
3951                 av.lanewise(VectorOperators.SINH).intoArray(r, i);
3952             }
3953         }
3954 
3955         assertArraysEqualsWithinOneUlp(r, a, DoubleMaxVectorTests::SINH, DoubleMaxVectorTests::strictSINH);
3956     }
3957 
3958 
3959     static double COSH(double a) {
3960         return (double)(Math.cosh((double)a));
3961     }
3962 
3963     static double strictCOSH(double a) {
3964         return (double)(StrictMath.cosh((double)a));
3965     }
3966 
3967     @Test(dataProvider = "doubleUnaryOpProvider")
3968     static void COSHDoubleMaxVectorTests(IntFunction<double[]> fa) {
3969         double[] a = fa.apply(SPECIES.length());
3970         double[] r = fr.apply(SPECIES.length());
3971 
3972         for (int ic = 0; ic < INVOC_COUNT; ic++) {
3973             for (int i = 0; i < a.length; i += SPECIES.length()) {
3974                 DoubleVector av = DoubleVector.fromArray(SPECIES, a, i);
3975                 av.lanewise(VectorOperators.COSH).intoArray(r, i);
3976             }
3977         }
3978 
3979         assertArraysEqualsWithinOneUlp(r, a, DoubleMaxVectorTests::COSH, DoubleMaxVectorTests::strictCOSH);
3980     }
3981 
3982 
3983     static double TANH(double a) {
3984         return (double)(Math.tanh((double)a));
3985     }
3986 
3987     static double strictTANH(double a) {
3988         return (double)(StrictMath.tanh((double)a));
3989     }
3990 
3991     @Test(dataProvider = "doubleUnaryOpProvider")
3992     static void TANHDoubleMaxVectorTests(IntFunction<double[]> fa) {
3993         double[] a = fa.apply(SPECIES.length());
3994         double[] r = fr.apply(SPECIES.length());
3995 
3996         for (int ic = 0; ic < INVOC_COUNT; ic++) {
3997             for (int i = 0; i < a.length; i += SPECIES.length()) {
3998                 DoubleVector av = DoubleVector.fromArray(SPECIES, a, i);
3999                 av.lanewise(VectorOperators.TANH).intoArray(r, i);
4000             }
4001         }
4002 
4003         assertArraysEqualsWithinOneUlp(r, a, DoubleMaxVectorTests::TANH, DoubleMaxVectorTests::strictTANH);
4004     }
4005 
4006 
4007     static double ASIN(double a) {
4008         return (double)(Math.asin((double)a));
4009     }
4010 
4011     static double strictASIN(double a) {
4012         return (double)(StrictMath.asin((double)a));
4013     }
4014 
4015     @Test(dataProvider = "doubleUnaryOpProvider")
4016     static void ASINDoubleMaxVectorTests(IntFunction<double[]> fa) {
4017         double[] a = fa.apply(SPECIES.length());
4018         double[] r = fr.apply(SPECIES.length());
4019 
4020         for (int ic = 0; ic < INVOC_COUNT; ic++) {
4021             for (int i = 0; i < a.length; i += SPECIES.length()) {
4022                 DoubleVector av = DoubleVector.fromArray(SPECIES, a, i);
4023                 av.lanewise(VectorOperators.ASIN).intoArray(r, i);
4024             }
4025         }
4026 
4027         assertArraysEqualsWithinOneUlp(r, a, DoubleMaxVectorTests::ASIN, DoubleMaxVectorTests::strictASIN);
4028     }
4029 
4030 
4031     static double ACOS(double a) {
4032         return (double)(Math.acos((double)a));
4033     }
4034 
4035     static double strictACOS(double a) {
4036         return (double)(StrictMath.acos((double)a));
4037     }
4038 
4039     @Test(dataProvider = "doubleUnaryOpProvider")
4040     static void ACOSDoubleMaxVectorTests(IntFunction<double[]> fa) {
4041         double[] a = fa.apply(SPECIES.length());
4042         double[] r = fr.apply(SPECIES.length());
4043 
4044         for (int ic = 0; ic < INVOC_COUNT; ic++) {
4045             for (int i = 0; i < a.length; i += SPECIES.length()) {
4046                 DoubleVector av = DoubleVector.fromArray(SPECIES, a, i);
4047                 av.lanewise(VectorOperators.ACOS).intoArray(r, i);
4048             }
4049         }
4050 
4051         assertArraysEqualsWithinOneUlp(r, a, DoubleMaxVectorTests::ACOS, DoubleMaxVectorTests::strictACOS);
4052     }
4053 
4054 
4055     static double ATAN(double a) {
4056         return (double)(Math.atan((double)a));
4057     }
4058 
4059     static double strictATAN(double a) {
4060         return (double)(StrictMath.atan((double)a));
4061     }
4062 
4063     @Test(dataProvider = "doubleUnaryOpProvider")
4064     static void ATANDoubleMaxVectorTests(IntFunction<double[]> fa) {
4065         double[] a = fa.apply(SPECIES.length());
4066         double[] r = fr.apply(SPECIES.length());
4067 
4068         for (int ic = 0; ic < INVOC_COUNT; ic++) {
4069             for (int i = 0; i < a.length; i += SPECIES.length()) {
4070                 DoubleVector av = DoubleVector.fromArray(SPECIES, a, i);
4071                 av.lanewise(VectorOperators.ATAN).intoArray(r, i);
4072             }
4073         }
4074 
4075         assertArraysEqualsWithinOneUlp(r, a, DoubleMaxVectorTests::ATAN, DoubleMaxVectorTests::strictATAN);
4076     }
4077 
4078 
4079     static double CBRT(double a) {
4080         return (double)(Math.cbrt((double)a));
4081     }
4082 
4083     static double strictCBRT(double a) {
4084         return (double)(StrictMath.cbrt((double)a));
4085     }
4086 
4087     @Test(dataProvider = "doubleUnaryOpProvider")
4088     static void CBRTDoubleMaxVectorTests(IntFunction<double[]> fa) {
4089         double[] a = fa.apply(SPECIES.length());
4090         double[] r = fr.apply(SPECIES.length());
4091 
4092         for (int ic = 0; ic < INVOC_COUNT; ic++) {
4093             for (int i = 0; i < a.length; i += SPECIES.length()) {
4094                 DoubleVector av = DoubleVector.fromArray(SPECIES, a, i);
4095                 av.lanewise(VectorOperators.CBRT).intoArray(r, i);
4096             }
4097         }
4098 
4099         assertArraysEqualsWithinOneUlp(r, a, DoubleMaxVectorTests::CBRT, DoubleMaxVectorTests::strictCBRT);
4100     }
4101 
4102 
4103     static double HYPOT(double a, double b) {
4104         return (double)(Math.hypot((double)a, (double)b));
4105     }
4106 
4107     static double strictHYPOT(double a, double b) {
4108         return (double)(StrictMath.hypot((double)a, (double)b));
4109     }
4110 
4111     @Test(dataProvider = "doubleBinaryOpProvider")
4112     static void HYPOTDoubleMaxVectorTests(IntFunction<double[]> fa, IntFunction<double[]> fb) {
4113         double[] a = fa.apply(SPECIES.length());
4114         double[] b = fb.apply(SPECIES.length());
4115         double[] r = fr.apply(SPECIES.length());
4116 
4117         for (int ic = 0; ic < INVOC_COUNT; ic++) {
4118             for (int i = 0; i < a.length; i += SPECIES.length()) {
4119                 DoubleVector av = DoubleVector.fromArray(SPECIES, a, i);
4120                 DoubleVector bv = DoubleVector.fromArray(SPECIES, b, i);
4121                 av.lanewise(VectorOperators.HYPOT, bv).intoArray(r, i);
4122             }
4123         }
4124 
4125         assertArraysEqualsWithinOneUlp(r, a, b, DoubleMaxVectorTests::HYPOT, DoubleMaxVectorTests::strictHYPOT);
4126     }
4127 
4128 
4129 
4130     static double POW(double a, double b) {
4131         return (double)(Math.pow((double)a, (double)b));
4132     }
4133 
4134     static double strictPOW(double a, double b) {
4135         return (double)(StrictMath.pow((double)a, (double)b));
4136     }
4137 
4138     @Test(dataProvider = "doubleBinaryOpProvider")
4139     static void POWDoubleMaxVectorTests(IntFunction<double[]> fa, IntFunction<double[]> fb) {
4140         double[] a = fa.apply(SPECIES.length());
4141         double[] b = fb.apply(SPECIES.length());
4142         double[] r = fr.apply(SPECIES.length());
4143 
4144         for (int ic = 0; ic < INVOC_COUNT; ic++) {
4145             for (int i = 0; i < a.length; i += SPECIES.length()) {
4146                 DoubleVector av = DoubleVector.fromArray(SPECIES, a, i);
4147                 DoubleVector bv = DoubleVector.fromArray(SPECIES, b, i);
4148                 av.lanewise(VectorOperators.POW, bv).intoArray(r, i);
4149             }
4150         }
4151 
4152         assertArraysEqualsWithinOneUlp(r, a, b, DoubleMaxVectorTests::POW, DoubleMaxVectorTests::strictPOW);
4153     }
4154 

4155     static double pow(double a, double b) {
4156         return (double)(Math.pow((double)a, (double)b));
4157     }
4158 
4159     static double strictpow(double a, double b) {
4160         return (double)(StrictMath.pow((double)a, (double)b));
4161     }
4162 
4163     @Test(dataProvider = "doubleBinaryOpProvider")
4164     static void powDoubleMaxVectorTests(IntFunction<double[]> fa, IntFunction<double[]> fb) {
4165         double[] a = fa.apply(SPECIES.length());
4166         double[] b = fb.apply(SPECIES.length());
4167         double[] r = fr.apply(SPECIES.length());
4168 
4169         for (int ic = 0; ic < INVOC_COUNT; ic++) {
4170             for (int i = 0; i < a.length; i += SPECIES.length()) {
4171                 DoubleVector av = DoubleVector.fromArray(SPECIES, a, i);
4172                 DoubleVector bv = DoubleVector.fromArray(SPECIES, b, i);
4173                 av.pow(bv).intoArray(r, i);
4174             }
4175         }
4176 
4177         assertArraysEqualsWithinOneUlp(r, a, b, DoubleMaxVectorTests::pow, DoubleMaxVectorTests::strictpow);
4178     }
4179 
4180 
4181 
4182     static double ATAN2(double a, double b) {
4183         return (double)(Math.atan2((double)a, (double)b));
4184     }
4185 
4186     static double strictATAN2(double a, double b) {
4187         return (double)(StrictMath.atan2((double)a, (double)b));
4188     }
4189 
4190     @Test(dataProvider = "doubleBinaryOpProvider")
4191     static void ATAN2DoubleMaxVectorTests(IntFunction<double[]> fa, IntFunction<double[]> fb) {
4192         double[] a = fa.apply(SPECIES.length());
4193         double[] b = fb.apply(SPECIES.length());
4194         double[] r = fr.apply(SPECIES.length());
4195 
4196         for (int ic = 0; ic < INVOC_COUNT; ic++) {
4197             for (int i = 0; i < a.length; i += SPECIES.length()) {
4198                 DoubleVector av = DoubleVector.fromArray(SPECIES, a, i);
4199                 DoubleVector bv = DoubleVector.fromArray(SPECIES, b, i);
4200                 av.lanewise(VectorOperators.ATAN2, bv).intoArray(r, i);
4201             }
4202         }
4203 
4204         assertArraysEqualsWithinOneUlp(r, a, b, DoubleMaxVectorTests::ATAN2, DoubleMaxVectorTests::strictATAN2);
4205     }
4206 
4207 
4208 
4209     @Test(dataProvider = "doubleBinaryOpProvider")
4210     static void POWDoubleMaxVectorTestsBroadcastSmokeTest(IntFunction<double[]> fa, IntFunction<double[]> fb) {
4211         double[] a = fa.apply(SPECIES.length());
4212         double[] b = fb.apply(SPECIES.length());
4213         double[] r = fr.apply(SPECIES.length());
4214 
4215         for (int i = 0; i < a.length; i += SPECIES.length()) {
4216             DoubleVector av = DoubleVector.fromArray(SPECIES, a, i);
4217             av.lanewise(VectorOperators.POW, b[i]).intoArray(r, i);
4218         }
4219 
4220         assertBroadcastArraysEqualsWithinOneUlp(r, a, b, DoubleMaxVectorTests::POW, DoubleMaxVectorTests::strictPOW);
4221     }
4222 

4223     @Test(dataProvider = "doubleBinaryOpProvider")
4224     static void powDoubleMaxVectorTestsBroadcastSmokeTest(IntFunction<double[]> fa, IntFunction<double[]> fb) {
4225         double[] a = fa.apply(SPECIES.length());
4226         double[] b = fb.apply(SPECIES.length());
4227         double[] r = fr.apply(SPECIES.length());
4228 
4229         for (int i = 0; i < a.length; i += SPECIES.length()) {
4230             DoubleVector av = DoubleVector.fromArray(SPECIES, a, i);
4231             av.pow(b[i]).intoArray(r, i);
4232         }
4233 
4234         assertBroadcastArraysEqualsWithinOneUlp(r, a, b, DoubleMaxVectorTests::pow, DoubleMaxVectorTests::strictpow);
4235     }
4236 
4237 
4238 
4239     static double FMA(double a, double b, double c) {
4240         return (double)(Math.fma(a, b, c));
4241     }

4242     static double fma(double a, double b, double c) {
4243         return (double)(Math.fma(a, b, c));
4244     }
4245 
4246 
4247     @Test(dataProvider = "doubleTernaryOpProvider")
4248     static void FMADoubleMaxVectorTests(IntFunction<double[]> fa, IntFunction<double[]> fb, IntFunction<double[]> fc) {
4249         int count = INVOC_COUNT;
4250         switch ("FMA") {
4251         case "fma": case "lanewise_FMA":
4252            // Math.fma uses BigDecimal
4253            count = Math.max(5, count/20); break;
4254         }
4255         final int INVOC_COUNT = count;
4256         double[] a = fa.apply(SPECIES.length());
4257         double[] b = fb.apply(SPECIES.length());
4258         double[] c = fc.apply(SPECIES.length());
4259         double[] r = fr.apply(SPECIES.length());
4260 
4261         for (int ic = 0; ic < INVOC_COUNT; ic++) {
4262             for (int i = 0; i < a.length; i += SPECIES.length()) {
4263                 DoubleVector av = DoubleVector.fromArray(SPECIES, a, i);
4264                 DoubleVector bv = DoubleVector.fromArray(SPECIES, b, i);
4265                 DoubleVector cv = DoubleVector.fromArray(SPECIES, c, i);
4266                 av.lanewise(VectorOperators.FMA, bv, cv).intoArray(r, i);
4267             }
4268         }
4269 
4270         assertArraysEquals(r, a, b, c, DoubleMaxVectorTests::FMA);
4271     }

4272     @Test(dataProvider = "doubleTernaryOpProvider")
4273     static void fmaDoubleMaxVectorTests(IntFunction<double[]> fa, IntFunction<double[]> fb, IntFunction<double[]> fc) {
4274         int count = INVOC_COUNT;
4275         switch ("fma") {
4276         case "fma": case "lanewise_FMA":
4277            // Math.fma uses BigDecimal
4278            count = Math.max(5, count/20); break;
4279         }
4280         final int INVOC_COUNT = count;
4281         double[] a = fa.apply(SPECIES.length());
4282         double[] b = fb.apply(SPECIES.length());
4283         double[] c = fc.apply(SPECIES.length());
4284         double[] r = fr.apply(SPECIES.length());
4285 
4286         for (int i = 0; i < a.length; i += SPECIES.length()) {
4287             DoubleVector av = DoubleVector.fromArray(SPECIES, a, i);
4288             DoubleVector bv = DoubleVector.fromArray(SPECIES, b, i);
4289             DoubleVector cv = DoubleVector.fromArray(SPECIES, c, i);
4290             av.fma(bv, cv).intoArray(r, i);
4291         }
4292 
4293         assertArraysEquals(r, a, b, c, DoubleMaxVectorTests::fma);
4294     }
4295 
4296 
4297     @Test(dataProvider = "doubleTernaryOpMaskProvider")
4298     static void FMADoubleMaxVectorTestsMasked(IntFunction<double[]> fa, IntFunction<double[]> fb,
4299                                           IntFunction<double[]> fc, IntFunction<boolean[]> fm) {
4300         int count = INVOC_COUNT;
4301         switch ("FMA") {
4302         case "fma": case "lanewise_FMA":
4303            // Math.fma uses BigDecimal
4304            count = Math.max(5, count/20); break;
4305         }
4306         final int INVOC_COUNT = count;
4307         double[] a = fa.apply(SPECIES.length());
4308         double[] b = fb.apply(SPECIES.length());
4309         double[] c = fc.apply(SPECIES.length());
4310         double[] r = fr.apply(SPECIES.length());
4311         boolean[] mask = fm.apply(SPECIES.length());
4312         VectorMask<Double> vmask = VectorMask.fromArray(SPECIES, mask, 0);
4313 
4314         for (int ic = 0; ic < INVOC_COUNT; ic++) {
4315             for (int i = 0; i < a.length; i += SPECIES.length()) {
4316                 DoubleVector av = DoubleVector.fromArray(SPECIES, a, i);
4317                 DoubleVector bv = DoubleVector.fromArray(SPECIES, b, i);
4318                 DoubleVector cv = DoubleVector.fromArray(SPECIES, c, i);
4319                 av.lanewise(VectorOperators.FMA, bv, cv, vmask).intoArray(r, i);
4320             }
4321         }
4322 
4323         assertArraysEquals(r, a, b, c, mask, DoubleMaxVectorTests::FMA);
4324     }
4325 
4326 
4327 
4328 
4329 
4330     @Test(dataProvider = "doubleTernaryOpProvider")
4331     static void FMADoubleMaxVectorTestsBroadcastSmokeTest(IntFunction<double[]> fa, IntFunction<double[]> fb, IntFunction<double[]> fc) {
4332         double[] a = fa.apply(SPECIES.length());
4333         double[] b = fb.apply(SPECIES.length());
4334         double[] c = fc.apply(SPECIES.length());
4335         double[] r = fr.apply(SPECIES.length());
4336 
4337         for (int i = 0; i < a.length; i += SPECIES.length()) {
4338             DoubleVector av = DoubleVector.fromArray(SPECIES, a, i);
4339             DoubleVector bv = DoubleVector.fromArray(SPECIES, b, i);
4340             av.lanewise(VectorOperators.FMA, bv, c[i]).intoArray(r, i);
4341         }
4342         assertBroadcastArraysEquals(r, a, b, c, DoubleMaxVectorTests::FMA);
4343     }
4344 
4345     @Test(dataProvider = "doubleTernaryOpProvider")
4346     static void FMADoubleMaxVectorTestsAltBroadcastSmokeTest(IntFunction<double[]> fa, IntFunction<double[]> fb, IntFunction<double[]> fc) {
4347         double[] a = fa.apply(SPECIES.length());
4348         double[] b = fb.apply(SPECIES.length());
4349         double[] c = fc.apply(SPECIES.length());
4350         double[] r = fr.apply(SPECIES.length());
4351 
4352         for (int i = 0; i < a.length; i += SPECIES.length()) {
4353             DoubleVector av = DoubleVector.fromArray(SPECIES, a, i);
4354             DoubleVector cv = DoubleVector.fromArray(SPECIES, c, i);
4355             av.lanewise(VectorOperators.FMA, b[i], cv).intoArray(r, i);
4356         }
4357         assertAltBroadcastArraysEquals(r, a, b, c, DoubleMaxVectorTests::FMA);
4358     }
4359 
4360 
4361     @Test(dataProvider = "doubleTernaryOpMaskProvider")
4362     static void FMADoubleMaxVectorTestsBroadcastMaskedSmokeTest(IntFunction<double[]> fa, IntFunction<double[]> fb,
4363                                           IntFunction<double[]> fc, IntFunction<boolean[]> fm) {
4364         double[] a = fa.apply(SPECIES.length());
4365         double[] b = fb.apply(SPECIES.length());
4366         double[] c = fc.apply(SPECIES.length());
4367         double[] r = fr.apply(SPECIES.length());
4368         boolean[] mask = fm.apply(SPECIES.length());
4369         VectorMask<Double> vmask = VectorMask.fromArray(SPECIES, mask, 0);
4370 
4371         for (int i = 0; i < a.length; i += SPECIES.length()) {
4372             DoubleVector av = DoubleVector.fromArray(SPECIES, a, i);
4373             DoubleVector bv = DoubleVector.fromArray(SPECIES, b, i);
4374             av.lanewise(VectorOperators.FMA, bv, c[i], vmask).intoArray(r, i);
4375         }
4376 
4377         assertBroadcastArraysEquals(r, a, b, c, mask, DoubleMaxVectorTests::FMA);
4378     }
4379 
4380     @Test(dataProvider = "doubleTernaryOpMaskProvider")
4381     static void FMADoubleMaxVectorTestsAltBroadcastMaskedSmokeTest(IntFunction<double[]> fa, IntFunction<double[]> fb,
4382                                           IntFunction<double[]> fc, IntFunction<boolean[]> fm) {
4383         double[] a = fa.apply(SPECIES.length());
4384         double[] b = fb.apply(SPECIES.length());
4385         double[] c = fc.apply(SPECIES.length());
4386         double[] r = fr.apply(SPECIES.length());
4387         boolean[] mask = fm.apply(SPECIES.length());
4388         VectorMask<Double> vmask = VectorMask.fromArray(SPECIES, mask, 0);
4389 
4390         for (int i = 0; i < a.length; i += SPECIES.length()) {
4391             DoubleVector av = DoubleVector.fromArray(SPECIES, a, i);
4392             DoubleVector cv = DoubleVector.fromArray(SPECIES, c, i);
4393             av.lanewise(VectorOperators.FMA, b[i], cv, vmask).intoArray(r, i);
4394         }
4395 
4396         assertAltBroadcastArraysEquals(r, a, b, c, mask, DoubleMaxVectorTests::FMA);
4397     }
4398 
4399 
4400 
4401 
4402     @Test(dataProvider = "doubleTernaryOpProvider")
4403     static void FMADoubleMaxVectorTestsDoubleBroadcastSmokeTest(IntFunction<double[]> fa, IntFunction<double[]> fb, IntFunction<double[]> fc) {
4404         int count = INVOC_COUNT;
4405         switch ("FMA") {
4406         case "fma": case "lanewise_FMA":
4407            // Math.fma uses BigDecimal
4408            count = Math.max(5, count/20); break;
4409         }
4410         final int INVOC_COUNT = count;
4411         double[] a = fa.apply(SPECIES.length());
4412         double[] b = fb.apply(SPECIES.length());
4413         double[] c = fc.apply(SPECIES.length());
4414         double[] r = fr.apply(SPECIES.length());
4415 
4416         for (int i = 0; i < a.length; i += SPECIES.length()) {
4417             DoubleVector av = DoubleVector.fromArray(SPECIES, a, i);
4418             av.lanewise(VectorOperators.FMA, b[i], c[i]).intoArray(r, i);
4419         }
4420 
4421         assertDoubleBroadcastArraysEquals(r, a, b, c, DoubleMaxVectorTests::FMA);
4422     }

4423     @Test(dataProvider = "doubleTernaryOpProvider")
4424     static void fmaDoubleMaxVectorTestsDoubleBroadcastSmokeTest(IntFunction<double[]> fa, IntFunction<double[]> fb, IntFunction<double[]> fc) {
4425         int count = INVOC_COUNT;
4426         switch ("fma") {
4427         case "fma": case "lanewise_FMA":
4428            // Math.fma uses BigDecimal
4429            count = Math.max(5, count/20); break;
4430         }
4431         final int INVOC_COUNT = count;
4432         double[] a = fa.apply(SPECIES.length());
4433         double[] b = fb.apply(SPECIES.length());
4434         double[] c = fc.apply(SPECIES.length());
4435         double[] r = fr.apply(SPECIES.length());
4436 
4437         for (int i = 0; i < a.length; i += SPECIES.length()) {
4438             DoubleVector av = DoubleVector.fromArray(SPECIES, a, i);
4439             av.fma(b[i], c[i]).intoArray(r, i);
4440         }
4441 
4442         assertDoubleBroadcastArraysEquals(r, a, b, c, DoubleMaxVectorTests::fma);
4443     }
4444 
4445 
4446     @Test(dataProvider = "doubleTernaryOpMaskProvider")
4447     static void FMADoubleMaxVectorTestsDoubleBroadcastMaskedSmokeTest(IntFunction<double[]> fa, IntFunction<double[]> fb,
4448                                           IntFunction<double[]> fc, IntFunction<boolean[]> fm) {
4449         int count = INVOC_COUNT;
4450         switch ("FMA") {
4451         case "fma": case "lanewise_FMA":
4452            // Math.fma uses BigDecimal
4453            count = Math.max(5, count/20); break;
4454         }
4455         final int INVOC_COUNT = count;
4456         double[] a = fa.apply(SPECIES.length());
4457         double[] b = fb.apply(SPECIES.length());
4458         double[] c = fc.apply(SPECIES.length());
4459         double[] r = fr.apply(SPECIES.length());
4460         boolean[] mask = fm.apply(SPECIES.length());
4461         VectorMask<Double> vmask = VectorMask.fromArray(SPECIES, mask, 0);
4462 
4463         for (int i = 0; i < a.length; i += SPECIES.length()) {
4464             DoubleVector av = DoubleVector.fromArray(SPECIES, a, i);
4465             av.lanewise(VectorOperators.FMA, b[i], c[i], vmask).intoArray(r, i);
4466         }
4467 
4468         assertDoubleBroadcastArraysEquals(r, a, b, c, mask, DoubleMaxVectorTests::FMA);
4469     }
4470 
4471 
4472 
4473 
4474     static double NEG(double a) {
4475         return (double)(-((double)a));
4476     }
4477 
4478     static double neg(double a) {
4479         return (double)(-((double)a));
4480     }
4481 
4482     @Test(dataProvider = "doubleUnaryOpProvider")
4483     static void NEGDoubleMaxVectorTests(IntFunction<double[]> fa) {
4484         double[] a = fa.apply(SPECIES.length());
4485         double[] r = fr.apply(SPECIES.length());
4486 
4487         for (int ic = 0; ic < INVOC_COUNT; ic++) {
4488             for (int i = 0; i < a.length; i += SPECIES.length()) {
4489                 DoubleVector av = DoubleVector.fromArray(SPECIES, a, i);
4490                 av.lanewise(VectorOperators.NEG).intoArray(r, i);
4491             }
4492         }
4493 

4566     }
4567 
4568     @Test(dataProvider = "doubleUnaryOpMaskProvider")
4569     static void ABSMaskedDoubleMaxVectorTests(IntFunction<double[]> fa,
4570                                                 IntFunction<boolean[]> fm) {
4571         double[] a = fa.apply(SPECIES.length());
4572         double[] r = fr.apply(SPECIES.length());
4573         boolean[] mask = fm.apply(SPECIES.length());
4574         VectorMask<Double> vmask = VectorMask.fromArray(SPECIES, mask, 0);
4575 
4576         for (int ic = 0; ic < INVOC_COUNT; ic++) {
4577             for (int i = 0; i < a.length; i += SPECIES.length()) {
4578                 DoubleVector av = DoubleVector.fromArray(SPECIES, a, i);
4579                 av.lanewise(VectorOperators.ABS, vmask).intoArray(r, i);
4580             }
4581         }
4582 
4583         assertArraysEquals(r, a, mask, DoubleMaxVectorTests::ABS);
4584     }
4585 
4586 
4587 
4588 
4589 
4590 
4591 
4592 
4593     static double SQRT(double a) {
4594         return (double)(Math.sqrt((double)a));
4595     }
4596 
4597     static double sqrt(double a) {
4598         return (double)(Math.sqrt((double)a));
4599     }
4600 
4601 
4602 
4603     @Test(dataProvider = "doubleUnaryOpProvider")
4604     static void SQRTDoubleMaxVectorTests(IntFunction<double[]> fa) {
4605         double[] a = fa.apply(SPECIES.length());
4606         double[] r = fr.apply(SPECIES.length());
4607 
4608         for (int ic = 0; ic < INVOC_COUNT; ic++) {
4609             for (int i = 0; i < a.length; i += SPECIES.length()) {
4610                 DoubleVector av = DoubleVector.fromArray(SPECIES, a, i);
4611                 av.lanewise(VectorOperators.SQRT).intoArray(r, i);
4612             }
4613         }
4614 
4615         assertArraysEquals(r, a, DoubleMaxVectorTests::SQRT);
4616     }
4617 
4618     @Test(dataProvider = "doubleUnaryOpProvider")
4619     static void sqrtDoubleMaxVectorTests(IntFunction<double[]> fa) {
4620         double[] a = fa.apply(SPECIES.length());
4621         double[] r = fr.apply(SPECIES.length());
4622 
4623         for (int ic = 0; ic < INVOC_COUNT; ic++) {
4624             for (int i = 0; i < a.length; i += SPECIES.length()) {
4625                 DoubleVector av = DoubleVector.fromArray(SPECIES, a, i);
4626                 av.sqrt().intoArray(r, i);
4627             }
4628         }
4629 
4630         assertArraysEquals(r, a, DoubleMaxVectorTests::sqrt);
4631     }
4632 
4633 
4634 
4635     @Test(dataProvider = "doubleUnaryOpMaskProvider")
4636     static void SQRTMaskedDoubleMaxVectorTests(IntFunction<double[]> fa,
4637                                                 IntFunction<boolean[]> fm) {
4638         double[] a = fa.apply(SPECIES.length());
4639         double[] r = fr.apply(SPECIES.length());
4640         boolean[] mask = fm.apply(SPECIES.length());
4641         VectorMask<Double> vmask = VectorMask.fromArray(SPECIES, mask, 0);
4642 
4643         for (int ic = 0; ic < INVOC_COUNT; ic++) {
4644             for (int i = 0; i < a.length; i += SPECIES.length()) {
4645                 DoubleVector av = DoubleVector.fromArray(SPECIES, a, i);
4646                 av.lanewise(VectorOperators.SQRT, vmask).intoArray(r, i);
4647             }
4648         }
4649 
4650         assertArraysEquals(r, a, mask, DoubleMaxVectorTests::SQRT);
4651     }
4652 
4653 
4654     @Test(dataProvider = "doubleCompareOpProvider")
4655     static void ltDoubleMaxVectorTestsBroadcastSmokeTest(IntFunction<double[]> fa, IntFunction<double[]> fb) {
4656         double[] a = fa.apply(SPECIES.length());
4657         double[] b = fb.apply(SPECIES.length());
4658 
4659         for (int i = 0; i < a.length; i += SPECIES.length()) {
4660             DoubleVector av = DoubleVector.fromArray(SPECIES, a, i);
4661             VectorMask<Double> mv = av.lt(b[i]);
4662 
4663             // Check results as part of computation.
4664             for (int j = 0; j < SPECIES.length(); j++) {
4665                 Assert.assertEquals(mv.laneIsSet(j), a[i + j] < b[i]);
4666             }
4667         }
4668     }
4669 
4670     @Test(dataProvider = "doubleCompareOpProvider")
4671     static void eqDoubleMaxVectorTestsBroadcastMaskedSmokeTest(IntFunction<double[]> fa, IntFunction<double[]> fb) {
4672         double[] a = fa.apply(SPECIES.length());
4673         double[] b = fb.apply(SPECIES.length());

5025             }
5026         }
5027         return i - idx;
5028     }
5029 
5030     @Test(dataProvider = "maskProvider")
5031     static void maskFirstTrueDoubleMaxVectorTestsSmokeTest(IntFunction<boolean[]> fa) {
5032         boolean[] a = fa.apply(SPECIES.length());
5033         int[] r = new int[a.length];
5034 
5035         for (int ic = 0; ic < INVOC_COUNT * INVOC_COUNT; ic++) {
5036             for (int i = 0; i < a.length; i += SPECIES.length()) {
5037                 var vmask = SPECIES.loadMask(a, i);
5038                 r[i] = vmask.firstTrue();
5039             }
5040         }
5041 
5042         assertMaskReductionArraysEquals(r, a, DoubleMaxVectorTests::maskFirstTrue);
5043     }
5044 

















5045 
5046     @DataProvider
5047     public static Object[][] offsetProvider() {
5048         return new Object[][]{
5049                 {0},
5050                 {-1},
5051                 {+1},
5052                 {+2},
5053                 {-2},
5054         };
5055     }
5056 
5057     @Test(dataProvider = "offsetProvider")
5058     static void indexInRangeDoubleMaxVectorTestsSmokeTest(int offset) {
5059         int limit = SPECIES.length() * BUFFER_REPS;
5060         for (int i = 0; i < limit; i += SPECIES.length()) {
5061             var actualMask = SPECIES.indexInRange(i + offset, limit);
5062             var expectedMask = SPECIES.maskAll(true).indexInRange(i + offset, limit);
5063             assert(actualMask.equals(expectedMask));
5064             for (int j = 0; j < SPECIES.length(); j++)  {
5065                 int index = i + j + offset;
5066                 Assert.assertEquals(actualMask.laneIsSet(j), index >= 0 && index < limit);
5067             }
5068         }
5069     }
5070 














5071     @DataProvider
5072     public static Object[][] lengthProvider() {
5073         return new Object[][]{
5074                 {0},
5075                 {1},
5076                 {32},
5077                 {37},
5078                 {1024},
5079                 {1024+1},
5080                 {1024+5},
5081         };
5082     }
5083 
5084     @Test(dataProvider = "lengthProvider")
5085     static void loopBoundDoubleMaxVectorTestsSmokeTest(int length) {
5086         int actualLoopBound = SPECIES.loopBound(length);
5087         int expectedLoopBound = length - Math.floorMod(length, SPECIES.length());
5088         Assert.assertEquals(actualLoopBound, expectedLoopBound);
5089     }
5090 








5091     @Test
5092     static void ElementSizeDoubleMaxVectorTestsSmokeTest() {
5093         DoubleVector av = DoubleVector.zero(SPECIES);
5094         int elsize = av.elementSize();
5095         Assert.assertEquals(elsize, Double.SIZE);
5096     }
5097 
5098     @Test
5099     static void VectorShapeDoubleMaxVectorTestsSmokeTest() {
5100         DoubleVector av = DoubleVector.zero(SPECIES);
5101         VectorShape vsh = av.shape();
5102         assert(vsh.equals(VectorShape.S_Max_BIT));
5103     }
5104 
5105     @Test
5106     static void ShapeWithLanesDoubleMaxVectorTestsSmokeTest() {
5107         DoubleVector av = DoubleVector.zero(SPECIES);
5108         VectorShape vsh = av.shape();
5109         VectorSpecies species = vsh.withLanes(double.class);
5110         assert(species.equals(SPECIES));

5133         DoubleVector av = DoubleVector.zero(SPECIES);
5134         VectorSpecies species = av.species().withLanes(double.class);
5135         assert(species.equals(SPECIES));
5136     }
5137 
5138     @Test
5139     static void WithShapeDoubleMaxVectorTestsSmokeTest() {
5140         DoubleVector av = DoubleVector.zero(SPECIES);
5141         VectorShape vsh = av.shape();
5142         VectorSpecies species = av.species().withShape(vsh);
5143         assert(species.equals(SPECIES));
5144     }
5145 
5146     @Test
5147     static void MaskAllTrueDoubleMaxVectorTestsSmokeTest() {
5148         for (int ic = 0; ic < INVOC_COUNT; ic++) {
5149           Assert.assertEquals(SPECIES.maskAll(true).toLong(), -1L >>> (64 - SPECIES.length()));
5150         }
5151     }
5152 }
5153 

  48 import java.util.function.BiFunction;
  49 import java.util.function.IntFunction;
  50 import java.util.Objects;
  51 import java.util.stream.Collectors;
  52 import java.util.stream.Stream;
  53 
  54 @Test
  55 public class DoubleMaxVectorTests extends AbstractVectorTest {
  56 
  57     static final VectorSpecies<Double> SPECIES =
  58                 DoubleVector.SPECIES_MAX;
  59 
  60     static final int INVOC_COUNT = Integer.getInteger("jdk.incubator.vector.test.loop-iterations", 100);
  61 
  62     static VectorShape getMaxBit() {
  63         return VectorShape.S_Max_BIT;
  64     }
  65 
  66     private static final int Max = 256;  // juts so we can do N/Max
  67 

  68 
  69     static final int BUFFER_REPS = Integer.getInteger("jdk.incubator.vector.test.buffer-vectors", 25000 / Max);
  70 
  71     interface FUnOp {
  72         double apply(double a);
  73     }
  74 
  75     static void assertArraysEquals(double[] r, double[] a, FUnOp f) {
  76         int i = 0;
  77         try {
  78             for (; i < a.length; i++) {
  79                 Assert.assertEquals(r[i], f.apply(a[i]));
  80             }
  81         } catch (AssertionError e) {
  82             Assert.assertEquals(r[i], f.apply(a[i]), "at index #" + i + ", input = " + a[i]);
  83         }
  84     }
  85 
  86     interface FUnArrayOp {
  87         double[] apply(double a);

 248             } else {
 249                 Assert.assertEquals(r[i], a[i], "at index #" + i);
 250             }
 251         }
 252     }
 253 
 254     static void assertRearrangeArraysEquals(double[] r, double[] a, int[] order, int vector_len) {
 255         int i = 0, j = 0;
 256         try {
 257             for (; i < a.length; i += vector_len) {
 258                 for (j = 0; j < vector_len; j++) {
 259                     Assert.assertEquals(r[i+j], a[i+order[i+j]]);
 260                 }
 261             }
 262         } catch (AssertionError e) {
 263             int idx = i + j;
 264             Assert.assertEquals(r[i+j], a[i+order[i+j]], "at index #" + idx + ", input = " + a[i+order[i+j]]);
 265         }
 266     }
 267 
 268     static void assertcompressArraysEquals(double[] r, double[] a, boolean[] m, int vector_len) {
 269         int i = 0, j = 0, k = 0;
 270         try {
 271             for (; i < a.length; i += vector_len) {
 272                 k = 0;
 273                 for (j = 0; j < vector_len; j++) {
 274                     if (m[(i + j) % SPECIES.length()]) {
 275                         Assert.assertEquals(r[i + k], a[i + j]);
 276                         k++;
 277                     }
 278                 }
 279                 for (; k < vector_len; k++) {
 280                     Assert.assertEquals(r[i + k], (double)0);
 281                 }
 282             }
 283         } catch (AssertionError e) {
 284             int idx = i + k;
 285             if (m[(i + j) % SPECIES.length()]) {
 286                 Assert.assertEquals(r[idx], a[i + j], "at index #" + idx);
 287             } else {
 288                 Assert.assertEquals(r[idx], (double)0, "at index #" + idx);
 289             }
 290         }
 291     }
 292 
 293     static void assertexpandArraysEquals(double[] r, double[] a, boolean[] m, int vector_len) {
 294         int i = 0, j = 0, k = 0;
 295         try {
 296             for (; i < a.length; i += vector_len) {
 297                 k = 0;
 298                 for (j = 0; j < vector_len; j++) {
 299                     if (m[(i + j) % SPECIES.length()]) {
 300                         Assert.assertEquals(r[i + j], a[i + k]);
 301                         k++;
 302                     } else {
 303                         Assert.assertEquals(r[i + j], (double)0);
 304                     }
 305                 }
 306             }
 307         } catch (AssertionError e) {
 308             int idx = i + j;
 309             if (m[idx % SPECIES.length()]) {
 310                 Assert.assertEquals(r[idx], a[i + k], "at index #" + idx);
 311             } else {
 312                 Assert.assertEquals(r[idx], (double)0, "at index #" + idx);
 313             }
 314         }
 315     }
 316 
 317     static void assertSelectFromArraysEquals(double[] r, double[] a, double[] order, int vector_len) {
 318         int i = 0, j = 0;
 319         try {
 320             for (; i < a.length; i += vector_len) {
 321                 for (j = 0; j < vector_len; j++) {
 322                     Assert.assertEquals(r[i+j], a[i+(int)order[i+j]]);
 323                 }
 324             }
 325         } catch (AssertionError e) {
 326             int idx = i + j;
 327             Assert.assertEquals(r[i+j], a[i+(int)order[i+j]], "at index #" + idx + ", input = " + a[i+(int)order[i+j]]);
 328         }
 329     }
 330 
 331     static void assertRearrangeArraysEquals(double[] r, double[] a, int[] order, boolean[] mask, int vector_len) {
 332         int i = 0, j = 0;
 333         try {
 334             for (; i < a.length; i += vector_len) {
 335                 for (j = 0; j < vector_len; j++) {
 336                     if (mask[j % SPECIES.length()])

1049                             i -> (((double)(i + 1) == 0) ? 1 : (double)(i + 1)));
1050             }),
1051             withToString("double[cornerCaseValue(i)]", (int s) -> {
1052                 return fill(s * BUFFER_REPS,
1053                             i -> (double)longCornerCaseValue(i));
1054             })
1055     );
1056 
1057 
1058     static void assertArraysEquals(long[] r, double[] a, int offs) {
1059         int i = 0;
1060         try {
1061             for (; i < r.length; i++) {
1062                 Assert.assertEquals(r[i], (long)(a[i+offs]));
1063             }
1064         } catch (AssertionError e) {
1065             Assert.assertEquals(r[i], (long)(a[i+offs]), "at index #" + i + ", input = " + a[i+offs]);
1066         }
1067     }
1068 


1069     static long bits(double e) {
1070         return  Double.doubleToLongBits(e);
1071     }
1072 
1073     static final List<IntFunction<double[]>> DOUBLE_GENERATORS = List.of(
1074             withToString("double[-i * 5]", (int s) -> {
1075                 return fill(s * BUFFER_REPS,
1076                             i -> (double)(-i * 5));
1077             }),
1078             withToString("double[i * 5]", (int s) -> {
1079                 return fill(s * BUFFER_REPS,
1080                             i -> (double)(i * 5));
1081             }),
1082             withToString("double[i + 1]", (int s) -> {
1083                 return fill(s * BUFFER_REPS,
1084                             i -> (((double)(i + 1) == 0) ? 1 : (double)(i + 1)));
1085             }),
1086             withToString("double[cornerCaseValue(i)]", (int s) -> {
1087                 return fill(s * BUFFER_REPS,
1088                             i -> cornerCaseValue(i));

1232 
1233     @DataProvider
1234     public Object[][] doubleUnaryOpSelectFromProvider() {
1235         return DOUBLE_SHUFFLE_GENERATORS.stream().
1236                 flatMap(fs -> DOUBLE_GENERATORS.stream().map(fa -> {
1237                     return new Object[] {fa, fs};
1238                 })).
1239                 toArray(Object[][]::new);
1240     }
1241 
1242     @DataProvider
1243     public Object[][] doubleUnaryOpSelectFromMaskProvider() {
1244         return BOOLEAN_MASK_GENERATORS.stream().
1245                 flatMap(fm -> DOUBLE_SHUFFLE_GENERATORS.stream().
1246                     flatMap(fs -> DOUBLE_GENERATORS.stream().map(fa -> {
1247                         return new Object[] {fa, fs, fm};
1248                 }))).
1249                 toArray(Object[][]::new);
1250     }
1251 

1252     static final List<IntFunction<double[]>> DOUBLE_COMPARE_GENERATORS = List.of(
1253             withToString("double[i]", (int s) -> {
1254                 return fill(s * BUFFER_REPS,
1255                             i -> (double)i);
1256             }),
1257             withToString("double[i - length / 2]", (int s) -> {
1258                 return fill(s * BUFFER_REPS,
1259                             i -> (double)(i - (s * BUFFER_REPS / 2)));
1260             }),
1261             withToString("double[i + 1]", (int s) -> {
1262                 return fill(s * BUFFER_REPS,
1263                             i -> (double)(i + 1));
1264             }),
1265             withToString("double[i - 2]", (int s) -> {
1266                 return fill(s * BUFFER_REPS,
1267                             i -> (double)(i - 2));
1268             }),
1269             withToString("double[zigZag(i)]", (int s) -> {
1270                 return fill(s * BUFFER_REPS,
1271                             i -> i%3 == 0 ? (double)i : (i%3 == 1 ? (double)(i + 1) : (double)(i - 2)));

1352 
1353     static double get(double[] a, int i) {
1354         return (double) a[i];
1355     }
1356 
1357     static final IntFunction<double[]> fr = (vl) -> {
1358         int length = BUFFER_REPS * vl;
1359         return new double[length];
1360     };
1361 
1362     static final IntFunction<boolean[]> fmr = (vl) -> {
1363         int length = BUFFER_REPS * vl;
1364         return new boolean[length];
1365     };
1366 
1367     static final IntFunction<long[]> lfr = (vl) -> {
1368         int length = BUFFER_REPS * vl;
1369         return new long[length];
1370     };
1371 

1372     static boolean eq(double a, double b) {
1373         return a == b;
1374     }
1375 
1376     static boolean neq(double a, double b) {
1377         return a != b;
1378     }
1379 
1380     static boolean lt(double a, double b) {
1381         return a < b;
1382     }
1383 
1384     static boolean le(double a, double b) {
1385         return a <= b;
1386     }
1387 
1388     static boolean gt(double a, double b) {
1389         return a > b;
1390     }
1391 
1392     static boolean ge(double a, double b) {
1393         return a >= b;
1394     }
1395 

1396     static double firstNonZero(double a, double b) {
1397         return Double.compare(a, (double) 0) != 0 ? a : b;
1398     }
1399 
1400     @Test
1401     static void smokeTest1() {
1402         DoubleVector three = DoubleVector.broadcast(SPECIES, (byte)-3);
1403         DoubleVector three2 = (DoubleVector) SPECIES.broadcast(-3);
1404         assert(three.eq(three2).allTrue());
1405         DoubleVector three3 = three2.broadcast(1).broadcast(-3);
1406         assert(three.eq(three3).allTrue());
1407         int scale = 2;
1408         Class<?> ETYPE = double.class;
1409         if (ETYPE == double.class || ETYPE == long.class)
1410             scale = 1000000;
1411         else if (ETYPE == byte.class && SPECIES.length() >= 64)
1412             scale = 1;
1413         DoubleVector higher = three.addIndex(scale);
1414         VectorMask<Double> m = three.compare(VectorOperators.LE, higher);
1415         assert(m.allTrue());

1492     static double ADD(double a, double b) {
1493         return (double)(a + b);
1494     }
1495 
1496     @Test(dataProvider = "doubleBinaryOpProvider")
1497     static void ADDDoubleMaxVectorTests(IntFunction<double[]> fa, IntFunction<double[]> fb) {
1498         double[] a = fa.apply(SPECIES.length());
1499         double[] b = fb.apply(SPECIES.length());
1500         double[] r = fr.apply(SPECIES.length());
1501 
1502         for (int ic = 0; ic < INVOC_COUNT; ic++) {
1503             for (int i = 0; i < a.length; i += SPECIES.length()) {
1504                 DoubleVector av = DoubleVector.fromArray(SPECIES, a, i);
1505                 DoubleVector bv = DoubleVector.fromArray(SPECIES, b, i);
1506                 av.lanewise(VectorOperators.ADD, bv).intoArray(r, i);
1507             }
1508         }
1509 
1510         assertArraysEquals(r, a, b, DoubleMaxVectorTests::ADD);
1511     }
1512 
1513     static double add(double a, double b) {
1514         return (double)(a + b);
1515     }
1516 
1517     @Test(dataProvider = "doubleBinaryOpProvider")
1518     static void addDoubleMaxVectorTests(IntFunction<double[]> fa, IntFunction<double[]> fb) {
1519         double[] a = fa.apply(SPECIES.length());
1520         double[] b = fb.apply(SPECIES.length());
1521         double[] r = fr.apply(SPECIES.length());
1522 
1523         for (int i = 0; i < a.length; i += SPECIES.length()) {
1524             DoubleVector av = DoubleVector.fromArray(SPECIES, a, i);
1525             DoubleVector bv = DoubleVector.fromArray(SPECIES, b, i);
1526             av.add(bv).intoArray(r, i);
1527         }
1528 
1529         assertArraysEquals(r, a, b, DoubleMaxVectorTests::add);
1530     }
1531 
1532     @Test(dataProvider = "doubleBinaryOpMaskProvider")

1549         assertArraysEquals(r, a, b, mask, DoubleMaxVectorTests::ADD);
1550     }
1551 
1552     @Test(dataProvider = "doubleBinaryOpMaskProvider")
1553     static void addDoubleMaxVectorTestsMasked(IntFunction<double[]> fa, IntFunction<double[]> fb,
1554                                           IntFunction<boolean[]> fm) {
1555         double[] a = fa.apply(SPECIES.length());
1556         double[] b = fb.apply(SPECIES.length());
1557         double[] r = fr.apply(SPECIES.length());
1558         boolean[] mask = fm.apply(SPECIES.length());
1559         VectorMask<Double> vmask = VectorMask.fromArray(SPECIES, mask, 0);
1560 
1561         for (int i = 0; i < a.length; i += SPECIES.length()) {
1562             DoubleVector av = DoubleVector.fromArray(SPECIES, a, i);
1563             DoubleVector bv = DoubleVector.fromArray(SPECIES, b, i);
1564             av.add(bv, vmask).intoArray(r, i);
1565         }
1566 
1567         assertArraysEquals(r, a, b, mask, DoubleMaxVectorTests::add);
1568     }
1569 
1570     static double SUB(double a, double b) {
1571         return (double)(a - b);
1572     }
1573 
1574     @Test(dataProvider = "doubleBinaryOpProvider")
1575     static void SUBDoubleMaxVectorTests(IntFunction<double[]> fa, IntFunction<double[]> fb) {
1576         double[] a = fa.apply(SPECIES.length());
1577         double[] b = fb.apply(SPECIES.length());
1578         double[] r = fr.apply(SPECIES.length());
1579 
1580         for (int ic = 0; ic < INVOC_COUNT; ic++) {
1581             for (int i = 0; i < a.length; i += SPECIES.length()) {
1582                 DoubleVector av = DoubleVector.fromArray(SPECIES, a, i);
1583                 DoubleVector bv = DoubleVector.fromArray(SPECIES, b, i);
1584                 av.lanewise(VectorOperators.SUB, bv).intoArray(r, i);
1585             }
1586         }
1587 
1588         assertArraysEquals(r, a, b, DoubleMaxVectorTests::SUB);
1589     }
1590 
1591     static double sub(double a, double b) {
1592         return (double)(a - b);
1593     }
1594 
1595     @Test(dataProvider = "doubleBinaryOpProvider")
1596     static void subDoubleMaxVectorTests(IntFunction<double[]> fa, IntFunction<double[]> fb) {
1597         double[] a = fa.apply(SPECIES.length());
1598         double[] b = fb.apply(SPECIES.length());
1599         double[] r = fr.apply(SPECIES.length());
1600 
1601         for (int i = 0; i < a.length; i += SPECIES.length()) {
1602             DoubleVector av = DoubleVector.fromArray(SPECIES, a, i);
1603             DoubleVector bv = DoubleVector.fromArray(SPECIES, b, i);
1604             av.sub(bv).intoArray(r, i);
1605         }
1606 
1607         assertArraysEquals(r, a, b, DoubleMaxVectorTests::sub);
1608     }
1609 
1610     @Test(dataProvider = "doubleBinaryOpMaskProvider")

1627         assertArraysEquals(r, a, b, mask, DoubleMaxVectorTests::SUB);
1628     }
1629 
1630     @Test(dataProvider = "doubleBinaryOpMaskProvider")
1631     static void subDoubleMaxVectorTestsMasked(IntFunction<double[]> fa, IntFunction<double[]> fb,
1632                                           IntFunction<boolean[]> fm) {
1633         double[] a = fa.apply(SPECIES.length());
1634         double[] b = fb.apply(SPECIES.length());
1635         double[] r = fr.apply(SPECIES.length());
1636         boolean[] mask = fm.apply(SPECIES.length());
1637         VectorMask<Double> vmask = VectorMask.fromArray(SPECIES, mask, 0);
1638 
1639         for (int i = 0; i < a.length; i += SPECIES.length()) {
1640             DoubleVector av = DoubleVector.fromArray(SPECIES, a, i);
1641             DoubleVector bv = DoubleVector.fromArray(SPECIES, b, i);
1642             av.sub(bv, vmask).intoArray(r, i);
1643         }
1644 
1645         assertArraysEquals(r, a, b, mask, DoubleMaxVectorTests::sub);
1646     }
1647 
1648     static double MUL(double a, double b) {
1649         return (double)(a * b);
1650     }
1651 
1652     @Test(dataProvider = "doubleBinaryOpProvider")
1653     static void MULDoubleMaxVectorTests(IntFunction<double[]> fa, IntFunction<double[]> fb) {
1654         double[] a = fa.apply(SPECIES.length());
1655         double[] b = fb.apply(SPECIES.length());
1656         double[] r = fr.apply(SPECIES.length());
1657 
1658         for (int ic = 0; ic < INVOC_COUNT; ic++) {
1659             for (int i = 0; i < a.length; i += SPECIES.length()) {
1660                 DoubleVector av = DoubleVector.fromArray(SPECIES, a, i);
1661                 DoubleVector bv = DoubleVector.fromArray(SPECIES, b, i);
1662                 av.lanewise(VectorOperators.MUL, bv).intoArray(r, i);
1663             }
1664         }
1665 
1666         assertArraysEquals(r, a, b, DoubleMaxVectorTests::MUL);
1667     }
1668 
1669     static double mul(double a, double b) {
1670         return (double)(a * b);
1671     }
1672 
1673     @Test(dataProvider = "doubleBinaryOpProvider")
1674     static void mulDoubleMaxVectorTests(IntFunction<double[]> fa, IntFunction<double[]> fb) {
1675         double[] a = fa.apply(SPECIES.length());
1676         double[] b = fb.apply(SPECIES.length());
1677         double[] r = fr.apply(SPECIES.length());
1678 
1679         for (int i = 0; i < a.length; i += SPECIES.length()) {
1680             DoubleVector av = DoubleVector.fromArray(SPECIES, a, i);
1681             DoubleVector bv = DoubleVector.fromArray(SPECIES, b, i);
1682             av.mul(bv).intoArray(r, i);
1683         }
1684 
1685         assertArraysEquals(r, a, b, DoubleMaxVectorTests::mul);
1686     }
1687 
1688     @Test(dataProvider = "doubleBinaryOpMaskProvider")

1726     static double DIV(double a, double b) {
1727         return (double)(a / b);
1728     }
1729 
1730     @Test(dataProvider = "doubleBinaryOpProvider")
1731     static void DIVDoubleMaxVectorTests(IntFunction<double[]> fa, IntFunction<double[]> fb) {
1732         double[] a = fa.apply(SPECIES.length());
1733         double[] b = fb.apply(SPECIES.length());
1734         double[] r = fr.apply(SPECIES.length());
1735 
1736         for (int ic = 0; ic < INVOC_COUNT; ic++) {
1737             for (int i = 0; i < a.length; i += SPECIES.length()) {
1738                 DoubleVector av = DoubleVector.fromArray(SPECIES, a, i);
1739                 DoubleVector bv = DoubleVector.fromArray(SPECIES, b, i);
1740                 av.lanewise(VectorOperators.DIV, bv).intoArray(r, i);
1741             }
1742         }
1743 
1744         assertArraysEquals(r, a, b, DoubleMaxVectorTests::DIV);
1745     }
1746 
1747     static double div(double a, double b) {
1748         return (double)(a / b);
1749     }
1750 
1751     @Test(dataProvider = "doubleBinaryOpProvider")
1752     static void divDoubleMaxVectorTests(IntFunction<double[]> fa, IntFunction<double[]> fb) {
1753         double[] a = fa.apply(SPECIES.length());
1754         double[] b = fb.apply(SPECIES.length());
1755         double[] r = fr.apply(SPECIES.length());
1756 
1757         for (int i = 0; i < a.length; i += SPECIES.length()) {
1758             DoubleVector av = DoubleVector.fromArray(SPECIES, a, i);
1759             DoubleVector bv = DoubleVector.fromArray(SPECIES, b, i);
1760             av.div(bv).intoArray(r, i);
1761         }
1762 
1763         assertArraysEquals(r, a, b, DoubleMaxVectorTests::div);
1764     }
1765 


1766     @Test(dataProvider = "doubleBinaryOpMaskProvider")
1767     static void DIVDoubleMaxVectorTestsMasked(IntFunction<double[]> fa, IntFunction<double[]> fb,
1768                                           IntFunction<boolean[]> fm) {
1769         double[] a = fa.apply(SPECIES.length());
1770         double[] b = fb.apply(SPECIES.length());
1771         double[] r = fr.apply(SPECIES.length());
1772         boolean[] mask = fm.apply(SPECIES.length());
1773         VectorMask<Double> vmask = VectorMask.fromArray(SPECIES, mask, 0);
1774 
1775         for (int ic = 0; ic < INVOC_COUNT; ic++) {
1776             for (int i = 0; i < a.length; i += SPECIES.length()) {
1777                 DoubleVector av = DoubleVector.fromArray(SPECIES, a, i);
1778                 DoubleVector bv = DoubleVector.fromArray(SPECIES, b, i);
1779                 av.lanewise(VectorOperators.DIV, bv, vmask).intoArray(r, i);
1780             }
1781         }
1782 
1783         assertArraysEquals(r, a, b, mask, DoubleMaxVectorTests::DIV);
1784     }
1785 
1786     @Test(dataProvider = "doubleBinaryOpMaskProvider")
1787     static void divDoubleMaxVectorTestsMasked(IntFunction<double[]> fa, IntFunction<double[]> fb,
1788                                           IntFunction<boolean[]> fm) {
1789         double[] a = fa.apply(SPECIES.length());
1790         double[] b = fb.apply(SPECIES.length());
1791         double[] r = fr.apply(SPECIES.length());
1792         boolean[] mask = fm.apply(SPECIES.length());
1793         VectorMask<Double> vmask = VectorMask.fromArray(SPECIES, mask, 0);
1794 
1795         for (int i = 0; i < a.length; i += SPECIES.length()) {
1796             DoubleVector av = DoubleVector.fromArray(SPECIES, a, i);
1797             DoubleVector bv = DoubleVector.fromArray(SPECIES, b, i);
1798             av.div(bv, vmask).intoArray(r, i);
1799         }
1800 
1801         assertArraysEquals(r, a, b, mask, DoubleMaxVectorTests::div);
1802     }
1803 


1804     static double FIRST_NONZERO(double a, double b) {
1805         return (double)(Double.doubleToLongBits(a)!=0?a:b);
1806     }
1807 
1808     @Test(dataProvider = "doubleBinaryOpProvider")
1809     static void FIRST_NONZERODoubleMaxVectorTests(IntFunction<double[]> fa, IntFunction<double[]> fb) {
1810         double[] a = fa.apply(SPECIES.length());
1811         double[] b = fb.apply(SPECIES.length());
1812         double[] r = fr.apply(SPECIES.length());
1813 
1814         for (int ic = 0; ic < INVOC_COUNT; ic++) {
1815             for (int i = 0; i < a.length; i += SPECIES.length()) {
1816                 DoubleVector av = DoubleVector.fromArray(SPECIES, a, i);
1817                 DoubleVector bv = DoubleVector.fromArray(SPECIES, b, i);
1818                 av.lanewise(VectorOperators.FIRST_NONZERO, bv).intoArray(r, i);
1819             }
1820         }
1821 
1822         assertArraysEquals(r, a, b, DoubleMaxVectorTests::FIRST_NONZERO);
1823     }

1825     @Test(dataProvider = "doubleBinaryOpMaskProvider")
1826     static void FIRST_NONZERODoubleMaxVectorTestsMasked(IntFunction<double[]> fa, IntFunction<double[]> fb,
1827                                           IntFunction<boolean[]> fm) {
1828         double[] a = fa.apply(SPECIES.length());
1829         double[] b = fb.apply(SPECIES.length());
1830         double[] r = fr.apply(SPECIES.length());
1831         boolean[] mask = fm.apply(SPECIES.length());
1832         VectorMask<Double> vmask = VectorMask.fromArray(SPECIES, mask, 0);
1833 
1834         for (int ic = 0; ic < INVOC_COUNT; ic++) {
1835             for (int i = 0; i < a.length; i += SPECIES.length()) {
1836                 DoubleVector av = DoubleVector.fromArray(SPECIES, a, i);
1837                 DoubleVector bv = DoubleVector.fromArray(SPECIES, b, i);
1838                 av.lanewise(VectorOperators.FIRST_NONZERO, bv, vmask).intoArray(r, i);
1839             }
1840         }
1841 
1842         assertArraysEquals(r, a, b, mask, DoubleMaxVectorTests::FIRST_NONZERO);
1843     }
1844 








1845     @Test(dataProvider = "doubleBinaryOpProvider")
1846     static void addDoubleMaxVectorTestsBroadcastSmokeTest(IntFunction<double[]> fa, IntFunction<double[]> fb) {
1847         double[] a = fa.apply(SPECIES.length());
1848         double[] b = fb.apply(SPECIES.length());
1849         double[] r = fr.apply(SPECIES.length());
1850 
1851         for (int i = 0; i < a.length; i += SPECIES.length()) {
1852             DoubleVector av = DoubleVector.fromArray(SPECIES, a, i);
1853             av.add(b[i]).intoArray(r, i);
1854         }
1855 
1856         assertBroadcastArraysEquals(r, a, b, DoubleMaxVectorTests::add);
1857     }
1858 
1859     @Test(dataProvider = "doubleBinaryOpMaskProvider")
1860     static void addDoubleMaxVectorTestsBroadcastMaskedSmokeTest(IntFunction<double[]> fa, IntFunction<double[]> fb,
1861                                           IntFunction<boolean[]> fm) {
1862         double[] a = fa.apply(SPECIES.length());
1863         double[] b = fb.apply(SPECIES.length());
1864         double[] r = fr.apply(SPECIES.length());

1918         assertBroadcastArraysEquals(r, a, b, DoubleMaxVectorTests::mul);
1919     }
1920 
1921     @Test(dataProvider = "doubleBinaryOpMaskProvider")
1922     static void mulDoubleMaxVectorTestsBroadcastMaskedSmokeTest(IntFunction<double[]> fa, IntFunction<double[]> fb,
1923                                           IntFunction<boolean[]> fm) {
1924         double[] a = fa.apply(SPECIES.length());
1925         double[] b = fb.apply(SPECIES.length());
1926         double[] r = fr.apply(SPECIES.length());
1927         boolean[] mask = fm.apply(SPECIES.length());
1928         VectorMask<Double> vmask = VectorMask.fromArray(SPECIES, mask, 0);
1929 
1930         for (int i = 0; i < a.length; i += SPECIES.length()) {
1931             DoubleVector av = DoubleVector.fromArray(SPECIES, a, i);
1932             av.mul(b[i], vmask).intoArray(r, i);
1933         }
1934 
1935         assertBroadcastArraysEquals(r, a, b, mask, DoubleMaxVectorTests::mul);
1936     }
1937 

1938     @Test(dataProvider = "doubleBinaryOpProvider")
1939     static void divDoubleMaxVectorTestsBroadcastSmokeTest(IntFunction<double[]> fa, IntFunction<double[]> fb) {
1940         double[] a = fa.apply(SPECIES.length());
1941         double[] b = fb.apply(SPECIES.length());
1942         double[] r = fr.apply(SPECIES.length());
1943 
1944         for (int i = 0; i < a.length; i += SPECIES.length()) {
1945             DoubleVector av = DoubleVector.fromArray(SPECIES, a, i);
1946             av.div(b[i]).intoArray(r, i);
1947         }
1948 
1949         assertBroadcastArraysEquals(r, a, b, DoubleMaxVectorTests::div);
1950     }
1951 


1952     @Test(dataProvider = "doubleBinaryOpMaskProvider")
1953     static void divDoubleMaxVectorTestsBroadcastMaskedSmokeTest(IntFunction<double[]> fa, IntFunction<double[]> fb,
1954                                           IntFunction<boolean[]> fm) {
1955         double[] a = fa.apply(SPECIES.length());
1956         double[] b = fb.apply(SPECIES.length());
1957         double[] r = fr.apply(SPECIES.length());
1958         boolean[] mask = fm.apply(SPECIES.length());
1959         VectorMask<Double> vmask = VectorMask.fromArray(SPECIES, mask, 0);
1960 
1961         for (int i = 0; i < a.length; i += SPECIES.length()) {
1962             DoubleVector av = DoubleVector.fromArray(SPECIES, a, i);
1963             av.div(b[i], vmask).intoArray(r, i);
1964         }
1965 
1966         assertBroadcastArraysEquals(r, a, b, mask, DoubleMaxVectorTests::div);
1967     }
1968 









1969     @Test(dataProvider = "doubleBinaryOpProvider")
1970     static void ADDDoubleMaxVectorTestsBroadcastLongSmokeTest(IntFunction<double[]> fa, IntFunction<double[]> fb) {
1971         double[] a = fa.apply(SPECIES.length());
1972         double[] b = fb.apply(SPECIES.length());
1973         double[] r = fr.apply(SPECIES.length());
1974 
1975         for (int i = 0; i < a.length; i += SPECIES.length()) {
1976             DoubleVector av = DoubleVector.fromArray(SPECIES, a, i);
1977             av.lanewise(VectorOperators.ADD, (long)b[i]).intoArray(r, i);
1978         }
1979 
1980         assertBroadcastLongArraysEquals(r, a, b, DoubleMaxVectorTests::ADD);
1981     }
1982 
1983     @Test(dataProvider = "doubleBinaryOpMaskProvider")
1984     static void ADDDoubleMaxVectorTestsBroadcastMaskedLongSmokeTest(IntFunction<double[]> fa, IntFunction<double[]> fb,
1985                                           IntFunction<boolean[]> fm) {
1986         double[] a = fa.apply(SPECIES.length());
1987         double[] b = fb.apply(SPECIES.length());
1988         double[] r = fr.apply(SPECIES.length());
1989         boolean[] mask = fm.apply(SPECIES.length());
1990         VectorMask<Double> vmask = VectorMask.fromArray(SPECIES, mask, 0);
1991 
1992         for (int i = 0; i < a.length; i += SPECIES.length()) {
1993             DoubleVector av = DoubleVector.fromArray(SPECIES, a, i);
1994             av.lanewise(VectorOperators.ADD, (long)b[i], vmask).intoArray(r, i);
1995         }
1996 
1997         assertBroadcastLongArraysEquals(r, a, b, mask, DoubleMaxVectorTests::ADD);
1998     }
1999 

























































2000     static double MIN(double a, double b) {
2001         return (double)(Math.min(a, b));
2002     }
2003 
2004     @Test(dataProvider = "doubleBinaryOpProvider")
2005     static void MINDoubleMaxVectorTests(IntFunction<double[]> fa, IntFunction<double[]> fb) {
2006         double[] a = fa.apply(SPECIES.length());
2007         double[] b = fb.apply(SPECIES.length());
2008         double[] r = fr.apply(SPECIES.length());
2009 
2010         for (int ic = 0; ic < INVOC_COUNT; ic++) {
2011             for (int i = 0; i < a.length; i += SPECIES.length()) {
2012                 DoubleVector av = DoubleVector.fromArray(SPECIES, a, i);
2013                 DoubleVector bv = DoubleVector.fromArray(SPECIES, b, i);
2014                 av.lanewise(VectorOperators.MIN, bv).intoArray(r, i);
2015             }
2016         }
2017 
2018         assertArraysEquals(r, a, b, DoubleMaxVectorTests::MIN);
2019     }
2020 
2021     static double min(double a, double b) {
2022         return (double)(Math.min(a, b));
2023     }
2024 
2025     @Test(dataProvider = "doubleBinaryOpProvider")
2026     static void minDoubleMaxVectorTests(IntFunction<double[]> fa, IntFunction<double[]> fb) {
2027         double[] a = fa.apply(SPECIES.length());
2028         double[] b = fb.apply(SPECIES.length());
2029         double[] r = fr.apply(SPECIES.length());
2030 
2031         for (int i = 0; i < a.length; i += SPECIES.length()) {
2032             DoubleVector av = DoubleVector.fromArray(SPECIES, a, i);
2033             DoubleVector bv = DoubleVector.fromArray(SPECIES, b, i);
2034             av.min(bv).intoArray(r, i);
2035         }
2036 
2037         assertArraysEquals(r, a, b, DoubleMaxVectorTests::min);
2038     }
2039 
2040     static double MAX(double a, double b) {
2041         return (double)(Math.max(a, b));
2042     }
2043 
2044     @Test(dataProvider = "doubleBinaryOpProvider")
2045     static void MAXDoubleMaxVectorTests(IntFunction<double[]> fa, IntFunction<double[]> fb) {
2046         double[] a = fa.apply(SPECIES.length());
2047         double[] b = fb.apply(SPECIES.length());
2048         double[] r = fr.apply(SPECIES.length());
2049 
2050         for (int ic = 0; ic < INVOC_COUNT; ic++) {
2051             for (int i = 0; i < a.length; i += SPECIES.length()) {
2052                 DoubleVector av = DoubleVector.fromArray(SPECIES, a, i);
2053                 DoubleVector bv = DoubleVector.fromArray(SPECIES, b, i);
2054                 av.lanewise(VectorOperators.MAX, bv).intoArray(r, i);
2055             }
2056         }
2057 
2058         assertArraysEquals(r, a, b, DoubleMaxVectorTests::MAX);
2059     }
2060 
2061     static double max(double a, double b) {
2062         return (double)(Math.max(a, b));
2063     }
2064 
2065     @Test(dataProvider = "doubleBinaryOpProvider")
2066     static void maxDoubleMaxVectorTests(IntFunction<double[]> fa, IntFunction<double[]> fb) {
2067         double[] a = fa.apply(SPECIES.length());
2068         double[] b = fb.apply(SPECIES.length());
2069         double[] r = fr.apply(SPECIES.length());
2070 
2071         for (int i = 0; i < a.length; i += SPECIES.length()) {
2072             DoubleVector av = DoubleVector.fromArray(SPECIES, a, i);
2073             DoubleVector bv = DoubleVector.fromArray(SPECIES, b, i);
2074             av.max(bv).intoArray(r, i);
2075         }
2076 
2077         assertArraysEquals(r, a, b, DoubleMaxVectorTests::max);
2078     }
2079 
2080     @Test(dataProvider = "doubleBinaryOpProvider")

2116             av.lanewise(VectorOperators.MAX, b[i]).intoArray(r, i);
2117         }
2118 
2119         assertBroadcastArraysEquals(r, a, b, DoubleMaxVectorTests::MAX);
2120     }
2121 
2122     @Test(dataProvider = "doubleBinaryOpProvider")
2123     static void maxDoubleMaxVectorTestsBroadcastSmokeTest(IntFunction<double[]> fa, IntFunction<double[]> fb) {
2124         double[] a = fa.apply(SPECIES.length());
2125         double[] b = fb.apply(SPECIES.length());
2126         double[] r = fr.apply(SPECIES.length());
2127 
2128         for (int i = 0; i < a.length; i += SPECIES.length()) {
2129             DoubleVector av = DoubleVector.fromArray(SPECIES, a, i);
2130             av.max(b[i]).intoArray(r, i);
2131         }
2132 
2133         assertBroadcastArraysEquals(r, a, b, DoubleMaxVectorTests::max);
2134     }
2135 











2136     static double ADDReduce(double[] a, int idx) {
2137         double res = 0;
2138         for (int i = idx; i < (idx + SPECIES.length()); i++) {
2139             res += a[i];
2140         }
2141 
2142         return res;
2143     }
2144 
2145     static double ADDReduceAll(double[] a) {
2146         double res = 0;
2147         for (int i = 0; i < a.length; i += SPECIES.length()) {
2148             res += ADDReduce(a, i);
2149         }
2150 
2151         return res;
2152     }
2153 
2154     @Test(dataProvider = "doubleUnaryOpProvider")
2155     static void ADDReduceDoubleMaxVectorTests(IntFunction<double[]> fa) {
2156         double[] a = fa.apply(SPECIES.length());
2157         double[] r = fr.apply(SPECIES.length());
2158         double ra = 0;
2159 
2160         for (int ic = 0; ic < INVOC_COUNT; ic++) {
2161             for (int i = 0; i < a.length; i += SPECIES.length()) {
2162                 DoubleVector av = DoubleVector.fromArray(SPECIES, a, i);
2163                 r[i] = av.reduceLanes(VectorOperators.ADD);
2164             }
2165         }
2166 
2167         for (int ic = 0; ic < INVOC_COUNT; ic++) {
2168             ra = 0;
2169             for (int i = 0; i < a.length; i += SPECIES.length()) {
2170                 DoubleVector av = DoubleVector.fromArray(SPECIES, a, i);
2171                 ra += av.reduceLanes(VectorOperators.ADD);
2172             }
2173         }
2174 
2175         assertReductionArraysEquals(r, ra, a,
2176                 DoubleMaxVectorTests::ADDReduce, DoubleMaxVectorTests::ADDReduceAll);
2177     }
2178 
2179     static double ADDReduceMasked(double[] a, int idx, boolean[] mask) {
2180         double res = 0;
2181         for (int i = idx; i < (idx + SPECIES.length()); i++) {
2182             if (mask[i % SPECIES.length()])
2183                 res += a[i];
2184         }
2185 
2186         return res;
2187     }
2188 
2189     static double ADDReduceAllMasked(double[] a, boolean[] mask) {
2190         double res = 0;
2191         for (int i = 0; i < a.length; i += SPECIES.length()) {
2192             res += ADDReduceMasked(a, i, mask);
2193         }
2194 
2195         return res;
2196     }
2197 
2198     @Test(dataProvider = "doubleUnaryOpMaskProvider")
2199     static void ADDReduceDoubleMaxVectorTestsMasked(IntFunction<double[]> fa, IntFunction<boolean[]> fm) {
2200         double[] a = fa.apply(SPECIES.length());
2201         double[] r = fr.apply(SPECIES.length());
2202         boolean[] mask = fm.apply(SPECIES.length());
2203         VectorMask<Double> vmask = VectorMask.fromArray(SPECIES, mask, 0);
2204         double ra = 0;
2205 
2206         for (int ic = 0; ic < INVOC_COUNT; ic++) {
2207             for (int i = 0; i < a.length; i += SPECIES.length()) {
2208                 DoubleVector av = DoubleVector.fromArray(SPECIES, a, i);
2209                 r[i] = av.reduceLanes(VectorOperators.ADD, vmask);
2210             }
2211         }
2212 
2213         for (int ic = 0; ic < INVOC_COUNT; ic++) {
2214             ra = 0;
2215             for (int i = 0; i < a.length; i += SPECIES.length()) {
2216                 DoubleVector av = DoubleVector.fromArray(SPECIES, a, i);
2217                 ra += av.reduceLanes(VectorOperators.ADD, vmask);
2218             }
2219         }
2220 
2221         assertReductionArraysEqualsMasked(r, ra, a, mask,
2222                 DoubleMaxVectorTests::ADDReduceMasked, DoubleMaxVectorTests::ADDReduceAllMasked);
2223     }
2224 
2225     static double MULReduce(double[] a, int idx) {
2226         double res = 1;
2227         for (int i = idx; i < (idx + SPECIES.length()); i++) {
2228             res *= a[i];
2229         }
2230 
2231         return res;
2232     }
2233 
2234     static double MULReduceAll(double[] a) {
2235         double res = 1;
2236         for (int i = 0; i < a.length; i += SPECIES.length()) {
2237             res *= MULReduce(a, i);
2238         }
2239 
2240         return res;
2241     }
2242 
2243     @Test(dataProvider = "doubleUnaryOpProvider")
2244     static void MULReduceDoubleMaxVectorTests(IntFunction<double[]> fa) {
2245         double[] a = fa.apply(SPECIES.length());
2246         double[] r = fr.apply(SPECIES.length());
2247         double ra = 1;
2248 
2249         for (int ic = 0; ic < INVOC_COUNT; ic++) {
2250             for (int i = 0; i < a.length; i += SPECIES.length()) {
2251                 DoubleVector av = DoubleVector.fromArray(SPECIES, a, i);
2252                 r[i] = av.reduceLanes(VectorOperators.MUL);
2253             }
2254         }
2255 
2256         for (int ic = 0; ic < INVOC_COUNT; ic++) {
2257             ra = 1;
2258             for (int i = 0; i < a.length; i += SPECIES.length()) {
2259                 DoubleVector av = DoubleVector.fromArray(SPECIES, a, i);
2260                 ra *= av.reduceLanes(VectorOperators.MUL);
2261             }
2262         }
2263 
2264         assertReductionArraysEquals(r, ra, a,
2265                 DoubleMaxVectorTests::MULReduce, DoubleMaxVectorTests::MULReduceAll);
2266     }
2267 
2268     static double MULReduceMasked(double[] a, int idx, boolean[] mask) {
2269         double res = 1;
2270         for (int i = idx; i < (idx + SPECIES.length()); i++) {
2271             if (mask[i % SPECIES.length()])
2272                 res *= a[i];
2273         }
2274 
2275         return res;
2276     }
2277 
2278     static double MULReduceAllMasked(double[] a, boolean[] mask) {
2279         double res = 1;
2280         for (int i = 0; i < a.length; i += SPECIES.length()) {
2281             res *= MULReduceMasked(a, i, mask);
2282         }
2283 
2284         return res;
2285     }
2286 
2287     @Test(dataProvider = "doubleUnaryOpMaskProvider")
2288     static void MULReduceDoubleMaxVectorTestsMasked(IntFunction<double[]> fa, IntFunction<boolean[]> fm) {
2289         double[] a = fa.apply(SPECIES.length());
2290         double[] r = fr.apply(SPECIES.length());
2291         boolean[] mask = fm.apply(SPECIES.length());
2292         VectorMask<Double> vmask = VectorMask.fromArray(SPECIES, mask, 0);
2293         double ra = 1;
2294 
2295         for (int ic = 0; ic < INVOC_COUNT; ic++) {
2296             for (int i = 0; i < a.length; i += SPECIES.length()) {
2297                 DoubleVector av = DoubleVector.fromArray(SPECIES, a, i);
2298                 r[i] = av.reduceLanes(VectorOperators.MUL, vmask);
2299             }
2300         }
2301 
2302         for (int ic = 0; ic < INVOC_COUNT; ic++) {
2303             ra = 1;
2304             for (int i = 0; i < a.length; i += SPECIES.length()) {
2305                 DoubleVector av = DoubleVector.fromArray(SPECIES, a, i);
2306                 ra *= av.reduceLanes(VectorOperators.MUL, vmask);
2307             }
2308         }
2309 
2310         assertReductionArraysEqualsMasked(r, ra, a, mask,
2311                 DoubleMaxVectorTests::MULReduceMasked, DoubleMaxVectorTests::MULReduceAllMasked);
2312     }
2313 
2314     static double MINReduce(double[] a, int idx) {
2315         double res = Double.POSITIVE_INFINITY;
2316         for (int i = idx; i < (idx + SPECIES.length()); i++) {
2317             res = (double) Math.min(res, a[i]);
2318         }
2319 
2320         return res;
2321     }
2322 
2323     static double MINReduceAll(double[] a) {
2324         double res = Double.POSITIVE_INFINITY;
2325         for (int i = 0; i < a.length; i += SPECIES.length()) {
2326             res = (double) Math.min(res, MINReduce(a, i));
2327         }
2328 
2329         return res;
2330     }
2331 
2332     @Test(dataProvider = "doubleUnaryOpProvider")
2333     static void MINReduceDoubleMaxVectorTests(IntFunction<double[]> fa) {
2334         double[] a = fa.apply(SPECIES.length());
2335         double[] r = fr.apply(SPECIES.length());
2336         double ra = Double.POSITIVE_INFINITY;
2337 
2338         for (int ic = 0; ic < INVOC_COUNT; ic++) {
2339             for (int i = 0; i < a.length; i += SPECIES.length()) {
2340                 DoubleVector av = DoubleVector.fromArray(SPECIES, a, i);
2341                 r[i] = av.reduceLanes(VectorOperators.MIN);
2342             }
2343         }
2344 
2345         for (int ic = 0; ic < INVOC_COUNT; ic++) {
2346             ra = Double.POSITIVE_INFINITY;
2347             for (int i = 0; i < a.length; i += SPECIES.length()) {
2348                 DoubleVector av = DoubleVector.fromArray(SPECIES, a, i);
2349                 ra = (double) Math.min(ra, av.reduceLanes(VectorOperators.MIN));
2350             }
2351         }
2352 
2353         assertReductionArraysEquals(r, ra, a,
2354                 DoubleMaxVectorTests::MINReduce, DoubleMaxVectorTests::MINReduceAll);
2355     }
2356 
2357     static double MINReduceMasked(double[] a, int idx, boolean[] mask) {
2358         double res = Double.POSITIVE_INFINITY;
2359         for (int i = idx; i < (idx + SPECIES.length()); i++) {
2360             if (mask[i % SPECIES.length()])
2361                 res = (double) Math.min(res, a[i]);
2362         }
2363 
2364         return res;
2365     }
2366 
2367     static double MINReduceAllMasked(double[] a, boolean[] mask) {
2368         double res = Double.POSITIVE_INFINITY;
2369         for (int i = 0; i < a.length; i += SPECIES.length()) {
2370             res = (double) Math.min(res, MINReduceMasked(a, i, mask));
2371         }
2372 
2373         return res;
2374     }
2375 
2376     @Test(dataProvider = "doubleUnaryOpMaskProvider")
2377     static void MINReduceDoubleMaxVectorTestsMasked(IntFunction<double[]> fa, IntFunction<boolean[]> fm) {
2378         double[] a = fa.apply(SPECIES.length());
2379         double[] r = fr.apply(SPECIES.length());
2380         boolean[] mask = fm.apply(SPECIES.length());
2381         VectorMask<Double> vmask = VectorMask.fromArray(SPECIES, mask, 0);
2382         double ra = Double.POSITIVE_INFINITY;
2383 
2384         for (int ic = 0; ic < INVOC_COUNT; ic++) {
2385             for (int i = 0; i < a.length; i += SPECIES.length()) {
2386                 DoubleVector av = DoubleVector.fromArray(SPECIES, a, i);
2387                 r[i] = av.reduceLanes(VectorOperators.MIN, vmask);
2388             }
2389         }
2390 
2391         for (int ic = 0; ic < INVOC_COUNT; ic++) {
2392             ra = Double.POSITIVE_INFINITY;
2393             for (int i = 0; i < a.length; i += SPECIES.length()) {
2394                 DoubleVector av = DoubleVector.fromArray(SPECIES, a, i);
2395                 ra = (double) Math.min(ra, av.reduceLanes(VectorOperators.MIN, vmask));
2396             }
2397         }
2398 
2399         assertReductionArraysEqualsMasked(r, ra, a, mask,
2400                 DoubleMaxVectorTests::MINReduceMasked, DoubleMaxVectorTests::MINReduceAllMasked);
2401     }
2402 
2403     static double MAXReduce(double[] a, int idx) {
2404         double res = Double.NEGATIVE_INFINITY;
2405         for (int i = idx; i < (idx + SPECIES.length()); i++) {
2406             res = (double) Math.max(res, a[i]);
2407         }
2408 
2409         return res;
2410     }
2411 
2412     static double MAXReduceAll(double[] a) {
2413         double res = Double.NEGATIVE_INFINITY;
2414         for (int i = 0; i < a.length; i += SPECIES.length()) {
2415             res = (double) Math.max(res, MAXReduce(a, i));
2416         }
2417 
2418         return res;
2419     }
2420 
2421     @Test(dataProvider = "doubleUnaryOpProvider")
2422     static void MAXReduceDoubleMaxVectorTests(IntFunction<double[]> fa) {
2423         double[] a = fa.apply(SPECIES.length());
2424         double[] r = fr.apply(SPECIES.length());
2425         double ra = Double.NEGATIVE_INFINITY;
2426 
2427         for (int ic = 0; ic < INVOC_COUNT; ic++) {
2428             for (int i = 0; i < a.length; i += SPECIES.length()) {
2429                 DoubleVector av = DoubleVector.fromArray(SPECIES, a, i);
2430                 r[i] = av.reduceLanes(VectorOperators.MAX);
2431             }
2432         }
2433 
2434         for (int ic = 0; ic < INVOC_COUNT; ic++) {
2435             ra = Double.NEGATIVE_INFINITY;
2436             for (int i = 0; i < a.length; i += SPECIES.length()) {
2437                 DoubleVector av = DoubleVector.fromArray(SPECIES, a, i);
2438                 ra = (double) Math.max(ra, av.reduceLanes(VectorOperators.MAX));
2439             }
2440         }
2441 
2442         assertReductionArraysEquals(r, ra, a,
2443                 DoubleMaxVectorTests::MAXReduce, DoubleMaxVectorTests::MAXReduceAll);
2444     }
2445 
2446     static double MAXReduceMasked(double[] a, int idx, boolean[] mask) {
2447         double res = Double.NEGATIVE_INFINITY;
2448         for (int i = idx; i < (idx + SPECIES.length()); i++) {
2449             if (mask[i % SPECIES.length()])
2450                 res = (double) Math.max(res, a[i]);
2451         }
2452 
2453         return res;
2454     }
2455 
2456     static double MAXReduceAllMasked(double[] a, boolean[] mask) {
2457         double res = Double.NEGATIVE_INFINITY;
2458         for (int i = 0; i < a.length; i += SPECIES.length()) {
2459             res = (double) Math.max(res, MAXReduceMasked(a, i, mask));
2460         }
2461 
2462         return res;
2463     }
2464 
2465     @Test(dataProvider = "doubleUnaryOpMaskProvider")
2466     static void MAXReduceDoubleMaxVectorTestsMasked(IntFunction<double[]> fa, IntFunction<boolean[]> fm) {
2467         double[] a = fa.apply(SPECIES.length());
2468         double[] r = fr.apply(SPECIES.length());
2469         boolean[] mask = fm.apply(SPECIES.length());
2470         VectorMask<Double> vmask = VectorMask.fromArray(SPECIES, mask, 0);
2471         double ra = Double.NEGATIVE_INFINITY;
2472 
2473         for (int ic = 0; ic < INVOC_COUNT; ic++) {
2474             for (int i = 0; i < a.length; i += SPECIES.length()) {
2475                 DoubleVector av = DoubleVector.fromArray(SPECIES, a, i);
2476                 r[i] = av.reduceLanes(VectorOperators.MAX, vmask);
2477             }
2478         }
2479 
2480         for (int ic = 0; ic < INVOC_COUNT; ic++) {
2481             ra = Double.NEGATIVE_INFINITY;
2482             for (int i = 0; i < a.length; i += SPECIES.length()) {
2483                 DoubleVector av = DoubleVector.fromArray(SPECIES, a, i);
2484                 ra = (double) Math.max(ra, av.reduceLanes(VectorOperators.MAX, vmask));
2485             }
2486         }
2487 
2488         assertReductionArraysEqualsMasked(r, ra, a, mask,
2489                 DoubleMaxVectorTests::MAXReduceMasked, DoubleMaxVectorTests::MAXReduceAllMasked);
2490     }
2491 
2492     static double FIRST_NONZEROReduce(double[] a, int idx) {
2493         double res = (double) 0;
2494         for (int i = idx; i < (idx + SPECIES.length()); i++) {
2495             res = firstNonZero(res, a[i]);
2496         }
2497 
2498         return res;
2499     }
2500 
2501     static double FIRST_NONZEROReduceAll(double[] a) {
2502         double res = (double) 0;
2503         for (int i = 0; i < a.length; i += SPECIES.length()) {
2504             res = firstNonZero(res, FIRST_NONZEROReduce(a, i));
2505         }
2506 
2507         return res;
2508     }
2509 
2510     @Test(dataProvider = "doubleUnaryOpProvider")
2511     static void FIRST_NONZEROReduceDoubleMaxVectorTests(IntFunction<double[]> fa) {
2512         double[] a = fa.apply(SPECIES.length());
2513         double[] r = fr.apply(SPECIES.length());
2514         double ra = (double) 0;
2515 
2516         for (int ic = 0; ic < INVOC_COUNT; ic++) {
2517             for (int i = 0; i < a.length; i += SPECIES.length()) {
2518                 DoubleVector av = DoubleVector.fromArray(SPECIES, a, i);
2519                 r[i] = av.reduceLanes(VectorOperators.FIRST_NONZERO);
2520             }
2521         }
2522 
2523         for (int ic = 0; ic < INVOC_COUNT; ic++) {
2524             ra = (double) 0;
2525             for (int i = 0; i < a.length; i += SPECIES.length()) {
2526                 DoubleVector av = DoubleVector.fromArray(SPECIES, a, i);
2527                 ra = firstNonZero(ra, av.reduceLanes(VectorOperators.FIRST_NONZERO));
2528             }
2529         }
2530 
2531         assertReductionArraysEquals(r, ra, a,
2532                 DoubleMaxVectorTests::FIRST_NONZEROReduce, DoubleMaxVectorTests::FIRST_NONZEROReduceAll);
2533     }
2534 
2535     static double FIRST_NONZEROReduceMasked(double[] a, int idx, boolean[] mask) {
2536         double res = (double) 0;
2537         for (int i = idx; i < (idx + SPECIES.length()); i++) {
2538             if (mask[i % SPECIES.length()])
2539                 res = firstNonZero(res, a[i]);
2540         }
2541 
2542         return res;
2543     }
2544 
2545     static double FIRST_NONZEROReduceAllMasked(double[] a, boolean[] mask) {
2546         double res = (double) 0;
2547         for (int i = 0; i < a.length; i += SPECIES.length()) {
2548             res = firstNonZero(res, FIRST_NONZEROReduceMasked(a, i, mask));
2549         }
2550 
2551         return res;
2552     }
2553 
2554     @Test(dataProvider = "doubleUnaryOpMaskProvider")
2555     static void FIRST_NONZEROReduceDoubleMaxVectorTestsMasked(IntFunction<double[]> fa, IntFunction<boolean[]> fm) {
2556         double[] a = fa.apply(SPECIES.length());
2557         double[] r = fr.apply(SPECIES.length());
2558         boolean[] mask = fm.apply(SPECIES.length());
2559         VectorMask<Double> vmask = VectorMask.fromArray(SPECIES, mask, 0);
2560         double ra = (double) 0;
2561 
2562         for (int ic = 0; ic < INVOC_COUNT; ic++) {
2563             for (int i = 0; i < a.length; i += SPECIES.length()) {
2564                 DoubleVector av = DoubleVector.fromArray(SPECIES, a, i);
2565                 r[i] = av.reduceLanes(VectorOperators.FIRST_NONZERO, vmask);
2566             }
2567         }
2568 
2569         for (int ic = 0; ic < INVOC_COUNT; ic++) {
2570             ra = (double) 0;
2571             for (int i = 0; i < a.length; i += SPECIES.length()) {
2572                 DoubleVector av = DoubleVector.fromArray(SPECIES, a, i);
2573                 ra = firstNonZero(ra, av.reduceLanes(VectorOperators.FIRST_NONZERO, vmask));
2574             }
2575         }
2576 
2577         assertReductionArraysEqualsMasked(r, ra, a, mask,
2578                 DoubleMaxVectorTests::FIRST_NONZEROReduceMasked, DoubleMaxVectorTests::FIRST_NONZEROReduceAllMasked);
2579     }
2580 




2581     @Test(dataProvider = "doubleUnaryOpProvider")
2582     static void withDoubleMaxVectorTests(IntFunction<double []> fa) {
2583         double[] a = fa.apply(SPECIES.length());
2584         double[] r = fr.apply(SPECIES.length());
2585 
2586         for (int ic = 0; ic < INVOC_COUNT; ic++) {
2587             for (int i = 0, j = 0; i < a.length; i += SPECIES.length()) {
2588                 DoubleVector av = DoubleVector.fromArray(SPECIES, a, i);
2589                 av.withLane((j++ & (SPECIES.length()-1)), (double)(65535+i)).intoArray(r, i);
2590             }
2591         }
2592 
2593 
2594         for (int i = 0, j = 0; i < a.length; i += SPECIES.length()) {
2595             assertInsertArraysEquals(r, a, (double)(65535+i), (j++ & (SPECIES.length()-1)), i , i + SPECIES.length());
2596         }
2597     }
2598 
2599     static boolean testIS_DEFAULT(double a) {
2600         return bits(a)==0;
2601     }
2602 
2603     @Test(dataProvider = "doubleTestOpProvider")
2604     static void IS_DEFAULTDoubleMaxVectorTests(IntFunction<double[]> fa) {
2605         double[] a = fa.apply(SPECIES.length());
2606 
2607         for (int ic = 0; ic < INVOC_COUNT; ic++) {
2608             for (int i = 0; i < a.length; i += SPECIES.length()) {
2609                 DoubleVector av = DoubleVector.fromArray(SPECIES, a, i);
2610                 VectorMask<Double> mv = av.test(VectorOperators.IS_DEFAULT);
2611 
2612                 // Check results as part of computation.
2613                 for (int j = 0; j < SPECIES.length(); j++) {
2614                     Assert.assertEquals(mv.laneIsSet(j), testIS_DEFAULT(a[i + j]));
2615                 }
2616             }
2617         }
2618     }
2619 
2620     @Test(dataProvider = "doubleTestOpMaskProvider")
2621     static void IS_DEFAULTMaskedDoubleMaxVectorTests(IntFunction<double[]> fa,
2622                                           IntFunction<boolean[]> fm) {
2623         double[] a = fa.apply(SPECIES.length());
2624         boolean[] mask = fm.apply(SPECIES.length());
2625         VectorMask<Double> vmask = VectorMask.fromArray(SPECIES, mask, 0);
2626 
2627         for (int ic = 0; ic < INVOC_COUNT; ic++) {
2628             for (int i = 0; i < a.length; i += SPECIES.length()) {
2629                 DoubleVector av = DoubleVector.fromArray(SPECIES, a, i);
2630                 VectorMask<Double> mv = av.test(VectorOperators.IS_DEFAULT, vmask);
2631 
2632                 // Check results as part of computation.
2633                 for (int j = 0; j < SPECIES.length(); j++) {
2634                     Assert.assertEquals(mv.laneIsSet(j),  vmask.laneIsSet(j) && testIS_DEFAULT(a[i + j]));
2635                 }
2636             }
2637         }
2638     }
2639 
2640     static boolean testIS_NEGATIVE(double a) {
2641         return bits(a)<0;
2642     }
2643 
2644     @Test(dataProvider = "doubleTestOpProvider")
2645     static void IS_NEGATIVEDoubleMaxVectorTests(IntFunction<double[]> fa) {
2646         double[] a = fa.apply(SPECIES.length());
2647 
2648         for (int ic = 0; ic < INVOC_COUNT; ic++) {
2649             for (int i = 0; i < a.length; i += SPECIES.length()) {
2650                 DoubleVector av = DoubleVector.fromArray(SPECIES, a, i);
2651                 VectorMask<Double> mv = av.test(VectorOperators.IS_NEGATIVE);
2652 
2653                 // Check results as part of computation.
2654                 for (int j = 0; j < SPECIES.length(); j++) {
2655                     Assert.assertEquals(mv.laneIsSet(j), testIS_NEGATIVE(a[i + j]));
2656                 }
2657             }
2658         }
2659     }

2702     @Test(dataProvider = "doubleTestOpMaskProvider")
2703     static void IS_FINITEMaskedDoubleMaxVectorTests(IntFunction<double[]> fa,
2704                                           IntFunction<boolean[]> fm) {
2705         double[] a = fa.apply(SPECIES.length());
2706         boolean[] mask = fm.apply(SPECIES.length());
2707         VectorMask<Double> vmask = VectorMask.fromArray(SPECIES, mask, 0);
2708 
2709         for (int ic = 0; ic < INVOC_COUNT; ic++) {
2710             for (int i = 0; i < a.length; i += SPECIES.length()) {
2711                 DoubleVector av = DoubleVector.fromArray(SPECIES, a, i);
2712                 VectorMask<Double> mv = av.test(VectorOperators.IS_FINITE, vmask);
2713 
2714                 // Check results as part of computation.
2715                 for (int j = 0; j < SPECIES.length(); j++) {
2716                     Assert.assertEquals(mv.laneIsSet(j),  vmask.laneIsSet(j) && testIS_FINITE(a[i + j]));
2717                 }
2718             }
2719         }
2720     }
2721 

2722     static boolean testIS_NAN(double a) {
2723         return Double.isNaN(a);
2724     }
2725 
2726     @Test(dataProvider = "doubleTestOpProvider")
2727     static void IS_NANDoubleMaxVectorTests(IntFunction<double[]> fa) {
2728         double[] a = fa.apply(SPECIES.length());
2729 
2730         for (int ic = 0; ic < INVOC_COUNT; ic++) {
2731             for (int i = 0; i < a.length; i += SPECIES.length()) {
2732                 DoubleVector av = DoubleVector.fromArray(SPECIES, a, i);
2733                 VectorMask<Double> mv = av.test(VectorOperators.IS_NAN);
2734 
2735                 // Check results as part of computation.
2736                 for (int j = 0; j < SPECIES.length(); j++) {
2737                     Assert.assertEquals(mv.laneIsSet(j), testIS_NAN(a[i + j]));
2738                 }
2739             }
2740         }
2741     }

2743     @Test(dataProvider = "doubleTestOpMaskProvider")
2744     static void IS_NANMaskedDoubleMaxVectorTests(IntFunction<double[]> fa,
2745                                           IntFunction<boolean[]> fm) {
2746         double[] a = fa.apply(SPECIES.length());
2747         boolean[] mask = fm.apply(SPECIES.length());
2748         VectorMask<Double> vmask = VectorMask.fromArray(SPECIES, mask, 0);
2749 
2750         for (int ic = 0; ic < INVOC_COUNT; ic++) {
2751             for (int i = 0; i < a.length; i += SPECIES.length()) {
2752                 DoubleVector av = DoubleVector.fromArray(SPECIES, a, i);
2753                 VectorMask<Double> mv = av.test(VectorOperators.IS_NAN, vmask);
2754 
2755                 // Check results as part of computation.
2756                 for (int j = 0; j < SPECIES.length(); j++) {
2757                     Assert.assertEquals(mv.laneIsSet(j),  vmask.laneIsSet(j) && testIS_NAN(a[i + j]));
2758                 }
2759             }
2760         }
2761     }
2762 

2763     static boolean testIS_INFINITE(double a) {
2764         return Double.isInfinite(a);
2765     }
2766 
2767     @Test(dataProvider = "doubleTestOpProvider")
2768     static void IS_INFINITEDoubleMaxVectorTests(IntFunction<double[]> fa) {
2769         double[] a = fa.apply(SPECIES.length());
2770 
2771         for (int ic = 0; ic < INVOC_COUNT; ic++) {
2772             for (int i = 0; i < a.length; i += SPECIES.length()) {
2773                 DoubleVector av = DoubleVector.fromArray(SPECIES, a, i);
2774                 VectorMask<Double> mv = av.test(VectorOperators.IS_INFINITE);
2775 
2776                 // Check results as part of computation.
2777                 for (int j = 0; j < SPECIES.length(); j++) {
2778                     Assert.assertEquals(mv.laneIsSet(j), testIS_INFINITE(a[i + j]));
2779                 }
2780             }
2781         }
2782     }

2784     @Test(dataProvider = "doubleTestOpMaskProvider")
2785     static void IS_INFINITEMaskedDoubleMaxVectorTests(IntFunction<double[]> fa,
2786                                           IntFunction<boolean[]> fm) {
2787         double[] a = fa.apply(SPECIES.length());
2788         boolean[] mask = fm.apply(SPECIES.length());
2789         VectorMask<Double> vmask = VectorMask.fromArray(SPECIES, mask, 0);
2790 
2791         for (int ic = 0; ic < INVOC_COUNT; ic++) {
2792             for (int i = 0; i < a.length; i += SPECIES.length()) {
2793                 DoubleVector av = DoubleVector.fromArray(SPECIES, a, i);
2794                 VectorMask<Double> mv = av.test(VectorOperators.IS_INFINITE, vmask);
2795 
2796                 // Check results as part of computation.
2797                 for (int j = 0; j < SPECIES.length(); j++) {
2798                     Assert.assertEquals(mv.laneIsSet(j),  vmask.laneIsSet(j) && testIS_INFINITE(a[i + j]));
2799                 }
2800             }
2801         }
2802     }
2803 

2804     @Test(dataProvider = "doubleCompareOpProvider")
2805     static void LTDoubleMaxVectorTests(IntFunction<double[]> fa, IntFunction<double[]> fb) {
2806         double[] a = fa.apply(SPECIES.length());
2807         double[] b = fb.apply(SPECIES.length());
2808 
2809         for (int ic = 0; ic < INVOC_COUNT; ic++) {
2810             for (int i = 0; i < a.length; i += SPECIES.length()) {
2811                 DoubleVector av = DoubleVector.fromArray(SPECIES, a, i);
2812                 DoubleVector bv = DoubleVector.fromArray(SPECIES, b, i);
2813                 VectorMask<Double> mv = av.compare(VectorOperators.LT, bv);
2814 
2815                 // Check results as part of computation.
2816                 for (int j = 0; j < SPECIES.length(); j++) {
2817                     Assert.assertEquals(mv.laneIsSet(j), lt(a[i + j], b[i + j]));
2818                 }
2819             }
2820         }
2821     }
2822 

2823     @Test(dataProvider = "doubleCompareOpProvider")
2824     static void ltDoubleMaxVectorTests(IntFunction<double[]> fa, IntFunction<double[]> fb) {
2825         double[] a = fa.apply(SPECIES.length());
2826         double[] b = fb.apply(SPECIES.length());
2827 
2828         for (int ic = 0; ic < INVOC_COUNT; ic++) {
2829             for (int i = 0; i < a.length; i += SPECIES.length()) {
2830                 DoubleVector av = DoubleVector.fromArray(SPECIES, a, i);
2831                 DoubleVector bv = DoubleVector.fromArray(SPECIES, b, i);
2832                 VectorMask<Double> mv = av.lt(bv);
2833 
2834                 // Check results as part of computation.
2835                 for (int j = 0; j < SPECIES.length(); j++) {
2836                     Assert.assertEquals(mv.laneIsSet(j), lt(a[i + j], b[i + j]));
2837                 }
2838             }
2839         }
2840     }
2841 
2842     @Test(dataProvider = "doubleCompareOpMaskProvider")

2845         double[] a = fa.apply(SPECIES.length());
2846         double[] b = fb.apply(SPECIES.length());
2847         boolean[] mask = fm.apply(SPECIES.length());
2848 
2849         VectorMask<Double> vmask = VectorMask.fromArray(SPECIES, mask, 0);
2850 
2851         for (int ic = 0; ic < INVOC_COUNT; ic++) {
2852             for (int i = 0; i < a.length; i += SPECIES.length()) {
2853                 DoubleVector av = DoubleVector.fromArray(SPECIES, a, i);
2854                 DoubleVector bv = DoubleVector.fromArray(SPECIES, b, i);
2855                 VectorMask<Double> mv = av.compare(VectorOperators.LT, bv, vmask);
2856 
2857                 // Check results as part of computation.
2858                 for (int j = 0; j < SPECIES.length(); j++) {
2859                     Assert.assertEquals(mv.laneIsSet(j), mask[j] && lt(a[i + j], b[i + j]));
2860                 }
2861             }
2862         }
2863     }
2864 

2865     @Test(dataProvider = "doubleCompareOpProvider")
2866     static void GTDoubleMaxVectorTests(IntFunction<double[]> fa, IntFunction<double[]> fb) {
2867         double[] a = fa.apply(SPECIES.length());
2868         double[] b = fb.apply(SPECIES.length());
2869 
2870         for (int ic = 0; ic < INVOC_COUNT; ic++) {
2871             for (int i = 0; i < a.length; i += SPECIES.length()) {
2872                 DoubleVector av = DoubleVector.fromArray(SPECIES, a, i);
2873                 DoubleVector bv = DoubleVector.fromArray(SPECIES, b, i);
2874                 VectorMask<Double> mv = av.compare(VectorOperators.GT, bv);
2875 
2876                 // Check results as part of computation.
2877                 for (int j = 0; j < SPECIES.length(); j++) {
2878                     Assert.assertEquals(mv.laneIsSet(j), gt(a[i + j], b[i + j]));
2879                 }
2880             }
2881         }
2882     }
2883 
2884     @Test(dataProvider = "doubleCompareOpMaskProvider")

2887         double[] a = fa.apply(SPECIES.length());
2888         double[] b = fb.apply(SPECIES.length());
2889         boolean[] mask = fm.apply(SPECIES.length());
2890 
2891         VectorMask<Double> vmask = VectorMask.fromArray(SPECIES, mask, 0);
2892 
2893         for (int ic = 0; ic < INVOC_COUNT; ic++) {
2894             for (int i = 0; i < a.length; i += SPECIES.length()) {
2895                 DoubleVector av = DoubleVector.fromArray(SPECIES, a, i);
2896                 DoubleVector bv = DoubleVector.fromArray(SPECIES, b, i);
2897                 VectorMask<Double> mv = av.compare(VectorOperators.GT, bv, vmask);
2898 
2899                 // Check results as part of computation.
2900                 for (int j = 0; j < SPECIES.length(); j++) {
2901                     Assert.assertEquals(mv.laneIsSet(j), mask[j] && gt(a[i + j], b[i + j]));
2902                 }
2903             }
2904         }
2905     }
2906 

2907     @Test(dataProvider = "doubleCompareOpProvider")
2908     static void EQDoubleMaxVectorTests(IntFunction<double[]> fa, IntFunction<double[]> fb) {
2909         double[] a = fa.apply(SPECIES.length());
2910         double[] b = fb.apply(SPECIES.length());
2911 
2912         for (int ic = 0; ic < INVOC_COUNT; ic++) {
2913             for (int i = 0; i < a.length; i += SPECIES.length()) {
2914                 DoubleVector av = DoubleVector.fromArray(SPECIES, a, i);
2915                 DoubleVector bv = DoubleVector.fromArray(SPECIES, b, i);
2916                 VectorMask<Double> mv = av.compare(VectorOperators.EQ, bv);
2917 
2918                 // Check results as part of computation.
2919                 for (int j = 0; j < SPECIES.length(); j++) {
2920                     Assert.assertEquals(mv.laneIsSet(j), eq(a[i + j], b[i + j]));
2921                 }
2922             }
2923         }
2924     }
2925 

2926     @Test(dataProvider = "doubleCompareOpProvider")
2927     static void eqDoubleMaxVectorTests(IntFunction<double[]> fa, IntFunction<double[]> fb) {
2928         double[] a = fa.apply(SPECIES.length());
2929         double[] b = fb.apply(SPECIES.length());
2930 
2931         for (int ic = 0; ic < INVOC_COUNT; ic++) {
2932             for (int i = 0; i < a.length; i += SPECIES.length()) {
2933                 DoubleVector av = DoubleVector.fromArray(SPECIES, a, i);
2934                 DoubleVector bv = DoubleVector.fromArray(SPECIES, b, i);
2935                 VectorMask<Double> mv = av.eq(bv);
2936 
2937                 // Check results as part of computation.
2938                 for (int j = 0; j < SPECIES.length(); j++) {
2939                     Assert.assertEquals(mv.laneIsSet(j), eq(a[i + j], b[i + j]));
2940                 }
2941             }
2942         }
2943     }
2944 
2945     @Test(dataProvider = "doubleCompareOpMaskProvider")

2948         double[] a = fa.apply(SPECIES.length());
2949         double[] b = fb.apply(SPECIES.length());
2950         boolean[] mask = fm.apply(SPECIES.length());
2951 
2952         VectorMask<Double> vmask = VectorMask.fromArray(SPECIES, mask, 0);
2953 
2954         for (int ic = 0; ic < INVOC_COUNT; ic++) {
2955             for (int i = 0; i < a.length; i += SPECIES.length()) {
2956                 DoubleVector av = DoubleVector.fromArray(SPECIES, a, i);
2957                 DoubleVector bv = DoubleVector.fromArray(SPECIES, b, i);
2958                 VectorMask<Double> mv = av.compare(VectorOperators.EQ, bv, vmask);
2959 
2960                 // Check results as part of computation.
2961                 for (int j = 0; j < SPECIES.length(); j++) {
2962                     Assert.assertEquals(mv.laneIsSet(j), mask[j] && eq(a[i + j], b[i + j]));
2963                 }
2964             }
2965         }
2966     }
2967 

2968     @Test(dataProvider = "doubleCompareOpProvider")
2969     static void NEDoubleMaxVectorTests(IntFunction<double[]> fa, IntFunction<double[]> fb) {
2970         double[] a = fa.apply(SPECIES.length());
2971         double[] b = fb.apply(SPECIES.length());
2972 
2973         for (int ic = 0; ic < INVOC_COUNT; ic++) {
2974             for (int i = 0; i < a.length; i += SPECIES.length()) {
2975                 DoubleVector av = DoubleVector.fromArray(SPECIES, a, i);
2976                 DoubleVector bv = DoubleVector.fromArray(SPECIES, b, i);
2977                 VectorMask<Double> mv = av.compare(VectorOperators.NE, bv);
2978 
2979                 // Check results as part of computation.
2980                 for (int j = 0; j < SPECIES.length(); j++) {
2981                     Assert.assertEquals(mv.laneIsSet(j), neq(a[i + j], b[i + j]));
2982                 }
2983             }
2984         }
2985     }
2986 
2987     @Test(dataProvider = "doubleCompareOpMaskProvider")

2990         double[] a = fa.apply(SPECIES.length());
2991         double[] b = fb.apply(SPECIES.length());
2992         boolean[] mask = fm.apply(SPECIES.length());
2993 
2994         VectorMask<Double> vmask = VectorMask.fromArray(SPECIES, mask, 0);
2995 
2996         for (int ic = 0; ic < INVOC_COUNT; ic++) {
2997             for (int i = 0; i < a.length; i += SPECIES.length()) {
2998                 DoubleVector av = DoubleVector.fromArray(SPECIES, a, i);
2999                 DoubleVector bv = DoubleVector.fromArray(SPECIES, b, i);
3000                 VectorMask<Double> mv = av.compare(VectorOperators.NE, bv, vmask);
3001 
3002                 // Check results as part of computation.
3003                 for (int j = 0; j < SPECIES.length(); j++) {
3004                     Assert.assertEquals(mv.laneIsSet(j), mask[j] && neq(a[i + j], b[i + j]));
3005                 }
3006             }
3007         }
3008     }
3009 

3010     @Test(dataProvider = "doubleCompareOpProvider")
3011     static void LEDoubleMaxVectorTests(IntFunction<double[]> fa, IntFunction<double[]> fb) {
3012         double[] a = fa.apply(SPECIES.length());
3013         double[] b = fb.apply(SPECIES.length());
3014 
3015         for (int ic = 0; ic < INVOC_COUNT; ic++) {
3016             for (int i = 0; i < a.length; i += SPECIES.length()) {
3017                 DoubleVector av = DoubleVector.fromArray(SPECIES, a, i);
3018                 DoubleVector bv = DoubleVector.fromArray(SPECIES, b, i);
3019                 VectorMask<Double> mv = av.compare(VectorOperators.LE, bv);
3020 
3021                 // Check results as part of computation.
3022                 for (int j = 0; j < SPECIES.length(); j++) {
3023                     Assert.assertEquals(mv.laneIsSet(j), le(a[i + j], b[i + j]));
3024                 }
3025             }
3026         }
3027     }
3028 
3029     @Test(dataProvider = "doubleCompareOpMaskProvider")

3032         double[] a = fa.apply(SPECIES.length());
3033         double[] b = fb.apply(SPECIES.length());
3034         boolean[] mask = fm.apply(SPECIES.length());
3035 
3036         VectorMask<Double> vmask = VectorMask.fromArray(SPECIES, mask, 0);
3037 
3038         for (int ic = 0; ic < INVOC_COUNT; ic++) {
3039             for (int i = 0; i < a.length; i += SPECIES.length()) {
3040                 DoubleVector av = DoubleVector.fromArray(SPECIES, a, i);
3041                 DoubleVector bv = DoubleVector.fromArray(SPECIES, b, i);
3042                 VectorMask<Double> mv = av.compare(VectorOperators.LE, bv, vmask);
3043 
3044                 // Check results as part of computation.
3045                 for (int j = 0; j < SPECIES.length(); j++) {
3046                     Assert.assertEquals(mv.laneIsSet(j), mask[j] && le(a[i + j], b[i + j]));
3047                 }
3048             }
3049         }
3050     }
3051 

3052     @Test(dataProvider = "doubleCompareOpProvider")
3053     static void GEDoubleMaxVectorTests(IntFunction<double[]> fa, IntFunction<double[]> fb) {
3054         double[] a = fa.apply(SPECIES.length());
3055         double[] 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                 DoubleVector av = DoubleVector.fromArray(SPECIES, a, i);
3060                 DoubleVector bv = DoubleVector.fromArray(SPECIES, b, i);
3061                 VectorMask<Double> mv = av.compare(VectorOperators.GE, bv);
3062 
3063                 // Check results as part of computation.
3064                 for (int j = 0; j < SPECIES.length(); j++) {
3065                     Assert.assertEquals(mv.laneIsSet(j), ge(a[i + j], b[i + j]));
3066                 }
3067             }
3068         }
3069     }
3070 
3071     @Test(dataProvider = "doubleCompareOpMaskProvider")

3074         double[] a = fa.apply(SPECIES.length());
3075         double[] b = fb.apply(SPECIES.length());
3076         boolean[] mask = fm.apply(SPECIES.length());
3077 
3078         VectorMask<Double> 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                 DoubleVector av = DoubleVector.fromArray(SPECIES, a, i);
3083                 DoubleVector bv = DoubleVector.fromArray(SPECIES, b, i);
3084                 VectorMask<Double> mv = av.compare(VectorOperators.GE, 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] && ge(a[i + j], b[i + j]));
3089                 }
3090             }
3091         }
3092     }
3093 









3094     @Test(dataProvider = "doubleCompareOpProvider")
3095     static void LTDoubleMaxVectorTestsBroadcastSmokeTest(IntFunction<double[]> fa, IntFunction<double[]> fb) {
3096         double[] a = fa.apply(SPECIES.length());
3097         double[] b = fb.apply(SPECIES.length());
3098 
3099         for (int i = 0; i < a.length; i += SPECIES.length()) {
3100             DoubleVector av = DoubleVector.fromArray(SPECIES, a, i);
3101             VectorMask<Double> mv = av.compare(VectorOperators.LT, b[i]);
3102 
3103             // Check results as part of computation.
3104             for (int j = 0; j < SPECIES.length(); j++) {
3105                 Assert.assertEquals(mv.laneIsSet(j), a[i + j] < b[i]);
3106             }
3107         }
3108     }
3109 

3110     @Test(dataProvider = "doubleCompareOpMaskProvider")
3111     static void LTDoubleMaxVectorTestsBroadcastMaskedSmokeTest(IntFunction<double[]> fa,
3112                                 IntFunction<double[]> fb, IntFunction<boolean[]> fm) {
3113         double[] a = fa.apply(SPECIES.length());
3114         double[] b = fb.apply(SPECIES.length());
3115         boolean[] mask = fm.apply(SPECIES.length());
3116 
3117         VectorMask<Double> vmask = VectorMask.fromArray(SPECIES, mask, 0);
3118 
3119         for (int i = 0; i < a.length; i += SPECIES.length()) {
3120             DoubleVector av = DoubleVector.fromArray(SPECIES, a, i);
3121             VectorMask<Double> mv = av.compare(VectorOperators.LT, b[i], vmask);
3122 
3123             // Check results as part of computation.
3124             for (int j = 0; j < SPECIES.length(); j++) {
3125                 Assert.assertEquals(mv.laneIsSet(j), mask[j] && (a[i + j] < b[i]));
3126             }
3127         }
3128     }
3129 
3130     @Test(dataProvider = "doubleCompareOpProvider")
3131     static void LTDoubleMaxVectorTestsBroadcastLongSmokeTest(IntFunction<double[]> fa, IntFunction<double[]> fb) {
3132         double[] a = fa.apply(SPECIES.length());
3133         double[] b = fb.apply(SPECIES.length());
3134 
3135         for (int i = 0; i < a.length; i += SPECIES.length()) {
3136             DoubleVector av = DoubleVector.fromArray(SPECIES, a, i);
3137             VectorMask<Double> mv = av.compare(VectorOperators.LT, (long)b[i]);
3138 
3139             // Check results as part of computation.
3140             for (int j = 0; j < SPECIES.length(); j++) {
3141                 Assert.assertEquals(mv.laneIsSet(j), a[i + j] < (double)((long)b[i]));
3142             }
3143         }
3144     }
3145 

3146     @Test(dataProvider = "doubleCompareOpMaskProvider")
3147     static void LTDoubleMaxVectorTestsBroadcastLongMaskedSmokeTest(IntFunction<double[]> fa,
3148                                 IntFunction<double[]> fb, IntFunction<boolean[]> fm) {
3149         double[] a = fa.apply(SPECIES.length());
3150         double[] b = fb.apply(SPECIES.length());
3151         boolean[] mask = fm.apply(SPECIES.length());
3152 
3153         VectorMask<Double> vmask = VectorMask.fromArray(SPECIES, mask, 0);
3154 
3155         for (int i = 0; i < a.length; i += SPECIES.length()) {
3156             DoubleVector av = DoubleVector.fromArray(SPECIES, a, i);
3157             VectorMask<Double> mv = av.compare(VectorOperators.LT, (long)b[i], vmask);
3158 
3159             // Check results as part of computation.
3160             for (int j = 0; j < SPECIES.length(); j++) {
3161                 Assert.assertEquals(mv.laneIsSet(j), mask[j] && (a[i + j] < (double)((long)b[i])));
3162             }
3163         }
3164     }
3165 
3166     @Test(dataProvider = "doubleCompareOpProvider")
3167     static void EQDoubleMaxVectorTestsBroadcastSmokeTest(IntFunction<double[]> fa, IntFunction<double[]> fb) {
3168         double[] a = fa.apply(SPECIES.length());
3169         double[] b = fb.apply(SPECIES.length());
3170 
3171         for (int i = 0; i < a.length; i += SPECIES.length()) {
3172             DoubleVector av = DoubleVector.fromArray(SPECIES, a, i);
3173             VectorMask<Double> mv = av.compare(VectorOperators.EQ, b[i]);
3174 
3175             // Check results as part of computation.
3176             for (int j = 0; j < SPECIES.length(); j++) {
3177                 Assert.assertEquals(mv.laneIsSet(j), a[i + j] == b[i]);
3178             }
3179         }
3180     }
3181 

3182     @Test(dataProvider = "doubleCompareOpMaskProvider")
3183     static void EQDoubleMaxVectorTestsBroadcastMaskedSmokeTest(IntFunction<double[]> fa,
3184                                 IntFunction<double[]> fb, IntFunction<boolean[]> fm) {
3185         double[] a = fa.apply(SPECIES.length());
3186         double[] b = fb.apply(SPECIES.length());
3187         boolean[] mask = fm.apply(SPECIES.length());
3188 
3189         VectorMask<Double> vmask = VectorMask.fromArray(SPECIES, mask, 0);
3190 
3191         for (int i = 0; i < a.length; i += SPECIES.length()) {
3192             DoubleVector av = DoubleVector.fromArray(SPECIES, a, i);
3193             VectorMask<Double> mv = av.compare(VectorOperators.EQ, b[i], vmask);
3194 
3195             // Check results as part of computation.
3196             for (int j = 0; j < SPECIES.length(); j++) {
3197                 Assert.assertEquals(mv.laneIsSet(j), mask[j] && (a[i + j] == b[i]));
3198             }
3199         }
3200     }
3201 
3202     @Test(dataProvider = "doubleCompareOpProvider")
3203     static void EQDoubleMaxVectorTestsBroadcastLongSmokeTest(IntFunction<double[]> fa, IntFunction<double[]> fb) {
3204         double[] a = fa.apply(SPECIES.length());
3205         double[] b = fb.apply(SPECIES.length());
3206 
3207         for (int i = 0; i < a.length; i += SPECIES.length()) {
3208             DoubleVector av = DoubleVector.fromArray(SPECIES, a, i);
3209             VectorMask<Double> mv = av.compare(VectorOperators.EQ, (long)b[i]);
3210 
3211             // Check results as part of computation.
3212             for (int j = 0; j < SPECIES.length(); j++) {
3213                 Assert.assertEquals(mv.laneIsSet(j), a[i + j] == (double)((long)b[i]));
3214             }
3215         }
3216     }
3217 

3218     @Test(dataProvider = "doubleCompareOpMaskProvider")
3219     static void EQDoubleMaxVectorTestsBroadcastLongMaskedSmokeTest(IntFunction<double[]> fa,
3220                                 IntFunction<double[]> fb, IntFunction<boolean[]> fm) {
3221         double[] a = fa.apply(SPECIES.length());
3222         double[] b = fb.apply(SPECIES.length());
3223         boolean[] mask = fm.apply(SPECIES.length());
3224 
3225         VectorMask<Double> vmask = VectorMask.fromArray(SPECIES, mask, 0);
3226 
3227         for (int i = 0; i < a.length; i += SPECIES.length()) {
3228             DoubleVector av = DoubleVector.fromArray(SPECIES, a, i);
3229             VectorMask<Double> mv = av.compare(VectorOperators.EQ, (long)b[i], vmask);
3230 
3231             // Check results as part of computation.
3232             for (int j = 0; j < SPECIES.length(); j++) {
3233                 Assert.assertEquals(mv.laneIsSet(j), mask[j] && (a[i + j] == (double)((long)b[i])));
3234             }
3235         }
3236     }
3237 

3276         assertRearrangeArraysEquals(r, a, order, SPECIES.length());
3277     }
3278 
3279     @Test(dataProvider = "doubleUnaryOpShuffleMaskProvider")
3280     static void RearrangeDoubleMaxVectorTestsMaskedSmokeTest(IntFunction<double[]> fa,
3281                                                           BiFunction<Integer,Integer,int[]> fs,
3282                                                           IntFunction<boolean[]> fm) {
3283         double[] a = fa.apply(SPECIES.length());
3284         int[] order = fs.apply(a.length, SPECIES.length());
3285         double[] r = fr.apply(SPECIES.length());
3286         boolean[] mask = fm.apply(SPECIES.length());
3287         VectorMask<Double> vmask = VectorMask.fromArray(SPECIES, mask, 0);
3288 
3289         for (int i = 0; i < a.length; i += SPECIES.length()) {
3290             DoubleVector av = DoubleVector.fromArray(SPECIES, a, i);
3291             av.rearrange(VectorShuffle.fromArray(SPECIES, order, i), vmask).intoArray(r, i);
3292         }
3293 
3294         assertRearrangeArraysEquals(r, a, order, mask, SPECIES.length());
3295     }
3296 
3297     @Test(dataProvider = "doubleUnaryOpMaskProvider")
3298     static void compressDoubleMaxVectorTests(IntFunction<double[]> fa,
3299                                                 IntFunction<boolean[]> fm) {
3300         double[] a = fa.apply(SPECIES.length());
3301         double[] r = fr.apply(SPECIES.length());
3302         boolean[] mask = fm.apply(SPECIES.length());
3303         VectorMask<Double> vmask = VectorMask.fromArray(SPECIES, mask, 0);
3304 
3305         for (int ic = 0; ic < INVOC_COUNT; ic++) {
3306             for (int i = 0; i < a.length; i += SPECIES.length()) {
3307                 DoubleVector av = DoubleVector.fromArray(SPECIES, a, i);
3308                 av.compress(vmask).intoArray(r, i);
3309             }
3310         }
3311 
3312         assertcompressArraysEquals(r, a, mask, SPECIES.length());
3313     }
3314 
3315     @Test(dataProvider = "doubleUnaryOpMaskProvider")
3316     static void expandDoubleMaxVectorTests(IntFunction<double[]> fa,
3317                                                 IntFunction<boolean[]> fm) {
3318         double[] a = fa.apply(SPECIES.length());
3319         double[] r = fr.apply(SPECIES.length());
3320         boolean[] mask = fm.apply(SPECIES.length());
3321         VectorMask<Double> vmask = VectorMask.fromArray(SPECIES, mask, 0);
3322 
3323         for (int ic = 0; ic < INVOC_COUNT; ic++) {
3324             for (int i = 0; i < a.length; i += SPECIES.length()) {
3325                 DoubleVector av = DoubleVector.fromArray(SPECIES, a, i);
3326                 av.expand(vmask).intoArray(r, i);
3327             }
3328         }
3329 
3330         assertexpandArraysEquals(r, a, mask, SPECIES.length());
3331     }
3332 
3333     @Test(dataProvider = "doubleUnaryOpProvider")
3334     static void getDoubleMaxVectorTests(IntFunction<double[]> fa) {
3335         double[] a = fa.apply(SPECIES.length());
3336         double[] r = fr.apply(SPECIES.length());
3337 
3338         for (int ic = 0; ic < INVOC_COUNT; ic++) {
3339             for (int i = 0; i < a.length; i += SPECIES.length()) {
3340                 DoubleVector av = DoubleVector.fromArray(SPECIES, a, i);
3341                 int num_lanes = SPECIES.length();
3342                 // Manually unroll because full unroll happens after intrinsification.
3343                 // Unroll is needed because get intrinsic requires for index to be a known constant.
3344                 if (num_lanes == 1) {
3345                     r[i]=av.lane(0);
3346                 } else if (num_lanes == 2) {
3347                     r[i]=av.lane(0);
3348                     r[i+1]=av.lane(1);
3349                 } else if (num_lanes == 4) {
3350                     r[i]=av.lane(0);
3351                     r[i+1]=av.lane(1);
3352                     r[i+2]=av.lane(2);

3483             }
3484         }
3485 
3486         assertArraysEquals(r, a, DoubleMaxVectorTests::get);
3487     }
3488 
3489     @Test(dataProvider = "doubleUnaryOpProvider")
3490     static void BroadcastDoubleMaxVectorTests(IntFunction<double[]> fa) {
3491         double[] a = fa.apply(SPECIES.length());
3492         double[] r = new double[a.length];
3493 
3494         for (int ic = 0; ic < INVOC_COUNT; ic++) {
3495             for (int i = 0; i < a.length; i += SPECIES.length()) {
3496                 DoubleVector.broadcast(SPECIES, a[i]).intoArray(r, i);
3497             }
3498         }
3499 
3500         assertBroadcastArraysEquals(r, a);
3501     }
3502 




3503     @Test(dataProvider = "doubleUnaryOpProvider")
3504     static void ZeroDoubleMaxVectorTests(IntFunction<double[]> fa) {
3505         double[] a = fa.apply(SPECIES.length());
3506         double[] r = new double[a.length];
3507 
3508         for (int ic = 0; ic < INVOC_COUNT; ic++) {
3509             for (int i = 0; i < a.length; i += SPECIES.length()) {
3510                 DoubleVector.zero(SPECIES).intoArray(a, i);
3511             }
3512         }
3513 
3514         Assert.assertEquals(a, r);
3515     }
3516 



3517     static double[] sliceUnary(double[] a, int origin, int idx) {
3518         double[] res = new double[SPECIES.length()];
3519         for (int i = 0; i < SPECIES.length(); i++){
3520             if(i+origin < SPECIES.length())
3521                 res[i] = a[idx+i+origin];
3522             else
3523                 res[i] = (double)0;
3524         }
3525         return res;
3526     }
3527 
3528     @Test(dataProvider = "doubleUnaryOpProvider")
3529     static void sliceUnaryDoubleMaxVectorTests(IntFunction<double[]> fa) {
3530         double[] a = fa.apply(SPECIES.length());
3531         double[] r = new double[a.length];
3532         int origin = (new java.util.Random()).nextInt(SPECIES.length());
3533         for (int ic = 0; ic < INVOC_COUNT; ic++) {
3534             for (int i = 0; i < a.length; i += SPECIES.length()) {
3535                 DoubleVector av = DoubleVector.fromArray(SPECIES, a, i);
3536                 av.slice(origin).intoArray(r, i);
3537             }
3538         }
3539 
3540         assertArraysEquals(r, a, origin, DoubleMaxVectorTests::sliceUnary);
3541     }
3542 
3543     static double[] sliceBinary(double[] a, double[] b, int origin, int idx) {
3544         double[] res = new double[SPECIES.length()];
3545         for (int i = 0, j = 0; i < SPECIES.length(); i++){
3546             if(i+origin < SPECIES.length())
3547                 res[i] = a[idx+i+origin];
3548             else {
3549                 res[i] = b[idx+j];
3550                 j++;
3551             }
3552         }
3553         return res;
3554     }
3555 
3556     @Test(dataProvider = "doubleBinaryOpProvider")
3557     static void sliceBinaryDoubleMaxVectorTestsBinary(IntFunction<double[]> fa, IntFunction<double[]> fb) {
3558         double[] a = fa.apply(SPECIES.length());
3559         double[] b = fb.apply(SPECIES.length());
3560         double[] r = new double[a.length];
3561         int origin = (new java.util.Random()).nextInt(SPECIES.length());
3562         for (int ic = 0; ic < INVOC_COUNT; ic++) {
3563             for (int i = 0; i < a.length; i += SPECIES.length()) {
3564                 DoubleVector av = DoubleVector.fromArray(SPECIES, a, i);
3565                 DoubleVector bv = DoubleVector.fromArray(SPECIES, b, i);
3566                 av.slice(origin, bv).intoArray(r, i);
3567             }
3568         }
3569 
3570         assertArraysEquals(r, a, b, origin, DoubleMaxVectorTests::sliceBinary);
3571     }
3572 
3573     static double[] slice(double[] a, double[] b, int origin, boolean[] mask, int idx) {
3574         double[] res = new double[SPECIES.length()];
3575         for (int i = 0, j = 0; i < SPECIES.length(); i++){
3576             if(i+origin < SPECIES.length())
3577                 res[i] = mask[i] ? a[idx+i+origin] : (double)0;
3578             else {
3579                 res[i] = mask[i] ? b[idx+j] : (double)0;
3580                 j++;
3581             }
3582         }
3583         return res;
3584     }
3585 
3586     @Test(dataProvider = "doubleBinaryOpMaskProvider")
3587     static void sliceDoubleMaxVectorTestsMasked(IntFunction<double[]> fa, IntFunction<double[]> fb,
3588     IntFunction<boolean[]> fm) {
3589         double[] a = fa.apply(SPECIES.length());
3590         double[] b = fb.apply(SPECIES.length());
3591         boolean[] mask = fm.apply(SPECIES.length());
3592         VectorMask<Double> vmask = VectorMask.fromArray(SPECIES, mask, 0);
3593 
3594         double[] r = new double[a.length];
3595         int origin = (new java.util.Random()).nextInt(SPECIES.length());
3596         for (int ic = 0; ic < INVOC_COUNT; ic++) {
3597             for (int i = 0; i < a.length; i += SPECIES.length()) {
3598                 DoubleVector av = DoubleVector.fromArray(SPECIES, a, i);
3599                 DoubleVector bv = DoubleVector.fromArray(SPECIES, b, i);
3600                 av.slice(origin, bv, vmask).intoArray(r, i);
3601             }
3602         }
3603 
3604         assertArraysEquals(r, a, b, origin, mask, DoubleMaxVectorTests::slice);
3605     }
3606 
3607     static double[] unsliceUnary(double[] a, int origin, int idx) {
3608         double[] res = new double[SPECIES.length()];
3609         for (int i = 0, j = 0; i < SPECIES.length(); i++){
3610             if(i < origin)
3611                 res[i] = (double)0;
3612             else {
3613                 res[i] = a[idx+j];
3614                 j++;
3615             }
3616         }
3617         return res;
3618     }
3619 
3620     @Test(dataProvider = "doubleUnaryOpProvider")
3621     static void unsliceUnaryDoubleMaxVectorTests(IntFunction<double[]> fa) {
3622         double[] a = fa.apply(SPECIES.length());
3623         double[] r = new double[a.length];
3624         int origin = (new java.util.Random()).nextInt(SPECIES.length());
3625         for (int ic = 0; ic < INVOC_COUNT; ic++) {
3626             for (int i = 0; i < a.length; i += SPECIES.length()) {
3627                 DoubleVector av = DoubleVector.fromArray(SPECIES, a, i);
3628                 av.unslice(origin).intoArray(r, i);
3629             }
3630         }
3631 
3632         assertArraysEquals(r, a, origin, DoubleMaxVectorTests::unsliceUnary);
3633     }
3634 
3635     static double[] unsliceBinary(double[] a, double[] b, int origin, int part, int idx) {
3636         double[] res = new double[SPECIES.length()];
3637         for (int i = 0, j = 0; i < SPECIES.length(); i++){
3638             if (part == 0) {
3639                 if (i < origin)
3640                     res[i] = b[idx+i];
3641                 else {
3642                     res[i] = a[idx+j];
3643                     j++;
3644                 }
3645             } else if (part == 1) {
3646                 if (i < origin)
3647                     res[i] = a[idx+SPECIES.length()-origin+i];
3648                 else {
3649                     res[i] = b[idx+origin+j];
3650                     j++;
3651                 }
3652             }
3653         }
3654         return res;
3655     }
3656 
3657     @Test(dataProvider = "doubleBinaryOpProvider")
3658     static void unsliceBinaryDoubleMaxVectorTestsBinary(IntFunction<double[]> fa, IntFunction<double[]> fb) {
3659         double[] a = fa.apply(SPECIES.length());
3660         double[] b = fb.apply(SPECIES.length());
3661         double[] r = new double[a.length];
3662         int origin = (new java.util.Random()).nextInt(SPECIES.length());
3663         int part = (new java.util.Random()).nextInt(2);
3664         for (int ic = 0; ic < INVOC_COUNT; ic++) {
3665             for (int i = 0; i < a.length; i += SPECIES.length()) {
3666                 DoubleVector av = DoubleVector.fromArray(SPECIES, a, i);
3667                 DoubleVector bv = DoubleVector.fromArray(SPECIES, b, i);
3668                 av.unslice(origin, bv, part).intoArray(r, i);
3669             }
3670         }
3671 
3672         assertArraysEquals(r, a, b, origin, part, DoubleMaxVectorTests::unsliceBinary);
3673     }
3674 
3675     static double[] unslice(double[] a, double[] b, int origin, int part, boolean[] mask, int idx) {
3676         double[] res = new double[SPECIES.length()];
3677         for (int i = 0, j = 0; i < SPECIES.length(); i++){
3678             if(i+origin < SPECIES.length())
3679                 res[i] = b[idx+i+origin];
3680             else {
3681                 res[i] = b[idx+j];
3682                 j++;
3683             }
3684         }
3685         for (int i = 0; i < SPECIES.length(); i++){
3686             res[i] = mask[i] ? a[idx+i] : res[i];
3687         }
3688         double[] res1 = new double[SPECIES.length()];
3689         if (part == 0) {
3690             for (int i = 0, j = 0; i < SPECIES.length(); i++){
3691                 if (i < origin)
3692                     res1[i] = b[idx+i];
3693                 else {
3694                    res1[i] = res[j];

3735 
3736     static double strictSIN(double a) {
3737         return (double)(StrictMath.sin((double)a));
3738     }
3739 
3740     @Test(dataProvider = "doubleUnaryOpProvider")
3741     static void SINDoubleMaxVectorTests(IntFunction<double[]> fa) {
3742         double[] a = fa.apply(SPECIES.length());
3743         double[] r = fr.apply(SPECIES.length());
3744 
3745         for (int ic = 0; ic < INVOC_COUNT; ic++) {
3746             for (int i = 0; i < a.length; i += SPECIES.length()) {
3747                 DoubleVector av = DoubleVector.fromArray(SPECIES, a, i);
3748                 av.lanewise(VectorOperators.SIN).intoArray(r, i);
3749             }
3750         }
3751 
3752         assertArraysEqualsWithinOneUlp(r, a, DoubleMaxVectorTests::SIN, DoubleMaxVectorTests::strictSIN);
3753     }
3754 

3755     static double EXP(double a) {
3756         return (double)(Math.exp((double)a));
3757     }
3758 
3759     static double strictEXP(double a) {
3760         return (double)(StrictMath.exp((double)a));
3761     }
3762 
3763     @Test(dataProvider = "doubleUnaryOpProvider")
3764     static void EXPDoubleMaxVectorTests(IntFunction<double[]> fa) {
3765         double[] a = fa.apply(SPECIES.length());
3766         double[] r = fr.apply(SPECIES.length());
3767 
3768         for (int ic = 0; ic < INVOC_COUNT; ic++) {
3769             for (int i = 0; i < a.length; i += SPECIES.length()) {
3770                 DoubleVector av = DoubleVector.fromArray(SPECIES, a, i);
3771                 av.lanewise(VectorOperators.EXP).intoArray(r, i);
3772             }
3773         }
3774 
3775         assertArraysEqualsWithinOneUlp(r, a, DoubleMaxVectorTests::EXP, DoubleMaxVectorTests::strictEXP);
3776     }
3777 

3778     static double LOG1P(double a) {
3779         return (double)(Math.log1p((double)a));
3780     }
3781 
3782     static double strictLOG1P(double a) {
3783         return (double)(StrictMath.log1p((double)a));
3784     }
3785 
3786     @Test(dataProvider = "doubleUnaryOpProvider")
3787     static void LOG1PDoubleMaxVectorTests(IntFunction<double[]> fa) {
3788         double[] a = fa.apply(SPECIES.length());
3789         double[] r = fr.apply(SPECIES.length());
3790 
3791         for (int ic = 0; ic < INVOC_COUNT; ic++) {
3792             for (int i = 0; i < a.length; i += SPECIES.length()) {
3793                 DoubleVector av = DoubleVector.fromArray(SPECIES, a, i);
3794                 av.lanewise(VectorOperators.LOG1P).intoArray(r, i);
3795             }
3796         }
3797 
3798         assertArraysEqualsWithinOneUlp(r, a, DoubleMaxVectorTests::LOG1P, DoubleMaxVectorTests::strictLOG1P);
3799     }
3800 

3801     static double LOG(double a) {
3802         return (double)(Math.log((double)a));
3803     }
3804 
3805     static double strictLOG(double a) {
3806         return (double)(StrictMath.log((double)a));
3807     }
3808 
3809     @Test(dataProvider = "doubleUnaryOpProvider")
3810     static void LOGDoubleMaxVectorTests(IntFunction<double[]> fa) {
3811         double[] a = fa.apply(SPECIES.length());
3812         double[] 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                 DoubleVector av = DoubleVector.fromArray(SPECIES, a, i);
3817                 av.lanewise(VectorOperators.LOG).intoArray(r, i);
3818             }
3819         }
3820 
3821         assertArraysEqualsWithinOneUlp(r, a, DoubleMaxVectorTests::LOG, DoubleMaxVectorTests::strictLOG);
3822     }
3823 

3824     static double LOG10(double a) {
3825         return (double)(Math.log10((double)a));
3826     }
3827 
3828     static double strictLOG10(double a) {
3829         return (double)(StrictMath.log10((double)a));
3830     }
3831 
3832     @Test(dataProvider = "doubleUnaryOpProvider")
3833     static void LOG10DoubleMaxVectorTests(IntFunction<double[]> fa) {
3834         double[] a = fa.apply(SPECIES.length());
3835         double[] r = fr.apply(SPECIES.length());
3836 
3837         for (int ic = 0; ic < INVOC_COUNT; ic++) {
3838             for (int i = 0; i < a.length; i += SPECIES.length()) {
3839                 DoubleVector av = DoubleVector.fromArray(SPECIES, a, i);
3840                 av.lanewise(VectorOperators.LOG10).intoArray(r, i);
3841             }
3842         }
3843 
3844         assertArraysEqualsWithinOneUlp(r, a, DoubleMaxVectorTests::LOG10, DoubleMaxVectorTests::strictLOG10);
3845     }
3846 

3847     static double EXPM1(double a) {
3848         return (double)(Math.expm1((double)a));
3849     }
3850 
3851     static double strictEXPM1(double a) {
3852         return (double)(StrictMath.expm1((double)a));
3853     }
3854 
3855     @Test(dataProvider = "doubleUnaryOpProvider")
3856     static void EXPM1DoubleMaxVectorTests(IntFunction<double[]> fa) {
3857         double[] a = fa.apply(SPECIES.length());
3858         double[] r = fr.apply(SPECIES.length());
3859 
3860         for (int ic = 0; ic < INVOC_COUNT; ic++) {
3861             for (int i = 0; i < a.length; i += SPECIES.length()) {
3862                 DoubleVector av = DoubleVector.fromArray(SPECIES, a, i);
3863                 av.lanewise(VectorOperators.EXPM1).intoArray(r, i);
3864             }
3865         }
3866 
3867         assertArraysEqualsWithinOneUlp(r, a, DoubleMaxVectorTests::EXPM1, DoubleMaxVectorTests::strictEXPM1);
3868     }
3869 

3870     static double COS(double a) {
3871         return (double)(Math.cos((double)a));
3872     }
3873 
3874     static double strictCOS(double a) {
3875         return (double)(StrictMath.cos((double)a));
3876     }
3877 
3878     @Test(dataProvider = "doubleUnaryOpProvider")
3879     static void COSDoubleMaxVectorTests(IntFunction<double[]> fa) {
3880         double[] a = fa.apply(SPECIES.length());
3881         double[] r = fr.apply(SPECIES.length());
3882 
3883         for (int ic = 0; ic < INVOC_COUNT; ic++) {
3884             for (int i = 0; i < a.length; i += SPECIES.length()) {
3885                 DoubleVector av = DoubleVector.fromArray(SPECIES, a, i);
3886                 av.lanewise(VectorOperators.COS).intoArray(r, i);
3887             }
3888         }
3889 
3890         assertArraysEqualsWithinOneUlp(r, a, DoubleMaxVectorTests::COS, DoubleMaxVectorTests::strictCOS);
3891     }
3892 

3893     static double TAN(double a) {
3894         return (double)(Math.tan((double)a));
3895     }
3896 
3897     static double strictTAN(double a) {
3898         return (double)(StrictMath.tan((double)a));
3899     }
3900 
3901     @Test(dataProvider = "doubleUnaryOpProvider")
3902     static void TANDoubleMaxVectorTests(IntFunction<double[]> fa) {
3903         double[] a = fa.apply(SPECIES.length());
3904         double[] r = fr.apply(SPECIES.length());
3905 
3906         for (int ic = 0; ic < INVOC_COUNT; ic++) {
3907             for (int i = 0; i < a.length; i += SPECIES.length()) {
3908                 DoubleVector av = DoubleVector.fromArray(SPECIES, a, i);
3909                 av.lanewise(VectorOperators.TAN).intoArray(r, i);
3910             }
3911         }
3912 
3913         assertArraysEqualsWithinOneUlp(r, a, DoubleMaxVectorTests::TAN, DoubleMaxVectorTests::strictTAN);
3914     }
3915 

3916     static double SINH(double a) {
3917         return (double)(Math.sinh((double)a));
3918     }
3919 
3920     static double strictSINH(double a) {
3921         return (double)(StrictMath.sinh((double)a));
3922     }
3923 
3924     @Test(dataProvider = "doubleUnaryOpProvider")
3925     static void SINHDoubleMaxVectorTests(IntFunction<double[]> fa) {
3926         double[] a = fa.apply(SPECIES.length());
3927         double[] r = fr.apply(SPECIES.length());
3928 
3929         for (int ic = 0; ic < INVOC_COUNT; ic++) {
3930             for (int i = 0; i < a.length; i += SPECIES.length()) {
3931                 DoubleVector av = DoubleVector.fromArray(SPECIES, a, i);
3932                 av.lanewise(VectorOperators.SINH).intoArray(r, i);
3933             }
3934         }
3935 
3936         assertArraysEqualsWithinOneUlp(r, a, DoubleMaxVectorTests::SINH, DoubleMaxVectorTests::strictSINH);
3937     }
3938 

3939     static double COSH(double a) {
3940         return (double)(Math.cosh((double)a));
3941     }
3942 
3943     static double strictCOSH(double a) {
3944         return (double)(StrictMath.cosh((double)a));
3945     }
3946 
3947     @Test(dataProvider = "doubleUnaryOpProvider")
3948     static void COSHDoubleMaxVectorTests(IntFunction<double[]> fa) {
3949         double[] a = fa.apply(SPECIES.length());
3950         double[] r = fr.apply(SPECIES.length());
3951 
3952         for (int ic = 0; ic < INVOC_COUNT; ic++) {
3953             for (int i = 0; i < a.length; i += SPECIES.length()) {
3954                 DoubleVector av = DoubleVector.fromArray(SPECIES, a, i);
3955                 av.lanewise(VectorOperators.COSH).intoArray(r, i);
3956             }
3957         }
3958 
3959         assertArraysEqualsWithinOneUlp(r, a, DoubleMaxVectorTests::COSH, DoubleMaxVectorTests::strictCOSH);
3960     }
3961 

3962     static double TANH(double a) {
3963         return (double)(Math.tanh((double)a));
3964     }
3965 
3966     static double strictTANH(double a) {
3967         return (double)(StrictMath.tanh((double)a));
3968     }
3969 
3970     @Test(dataProvider = "doubleUnaryOpProvider")
3971     static void TANHDoubleMaxVectorTests(IntFunction<double[]> fa) {
3972         double[] a = fa.apply(SPECIES.length());
3973         double[] r = fr.apply(SPECIES.length());
3974 
3975         for (int ic = 0; ic < INVOC_COUNT; ic++) {
3976             for (int i = 0; i < a.length; i += SPECIES.length()) {
3977                 DoubleVector av = DoubleVector.fromArray(SPECIES, a, i);
3978                 av.lanewise(VectorOperators.TANH).intoArray(r, i);
3979             }
3980         }
3981 
3982         assertArraysEqualsWithinOneUlp(r, a, DoubleMaxVectorTests::TANH, DoubleMaxVectorTests::strictTANH);
3983     }
3984 

3985     static double ASIN(double a) {
3986         return (double)(Math.asin((double)a));
3987     }
3988 
3989     static double strictASIN(double a) {
3990         return (double)(StrictMath.asin((double)a));
3991     }
3992 
3993     @Test(dataProvider = "doubleUnaryOpProvider")
3994     static void ASINDoubleMaxVectorTests(IntFunction<double[]> fa) {
3995         double[] a = fa.apply(SPECIES.length());
3996         double[] r = fr.apply(SPECIES.length());
3997 
3998         for (int ic = 0; ic < INVOC_COUNT; ic++) {
3999             for (int i = 0; i < a.length; i += SPECIES.length()) {
4000                 DoubleVector av = DoubleVector.fromArray(SPECIES, a, i);
4001                 av.lanewise(VectorOperators.ASIN).intoArray(r, i);
4002             }
4003         }
4004 
4005         assertArraysEqualsWithinOneUlp(r, a, DoubleMaxVectorTests::ASIN, DoubleMaxVectorTests::strictASIN);
4006     }
4007 

4008     static double ACOS(double a) {
4009         return (double)(Math.acos((double)a));
4010     }
4011 
4012     static double strictACOS(double a) {
4013         return (double)(StrictMath.acos((double)a));
4014     }
4015 
4016     @Test(dataProvider = "doubleUnaryOpProvider")
4017     static void ACOSDoubleMaxVectorTests(IntFunction<double[]> fa) {
4018         double[] a = fa.apply(SPECIES.length());
4019         double[] r = fr.apply(SPECIES.length());
4020 
4021         for (int ic = 0; ic < INVOC_COUNT; ic++) {
4022             for (int i = 0; i < a.length; i += SPECIES.length()) {
4023                 DoubleVector av = DoubleVector.fromArray(SPECIES, a, i);
4024                 av.lanewise(VectorOperators.ACOS).intoArray(r, i);
4025             }
4026         }
4027 
4028         assertArraysEqualsWithinOneUlp(r, a, DoubleMaxVectorTests::ACOS, DoubleMaxVectorTests::strictACOS);
4029     }
4030 

4031     static double ATAN(double a) {
4032         return (double)(Math.atan((double)a));
4033     }
4034 
4035     static double strictATAN(double a) {
4036         return (double)(StrictMath.atan((double)a));
4037     }
4038 
4039     @Test(dataProvider = "doubleUnaryOpProvider")
4040     static void ATANDoubleMaxVectorTests(IntFunction<double[]> fa) {
4041         double[] a = fa.apply(SPECIES.length());
4042         double[] r = fr.apply(SPECIES.length());
4043 
4044         for (int ic = 0; ic < INVOC_COUNT; ic++) {
4045             for (int i = 0; i < a.length; i += SPECIES.length()) {
4046                 DoubleVector av = DoubleVector.fromArray(SPECIES, a, i);
4047                 av.lanewise(VectorOperators.ATAN).intoArray(r, i);
4048             }
4049         }
4050 
4051         assertArraysEqualsWithinOneUlp(r, a, DoubleMaxVectorTests::ATAN, DoubleMaxVectorTests::strictATAN);
4052     }
4053 

4054     static double CBRT(double a) {
4055         return (double)(Math.cbrt((double)a));
4056     }
4057 
4058     static double strictCBRT(double a) {
4059         return (double)(StrictMath.cbrt((double)a));
4060     }
4061 
4062     @Test(dataProvider = "doubleUnaryOpProvider")
4063     static void CBRTDoubleMaxVectorTests(IntFunction<double[]> fa) {
4064         double[] a = fa.apply(SPECIES.length());
4065         double[] r = fr.apply(SPECIES.length());
4066 
4067         for (int ic = 0; ic < INVOC_COUNT; ic++) {
4068             for (int i = 0; i < a.length; i += SPECIES.length()) {
4069                 DoubleVector av = DoubleVector.fromArray(SPECIES, a, i);
4070                 av.lanewise(VectorOperators.CBRT).intoArray(r, i);
4071             }
4072         }
4073 
4074         assertArraysEqualsWithinOneUlp(r, a, DoubleMaxVectorTests::CBRT, DoubleMaxVectorTests::strictCBRT);
4075     }
4076 

4077     static double HYPOT(double a, double b) {
4078         return (double)(Math.hypot((double)a, (double)b));
4079     }
4080 
4081     static double strictHYPOT(double a, double b) {
4082         return (double)(StrictMath.hypot((double)a, (double)b));
4083     }
4084 
4085     @Test(dataProvider = "doubleBinaryOpProvider")
4086     static void HYPOTDoubleMaxVectorTests(IntFunction<double[]> fa, IntFunction<double[]> fb) {
4087         double[] a = fa.apply(SPECIES.length());
4088         double[] b = fb.apply(SPECIES.length());
4089         double[] r = fr.apply(SPECIES.length());
4090 
4091         for (int ic = 0; ic < INVOC_COUNT; ic++) {
4092             for (int i = 0; i < a.length; i += SPECIES.length()) {
4093                 DoubleVector av = DoubleVector.fromArray(SPECIES, a, i);
4094                 DoubleVector bv = DoubleVector.fromArray(SPECIES, b, i);
4095                 av.lanewise(VectorOperators.HYPOT, bv).intoArray(r, i);
4096             }
4097         }
4098 
4099         assertArraysEqualsWithinOneUlp(r, a, b, DoubleMaxVectorTests::HYPOT, DoubleMaxVectorTests::strictHYPOT);
4100     }
4101 
4102 

4103     static double POW(double a, double b) {
4104         return (double)(Math.pow((double)a, (double)b));
4105     }
4106 
4107     static double strictPOW(double a, double b) {
4108         return (double)(StrictMath.pow((double)a, (double)b));
4109     }
4110 
4111     @Test(dataProvider = "doubleBinaryOpProvider")
4112     static void POWDoubleMaxVectorTests(IntFunction<double[]> fa, IntFunction<double[]> fb) {
4113         double[] a = fa.apply(SPECIES.length());
4114         double[] b = fb.apply(SPECIES.length());
4115         double[] r = fr.apply(SPECIES.length());
4116 
4117         for (int ic = 0; ic < INVOC_COUNT; ic++) {
4118             for (int i = 0; i < a.length; i += SPECIES.length()) {
4119                 DoubleVector av = DoubleVector.fromArray(SPECIES, a, i);
4120                 DoubleVector bv = DoubleVector.fromArray(SPECIES, b, i);
4121                 av.lanewise(VectorOperators.POW, bv).intoArray(r, i);
4122             }
4123         }
4124 
4125         assertArraysEqualsWithinOneUlp(r, a, b, DoubleMaxVectorTests::POW, DoubleMaxVectorTests::strictPOW);
4126     }
4127 
4128 
4129     static double pow(double a, double b) {
4130         return (double)(Math.pow((double)a, (double)b));
4131     }
4132 
4133     static double strictpow(double a, double b) {
4134         return (double)(StrictMath.pow((double)a, (double)b));
4135     }
4136 
4137     @Test(dataProvider = "doubleBinaryOpProvider")
4138     static void powDoubleMaxVectorTests(IntFunction<double[]> fa, IntFunction<double[]> fb) {
4139         double[] a = fa.apply(SPECIES.length());
4140         double[] b = fb.apply(SPECIES.length());
4141         double[] r = fr.apply(SPECIES.length());
4142 
4143         for (int ic = 0; ic < INVOC_COUNT; ic++) {
4144             for (int i = 0; i < a.length; i += SPECIES.length()) {
4145                 DoubleVector av = DoubleVector.fromArray(SPECIES, a, i);
4146                 DoubleVector bv = DoubleVector.fromArray(SPECIES, b, i);
4147                 av.pow(bv).intoArray(r, i);
4148             }
4149         }
4150 
4151         assertArraysEqualsWithinOneUlp(r, a, b, DoubleMaxVectorTests::pow, DoubleMaxVectorTests::strictpow);
4152     }
4153 
4154 

4155     static double ATAN2(double a, double b) {
4156         return (double)(Math.atan2((double)a, (double)b));
4157     }
4158 
4159     static double strictATAN2(double a, double b) {
4160         return (double)(StrictMath.atan2((double)a, (double)b));
4161     }
4162 
4163     @Test(dataProvider = "doubleBinaryOpProvider")
4164     static void ATAN2DoubleMaxVectorTests(IntFunction<double[]> fa, IntFunction<double[]> fb) {
4165         double[] a = fa.apply(SPECIES.length());
4166         double[] b = fb.apply(SPECIES.length());
4167         double[] r = fr.apply(SPECIES.length());
4168 
4169         for (int ic = 0; ic < INVOC_COUNT; ic++) {
4170             for (int i = 0; i < a.length; i += SPECIES.length()) {
4171                 DoubleVector av = DoubleVector.fromArray(SPECIES, a, i);
4172                 DoubleVector bv = DoubleVector.fromArray(SPECIES, b, i);
4173                 av.lanewise(VectorOperators.ATAN2, bv).intoArray(r, i);
4174             }
4175         }
4176 
4177         assertArraysEqualsWithinOneUlp(r, a, b, DoubleMaxVectorTests::ATAN2, DoubleMaxVectorTests::strictATAN2);
4178     }
4179 
4180 

4181     @Test(dataProvider = "doubleBinaryOpProvider")
4182     static void POWDoubleMaxVectorTestsBroadcastSmokeTest(IntFunction<double[]> fa, IntFunction<double[]> fb) {
4183         double[] a = fa.apply(SPECIES.length());
4184         double[] b = fb.apply(SPECIES.length());
4185         double[] r = fr.apply(SPECIES.length());
4186 
4187         for (int i = 0; i < a.length; i += SPECIES.length()) {
4188             DoubleVector av = DoubleVector.fromArray(SPECIES, a, i);
4189             av.lanewise(VectorOperators.POW, b[i]).intoArray(r, i);
4190         }
4191 
4192         assertBroadcastArraysEqualsWithinOneUlp(r, a, b, DoubleMaxVectorTests::POW, DoubleMaxVectorTests::strictPOW);
4193     }
4194 
4195 
4196     @Test(dataProvider = "doubleBinaryOpProvider")
4197     static void powDoubleMaxVectorTestsBroadcastSmokeTest(IntFunction<double[]> fa, IntFunction<double[]> fb) {
4198         double[] a = fa.apply(SPECIES.length());
4199         double[] b = fb.apply(SPECIES.length());
4200         double[] r = fr.apply(SPECIES.length());
4201 
4202         for (int i = 0; i < a.length; i += SPECIES.length()) {
4203             DoubleVector av = DoubleVector.fromArray(SPECIES, a, i);
4204             av.pow(b[i]).intoArray(r, i);
4205         }
4206 
4207         assertBroadcastArraysEqualsWithinOneUlp(r, a, b, DoubleMaxVectorTests::pow, DoubleMaxVectorTests::strictpow);
4208     }
4209 
4210 

4211     static double FMA(double a, double b, double c) {
4212         return (double)(Math.fma(a, b, c));
4213     }
4214 
4215     static double fma(double a, double b, double c) {
4216         return (double)(Math.fma(a, b, c));
4217     }
4218 

4219     @Test(dataProvider = "doubleTernaryOpProvider")
4220     static void FMADoubleMaxVectorTests(IntFunction<double[]> fa, IntFunction<double[]> fb, IntFunction<double[]> fc) {
4221         int count = INVOC_COUNT;
4222         switch ("FMA") {
4223         case "fma": case "lanewise_FMA":
4224            // Math.fma uses BigDecimal
4225            count = Math.max(5, count/20); break;
4226         }
4227         final int INVOC_COUNT = count;
4228         double[] a = fa.apply(SPECIES.length());
4229         double[] b = fb.apply(SPECIES.length());
4230         double[] c = fc.apply(SPECIES.length());
4231         double[] r = fr.apply(SPECIES.length());
4232 
4233         for (int ic = 0; ic < INVOC_COUNT; ic++) {
4234             for (int i = 0; i < a.length; i += SPECIES.length()) {
4235                 DoubleVector av = DoubleVector.fromArray(SPECIES, a, i);
4236                 DoubleVector bv = DoubleVector.fromArray(SPECIES, b, i);
4237                 DoubleVector cv = DoubleVector.fromArray(SPECIES, c, i);
4238                 av.lanewise(VectorOperators.FMA, bv, cv).intoArray(r, i);
4239             }
4240         }
4241 
4242         assertArraysEquals(r, a, b, c, DoubleMaxVectorTests::FMA);
4243     }
4244 
4245     @Test(dataProvider = "doubleTernaryOpProvider")
4246     static void fmaDoubleMaxVectorTests(IntFunction<double[]> fa, IntFunction<double[]> fb, IntFunction<double[]> fc) {
4247         int count = INVOC_COUNT;
4248         switch ("fma") {
4249         case "fma": case "lanewise_FMA":
4250            // Math.fma uses BigDecimal
4251            count = Math.max(5, count/20); break;
4252         }
4253         final int INVOC_COUNT = count;
4254         double[] a = fa.apply(SPECIES.length());
4255         double[] b = fb.apply(SPECIES.length());
4256         double[] c = fc.apply(SPECIES.length());
4257         double[] r = fr.apply(SPECIES.length());
4258 
4259         for (int i = 0; i < a.length; i += SPECIES.length()) {
4260             DoubleVector av = DoubleVector.fromArray(SPECIES, a, i);
4261             DoubleVector bv = DoubleVector.fromArray(SPECIES, b, i);
4262             DoubleVector cv = DoubleVector.fromArray(SPECIES, c, i);
4263             av.fma(bv, cv).intoArray(r, i);
4264         }
4265 
4266         assertArraysEquals(r, a, b, c, DoubleMaxVectorTests::fma);
4267     }
4268 

4269     @Test(dataProvider = "doubleTernaryOpMaskProvider")
4270     static void FMADoubleMaxVectorTestsMasked(IntFunction<double[]> fa, IntFunction<double[]> fb,
4271                                           IntFunction<double[]> fc, IntFunction<boolean[]> fm) {
4272         int count = INVOC_COUNT;
4273         switch ("FMA") {
4274         case "fma": case "lanewise_FMA":
4275            // Math.fma uses BigDecimal
4276            count = Math.max(5, count/20); break;
4277         }
4278         final int INVOC_COUNT = count;
4279         double[] a = fa.apply(SPECIES.length());
4280         double[] b = fb.apply(SPECIES.length());
4281         double[] c = fc.apply(SPECIES.length());
4282         double[] r = fr.apply(SPECIES.length());
4283         boolean[] mask = fm.apply(SPECIES.length());
4284         VectorMask<Double> vmask = VectorMask.fromArray(SPECIES, mask, 0);
4285 
4286         for (int ic = 0; ic < INVOC_COUNT; ic++) {
4287             for (int i = 0; i < a.length; i += SPECIES.length()) {
4288                 DoubleVector av = DoubleVector.fromArray(SPECIES, a, i);
4289                 DoubleVector bv = DoubleVector.fromArray(SPECIES, b, i);
4290                 DoubleVector cv = DoubleVector.fromArray(SPECIES, c, i);
4291                 av.lanewise(VectorOperators.FMA, bv, cv, vmask).intoArray(r, i);
4292             }
4293         }
4294 
4295         assertArraysEquals(r, a, b, c, mask, DoubleMaxVectorTests::FMA);
4296     }
4297 




4298     @Test(dataProvider = "doubleTernaryOpProvider")
4299     static void FMADoubleMaxVectorTestsBroadcastSmokeTest(IntFunction<double[]> fa, IntFunction<double[]> fb, IntFunction<double[]> fc) {
4300         double[] a = fa.apply(SPECIES.length());
4301         double[] b = fb.apply(SPECIES.length());
4302         double[] c = fc.apply(SPECIES.length());
4303         double[] r = fr.apply(SPECIES.length());
4304 
4305         for (int i = 0; i < a.length; i += SPECIES.length()) {
4306             DoubleVector av = DoubleVector.fromArray(SPECIES, a, i);
4307             DoubleVector bv = DoubleVector.fromArray(SPECIES, b, i);
4308             av.lanewise(VectorOperators.FMA, bv, c[i]).intoArray(r, i);
4309         }
4310         assertBroadcastArraysEquals(r, a, b, c, DoubleMaxVectorTests::FMA);
4311     }
4312 
4313     @Test(dataProvider = "doubleTernaryOpProvider")
4314     static void FMADoubleMaxVectorTestsAltBroadcastSmokeTest(IntFunction<double[]> fa, IntFunction<double[]> fb, IntFunction<double[]> fc) {
4315         double[] a = fa.apply(SPECIES.length());
4316         double[] b = fb.apply(SPECIES.length());
4317         double[] c = fc.apply(SPECIES.length());
4318         double[] r = fr.apply(SPECIES.length());
4319 
4320         for (int i = 0; i < a.length; i += SPECIES.length()) {
4321             DoubleVector av = DoubleVector.fromArray(SPECIES, a, i);
4322             DoubleVector cv = DoubleVector.fromArray(SPECIES, c, i);
4323             av.lanewise(VectorOperators.FMA, b[i], cv).intoArray(r, i);
4324         }
4325         assertAltBroadcastArraysEquals(r, a, b, c, DoubleMaxVectorTests::FMA);
4326     }
4327 

4328     @Test(dataProvider = "doubleTernaryOpMaskProvider")
4329     static void FMADoubleMaxVectorTestsBroadcastMaskedSmokeTest(IntFunction<double[]> fa, IntFunction<double[]> fb,
4330                                           IntFunction<double[]> fc, IntFunction<boolean[]> fm) {
4331         double[] a = fa.apply(SPECIES.length());
4332         double[] b = fb.apply(SPECIES.length());
4333         double[] c = fc.apply(SPECIES.length());
4334         double[] r = fr.apply(SPECIES.length());
4335         boolean[] mask = fm.apply(SPECIES.length());
4336         VectorMask<Double> vmask = VectorMask.fromArray(SPECIES, mask, 0);
4337 
4338         for (int i = 0; i < a.length; i += SPECIES.length()) {
4339             DoubleVector av = DoubleVector.fromArray(SPECIES, a, i);
4340             DoubleVector bv = DoubleVector.fromArray(SPECIES, b, i);
4341             av.lanewise(VectorOperators.FMA, bv, c[i], vmask).intoArray(r, i);
4342         }
4343 
4344         assertBroadcastArraysEquals(r, a, b, c, mask, DoubleMaxVectorTests::FMA);
4345     }
4346 
4347     @Test(dataProvider = "doubleTernaryOpMaskProvider")
4348     static void FMADoubleMaxVectorTestsAltBroadcastMaskedSmokeTest(IntFunction<double[]> fa, IntFunction<double[]> fb,
4349                                           IntFunction<double[]> fc, IntFunction<boolean[]> fm) {
4350         double[] a = fa.apply(SPECIES.length());
4351         double[] b = fb.apply(SPECIES.length());
4352         double[] c = fc.apply(SPECIES.length());
4353         double[] r = fr.apply(SPECIES.length());
4354         boolean[] mask = fm.apply(SPECIES.length());
4355         VectorMask<Double> vmask = VectorMask.fromArray(SPECIES, mask, 0);
4356 
4357         for (int i = 0; i < a.length; i += SPECIES.length()) {
4358             DoubleVector av = DoubleVector.fromArray(SPECIES, a, i);
4359             DoubleVector cv = DoubleVector.fromArray(SPECIES, c, i);
4360             av.lanewise(VectorOperators.FMA, b[i], cv, vmask).intoArray(r, i);
4361         }
4362 
4363         assertAltBroadcastArraysEquals(r, a, b, c, mask, DoubleMaxVectorTests::FMA);
4364     }
4365 



4366     @Test(dataProvider = "doubleTernaryOpProvider")
4367     static void FMADoubleMaxVectorTestsDoubleBroadcastSmokeTest(IntFunction<double[]> fa, IntFunction<double[]> fb, IntFunction<double[]> fc) {
4368         int count = INVOC_COUNT;
4369         switch ("FMA") {
4370         case "fma": case "lanewise_FMA":
4371            // Math.fma uses BigDecimal
4372            count = Math.max(5, count/20); break;
4373         }
4374         final int INVOC_COUNT = count;
4375         double[] a = fa.apply(SPECIES.length());
4376         double[] b = fb.apply(SPECIES.length());
4377         double[] c = fc.apply(SPECIES.length());
4378         double[] r = fr.apply(SPECIES.length());
4379 
4380         for (int i = 0; i < a.length; i += SPECIES.length()) {
4381             DoubleVector av = DoubleVector.fromArray(SPECIES, a, i);
4382             av.lanewise(VectorOperators.FMA, b[i], c[i]).intoArray(r, i);
4383         }
4384 
4385         assertDoubleBroadcastArraysEquals(r, a, b, c, DoubleMaxVectorTests::FMA);
4386     }
4387 
4388     @Test(dataProvider = "doubleTernaryOpProvider")
4389     static void fmaDoubleMaxVectorTestsDoubleBroadcastSmokeTest(IntFunction<double[]> fa, IntFunction<double[]> fb, IntFunction<double[]> fc) {
4390         int count = INVOC_COUNT;
4391         switch ("fma") {
4392         case "fma": case "lanewise_FMA":
4393            // Math.fma uses BigDecimal
4394            count = Math.max(5, count/20); break;
4395         }
4396         final int INVOC_COUNT = count;
4397         double[] a = fa.apply(SPECIES.length());
4398         double[] b = fb.apply(SPECIES.length());
4399         double[] c = fc.apply(SPECIES.length());
4400         double[] r = fr.apply(SPECIES.length());
4401 
4402         for (int i = 0; i < a.length; i += SPECIES.length()) {
4403             DoubleVector av = DoubleVector.fromArray(SPECIES, a, i);
4404             av.fma(b[i], c[i]).intoArray(r, i);
4405         }
4406 
4407         assertDoubleBroadcastArraysEquals(r, a, b, c, DoubleMaxVectorTests::fma);
4408     }
4409 

4410     @Test(dataProvider = "doubleTernaryOpMaskProvider")
4411     static void FMADoubleMaxVectorTestsDoubleBroadcastMaskedSmokeTest(IntFunction<double[]> fa, IntFunction<double[]> fb,
4412                                           IntFunction<double[]> fc, IntFunction<boolean[]> fm) {
4413         int count = INVOC_COUNT;
4414         switch ("FMA") {
4415         case "fma": case "lanewise_FMA":
4416            // Math.fma uses BigDecimal
4417            count = Math.max(5, count/20); break;
4418         }
4419         final int INVOC_COUNT = count;
4420         double[] a = fa.apply(SPECIES.length());
4421         double[] b = fb.apply(SPECIES.length());
4422         double[] c = fc.apply(SPECIES.length());
4423         double[] r = fr.apply(SPECIES.length());
4424         boolean[] mask = fm.apply(SPECIES.length());
4425         VectorMask<Double> vmask = VectorMask.fromArray(SPECIES, mask, 0);
4426 
4427         for (int i = 0; i < a.length; i += SPECIES.length()) {
4428             DoubleVector av = DoubleVector.fromArray(SPECIES, a, i);
4429             av.lanewise(VectorOperators.FMA, b[i], c[i], vmask).intoArray(r, i);
4430         }
4431 
4432         assertDoubleBroadcastArraysEquals(r, a, b, c, mask, DoubleMaxVectorTests::FMA);
4433     }
4434 



4435     static double NEG(double a) {
4436         return (double)(-((double)a));
4437     }
4438 
4439     static double neg(double a) {
4440         return (double)(-((double)a));
4441     }
4442 
4443     @Test(dataProvider = "doubleUnaryOpProvider")
4444     static void NEGDoubleMaxVectorTests(IntFunction<double[]> fa) {
4445         double[] a = fa.apply(SPECIES.length());
4446         double[] r = fr.apply(SPECIES.length());
4447 
4448         for (int ic = 0; ic < INVOC_COUNT; ic++) {
4449             for (int i = 0; i < a.length; i += SPECIES.length()) {
4450                 DoubleVector av = DoubleVector.fromArray(SPECIES, a, i);
4451                 av.lanewise(VectorOperators.NEG).intoArray(r, i);
4452             }
4453         }
4454 

4527     }
4528 
4529     @Test(dataProvider = "doubleUnaryOpMaskProvider")
4530     static void ABSMaskedDoubleMaxVectorTests(IntFunction<double[]> fa,
4531                                                 IntFunction<boolean[]> fm) {
4532         double[] a = fa.apply(SPECIES.length());
4533         double[] r = fr.apply(SPECIES.length());
4534         boolean[] mask = fm.apply(SPECIES.length());
4535         VectorMask<Double> vmask = VectorMask.fromArray(SPECIES, mask, 0);
4536 
4537         for (int ic = 0; ic < INVOC_COUNT; ic++) {
4538             for (int i = 0; i < a.length; i += SPECIES.length()) {
4539                 DoubleVector av = DoubleVector.fromArray(SPECIES, a, i);
4540                 av.lanewise(VectorOperators.ABS, vmask).intoArray(r, i);
4541             }
4542         }
4543 
4544         assertArraysEquals(r, a, mask, DoubleMaxVectorTests::ABS);
4545     }
4546 







4547     static double SQRT(double a) {
4548         return (double)(Math.sqrt((double)a));
4549     }
4550 
4551     static double sqrt(double a) {
4552         return (double)(Math.sqrt((double)a));
4553     }
4554 


4555     @Test(dataProvider = "doubleUnaryOpProvider")
4556     static void SQRTDoubleMaxVectorTests(IntFunction<double[]> fa) {
4557         double[] a = fa.apply(SPECIES.length());
4558         double[] r = fr.apply(SPECIES.length());
4559 
4560         for (int ic = 0; ic < INVOC_COUNT; ic++) {
4561             for (int i = 0; i < a.length; i += SPECIES.length()) {
4562                 DoubleVector av = DoubleVector.fromArray(SPECIES, a, i);
4563                 av.lanewise(VectorOperators.SQRT).intoArray(r, i);
4564             }
4565         }
4566 
4567         assertArraysEquals(r, a, DoubleMaxVectorTests::SQRT);
4568     }
4569 
4570     @Test(dataProvider = "doubleUnaryOpProvider")
4571     static void sqrtDoubleMaxVectorTests(IntFunction<double[]> fa) {
4572         double[] a = fa.apply(SPECIES.length());
4573         double[] r = fr.apply(SPECIES.length());
4574 
4575         for (int ic = 0; ic < INVOC_COUNT; ic++) {
4576             for (int i = 0; i < a.length; i += SPECIES.length()) {
4577                 DoubleVector av = DoubleVector.fromArray(SPECIES, a, i);
4578                 av.sqrt().intoArray(r, i);
4579             }
4580         }
4581 
4582         assertArraysEquals(r, a, DoubleMaxVectorTests::sqrt);
4583     }
4584 


4585     @Test(dataProvider = "doubleUnaryOpMaskProvider")
4586     static void SQRTMaskedDoubleMaxVectorTests(IntFunction<double[]> fa,
4587                                                 IntFunction<boolean[]> fm) {
4588         double[] a = fa.apply(SPECIES.length());
4589         double[] r = fr.apply(SPECIES.length());
4590         boolean[] mask = fm.apply(SPECIES.length());
4591         VectorMask<Double> vmask = VectorMask.fromArray(SPECIES, mask, 0);
4592 
4593         for (int ic = 0; ic < INVOC_COUNT; ic++) {
4594             for (int i = 0; i < a.length; i += SPECIES.length()) {
4595                 DoubleVector av = DoubleVector.fromArray(SPECIES, a, i);
4596                 av.lanewise(VectorOperators.SQRT, vmask).intoArray(r, i);
4597             }
4598         }
4599 
4600         assertArraysEquals(r, a, mask, DoubleMaxVectorTests::SQRT);
4601     }
4602 

4603     @Test(dataProvider = "doubleCompareOpProvider")
4604     static void ltDoubleMaxVectorTestsBroadcastSmokeTest(IntFunction<double[]> fa, IntFunction<double[]> fb) {
4605         double[] a = fa.apply(SPECIES.length());
4606         double[] b = fb.apply(SPECIES.length());
4607 
4608         for (int i = 0; i < a.length; i += SPECIES.length()) {
4609             DoubleVector av = DoubleVector.fromArray(SPECIES, a, i);
4610             VectorMask<Double> mv = av.lt(b[i]);
4611 
4612             // Check results as part of computation.
4613             for (int j = 0; j < SPECIES.length(); j++) {
4614                 Assert.assertEquals(mv.laneIsSet(j), a[i + j] < b[i]);
4615             }
4616         }
4617     }
4618 
4619     @Test(dataProvider = "doubleCompareOpProvider")
4620     static void eqDoubleMaxVectorTestsBroadcastMaskedSmokeTest(IntFunction<double[]> fa, IntFunction<double[]> fb) {
4621         double[] a = fa.apply(SPECIES.length());
4622         double[] b = fb.apply(SPECIES.length());

4974             }
4975         }
4976         return i - idx;
4977     }
4978 
4979     @Test(dataProvider = "maskProvider")
4980     static void maskFirstTrueDoubleMaxVectorTestsSmokeTest(IntFunction<boolean[]> fa) {
4981         boolean[] a = fa.apply(SPECIES.length());
4982         int[] r = new int[a.length];
4983 
4984         for (int ic = 0; ic < INVOC_COUNT * INVOC_COUNT; ic++) {
4985             for (int i = 0; i < a.length; i += SPECIES.length()) {
4986                 var vmask = SPECIES.loadMask(a, i);
4987                 r[i] = vmask.firstTrue();
4988             }
4989         }
4990 
4991         assertMaskReductionArraysEquals(r, a, DoubleMaxVectorTests::maskFirstTrue);
4992     }
4993 
4994     @Test(dataProvider = "maskProvider")
4995     static void maskCompressDoubleMaxVectorTestsSmokeTest(IntFunction<boolean[]> fa) {
4996         int trueCount = 0;
4997         boolean[] a = fa.apply(SPECIES.length());
4998 
4999         for (int ic = 0; ic < INVOC_COUNT * INVOC_COUNT; ic++) {
5000             for (int i = 0; i < a.length; i += SPECIES.length()) {
5001                 var vmask = SPECIES.loadMask(a, i);
5002                 trueCount = vmask.trueCount();
5003                 var rmask = vmask.compress();
5004                 for (int j = 0; j < SPECIES.length(); j++)  {
5005                     Assert.assertEquals(rmask.laneIsSet(j), j < trueCount);
5006                 }
5007             }
5008         }
5009     }
5010 
5011 
5012     @DataProvider
5013     public static Object[][] offsetProvider() {
5014         return new Object[][]{
5015                 {0},
5016                 {-1},
5017                 {+1},
5018                 {+2},
5019                 {-2},
5020         };
5021     }
5022 
5023     @Test(dataProvider = "offsetProvider")
5024     static void indexInRangeDoubleMaxVectorTestsSmokeTest(int offset) {
5025         int limit = SPECIES.length() * BUFFER_REPS;
5026         for (int i = 0; i < limit; i += SPECIES.length()) {
5027             var actualMask = SPECIES.indexInRange(i + offset, limit);
5028             var expectedMask = SPECIES.maskAll(true).indexInRange(i + offset, limit);
5029             assert(actualMask.equals(expectedMask));
5030             for (int j = 0; j < SPECIES.length(); j++)  {
5031                 int index = i + j + offset;
5032                 Assert.assertEquals(actualMask.laneIsSet(j), index >= 0 && index < limit);
5033             }
5034         }
5035     }
5036 
5037     @Test(dataProvider = "offsetProvider")
5038     static void indexInRangeLongDoubleMaxVectorTestsSmokeTest(int offset) {
5039         long limit = SPECIES.length() * BUFFER_REPS;
5040         for (long i = 0; i < limit; i += SPECIES.length()) {
5041             var actualMask = SPECIES.indexInRange(i + offset, limit);
5042             var expectedMask = SPECIES.maskAll(true).indexInRange(i + offset, limit);
5043             assert(actualMask.equals(expectedMask));
5044             for (int j = 0; j < SPECIES.length(); j++)  {
5045                 long index = i + j + offset;
5046                 Assert.assertEquals(actualMask.laneIsSet(j), index >= 0 && index < limit);
5047             }
5048         }
5049     }
5050 
5051     @DataProvider
5052     public static Object[][] lengthProvider() {
5053         return new Object[][]{
5054                 {0},
5055                 {1},
5056                 {32},
5057                 {37},
5058                 {1024},
5059                 {1024+1},
5060                 {1024+5},
5061         };
5062     }
5063 
5064     @Test(dataProvider = "lengthProvider")
5065     static void loopBoundDoubleMaxVectorTestsSmokeTest(int length) {
5066         int actualLoopBound = SPECIES.loopBound(length);
5067         int expectedLoopBound = length - Math.floorMod(length, SPECIES.length());
5068         Assert.assertEquals(actualLoopBound, expectedLoopBound);
5069     }
5070 
5071     @Test(dataProvider = "lengthProvider")
5072     static void loopBoundLongDoubleMaxVectorTestsSmokeTest(int _length) {
5073         long length = _length;
5074         long actualLoopBound = SPECIES.loopBound(length);
5075         long expectedLoopBound = length - Math.floorMod(length, SPECIES.length());
5076         Assert.assertEquals(actualLoopBound, expectedLoopBound);
5077     }
5078 
5079     @Test
5080     static void ElementSizeDoubleMaxVectorTestsSmokeTest() {
5081         DoubleVector av = DoubleVector.zero(SPECIES);
5082         int elsize = av.elementSize();
5083         Assert.assertEquals(elsize, Double.SIZE);
5084     }
5085 
5086     @Test
5087     static void VectorShapeDoubleMaxVectorTestsSmokeTest() {
5088         DoubleVector av = DoubleVector.zero(SPECIES);
5089         VectorShape vsh = av.shape();
5090         assert(vsh.equals(VectorShape.S_Max_BIT));
5091     }
5092 
5093     @Test
5094     static void ShapeWithLanesDoubleMaxVectorTestsSmokeTest() {
5095         DoubleVector av = DoubleVector.zero(SPECIES);
5096         VectorShape vsh = av.shape();
5097         VectorSpecies species = vsh.withLanes(double.class);
5098         assert(species.equals(SPECIES));

5121         DoubleVector av = DoubleVector.zero(SPECIES);
5122         VectorSpecies species = av.species().withLanes(double.class);
5123         assert(species.equals(SPECIES));
5124     }
5125 
5126     @Test
5127     static void WithShapeDoubleMaxVectorTestsSmokeTest() {
5128         DoubleVector av = DoubleVector.zero(SPECIES);
5129         VectorShape vsh = av.shape();
5130         VectorSpecies species = av.species().withShape(vsh);
5131         assert(species.equals(SPECIES));
5132     }
5133 
5134     @Test
5135     static void MaskAllTrueDoubleMaxVectorTestsSmokeTest() {
5136         for (int ic = 0; ic < INVOC_COUNT; ic++) {
5137           Assert.assertEquals(SPECIES.maskAll(true).toLong(), -1L >>> (64 - SPECIES.length()));
5138         }
5139     }
5140 }

< prev index next >