< prev index next >

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

Print this page




 146 
 147     @Override
 148     double rOp(double v, FBinOp f) {
 149         double[] vec = getElements();
 150         for (int i = 0; i < length(); i++) {
 151             v = f.apply(i, v, vec[i]);
 152         }
 153         return v;
 154     }
 155 
 156     @Override
 157     @ForceInline
 158     public <F> Vector<F> cast(VectorSpecies<F> s) {
 159         Objects.requireNonNull(s);
 160         if (s.length() != LENGTH)
 161             throw new IllegalArgumentException("Vector length this species length differ");
 162 
 163         return VectorIntrinsics.cast(
 164             DoubleMaxVector.class,
 165             double.class, LENGTH,
 166             s.boxType(),
 167             s.elementType(), LENGTH,
 168             this, s,
 169             (species, vector) -> vector.castDefault(species)
 170         );
 171     }
 172 
 173     @SuppressWarnings("unchecked")
 174     @ForceInline
 175     private <F> Vector<F> castDefault(VectorSpecies<F> s) {
 176         int limit = s.length();
 177 
 178         Class<?> stype = s.elementType();
 179         if (stype == byte.class) {
 180             byte[] a = new byte[limit];
 181             for (int i = 0; i < limit; i++) {
 182                 a[i] = (byte) this.lane(i);
 183             }
 184             return (Vector) ByteVector.fromArray((VectorSpecies<Byte>) s, a, 0);
 185         } else if (stype == short.class) {
 186             short[] a = new short[limit];


 284                 (species, vector) -> vector.defaultReinterpret(species)
 285             );
 286         } else if (stype == double.class) {
 287             return VectorIntrinsics.reinterpret(
 288                 DoubleMaxVector.class,
 289                 double.class, LENGTH,
 290                 DoubleMaxVector.class,
 291                 double.class, DoubleMaxVector.LENGTH,
 292                 this, s,
 293                 (species, vector) -> vector.defaultReinterpret(species)
 294             );
 295         } else {
 296             throw new UnsupportedOperationException("Bad lane type for casting.");
 297         }
 298     }
 299 
 300     @Override
 301     @ForceInline
 302     public DoubleVector reshape(VectorSpecies<Double> s) {
 303         Objects.requireNonNull(s);
 304         if (s.bitSize() == 64 && (s.boxType() == Double64Vector.class)) {
 305             return VectorIntrinsics.reinterpret(
 306                 DoubleMaxVector.class,
 307                 double.class, LENGTH,
 308                 Double64Vector.class,
 309                 double.class, Double64Vector.LENGTH,
 310                 this, s,
 311                 (species, vector) -> (DoubleVector) vector.defaultReinterpret(species)
 312             );
 313         } else if (s.bitSize() == 128 && (s.boxType() == Double128Vector.class)) {
 314             return VectorIntrinsics.reinterpret(
 315                 DoubleMaxVector.class,
 316                 double.class, LENGTH,
 317                 Double128Vector.class,
 318                 double.class, Double128Vector.LENGTH,
 319                 this, s,
 320                 (species, vector) -> (DoubleVector) vector.defaultReinterpret(species)
 321             );
 322         } else if (s.bitSize() == 256 && (s.boxType() == Double256Vector.class)) {
 323             return VectorIntrinsics.reinterpret(
 324                 DoubleMaxVector.class,
 325                 double.class, LENGTH,
 326                 Double256Vector.class,
 327                 double.class, Double256Vector.LENGTH,
 328                 this, s,
 329                 (species, vector) -> (DoubleVector) vector.defaultReinterpret(species)
 330             );
 331         } else if (s.bitSize() == 512 && (s.boxType() == Double512Vector.class)) {
 332             return VectorIntrinsics.reinterpret(
 333                 DoubleMaxVector.class,
 334                 double.class, LENGTH,
 335                 Double512Vector.class,
 336                 double.class, Double512Vector.LENGTH,
 337                 this, s,
 338                 (species, vector) -> (DoubleVector) vector.defaultReinterpret(species)
 339             );
 340         } else if ((s.bitSize() > 0) && (s.bitSize() <= 2048)
 341                 && (s.bitSize() % 128 == 0) && (s.boxType() == DoubleMaxVector.class)) {
 342             return VectorIntrinsics.reinterpret(
 343                 DoubleMaxVector.class,
 344                 double.class, LENGTH,
 345                 DoubleMaxVector.class,
 346                 double.class, DoubleMaxVector.LENGTH,
 347                 this, s,
 348                 (species, vector) -> (DoubleVector) vector.defaultReinterpret(species)
 349             );
 350         } else {
 351             throw new InternalError("Unimplemented size");
 352         }
 353     }
 354 
 355     // Binary operations with scalars
 356 
 357     @Override
 358     @ForceInline
 359     public DoubleVector add(double o) {
 360         return add((DoubleMaxVector)DoubleVector.broadcast(SPECIES, o));
 361     }


