< prev index next >

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

Print this page




 229 
 230     interface FBinMaskOp {
 231         double apply(double a, double b, boolean m);
 232 
 233         static FBinMaskOp lift(FBinOp f) {
 234             return (a, b, m) -> m ? f.apply(a, b) : a;
 235         }
 236     }
 237 
 238     static void assertArraysEquals(double[] a, double[] b, double[] r, FBinOp f) {
 239         int i = 0;
 240         try {
 241             for (; i < a.length; i++) {
 242                 Assert.assertEquals(r[i], f.apply(a[i], b[i]));
 243             }
 244         } catch (AssertionError e) {
 245             Assert.assertEquals(r[i], f.apply(a[i], b[i]), "(" + a[i] + ", " + b[i] + ") at index #" + i);
 246         }
 247     }
 248 












 249     static void assertArraysEquals(double[] a, double[] b, double[] r, boolean[] mask, FBinOp f) {
 250         assertArraysEquals(a, b, r, mask, FBinMaskOp.lift(f));
 251     }
 252 
 253     static void assertArraysEquals(double[] a, double[] b, double[] r, boolean[] mask, FBinMaskOp f) {
 254         int i = 0;
 255         try {
 256             for (; i < a.length; i++) {
 257                 Assert.assertEquals(r[i], f.apply(a[i], b[i], mask[i % SPECIES.length()]));
 258             }
 259         } catch (AssertionError err) {
 260             Assert.assertEquals(r[i], f.apply(a[i], b[i], mask[i % SPECIES.length()]), "at index #" + i + ", input1 = " + a[i] + ", input2 = " + b[i] + ", mask = " + mask[i % SPECIES.length()]);
 261         }
 262     }
 263 


















 264     static void assertShiftArraysEquals(double[] a, double[] b, double[] r, FBinOp f) {
 265         int i = 0;
 266         int j = 0;
 267         try {
 268             for (; j < a.length; j += SPECIES.length()) {
 269                 for (i = 0; i < SPECIES.length(); i++) {
 270                     Assert.assertEquals(r[i+j], f.apply(a[i+j], b[j]));
 271                 }
 272             }
 273         } catch (AssertionError e) {
 274             Assert.assertEquals(r[i+j], f.apply(a[i+j], b[j]), "at index #" + i + ", " + j);
 275         }
 276     }
 277 
 278     static void assertShiftArraysEquals(double[] a, double[] b, double[] r, boolean[] mask, FBinOp f) {
 279         assertShiftArraysEquals(a, b, r, mask, FBinMaskOp.lift(f));
 280     }
 281 
 282     static void assertShiftArraysEquals(double[] a, double[] b, double[] r, boolean[] mask, FBinMaskOp f) {
 283         int i = 0;


1253 
1254         for (int ic = 0; ic < INVOC_COUNT; ic++) {
1255             for (int i = 0; i < a.length; i += SPECIES.length()) {
1256                 DoubleVector av = DoubleVector.fromArray(SPECIES, a, i);
1257                 DoubleVector bv = DoubleVector.fromArray(SPECIES, b, i);
1258                 av.lanewise(VectorOperators.FIRST_NONZERO, bv, vmask).intoArray(r, i);
1259             }
1260         }
1261 
1262         assertArraysEquals(a, b, r, mask, DoubleMaxVectorTests::FIRST_NONZERO);
1263     }
1264 
1265 
1266 
1267 
1268 
1269 
1270 
1271 
1272 




































































































































1273 
1274 
1275 
1276 
1277 
1278 
1279 
1280 
1281 
1282 
1283 
1284 
1285 
1286 
1287 
1288 
1289 
1290 
1291 
1292 


