< prev index next >

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

Print this page




1137 
1138     @Override
1139     void forEach(VectorMask<Double> o, FUnCon f) {
1140         boolean[] mbits = ((Double64Mask)o).getBits();
1141         forEach((i, a) -> {
1142             if (mbits[i]) { f.apply(i, a); }
1143         });
1144     }
1145 
1146     Long64Vector toBits() {
1147         double[] vec = getElements();
1148         long[] res = new long[this.species().length()];
1149         for(int i = 0; i < this.species().length(); i++){
1150             res[i] = Double.doubleToLongBits(vec[i]);
1151         }
1152         return new Long64Vector(res);
1153     }
1154 
1155 
1156     @Override

1157     public Double64Vector rotateLanesLeft(int j) {
1158         double[] vec = getElements();
1159         double[] res = new double[length()];
1160         for (int i = 0; i < length(); i++){
1161             res[(j + i) % length()] = vec[i];



1162         }
1163         return new Double64Vector(res);
1164     }
1165 
1166     @Override

1167     public Double64Vector rotateLanesRight(int j) {
1168         double[] vec = getElements();
1169         double[] res = new double[length()];
1170         for (int i = 0; i < length(); i++){
1171             int z = i - j;
1172             if(j < 0) {
1173                 res[length() + z] = vec[i];
1174             } else {
1175                 res[z] = vec[i];
1176             }

1177         }
1178         return new Double64Vector(res);
1179     }
1180 
1181     @Override


1182     public Double64Vector shiftLanesLeft(int j) {
1183         double[] vec = getElements();
1184         double[] res = new double[length()];
1185         for (int i = 0; i < length() - j; i++) {
1186             res[i] = vec[i + j];






1187         }
1188         return new Double64Vector(res);
1189     }
1190 
1191     @Override