1150 
1151     @Override
1152     void forEach(VectorMask<Double> o, FUnCon f) {
1153         boolean[] mbits = ((DoubleMaxMask)o).getBits();
1154         forEach((i, a) -> {
1155             if (mbits[i]) { f.apply(i, a); }
1156         });
1157     }
1158 
1159     LongMaxVector toBits() {
1160         double[] vec = getElements();
1161         long[] res = new long[this.species().length()];
1162         for(int i = 0; i < this.species().length(); i++){
1163             res[i] = Double.doubleToLongBits(vec[i]);
1164         }
1165         return new LongMaxVector(res);
1166     }
1167 
1168 
1169     @Override
1170     public DoubleMaxVector rotateEL(int j) {
1171         double[] vec = getElements();
1172         double[] res = new double[length()];
1173         for (int i = 0; i < length(); i++){
1174             res[(j + i) % length()] = vec[i];
1175         }
1176         return new DoubleMaxVector(res);
1177     }
1178 
1179     @Override
1180     public DoubleMaxVector rotateER(int j) {
1181         double[] vec = getElements();
1182         double[] res = new double[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 DoubleMaxVector(res);
1192     }
1193 
1194     @Override
1195     public DoubleMaxVector shiftEL(int j) {
1196         double[] vec = getElements();
1197         double[] res = new double[length()];
1198         for (int i = 0; i < length() - j; i++) {
1199             res[i] = vec[i + j];
1200         }
1201         return new DoubleMaxVector(res);
1202     }
1203 
1204     @Override
1205     public DoubleMaxVector shiftER(int j) {
1206         double[] vec = getElements();
1207         double[] res = new double[length()];
1208         for (int i = 0; i < length() - j; i++){
1209             res[i + j] = vec[i];
1210         }
1211         return new DoubleMaxVector(res);
1212     }
1213 
1214     @Override
1215     @ForceInline
1216     public DoubleMaxVector rearrange(Vector<Double> v,
1217                                   VectorShuffle<Double> s, VectorMask<Double> m) {
1218         return this.rearrange(s).blend(v.rearrange(s), m);
1219     }
1220 
1221     @Override
1222     @ForceInline
1223     public DoubleMaxVector rearrange(VectorShuffle<Double> o1) {
1224         Objects.requireNonNull(o1);
1225         DoubleMaxShuffle s =  (DoubleMaxShuffle)o1;




 146 
 147     @Override
 148     double rOp(double v, FBinOp f) {
 149         double[] vec = getElements();
 150         for (int i = 0; i < length(); i++) {
 151             v = f.apply(i, v, vec[i]);
 152         }
 153         return v;
 154     }
 155 
 156     @Override
 157     @ForceInline
 158     public <F> Vector<F> cast(VectorSpecies<F> s) {
 159         Objects.requireNonNull(s);
 160         if (s.length() != LENGTH)
 161             throw new IllegalArgumentException("Vector length this species length differ");
 162 
 163         return VectorIntrinsics.cast(
 164             DoubleMaxVector.class,
 165             double.class, LENGTH,
 166             s.vectorType(),
 167             s.elementType(), LENGTH,
 168             this, s,
 169             (species, vector) -> vector.castDefault(species)
 170         );
 171     }
 172 
 173     @SuppressWarnings("unchecked")
 174     @ForceInline
 175     private <F> Vector<F> castDefault(VectorSpecies<F> s) {
 176         int limit = s.length();
 177 
 178         Class<?> stype = s.elementType();
 179         if (stype == byte.class) {
 180             byte[] a = new byte[limit];
 181             for (int i = 0; i < limit; i++) {
 182                 a[i] = (byte) this.lane(i);
 183             }
 184             return (Vector) ByteVector.fromArray((VectorSpecies<Byte>) s, a, 0);
 185         } else if (stype == short.class) {
 186             short[] a = new short[limit];


 284                 (species, vector) -> vector.defaultReinterpret(species)
 285             );
 286         } else if (stype == double.class) {
 287             return VectorIntrinsics.reinterpret(
 288                 DoubleMaxVector.class,
 289                 double.class, LENGTH,
 290                 DoubleMaxVector.class,
 291                 double.class, DoubleMaxVector.LENGTH,
 292                 this, s,
 293                 (species, vector) -> vector.defaultReinterpret(species)
 294             );
 295         } else {
 296             throw new UnsupportedOperationException("Bad lane type for casting.");
 297         }
 298     }
 299 
 300     @Override
 301     @ForceInline
 302     public DoubleVector reshape(VectorSpecies<Double> s) {
 303         Objects.requireNonNull(s);
 304         if (s.bitSize() == 64 && (s.vectorType() == Double64Vector.class)) {
 305             return VectorIntrinsics.reinterpret(
 306                 DoubleMaxVector.class,
 307                 double.class, LENGTH,
 308                 Double64Vector.class,
 309                 double.class, Double64Vector.LENGTH,
 310                 this, s,
 311                 (species, vector) -> (DoubleVector) vector.defaultReinterpret(species)
 312             );
 313         } else if (s.bitSize() == 128 && (s.vectorType() == Double128Vector.class)) {
 314             return VectorIntrinsics.reinterpret(
 315                 DoubleMaxVector.class,
 316                 double.class, LENGTH,
 317                 Double128Vector.class,
 318                 double.class, Double128Vector.LENGTH,
 319                 this, s,
 320                 (species, vector) -> (DoubleVector) vector.defaultReinterpret(species)
 321             );
 322         } else if (s.bitSize() == 256 && (s.vectorType() == Double256Vector.class)) {
 323             return VectorIntrinsics.reinterpret(
 324                 DoubleMaxVector.class,
 325                 double.class, LENGTH,
 326                 Double256Vector.class,
 327                 double.class, Double256Vector.LENGTH,
 328                 this, s,
 329                 (species, vector) -> (DoubleVector) vector.defaultReinterpret(species)
 330             );
 331         } else if (s.bitSize() == 512 && (s.vectorType() == Double512Vector.class)) {
 332             return VectorIntrinsics.reinterpret(
 333                 DoubleMaxVector.class,
 334                 double.class, LENGTH,
 335                 Double512Vector.class,
 336                 double.class, Double512Vector.LENGTH,
 337                 this, s,
 338                 (species, vector) -> (DoubleVector) vector.defaultReinterpret(species)
 339             );
 340         } else if ((s.bitSize() > 0) && (s.bitSize() <= 2048)
 341                 && (s.bitSize() % 128 == 0) && (s.vectorType() == DoubleMaxVector.class)) {
 342             return VectorIntrinsics.reinterpret(
 343                 DoubleMaxVector.class,
 344                 double.class, LENGTH,
 345                 DoubleMaxVector.class,
 346                 double.class, DoubleMaxVector.LENGTH,
 347                 this, s,
 348                 (species, vector) -> (DoubleVector) vector.defaultReinterpret(species)
 349             );
 350         } else {
 351             throw new InternalError("Unimplemented size");
 352         }
 353     }
 354 
 355     // Binary operations with scalars
 356 
 357     @Override
 358     @ForceInline
 359     public DoubleVector add(double o) {
 360         return add((DoubleMaxVector)DoubleVector.broadcast(SPECIES, o));
 361     }


1150 
1151     @Override
1152     void forEach(VectorMask<Double> o, FUnCon f) {
1153         boolean[] mbits = ((DoubleMaxMask)o).getBits();
1154         forEach((i, a) -> {
1155             if (mbits[i]) { f.apply(i, a); }
1156         });
1157     }
1158 
1159     LongMaxVector toBits() {
1160         double[] vec = getElements();
1161         long[] res = new long[this.species().length()];
1162         for(int i = 0; i < this.species().length(); i++){
1163             res[i] = Double.doubleToLongBits(vec[i]);
1164         }
1165         return new LongMaxVector(res);
1166     }
1167 
1168 
1169     @Override
1170     public DoubleMaxVector rotateLanesLeft(int j) {
1171         double[] vec = getElements();
1172         double[] res = new double[length()];
1173         for (int i = 0; i < length(); i++){
1174             res[(j + i) % length()] = vec[i];
1175         }
1176         return new DoubleMaxVector(res);
1177     }
1178 
1179     @Override
1180     public DoubleMaxVector rotateLanesRight(int j) {
1181         double[] vec = getElements();
1182         double[] res = new double[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 DoubleMaxVector(res);
1192     }
1193 
1194     @Override
1195     public DoubleMaxVector shiftLanesLeft(int j) {
1196         double[] vec = getElements();
1197         double[] res = new double[length()];
1198         for (int i = 0; i < length() - j; i++) {
1199             res[i] = vec[i + j];
1200         }
1201         return new DoubleMaxVector(res);
1202     }
1203 
1204     @Override
1205     public DoubleMaxVector shiftLanesRight(int j) {
1206         double[] vec = getElements();
1207         double[] res = new double[length()];
1208         for (int i = 0; i < length() - j; i++){
1209             res[i + j] = vec[i];
1210         }
1211         return new DoubleMaxVector(res);
1212     }
1213 
1214     @Override
1215     @ForceInline
1216     public DoubleMaxVector rearrange(Vector<Double> v,
1217                                   VectorShuffle<Double> s, VectorMask<Double> m) {
1218         return this.rearrange(s).blend(v.rearrange(s), m);
1219     }
1220 
1221     @Override
1222     @ForceInline
1223     public DoubleMaxVector rearrange(VectorShuffle<Double> o1) {
1224         Objects.requireNonNull(o1);
1225         DoubleMaxShuffle s =  (DoubleMaxShuffle)o1;


< prev index next >