1369         return (double)(Math.max(a, b));
1370     }
1371 
1372     @Test(dataProvider = "doubleBinaryOpProvider")
1373     static void maxDoubleMaxVectorTests(IntFunction<double[]> fa, IntFunction<double[]> fb) {
1374         double[] a = fa.apply(SPECIES.length());
1375         double[] b = fb.apply(SPECIES.length());
1376         double[] r = fr.apply(SPECIES.length());
1377 
1378         for (int ic = 0; ic < INVOC_COUNT; ic++) {
1379             for (int i = 0; i < a.length; i += SPECIES.length()) {
1380                 DoubleVector av = DoubleVector.fromArray(SPECIES, a, i);
1381                 DoubleVector bv = DoubleVector.fromArray(SPECIES, b, i);
1382                 av.max(bv).intoArray(r, i);
1383             }
1384         }
1385 
1386         assertArraysEquals(a, b, r, DoubleMaxVectorTests::max);
1387     }
1388 
























































1389 
1390 
1391 
1392 
1393 
1394 
1395 
1396 
1397 
1398 
1399 
1400     static double ADD(double[] a, int idx) {
1401         double res = 0;
1402         for (int i = idx; i < (idx + SPECIES.length()); i++) {
1403             res += a[i];
1404         }
1405 
1406         return res;
1407     }
1408 


2983         for (int ic = 0; ic < INVOC_COUNT; ic++) {
2984             for (int i = 0; i < a.length; i += SPECIES.length()) {
2985                 DoubleVector av = DoubleVector.fromArray(SPECIES, a, i);
2986                 DoubleVector bv = DoubleVector.fromArray(SPECIES, b, i);
2987                 DoubleVector cv = DoubleVector.fromArray(SPECIES, c, i);
2988                 av.lanewise(VectorOperators.FMA, bv, cv, vmask).intoArray(r, i);
2989             }
2990         }
2991 
2992         assertArraysEquals(a, b, c, r, mask, DoubleMaxVectorTests::FMA);
2993     }
2994 
2995 
2996 
2997 
2998 
2999     static double NEG(double a) {
3000         return (double)(-((double)a));
3001     }
3002 