1192     public Double64Vector shiftLanesRight(int j) {
1193         double[] vec = getElements();
1194         double[] res = new double[length()];
1195         for (int i = 0; i < length() - j; i++){
1196             res[i + j] = vec[i];






1197         }
1198         return new Double64Vector(res);
1199     }
1200 
1201     @Override
1202     @ForceInline
1203     public Double64Vector rearrange(Vector<Double> v,
1204                                   VectorShuffle<Double> s, VectorMask<Double> m) {
1205         return this.rearrange(s).blend(v.rearrange(s), m);
1206     }
1207 
1208     @Override
1209     @ForceInline
1210     public Double64Vector rearrange(VectorShuffle<Double> o1) {
1211         Objects.requireNonNull(o1);
1212         Double64Shuffle s =  (Double64Shuffle)o1;
1213 
1214         return VectorIntrinsics.rearrangeOp(
1215             Double64Vector.class, Double64Shuffle.class, double.class, LENGTH,
1216             this, s,
1217             (v1, s_) -> v1.uOp((i, a) -> {
1218                 int ei = s_.lane(i);


1418             super(reorder);
1419         }
1420 
1421         public Double64Shuffle(int[] reorder) {
1422             super(reorder);
1423         }
1424 
1425         public Double64Shuffle(int[] reorder, int i) {
1426             super(reorder, i);
1427         }
1428 
1429         public Double64Shuffle(IntUnaryOperator f) {
1430             super(f);
1431         }
1432 
1433         @Override
1434         public VectorSpecies<Double> species() {
1435             return SPECIES;
1436         }
1437 
1438         @Override
1439         public DoubleVector toVector() {
1440             double[] va = new double[SPECIES.length()];
1441             for (int i = 0; i < va.length; i++) {
1442               va[i] = (double) lane(i);
1443             }
1444             return DoubleVector.fromArray(SPECIES, va, 0);
1445         }
1446 
1447         @Override
1448         @ForceInline








1449         @SuppressWarnings("unchecked")
1450         public <F> VectorShuffle<F> cast(VectorSpecies<F> species) {
1451             if (length() != species.length())
1452                 throw new IllegalArgumentException("Shuffle length and species length differ");
1453             Class<?> stype = species.elementType();
1454             int [] shuffleArray = toArray();
1455             if (stype == byte.class) {
1456                 return (VectorShuffle<F>) new Byte64Vector.Byte64Shuffle(shuffleArray);
1457             } else if (stype == short.class) {
1458                 return (VectorShuffle<F>) new Short64Vector.Short64Shuffle(shuffleArray);
1459             } else if (stype == int.class) {
1460                 return (VectorShuffle<F>) new Int64Vector.Int64Shuffle(shuffleArray);
1461             } else if (stype == long.class) {
1462                 return (VectorShuffle<F>) new Long64Vector.Long64Shuffle(shuffleArray);
1463             } else if (stype == float.class) {
1464                 return (VectorShuffle<F>) new Float64Vector.Float64Shuffle(shuffleArray);
1465             } else if (stype == double.class) {
1466                 return (VectorShuffle<F>) new Double64Vector.Double64Shuffle(shuffleArray);
1467             } else {
1468                 throw new UnsupportedOperationException("Bad lane type for casting.");
1469             }
1470         }

1471 
1472         @Override
1473         public Double64Shuffle rearrange(VectorShuffle<Double> o) {
1474             Double64Shuffle s = (Double64Shuffle) o;
1475             byte[] r = new byte[reorder.length];
1476             for (int i = 0; i < reorder.length; i++) {
1477                 r[i] = reorder[s.reorder[i]];
1478             }
1479             return new Double64Shuffle(r);
1480         }
1481     }
1482 
1483     // VectorSpecies
1484 
1485     @Override
1486     public VectorSpecies<Double> species() {
1487         return SPECIES;
1488     }
1489 }


1137 
1138     @Override
1139     void forEach(VectorMask<Double> o, FUnCon f) {
1140         boolean[] mbits = ((Double64Mask)o).getBits();
1141         forEach((i, a) -> {
1142             if (mbits[i]) { f.apply(i, a); }
1143         });
1144     }
1145 
1146     Long64Vector toBits() {
1147         double[] vec = getElements();
1148         long[] res = new long[this.species().length()];
1149         for(int i = 0; i < this.species().length(); i++){
1150             res[i] = Double.doubleToLongBits(vec[i]);
1151         }
1152         return new Long64Vector(res);
1153     }
1154 
1155 
1156     @Override
1157     @ForceInline
1158     public Double64Vector rotateLanesLeft(int j) {
1159       int L = length();
1160       if (j < 0) {
1161          throw new IllegalArgumentException("Index " + j + " must be zero or positive");
1162       } else {
1163         j = j & (L-1);
1164         VectorShuffle<Double> PermMask  = VectorShuffle.shuffleIota(SPECIES, L - j);
1165         return this.rearrange(PermMask);
1166       }

1167     }
1168 
1169     @Override
1170     @ForceInline
1171     public Double64Vector rotateLanesRight(int j) {
1172       int L = length();
1173       if (j < 0) {
1174          throw new IllegalArgumentException("Index " + j + " must be zero or positive");



1175       } else {
1176         j = j & (L-1);
1177         VectorShuffle<Double> PermMask = VectorShuffle.shuffleIota(SPECIES, j);
1178         return this.rearrange(PermMask);
1179       }

1180     }
1181 
1182     @Override
1183     @ForceInline
1184     @SuppressWarnings("unchecked")
1185     public Double64Vector shiftLanesLeft(int j) {
1186        int L = length();
1187        if (j < 0) {
1188          throw new IllegalArgumentException("Index " + j + " must be zero or positive");
1189        } else if ( j >= L ) {
1190          return ZERO;
1191        } else {
1192          Double64Shuffle     Iota    = (Double64Shuffle)(VectorShuffle.shuffleIota(SPECIES, L-j));
1193          VectorMask<Double> BlendMask = Iota.toVector().lessThan(Double64Vector.broadcast(SPECIES, (double)(L-j)));
1194          Iota    = (Double64Shuffle)(VectorShuffle.shuffleIota(SPECIES, L -j));
1195          return ZERO.blend(this.rearrange(Iota),BlendMask);
1196        }

1197     }
1198 
1199     @Override
1200     @ForceInline
1201     @SuppressWarnings("unchecked")
1202     public Double64Vector shiftLanesRight(int j) {
1203        int L = length();
1204        if (j < 0) {
1205          throw new IllegalArgumentException("Index " + j + " must be zero or positive");
1206        } else if ( j >= L ) {
1207          return ZERO;
1208        } else {
1209          Double64Shuffle     Iota    = (Double64Shuffle)(VectorShuffle.shuffleIota(SPECIES, j));
1210          VectorMask<Double> BlendMask = Iota.toVector().greaterThanEq(Double64Vector.broadcast(SPECIES, (double)(j)));
1211          Iota    = (Double64Shuffle)(VectorShuffle.shuffleIota(SPECIES, j));
1212          return ZERO.blend(this.rearrange(Iota),BlendMask);
1213        }

1214     }
1215 
1216     @Override
1217     @ForceInline
1218     public Double64Vector rearrange(Vector<Double> v,
1219                                   VectorShuffle<Double> s, VectorMask<Double> m) {
1220         return this.rearrange(s).blend(v.rearrange(s), m);
1221     }
1222 
1223     @Override
1224     @ForceInline
1225     public Double64Vector rearrange(VectorShuffle<Double> o1) {
1226         Objects.requireNonNull(o1);
1227         Double64Shuffle s =  (Double64Shuffle)o1;
1228 
1229         return VectorIntrinsics.rearrangeOp(
1230             Double64Vector.class, Double64Shuffle.class, double.class, LENGTH,
1231             this, s,
1232             (v1, s_) -> v1.uOp((i, a) -> {
1233                 int ei = s_.lane(i);


1433             super(reorder);
1434         }
1435 
1436         public Double64Shuffle(int[] reorder) {
1437             super(reorder);
1438         }
1439 
1440         public Double64Shuffle(int[] reorder, int i) {
1441             super(reorder, i);
1442         }
1443 
1444         public Double64Shuffle(IntUnaryOperator f) {
1445             super(f);
1446         }
1447 
1448         @Override
1449         public VectorSpecies<Double> species() {
1450             return SPECIES;
1451         }
1452 
1453         private DoubleVector toVector_helper() {

1454             double[] va = new double[SPECIES.length()];
1455             for (int i = 0; i < va.length; i++) {
1456               va[i] = (double) lane(i);
1457             }
1458             return DoubleVector.fromArray(SPECIES, va, 0);
1459         }
1460 
1461         @Override
1462         @ForceInline
1463         public DoubleVector toVector() {
1464             return VectorIntrinsics.shuffleToVector(Double64Vector.class, double.class, Double64Shuffle.class, this,
1465                                                     SPECIES.length(), 
1466                                                     (s) -> (((Double64Shuffle)(s)).toVector_helper()));
1467         }
1468 
1469         @Override
1470         @ForceInline
1471         @SuppressWarnings("unchecked")
1472         public <F> VectorShuffle<F> cast(VectorSpecies<F> species) {
1473             if (length() != species.length())
1474                 throw new IllegalArgumentException("Shuffle length and species length differ");
1475             Class<?> stype = species.elementType();
1476             int [] shuffleArray = toArray();
1477             if (stype == byte.class) {
1478                 return (VectorShuffle<F>) new Byte64Vector.Byte64Shuffle(shuffleArray);
1479             } else if (stype == short.class) {
1480                 return (VectorShuffle<F>) new Short64Vector.Short64Shuffle(shuffleArray);
1481             } else if (stype == int.class) {
1482                 return (VectorShuffle<F>) new Int64Vector.Int64Shuffle(shuffleArray);
1483             } else if (stype == long.class) {
1484                 return (VectorShuffle<F>) new Long64Vector.Long64Shuffle(shuffleArray);
1485             } else if (stype == float.class) {
1486                 return (VectorShuffle<F>) new Float64Vector.Float64Shuffle(shuffleArray);
1487             } else if (stype == double.class) {
1488                 return (VectorShuffle<F>) new Double64Vector.Double64Shuffle(shuffleArray);
1489             } else {
1490                 throw new UnsupportedOperationException("Bad lane type for casting.");
1491             }
1492         }
1493 
1494 
1495         @Override
1496         public Double64Shuffle rearrange(VectorShuffle<Double> o) {
1497             Double64Shuffle s = (Double64Shuffle) o;
1498             byte[] r = new byte[reorder.length];
1499             for (int i = 0; i < reorder.length; i++) {
1500                 r[i] = reorder[s.reorder[i]];
1501             }
1502             return new Double64Shuffle(r);
1503         }
1504     }
1505 
1506     // VectorSpecies
1507 
1508     @Override
1509     public VectorSpecies<Double> species() {
1510         return SPECIES;
1511     }
1512 }
< prev index next >