< prev index next >

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

Print this page




1150 
1151     @Override
1152     void forEach(VectorMask<Float> o, FUnCon f) {
1153         boolean[] mbits = ((FloatMaxMask)o).getBits();
1154         forEach((i, a) -> {
1155             if (mbits[i]) { f.apply(i, a); }
1156         });
1157     }
1158 
1159     IntMaxVector toBits() {
1160         float[] vec = getElements();
1161         int[] res = new int[this.species().length()];
1162         for(int i = 0; i < this.species().length(); i++){
1163             res[i] = Float.floatToIntBits(vec[i]);
1164         }
1165         return new IntMaxVector(res);
1166     }
1167 
1168 
1169     @Override

1170     public FloatMaxVector rotateLanesLeft(int j) {
1171         float[] vec = getElements();
1172         float[] res = new float[length()];
1173         for (int i = 0; i < length(); i++){
1174             res[(j + i) % length()] = vec[i];



1175         }
1176         return new FloatMaxVector(res);
1177     }
1178 
1179     @Override

1180     public FloatMaxVector rotateLanesRight(int j) {
1181         float[] vec = getElements();
1182         float[] res = new float[length()];
1183         for (int i = 0; i < length(); i++){
1184             int z = i - j;
1185             if(j < 0) {
1186                 res[length() + z] = vec[i];
1187             } else {
1188                 res[z] = vec[i];
1189             }

1190         }
1191         return new FloatMaxVector(res);
1192     }
1193 
1194     @Override


1195     public FloatMaxVector shiftLanesLeft(int j) {
1196         float[] vec = getElements();
1197         float[] res = new float[length()];
1198         for (int i = 0; i < length() - j; i++) {
1199             res[i] = vec[i + j];






1200         }
1201         return new FloatMaxVector(res);
1202     }
1203 
1204     @Override