3003     @Test(dataProvider = "doubleUnaryOpProvider")
3004     static void NEGDoubleMaxVectorTests(IntFunction<double[]> fa) {
3005         double[] a = fa.apply(SPECIES.length());
3006         double[] r = fr.apply(SPECIES.length());
3007 
3008         for (int ic = 0; ic < INVOC_COUNT; ic++) {
3009             for (int i = 0; i < a.length; i += SPECIES.length()) {
3010                 DoubleVector av = DoubleVector.fromArray(SPECIES, a, i);
3011                 av.lanewise(VectorOperators.NEG).intoArray(r, i);
3012             }
3013         }
3014 
3015         assertArraysEquals(a, r, DoubleMaxVectorTests::NEG);















3016     }
3017 
3018     @Test(dataProvider = "doubleUnaryOpMaskProvider")
3019     static void NEGMaskedDoubleMaxVectorTests(IntFunction<double[]> fa,
3020                                                 IntFunction<boolean[]> fm) {
3021         double[] a = fa.apply(SPECIES.length());
3022         double[] r = fr.apply(SPECIES.length());
3023         boolean[] mask = fm.apply(SPECIES.length());
3024         VectorMask<Double> vmask = VectorMask.fromArray(SPECIES, mask, 0);
3025 
3026         for (int ic = 0; ic < INVOC_COUNT; ic++) {
3027             for (int i = 0; i < a.length; i += SPECIES.length()) {
3028                 DoubleVector av = DoubleVector.fromArray(SPECIES, a, i);
3029                 av.lanewise(VectorOperators.NEG, vmask).intoArray(r, i);
3030             }
3031         }
3032 
3033         assertArraysEquals(a, r, mask, DoubleMaxVectorTests::NEG);
3034     }
3035 




 229 
 230     interface FBinMaskOp {
 231         double apply(double a, double b, boolean m);
 232 
 233         static FBinMaskOp lift(FBinOp f) {
 234             return (a, b, m) -> m ? f.apply(a, b) : a;
 235         }
 236     }
 237 
 238     static void assertArraysEquals(double[] a, double[] b, double[] r, FBinOp f) {
 239         int i = 0;
 240         try {
 241             for (; i < a.length; i++) {
 242                 Assert.assertEquals(r[i], f.apply(a[i], b[i]));
 243             }
 244         } catch (AssertionError e) {
 245             Assert.assertEquals(r[i], f.apply(a[i], b[i]), "(" + a[i] + ", " + b[i] + ") at index #" + i);
 246         }
 247     }
 248 
 249     static void assertBroadcastArraysEquals(double[] a, double[] b, double[] r, FBinOp f) {
 250         int i = 0;
 251         try {
 252             for (; i < a.length; i++) {
 253                 Assert.assertEquals(r[i], f.apply(a[i], b[(i / SPECIES.length()) * SPECIES.length()]));
 254             }
 255         } catch (AssertionError e) {
 256             Assert.assertEquals(r[i], f.apply(a[i], b[(i / SPECIES.length()) * SPECIES.length()]),
 257                                 "(" + a[i] + ", " + b[(i / SPECIES.length()) * SPECIES.length()] + ") at index #" + i);
 258         }
 259     }
 260 
 261     static void assertArraysEquals(double[] a, double[] b, double[] r, boolean[] mask, FBinOp f) {
 262         assertArraysEquals(a, b, r, mask, FBinMaskOp.lift(f));
 263     }
 264 
 265     static void assertArraysEquals(double[] a, double[] b, double[] r, boolean[] mask, FBinMaskOp f) {
 266         int i = 0;
 267         try {
 268             for (; i < a.length; i++) {
 269                 Assert.assertEquals(r[i], f.apply(a[i], b[i], mask[i % SPECIES.length()]));
 270             }
 271         } catch (AssertionError err) {
 272             Assert.assertEquals(r[i], f.apply(a[i], b[i], mask[i % SPECIES.length()]), "at index #" + i + ", input1 = " + a[i] + ", input2 = " + b[i] + ", mask = " + mask[i % SPECIES.length()]);
 273         }
 274     }
 275 
 276     static void assertBroadcastArraysEquals(double[] a, double[] b, double[] r, boolean[] mask, FBinOp f) {
 277         assertBroadcastArraysEquals(a, b, r, mask, FBinMaskOp.lift(f));
 278     }
 279 
 280     static void assertBroadcastArraysEquals(double[] a, double[] b, double[] r, boolean[] mask, FBinMaskOp f) {
 281         int i = 0;
 282         try {
 283             for (; i < a.length; i++) {
 284                 Assert.assertEquals(r[i], f.apply(a[i], b[(i / SPECIES.length()) * SPECIES.length()], mask[i % SPECIES.length()]));
 285             }
 286         } catch (AssertionError err) {
 287             Assert.assertEquals(r[i], f.apply(a[i], b[(i / SPECIES.length()) * SPECIES.length()], 
 288                                 mask[i % SPECIES.length()]), "at index #" + i + ", input1 = " + a[i] + 
 289                                 ", input2 = " + b[(i / SPECIES.length()) * SPECIES.length()] + ", mask = " +
 290                                 mask[i % SPECIES.length()]);
 291         }
 292     }
 293 
 294     static void assertShiftArraysEquals(double[] a, double[] b, double[] r, FBinOp f) {
 295         int i = 0;
 296         int j = 0;
 297         try {
 298             for (; j < a.length; j += SPECIES.length()) {
 299                 for (i = 0; i < SPECIES.length(); i++) {
 300                     Assert.assertEquals(r[i+j], f.apply(a[i+j], b[j]));
 301                 }
 302             }
 303         } catch (AssertionError e) {
 304             Assert.assertEquals(r[i+j], f.apply(a[i+j], b[j]), "at index #" + i + ", " + j);
 305         }
 306     }
 307 
 308     static void assertShiftArraysEquals(double[] a, double[] b, double[] r, boolean[] mask, FBinOp f) {
 309         assertShiftArraysEquals(a, b, r, mask, FBinMaskOp.lift(f));
 310     }
 311 
 312     static void assertShiftArraysEquals(double[] a, double[] b, double[] r, boolean[] mask, FBinMaskOp f) {
 313         int i = 0;


1283 
1284         for (int ic = 0; ic < INVOC_COUNT; ic++) {
1285             for (int i = 0; i < a.length; i += SPECIES.length()) {
1286                 DoubleVector av = DoubleVector.fromArray(SPECIES, a, i);
1287                 DoubleVector bv = DoubleVector.fromArray(SPECIES, b, i);
1288                 av.lanewise(VectorOperators.FIRST_NONZERO, bv, vmask).intoArray(r, i);
1289             }
1290         }
1291 
1292         assertArraysEquals(a, b, r, mask, DoubleMaxVectorTests::FIRST_NONZERO);
1293     }
1294 
1295 
1296 
1297 
1298 
1299 
1300 
1301 
1302 
1303     @Test(dataProvider = "doubleBinaryOpProvider")
1304     static void addDoubleMaxVectorTestsBroadcastSmokeTest(IntFunction<double[]> fa, IntFunction<double[]> fb) {
1305         double[] a = fa.apply(SPECIES.length());
1306         double[] b = fb.apply(SPECIES.length());
1307         double[] r = fr.apply(SPECIES.length());
1308 
1309         for (int i = 0; i < a.length; i += SPECIES.length()) {
1310             DoubleVector av = DoubleVector.fromArray(SPECIES, a, i);
1311             av.add(b[i]).intoArray(r, i);
1312         }
1313 
1314         assertBroadcastArraysEquals(a, b, r, DoubleMaxVectorTests::add);
1315     }
1316 
1317     @Test(dataProvider = "doubleBinaryOpMaskProvider")
1318     static void addDoubleMaxVectorTestsBroadcastMaskedSmokeTest(IntFunction<double[]> fa, IntFunction<double[]> fb,
1319                                           IntFunction<boolean[]> fm) {
1320         double[] a = fa.apply(SPECIES.length());
1321         double[] b = fb.apply(SPECIES.length());
1322         double[] r = fr.apply(SPECIES.length());
1323         boolean[] mask = fm.apply(SPECIES.length());
1324         VectorMask<Double> vmask = VectorMask.fromArray(SPECIES, mask, 0);
1325 
1326         for (int i = 0; i < a.length; i += SPECIES.length()) {
1327             DoubleVector av = DoubleVector.fromArray(SPECIES, a, i);
1328             av.add(b[i], vmask).intoArray(r, i);
1329         }
1330 
1331         assertBroadcastArraysEquals(a, b, r, mask, DoubleMaxVectorTests::add);
1332     }
1333 
1334     @Test(dataProvider = "doubleBinaryOpProvider")
1335     static void subDoubleMaxVectorTestsBroadcastSmokeTest(IntFunction<double[]> fa, IntFunction<double[]> fb) {
1336         double[] a = fa.apply(SPECIES.length());
1337         double[] b = fb.apply(SPECIES.length());
1338         double[] r = fr.apply(SPECIES.length());
1339 
1340         for (int i = 0; i < a.length; i += SPECIES.length()) {
1341             DoubleVector av = DoubleVector.fromArray(SPECIES, a, i);
1342             av.sub(b[i]).intoArray(r, i);
1343         }
1344 
1345         assertBroadcastArraysEquals(a, b, r, DoubleMaxVectorTests::sub);
1346     }
1347 
1348     @Test(dataProvider = "doubleBinaryOpMaskProvider")
1349     static void subDoubleMaxVectorTestsBroadcastMaskedSmokeTest(IntFunction<double[]> fa, IntFunction<double[]> fb,
1350                                           IntFunction<boolean[]> fm) {
1351         double[] a = fa.apply(SPECIES.length());
1352         double[] b = fb.apply(SPECIES.length());
1353         double[] r = fr.apply(SPECIES.length());
1354         boolean[] mask = fm.apply(SPECIES.length());
1355         VectorMask<Double> vmask = VectorMask.fromArray(SPECIES, mask, 0);
1356 
1357         for (int i = 0; i < a.length; i += SPECIES.length()) {
1358             DoubleVector av = DoubleVector.fromArray(SPECIES, a, i);
1359             av.sub(b[i], vmask).intoArray(r, i);
1360         }
1361 
1362         assertBroadcastArraysEquals(a, b, r, mask, DoubleMaxVectorTests::sub);
1363     }
1364 
1365     @Test(dataProvider = "doubleBinaryOpProvider")
1366     static void mulDoubleMaxVectorTestsBroadcastSmokeTest(IntFunction<double[]> fa, IntFunction<double[]> fb) {
1367         double[] a = fa.apply(SPECIES.length());
1368         double[] b = fb.apply(SPECIES.length());
1369         double[] r = fr.apply(SPECIES.length());
1370 
1371         for (int i = 0; i < a.length; i += SPECIES.length()) {
1372             DoubleVector av = DoubleVector.fromArray(SPECIES, a, i);
1373             av.mul(b[i]).intoArray(r, i);
1374         }
1375 
1376         assertBroadcastArraysEquals(a, b, r, DoubleMaxVectorTests::mul);
1377     }
1378 
1379     @Test(dataProvider = "doubleBinaryOpMaskProvider")
1380     static void mulDoubleMaxVectorTestsBroadcastMaskedSmokeTest(IntFunction<double[]> fa, IntFunction<double[]> fb,
1381                                           IntFunction<boolean[]> fm) {
1382         double[] a = fa.apply(SPECIES.length());
1383         double[] b = fb.apply(SPECIES.length());
1384         double[] r = fr.apply(SPECIES.length());
1385         boolean[] mask = fm.apply(SPECIES.length());
1386         VectorMask<Double> vmask = VectorMask.fromArray(SPECIES, mask, 0);
1387 
1388         for (int i = 0; i < a.length; i += SPECIES.length()) {
1389             DoubleVector av = DoubleVector.fromArray(SPECIES, a, i);
1390             av.mul(b[i], vmask).intoArray(r, i);
1391         }
1392 
1393         assertBroadcastArraysEquals(a, b, r, mask, DoubleMaxVectorTests::mul);
1394     }
1395 
1396 
1397     @Test(dataProvider = "doubleBinaryOpProvider")
1398     static void divDoubleMaxVectorTestsBroadcastSmokeTest(IntFunction<double[]> fa, IntFunction<double[]> fb) {
1399         double[] a = fa.apply(SPECIES.length());
1400         double[] b = fb.apply(SPECIES.length());
1401         double[] r = fr.apply(SPECIES.length());
1402 
1403         for (int i = 0; i < a.length; i += SPECIES.length()) {
1404             DoubleVector av = DoubleVector.fromArray(SPECIES, a, i);
1405             av.div(b[i]).intoArray(r, i);
1406         }
1407 
1408         assertBroadcastArraysEquals(a, b, r, DoubleMaxVectorTests::div);
1409     }
1410 
1411 
1412 
1413     @Test(dataProvider = "doubleBinaryOpMaskProvider")
1414     static void divDoubleMaxVectorTestsBroadcastMaskedSmokeTest(IntFunction<double[]> fa, IntFunction<double[]> fb,
1415                                           IntFunction<boolean[]> fm) {
1416         double[] a = fa.apply(SPECIES.length());
1417         double[] b = fb.apply(SPECIES.length());
1418         double[] r = fr.apply(SPECIES.length());
1419         boolean[] mask = fm.apply(SPECIES.length());
1420         VectorMask<Double> vmask = VectorMask.fromArray(SPECIES, mask, 0);
1421 
1422         for (int i = 0; i < a.length; i += SPECIES.length()) {
1423             DoubleVector av = DoubleVector.fromArray(SPECIES, a, i);
1424             av.div(b[i], vmask).intoArray(r, i);
1425         }
1426 
1427         assertBroadcastArraysEquals(a, b, r, mask, DoubleMaxVectorTests::div);
1428     }
1429 
1430 
1431 
1432 
1433 
1434 
1435 
1436 
1437 
1438 
1439 
1440 
1441 
1442 
1443 
1444 
1445 
1446 
1447 
1448 
1449 
1450 
1451 
1452 
1453 
1454 


