< prev index next >

src/jdk.incubator.vector/share/classes/jdk/incubator/vector/Short64Vector.java

Print this page




1039 
1040     @Override
1041     void forEach(FUnCon f) {
1042         short[] vec = getElements();
1043         for (int i = 0; i < length(); i++) {
1044             f.apply(i, vec[i]);
1045         }
1046     }
1047 
1048     @Override
1049     void forEach(VectorMask<Short> o, FUnCon f) {
1050         boolean[] mbits = ((Short64Mask)o).getBits();
1051         forEach((i, a) -> {
1052             if (mbits[i]) { f.apply(i, a); }
1053         });
1054     }
1055 
1056 
1057 
1058     @Override

1059     public Short64Vector rotateLanesLeft(int j) {
1060         short[] vec = getElements();
1061         short[] res = new short[length()];
1062         for (int i = 0; i < length(); i++){
1063             res[(j + i) % length()] = vec[i];



1064         }
1065         return new Short64Vector(res);
1066     }
1067 
1068     @Override

1069     public Short64Vector rotateLanesRight(int j) {
1070         short[] vec = getElements();
1071         short[] res = new short[length()];
1072         for (int i = 0; i < length(); i++){
1073             int z = i - j;
1074             if(j < 0) {
1075                 res[length() + z] = vec[i];
1076             } else {
1077                 res[z] = vec[i];
1078             }

1079         }
1080         return new Short64Vector(res);
1081     }
1082 
1083     @Override


1084     public Short64Vector shiftLanesLeft(int j) {
1085         short[] vec = getElements();
1086         short[] res = new short[length()];
1087         for (int i = 0; i < length() - j; i++) {
1088             res[i] = vec[i + j];






1089         }
1090         return new Short64Vector(res);
1091     }
1092 
1093     @Override