1205     public FloatMaxVector shiftLanesRight(int j) {
1206         float[] vec = getElements();
1207         float[] res = new float[length()];
1208         for (int i = 0; i < length() - j; i++){
1209             res[i + j] = vec[i];






1210         }
1211         return new FloatMaxVector(res);
1212     }
1213 
1214     @Override
1215     @ForceInline
1216     public FloatMaxVector rearrange(Vector<Float> v,
1217                                   VectorShuffle<Float> s, VectorMask<Float> m) {
1218         return this.rearrange(s).blend(v.rearrange(s), m);
1219     }
1220 
1221     @Override
1222     @ForceInline
1223     public FloatMaxVector rearrange(VectorShuffle<Float> o1) {
1224         Objects.requireNonNull(o1);
1225         FloatMaxShuffle s =  (FloatMaxShuffle)o1;
1226 
1227         return VectorIntrinsics.rearrangeOp(
1228             FloatMaxVector.class, FloatMaxShuffle.class, float.class, LENGTH,
1229             this, s,
1230             (v1, s_) -> v1.uOp((i, a) -> {
1231                 int ei = s_.lane(i);


1431             super(reorder);
1432         }
1433 
1434         public FloatMaxShuffle(int[] reorder) {
1435             super(reorder);
1436         }
1437 
1438         public FloatMaxShuffle(int[] reorder, int i) {
1439             super(reorder, i);
1440         }
1441 
1442         public FloatMaxShuffle(IntUnaryOperator f) {
1443             super(f);
1444         }
1445 
1446         @Override
1447         public VectorSpecies<Float> species() {
1448             return SPECIES;
1449         }
1450 
1451         @Override
1452         public FloatVector toVector() {
1453             float[] va = new float[SPECIES.length()];
1454             for (int i = 0; i < va.length; i++) {
1455               va[i] = (float) lane(i);
1456             }
1457             return FloatVector.fromArray(SPECIES, va, 0);
1458         }
1459 
1460         @Override
1461         @ForceInline








1462         @SuppressWarnings("unchecked")
1463         public <F> VectorShuffle<F> cast(VectorSpecies<F> species) {
1464             if (length() != species.length())
1465                 throw new IllegalArgumentException("Shuffle length and species length differ");
1466             Class<?> stype = species.elementType();
1467             int [] shuffleArray = toArray();
1468             if (stype == byte.class) {
1469                 return (VectorShuffle<F>) new ByteMaxVector.ByteMaxShuffle(shuffleArray);
1470             } else if (stype == short.class) {
1471                 return (VectorShuffle<F>) new ShortMaxVector.ShortMaxShuffle(shuffleArray);
1472             } else if (stype == int.class) {
1473                 return (VectorShuffle<F>) new IntMaxVector.IntMaxShuffle(shuffleArray);
1474             } else if (stype == long.class) {
1475                 return (VectorShuffle<F>) new LongMaxVector.LongMaxShuffle(shuffleArray);
1476             } else if (stype == float.class) {
1477                 return (VectorShuffle<F>) new FloatMaxVector.FloatMaxShuffle(shuffleArray);
1478             } else if (stype == double.class) {
1479                 return (VectorShuffle<F>) new DoubleMaxVector.DoubleMaxShuffle(shuffleArray);
1480             } else {
1481                 throw new UnsupportedOperationException("Bad lane type for casting.");
1482             }
1483         }

1484 
1485         @Override
1486         public FloatMaxShuffle rearrange(VectorShuffle<Float> o) {
1487             FloatMaxShuffle s = (FloatMaxShuffle) o;
1488             byte[] r = new byte[reorder.length];
1489             for (int i = 0; i < reorder.length; i++) {
1490                 r[i] = reorder[s.reorder[i]];
1491             }
1492             return new FloatMaxShuffle(r);
1493         }
1494     }
1495 
1496     // VectorSpecies
1497 
1498     @Override
1499     public VectorSpecies<Float> species() {
1500         return SPECIES;
1501     }
1502 }


1150 
1151     @Override
1152     void forEach(VectorMask<Float> o, FUnCon f) {
1153         boolean[] mbits = ((FloatMaxMask)o).getBits();
1154         forEach((i, a) -> {
1155             if (mbits[i]) { f.apply(i, a); }
1156         });
1157     }
1158 
1159     IntMaxVector toBits() {
1160         float[] vec = getElements();
1161         int[] res = new int[this.species().length()];
1162         for(int i = 0; i < this.species().length(); i++){
1163             res[i] = Float.floatToIntBits(vec[i]);
1164         }
1165         return new IntMaxVector(res);
1166     }
1167 
1168 
1169     @Override
1170     @ForceInline
1171     public FloatMaxVector rotateLanesLeft(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<Float> PermMask  = VectorShuffle.shuffleIota(SPECIES, L - j);
1178         return this.rearrange(PermMask);
1179       }

1180     }
1181 
1182     @Override
1183     @ForceInline
1184     public FloatMaxVector rotateLanesRight(int j) {
1185       int L = length();
1186       if (j < 0) {
1187          throw new IllegalArgumentException("Index " + j + " must be zero or positive");



1188       } else {
1189         j = j & (L-1);
1190         VectorShuffle<Float> PermMask = VectorShuffle.shuffleIota(SPECIES, j);
1191         return this.rearrange(PermMask);
1192       }

1193     }
1194 
1195     @Override
1196     @ForceInline
1197     @SuppressWarnings("unchecked")
1198     public FloatMaxVector shiftLanesLeft(int j) {
1199        int L = length();
1200        if (j < 0) {
1201          throw new IllegalArgumentException("Index " + j + " must be zero or positive");
1202        } else if ( j >= L ) {
1203          return ZERO;
1204        } else {
1205          FloatMaxShuffle     Iota    = (FloatMaxShuffle)(VectorShuffle.shuffleIota(SPECIES, L-j));
1206          VectorMask<Float> BlendMask = Iota.toVector().lessThan(FloatMaxVector.broadcast(SPECIES, (float)(L-j)));
1207          Iota    = (FloatMaxShuffle)(VectorShuffle.shuffleIota(SPECIES, L -j));
1208          return ZERO.blend(this.rearrange(Iota),BlendMask);
1209        }

1210     }
1211 
1212     @Override
1213     @ForceInline
1214     @SuppressWarnings("unchecked")
1215     public FloatMaxVector shiftLanesRight(int j) {
1216        int L = length();
1217        if (j < 0) {
1218          throw new IllegalArgumentException("Index " + j + " must be zero or positive");
1219        } else if ( j >= L ) {
1220          return ZERO;
1221        } else {
1222          FloatMaxShuffle     Iota    = (FloatMaxShuffle)(VectorShuffle.shuffleIota(SPECIES, j));
1223          VectorMask<Float> BlendMask = Iota.toVector().greaterThanEq(FloatMaxVector.broadcast(SPECIES, (float)(j)));
1224          Iota    = (FloatMaxShuffle)(VectorShuffle.shuffleIota(SPECIES, j));
1225          return ZERO.blend(this.rearrange(Iota),BlendMask);
1226        }

1227     }
1228 
1229     @Override
1230     @ForceInline
1231     public FloatMaxVector rearrange(Vector<Float> v,
1232                                   VectorShuffle<Float> s, VectorMask<Float> m) {
1233         return this.rearrange(s).blend(v.rearrange(s), m);
1234     }
1235 
1236     @Override
1237     @ForceInline
1238     public FloatMaxVector rearrange(VectorShuffle<Float> o1) {
1239         Objects.requireNonNull(o1);
1240         FloatMaxShuffle s =  (FloatMaxShuffle)o1;
1241 
1242         return VectorIntrinsics.rearrangeOp(
1243             FloatMaxVector.class, FloatMaxShuffle.class, float.class, LENGTH,
1244             this, s,
1245             (v1, s_) -> v1.uOp((i, a) -> {
1246                 int ei = s_.lane(i);


1446             super(reorder);
1447         }
1448 
1449         public FloatMaxShuffle(int[] reorder) {
1450             super(reorder);
1451         }
1452 
1453         public FloatMaxShuffle(int[] reorder, int i) {
1454             super(reorder, i);
1455         }
1456 
1457         public FloatMaxShuffle(IntUnaryOperator f) {
1458             super(f);
1459         }
1460 
1461         @Override
1462         public VectorSpecies<Float> species() {
1463             return SPECIES;
1464         }
1465 
1466         private FloatVector toVector_helper() {

1467             float[] va = new float[SPECIES.length()];
1468             for (int i = 0; i < va.length; i++) {
1469               va[i] = (float) lane(i);
1470             }
1471             return FloatVector.fromArray(SPECIES, va, 0);
1472         }
1473 
1474         @Override
1475         @ForceInline
1476         public FloatVector toVector() {
1477             return VectorIntrinsics.shuffleToVector(FloatMaxVector.class, float.class, FloatMaxShuffle.class, this,
1478                                                     SPECIES.length(), 
1479                                                     (s) -> (((FloatMaxShuffle)(s)).toVector_helper()));
1480         }
1481 
1482         @Override
1483         @ForceInline
1484         @SuppressWarnings("unchecked")
1485         public <F> VectorShuffle<F> cast(VectorSpecies<F> species) {
1486             if (length() != species.length())
1487                 throw new IllegalArgumentException("Shuffle length and species length differ");
1488             Class<?> stype = species.elementType();
1489             int [] shuffleArray = toArray();
1490             if (stype == byte.class) {
1491                 return (VectorShuffle<F>) new ByteMaxVector.ByteMaxShuffle(shuffleArray);
1492             } else if (stype == short.class) {
1493                 return (VectorShuffle<F>) new ShortMaxVector.ShortMaxShuffle(shuffleArray);
1494             } else if (stype == int.class) {
1495                 return (VectorShuffle<F>) new IntMaxVector.IntMaxShuffle(shuffleArray);
1496             } else if (stype == long.class) {
1497                 return (VectorShuffle<F>) new LongMaxVector.LongMaxShuffle(shuffleArray);
1498             } else if (stype == float.class) {
1499                 return (VectorShuffle<F>) new FloatMaxVector.FloatMaxShuffle(shuffleArray);
1500             } else if (stype == double.class) {
1501                 return (VectorShuffle<F>) new DoubleMaxVector.DoubleMaxShuffle(shuffleArray);
1502             } else {
1503                 throw new UnsupportedOperationException("Bad lane type for casting.");
1504             }
1505         }
1506 
1507 
1508         @Override
1509         public FloatMaxShuffle rearrange(VectorShuffle<Float> o) {
1510             FloatMaxShuffle s = (FloatMaxShuffle) o;
1511             byte[] r = new byte[reorder.length];
1512             for (int i = 0; i < reorder.length; i++) {
1513                 r[i] = reorder[s.reorder[i]];
1514             }
1515             return new FloatMaxShuffle(r);
1516         }
1517     }
1518 
1519     // VectorSpecies
1520 
1521     @Override
1522     public VectorSpecies<Float> species() {
1523         return SPECIES;
1524     }
1525 }
< prev index next >