1531         return (double)(Math.max(a, b));
1532     }
1533 
1534     @Test(dataProvider = "doubleBinaryOpProvider")
1535     static void maxDoubleMaxVectorTests(IntFunction<double[]> fa, IntFunction<double[]> fb) {
1536         double[] a = fa.apply(SPECIES.length());
1537         double[] b = fb.apply(SPECIES.length());
1538         double[] r = fr.apply(SPECIES.length());
1539 
1540         for (int ic = 0; ic < INVOC_COUNT; ic++) {
1541             for (int i = 0; i < a.length; i += SPECIES.length()) {
1542                 DoubleVector av = DoubleVector.fromArray(SPECIES, a, i);
1543                 DoubleVector bv = DoubleVector.fromArray(SPECIES, b, i);
1544                 av.max(bv).intoArray(r, i);
1545             }
1546         }
1547 
1548         assertArraysEquals(a, b, r, DoubleMaxVectorTests::max);
1549     }
1550 
1551     @Test(dataProvider = "doubleBinaryOpProvider")
1552     static void MINDoubleMaxVectorTestsBroadcastSmokeTest(IntFunction<double[]> fa, IntFunction<double[]> fb) {
1553         double[] a = fa.apply(SPECIES.length());
1554         double[] b = fb.apply(SPECIES.length());
1555         double[] r = fr.apply(SPECIES.length());
1556 
1557         for (int i = 0; i < a.length; i += SPECIES.length()) {
1558             DoubleVector av = DoubleVector.fromArray(SPECIES, a, i);
1559             av.lanewise(VectorOperators.MIN, b[i]).intoArray(r, i);
1560         }
1561 
1562         assertBroadcastArraysEquals(a, b, r, DoubleMaxVectorTests::MIN);
1563     }
1564 
1565     @Test(dataProvider = "doubleBinaryOpProvider")
1566     static void minDoubleMaxVectorTestsBroadcastSmokeTest(IntFunction<double[]> fa, IntFunction<double[]> fb) {
1567         double[] a = fa.apply(SPECIES.length());
1568         double[] b = fb.apply(SPECIES.length());
1569         double[] r = fr.apply(SPECIES.length());
1570 
1571         for (int i = 0; i < a.length; i += SPECIES.length()) {
1572             DoubleVector av = DoubleVector.fromArray(SPECIES, a, i);
1573             av.min(b[i]).intoArray(r, i);
1574         }
1575 
1576         assertBroadcastArraysEquals(a, b, r, DoubleMaxVectorTests::min);
1577     }
1578 
1579     @Test(dataProvider = "doubleBinaryOpProvider")
1580     static void MAXDoubleMaxVectorTestsBroadcastSmokeTest(IntFunction<double[]> fa, IntFunction<double[]> fb) {
1581         double[] a = fa.apply(SPECIES.length());
1582         double[] b = fb.apply(SPECIES.length());
1583         double[] r = fr.apply(SPECIES.length());
1584 
1585         for (int i = 0; i < a.length; i += SPECIES.length()) {
1586             DoubleVector av = DoubleVector.fromArray(SPECIES, a, i);
1587             av.lanewise(VectorOperators.MAX, b[i]).intoArray(r, i);
1588         }
1589 
1590         assertBroadcastArraysEquals(a, b, r, DoubleMaxVectorTests::MAX);
1591     }
1592 
1593     @Test(dataProvider = "doubleBinaryOpProvider")
1594     static void maxDoubleMaxVectorTestsBroadcastSmokeTest(IntFunction<double[]> fa, IntFunction<double[]> fb) {
1595         double[] a = fa.apply(SPECIES.length());
1596         double[] b = fb.apply(SPECIES.length());
1597         double[] r = fr.apply(SPECIES.length());
1598 
1599         for (int i = 0; i < a.length; i += SPECIES.length()) {
1600             DoubleVector av = DoubleVector.fromArray(SPECIES, a, i);
1601             av.max(b[i]).intoArray(r, i);
1602         }
1603 
1604         assertBroadcastArraysEquals(a, b, r, DoubleMaxVectorTests::max);
1605     }
1606 
1607 
1608 
1609 
1610 
1611 
1612 
1613 
1614 
1615 
1616 
1617 
1618     static double ADD(double[] a, int idx) {
1619         double res = 0;
1620         for (int i = idx; i < (idx + SPECIES.length()); i++) {
1621             res += a[i];
1622         }
1623 
1624         return res;
1625     }
1626 