1094     public Short64Vector shiftLanesRight(int j) {
1095         short[] vec = getElements();
1096         short[] res = new short[length()];
1097         for (int i = 0; i < length() - j; i++){
1098             res[i + j] = vec[i];






1099         }
1100         return new Short64Vector(res);
1101     }
1102 
1103     @Override
1104     @ForceInline
1105     public Short64Vector rearrange(Vector<Short> v,
1106                                   VectorShuffle<Short> s, VectorMask<Short> m) {
1107         return this.rearrange(s).blend(v.rearrange(s), m);
1108     }
1109 
1110     @Override
1111     @ForceInline
1112     public Short64Vector rearrange(VectorShuffle<Short> o1) {
1113         Objects.requireNonNull(o1);
1114         Short64Shuffle s =  (Short64Shuffle)o1;
1115 
1116         return VectorIntrinsics.rearrangeOp(
1117             Short64Vector.class, Short64Shuffle.class, short.class, LENGTH,
1118             this, s,
1119             (v1, s_) -> v1.uOp((i, a) -> {
1120                 int ei = s_.lane(i);


1319             super(reorder);
1320         }
1321 
1322         public Short64Shuffle(int[] reorder) {
1323             super(reorder);
1324         }
1325 
1326         public Short64Shuffle(int[] reorder, int i) {
1327             super(reorder, i);
1328         }
1329 
1330         public Short64Shuffle(IntUnaryOperator f) {
1331             super(f);
1332         }
1333 
1334         @Override
1335         public VectorSpecies<Short> species() {
1336             return SPECIES;
1337         }
1338 
1339         @Override
1340         public ShortVector toVector() {
1341             short[] va = new short[SPECIES.length()];
1342             for (int i = 0; i < va.length; i++) {
1343               va[i] = (short) lane(i);
1344             }
1345             return ShortVector.fromArray(SPECIES, va, 0);
1346         }
1347 
1348         @Override
1349         @ForceInline








1350         @SuppressWarnings("unchecked")
1351         public <F> VectorShuffle<F> cast(VectorSpecies<F> species) {
1352             if (length() != species.length())
1353                 throw new IllegalArgumentException("Shuffle length and species length differ");
1354             Class<?> stype = species.elementType();
1355             int [] shuffleArray = toArray();
1356             if (stype == byte.class) {
1357                 return (VectorShuffle<F>) new Byte64Vector.Byte64Shuffle(shuffleArray);
1358             } else if (stype == short.class) {
1359                 return (VectorShuffle<F>) new Short64Vector.Short64Shuffle(shuffleArray);
1360             } else if (stype == int.class) {
1361                 return (VectorShuffle<F>) new Int64Vector.Int64Shuffle(shuffleArray);
1362             } else if (stype == long.class) {
1363                 return (VectorShuffle<F>) new Long64Vector.Long64Shuffle(shuffleArray);
1364             } else if (stype == float.class) {
1365                 return (VectorShuffle<F>) new Float64Vector.Float64Shuffle(shuffleArray);
1366             } else if (stype == double.class) {
1367                 return (VectorShuffle<F>) new Double64Vector.Double64Shuffle(shuffleArray);
1368             } else {
1369                 throw new UnsupportedOperationException("Bad lane type for casting.");
1370             }
1371         }

1372 
1373         @Override
1374         public Short64Shuffle rearrange(VectorShuffle<Short> o) {
1375             Short64Shuffle s = (Short64Shuffle) o;
1376             byte[] r = new byte[reorder.length];
1377             for (int i = 0; i < reorder.length; i++) {
1378                 r[i] = reorder[s.reorder[i]];
1379             }
1380             return new Short64Shuffle(r);
1381         }
1382     }
1383 
1384     // VectorSpecies
1385 
1386     @Override
1387     public VectorSpecies<Short> species() {
1388         return SPECIES;
1389     }
1390 }


1039 
1040     @Override
1041     void forEach(FUnCon f) {
1042         short[] vec = getElements();
1043         for (int i = 0; i < length(); i++) {
1044             f.apply(i, vec[i]);
1045         }
1046     }
1047 
1048     @Override
1049     void forEach(VectorMask<Short> o, FUnCon f) {
1050         boolean[] mbits = ((Short64Mask)o).getBits();
1051         forEach((i, a) -> {
1052             if (mbits[i]) { f.apply(i, a); }
1053         });
1054     }
1055 
1056 
1057 
1058     @Override
1059     @ForceInline
1060     public Short64Vector rotateLanesLeft(int j) {
1061       int L = length();
1062       if (j < 0) {
1063          throw new IllegalArgumentException("Index " + j + " must be zero or positive");
1064       } else {
1065         j = j & (L-1);
1066         VectorShuffle<Short> PermMask  = VectorShuffle.shuffleIota(SPECIES, L - j);
1067         return this.rearrange(PermMask);
1068       }

1069     }
1070 
1071     @Override
1072     @ForceInline
1073     public Short64Vector rotateLanesRight(int j) {
1074       int L = length();
1075       if (j < 0) {
1076          throw new IllegalArgumentException("Index " + j + " must be zero or positive");



1077       } else {
1078         j = j & (L-1);
1079         VectorShuffle<Short> PermMask = VectorShuffle.shuffleIota(SPECIES, j);
1080         return this.rearrange(PermMask);
1081       }

1082     }
1083 
1084     @Override
1085     @ForceInline
1086     @SuppressWarnings("unchecked")
1087     public Short64Vector shiftLanesLeft(int j) {
1088        int L = length();
1089        if (j < 0) {
1090          throw new IllegalArgumentException("Index " + j + " must be zero or positive");
1091        } else if ( j >= L ) {
1092          return ZERO;
1093        } else {
1094          Short64Shuffle     Iota    = (Short64Shuffle)(VectorShuffle.shuffleIota(SPECIES, L-j));
1095          VectorMask<Short> BlendMask = Iota.toVector().lessThan(Short64Vector.broadcast(SPECIES, (short)(L-j)));
1096          Iota    = (Short64Shuffle)(VectorShuffle.shuffleIota(SPECIES, L -j));
1097          return ZERO.blend(this.rearrange(Iota),BlendMask);
1098        }

1099     }
1100 
1101     @Override
1102     @ForceInline
1103     @SuppressWarnings("unchecked")
1104     public Short64Vector shiftLanesRight(int j) {
1105        int L = length();
1106        if (j < 0) {
1107          throw new IllegalArgumentException("Index " + j + " must be zero or positive");
1108        } else if ( j >= L ) {
1109          return ZERO;
1110        } else {
1111          Short64Shuffle     Iota    = (Short64Shuffle)(VectorShuffle.shuffleIota(SPECIES, j));
1112          VectorMask<Short> BlendMask = Iota.toVector().greaterThanEq(Short64Vector.broadcast(SPECIES, (short)(j)));
1113          Iota    = (Short64Shuffle)(VectorShuffle.shuffleIota(SPECIES, j));
1114          return ZERO.blend(this.rearrange(Iota),BlendMask);
1115        }

1116     }
1117 
1118     @Override
1119     @ForceInline
1120     public Short64Vector rearrange(Vector<Short> v,
1121                                   VectorShuffle<Short> s, VectorMask<Short> m) {
1122         return this.rearrange(s).blend(v.rearrange(s), m);
1123     }
1124 
1125     @Override
1126     @ForceInline
1127     public Short64Vector rearrange(VectorShuffle<Short> o1) {
1128         Objects.requireNonNull(o1);
1129         Short64Shuffle s =  (Short64Shuffle)o1;
1130 
1131         return VectorIntrinsics.rearrangeOp(
1132             Short64Vector.class, Short64Shuffle.class, short.class, LENGTH,
1133             this, s,
1134             (v1, s_) -> v1.uOp((i, a) -> {
1135                 int ei = s_.lane(i);


1334             super(reorder);
1335         }
1336 
1337         public Short64Shuffle(int[] reorder) {
1338             super(reorder);
1339         }
1340 
1341         public Short64Shuffle(int[] reorder, int i) {
1342             super(reorder, i);
1343         }
1344 
1345         public Short64Shuffle(IntUnaryOperator f) {
1346             super(f);
1347         }
1348 
1349         @Override
1350         public VectorSpecies<Short> species() {
1351             return SPECIES;
1352         }
1353 
1354         private ShortVector toVector_helper() {

1355             short[] va = new short[SPECIES.length()];
1356             for (int i = 0; i < va.length; i++) {
1357               va[i] = (short) lane(i);
1358             }
1359             return ShortVector.fromArray(SPECIES, va, 0);
1360         }
1361 
1362         @Override
1363         @ForceInline
1364         public ShortVector toVector() {
1365             return VectorIntrinsics.shuffleToVector(Short64Vector.class, short.class, Short64Shuffle.class, this,
1366                                                     SPECIES.length(), 
1367                                                     (s) -> (((Short64Shuffle)(s)).toVector_helper()));
1368         }
1369 
1370         @Override
1371         @ForceInline
1372         @SuppressWarnings("unchecked")
1373         public <F> VectorShuffle<F> cast(VectorSpecies<F> species) {
1374             if (length() != species.length())
1375                 throw new IllegalArgumentException("Shuffle length and species length differ");
1376             Class<?> stype = species.elementType();
1377             int [] shuffleArray = toArray();
1378             if (stype == byte.class) {
1379                 return (VectorShuffle<F>) new Byte64Vector.Byte64Shuffle(shuffleArray);
1380             } else if (stype == short.class) {
1381                 return (VectorShuffle<F>) new Short64Vector.Short64Shuffle(shuffleArray);
1382             } else if (stype == int.class) {
1383                 return (VectorShuffle<F>) new Int64Vector.Int64Shuffle(shuffleArray);
1384             } else if (stype == long.class) {
1385                 return (VectorShuffle<F>) new Long64Vector.Long64Shuffle(shuffleArray);
1386             } else if (stype == float.class) {
1387                 return (VectorShuffle<F>) new Float64Vector.Float64Shuffle(shuffleArray);
1388             } else if (stype == double.class) {
1389                 return (VectorShuffle<F>) new Double64Vector.Double64Shuffle(shuffleArray);
1390             } else {
1391                 throw new UnsupportedOperationException("Bad lane type for casting.");
1392             }
1393         }
1394 
1395 
1396         @Override
1397         public Short64Shuffle rearrange(VectorShuffle<Short> o) {
1398             Short64Shuffle s = (Short64Shuffle) o;
1399             byte[] r = new byte[reorder.length];
1400             for (int i = 0; i < reorder.length; i++) {
1401                 r[i] = reorder[s.reorder[i]];
1402             }
1403             return new Short64Shuffle(r);
1404         }
1405     }
1406 
1407     // VectorSpecies
1408 
1409     @Override
1410     public VectorSpecies<Short> species() {
1411         return SPECIES;
1412     }
1413 }
< prev index next >