3201         for (int ic = 0; ic < INVOC_COUNT; ic++) {
3202             for (int i = 0; i < a.length; i += SPECIES.length()) {
3203                 DoubleVector av = DoubleVector.fromArray(SPECIES, a, i);
3204                 DoubleVector bv = DoubleVector.fromArray(SPECIES, b, i);
3205                 DoubleVector cv = DoubleVector.fromArray(SPECIES, c, i);
3206                 av.lanewise(VectorOperators.FMA, bv, cv, vmask).intoArray(r, i);
3207             }
3208         }
3209 
3210         assertArraysEquals(a, b, c, r, mask, DoubleMaxVectorTests::FMA);
3211     }
3212 
3213 
3214 
3215 
3216 
3217     static double NEG(double a) {
3218         return (double)(-((double)a));
3219     }
3220 
3221     static double neg(double a) {
3222         return (double)(-((double)a));
3223     }
3224 
3225     @Test(dataProvider = "doubleUnaryOpProvider")
3226     static void NEGDoubleMaxVectorTests(IntFunction<double[]> fa) {
3227         double[] a = fa.apply(SPECIES.length());
3228         double[] r = fr.apply(SPECIES.length());
3229 
3230         for (int ic = 0; ic < INVOC_COUNT; ic++) {
3231             for (int i = 0; i < a.length; i += SPECIES.length()) {
3232                 DoubleVector av = DoubleVector.fromArray(SPECIES, a, i);
3233                 av.lanewise(VectorOperators.NEG).intoArray(r, i);
3234             }
3235         }
3236 
3237         assertArraysEquals(a, r, DoubleMaxVectorTests::NEG);
3238     }
3239 
3240     @Test(dataProvider = "doubleUnaryOpProvider")
3241     static void negDoubleMaxVectorTests(IntFunction<double[]> fa) {
3242         double[] a = fa.apply(SPECIES.length());
3243         double[] r = fr.apply(SPECIES.length());
3244 
3245         for (int ic = 0; ic < INVOC_COUNT; ic++) {
3246             for (int i = 0; i < a.length; i += SPECIES.length()) {
3247                 DoubleVector av = DoubleVector.fromArray(SPECIES, a, i);
3248                 av.neg().intoArray(r, i);
3249             }
3250         }
3251 
3252         assertArraysEquals(a, r, DoubleMaxVectorTests::neg);
3253     }
3254 
3255     @Test(dataProvider = "doubleUnaryOpMaskProvider")
3256     static void NEGMaskedDoubleMaxVectorTests(IntFunction<double[]> fa,
3257                                                 IntFunction<boolean[]> fm) {
3258         double[] a = fa.apply(SPECIES.length());
3259         double[] r = fr.apply(SPECIES.length());
3260         boolean[] mask = fm.apply(SPECIES.length());
3261         VectorMask<Double> vmask = VectorMask.fromArray(SPECIES, mask, 0);
3262 
3263         for (int ic = 0; ic < INVOC_COUNT; ic++) {
3264             for (int i = 0; i < a.length; i += SPECIES.length()) {
3265                 DoubleVector av = DoubleVector.fromArray(SPECIES, a, i);
3266                 av.lanewise(VectorOperators.NEG, vmask).intoArray(r, i);
3267             }
3268         }
3269 
3270         assertArraysEquals(a, r, mask, DoubleMaxVectorTests::NEG);
3271     }
3272 


< prev index next >