161
162 return VectorIntrinsics.cast(
163 Double64Vector.class,
164 double.class, LENGTH,
165 s.boxType(),
166 s.elementType(), LENGTH,
167 this, s,
168 (species, vector) -> vector.castDefault(species)
169 );
170 }
171
172 @SuppressWarnings("unchecked")
173 @ForceInline
174 private <F> Vector<F> castDefault(VectorSpecies<F> s) {
175 int limit = s.length();
176
177 Class<?> stype = s.elementType();
178 if (stype == byte.class) {
179 byte[] a = new byte[limit];
180 for (int i = 0; i < limit; i++) {
181 a[i] = (byte) this.get(i);
182 }
183 return (Vector) ByteVector.fromArray((VectorSpecies<Byte>) s, a, 0);
184 } else if (stype == short.class) {
185 short[] a = new short[limit];
186 for (int i = 0; i < limit; i++) {
187 a[i] = (short) this.get(i);
188 }
189 return (Vector) ShortVector.fromArray((VectorSpecies<Short>) s, a, 0);
190 } else if (stype == int.class) {
191 int[] a = new int[limit];
192 for (int i = 0; i < limit; i++) {
193 a[i] = (int) this.get(i);
194 }
195 return (Vector) IntVector.fromArray((VectorSpecies<Integer>) s, a, 0);
196 } else if (stype == long.class) {
197 long[] a = new long[limit];
198 for (int i = 0; i < limit; i++) {
199 a[i] = (long) this.get(i);
200 }
201 return (Vector) LongVector.fromArray((VectorSpecies<Long>) s, a, 0);
202 } else if (stype == float.class) {
203 float[] a = new float[limit];
204 for (int i = 0; i < limit; i++) {
205 a[i] = (float) this.get(i);
206 }
207 return (Vector) FloatVector.fromArray((VectorSpecies<Float>) s, a, 0);
208 } else if (stype == double.class) {
209 double[] a = new double[limit];
210 for (int i = 0; i < limit; i++) {
211 a[i] = (double) this.get(i);
212 }
213 return (Vector) DoubleVector.fromArray((VectorSpecies<Double>) s, a, 0);
214 } else {
215 throw new UnsupportedOperationException("Bad lane type for casting.");
216 }
217 }
218
219 @Override
220 @ForceInline
221 @SuppressWarnings("unchecked")
222 public <F> Vector<F> reinterpret(VectorSpecies<F> s) {
223 Objects.requireNonNull(s);
224
225 if(s.elementType().equals(double.class)) {
226 return (Vector<F>) reshape((VectorSpecies<Double>)s);
227 }
228 if(s.bitSize() == bitSize()) {
229 return reinterpretType(s);
230 }
231
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_.getElement(i);
1219 return v1.get(ei);
1220 }));
1221 }
1222
1223 @Override
1224 @ForceInline
1225 public Double64Vector blend(Vector<Double> o1, VectorMask<Double> o2) {
1226 Objects.requireNonNull(o1);
1227 Objects.requireNonNull(o2);
1228 Double64Vector v = (Double64Vector)o1;
1229 Double64Mask m = (Double64Mask)o2;
1230
1231 return VectorIntrinsics.blend(
1232 Double64Vector.class, Double64Mask.class, double.class, LENGTH,
1233 this, v, m,
1234 (v1, v2, m_) -> v1.bOp(v2, (i, a, b) -> m_.getElement(i) ? b : a));
1235 }
1236
1237 // Accessors
1238
1239 @Override
1240 public double get(int i) {
1241 if (i < 0 || i >= LENGTH) {
1242 throw new IllegalArgumentException("Index " + i + " must be zero or positive, and less than " + LENGTH);
1243 }
1244 long bits = (long) VectorIntrinsics.extract(
1245 Double64Vector.class, double.class, LENGTH,
1246 this, i,
1247 (vec, ix) -> {
1248 double[] vecarr = vec.getElements();
1249 return (long)Double.doubleToLongBits(vecarr[ix]);
1250 });
1251 return Double.longBitsToDouble(bits);
1252 }
1253
1254 @Override
1255 public Double64Vector with(int i, double e) {
1256 if (i < 0 || i >= LENGTH) {
1257 throw new IllegalArgumentException("Index " + i + " must be zero or positive, and less than " + LENGTH);
1258 }
1259 return VectorIntrinsics.insert(
1260 Double64Vector.class, double.class, LENGTH,
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) getElement(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);
|
161
162 return VectorIntrinsics.cast(
163 Double64Vector.class,
164 double.class, LENGTH,
165 s.boxType(),
166 s.elementType(), LENGTH,
167 this, s,
168 (species, vector) -> vector.castDefault(species)
169 );
170 }
171
172 @SuppressWarnings("unchecked")
173 @ForceInline
174 private <F> Vector<F> castDefault(VectorSpecies<F> s) {
175 int limit = s.length();
176
177 Class<?> stype = s.elementType();
178 if (stype == byte.class) {
179 byte[] a = new byte[limit];
180 for (int i = 0; i < limit; i++) {
181 a[i] = (byte) this.lane(i);
182 }
183 return (Vector) ByteVector.fromArray((VectorSpecies<Byte>) s, a, 0);
184 } else if (stype == short.class) {
185 short[] a = new short[limit];
186 for (int i = 0; i < limit; i++) {
187 a[i] = (short) this.lane(i);
188 }
189 return (Vector) ShortVector.fromArray((VectorSpecies<Short>) s, a, 0);
190 } else if (stype == int.class) {
191 int[] a = new int[limit];
192 for (int i = 0; i < limit; i++) {
193 a[i] = (int) this.lane(i);
194 }
195 return (Vector) IntVector.fromArray((VectorSpecies<Integer>) s, a, 0);
196 } else if (stype == long.class) {
197 long[] a = new long[limit];
198 for (int i = 0; i < limit; i++) {
199 a[i] = (long) this.lane(i);
200 }
201 return (Vector) LongVector.fromArray((VectorSpecies<Long>) s, a, 0);
202 } else if (stype == float.class) {
203 float[] a = new float[limit];
204 for (int i = 0; i < limit; i++) {
205 a[i] = (float) this.lane(i);
206 }
207 return (Vector) FloatVector.fromArray((VectorSpecies<Float>) s, a, 0);
208 } else if (stype == double.class) {
209 double[] a = new double[limit];
210 for (int i = 0; i < limit; i++) {
211 a[i] = (double) this.lane(i);
212 }
213 return (Vector) DoubleVector.fromArray((VectorSpecies<Double>) s, a, 0);
214 } else {
215 throw new UnsupportedOperationException("Bad lane type for casting.");
216 }
217 }
218
219 @Override
220 @ForceInline
221 @SuppressWarnings("unchecked")
222 public <F> Vector<F> reinterpret(VectorSpecies<F> s) {
223 Objects.requireNonNull(s);
224
225 if(s.elementType().equals(double.class)) {
226 return (Vector<F>) reshape((VectorSpecies<Double>)s);
227 }
228 if(s.bitSize() == bitSize()) {
229 return reinterpretType(s);
230 }
231
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);
1219 return v1.lane(ei);
1220 }));
1221 }
1222
1223 @Override
1224 @ForceInline
1225 public Double64Vector blend(Vector<Double> o1, VectorMask<Double> o2) {
1226 Objects.requireNonNull(o1);
1227 Objects.requireNonNull(o2);
1228 Double64Vector v = (Double64Vector)o1;
1229 Double64Mask m = (Double64Mask)o2;
1230
1231 return VectorIntrinsics.blend(
1232 Double64Vector.class, Double64Mask.class, double.class, LENGTH,
1233 this, v, m,
1234 (v1, v2, m_) -> v1.bOp(v2, (i, a, b) -> m_.lane(i) ? b : a));
1235 }
1236
1237 // Accessors
1238
1239 @Override
1240 public double lane(int i) {
1241 if (i < 0 || i >= LENGTH) {
1242 throw new IllegalArgumentException("Index " + i + " must be zero or positive, and less than " + LENGTH);
1243 }
1244 long bits = (long) VectorIntrinsics.extract(
1245 Double64Vector.class, double.class, LENGTH,
1246 this, i,
1247 (vec, ix) -> {
1248 double[] vecarr = vec.getElements();
1249 return (long)Double.doubleToLongBits(vecarr[ix]);
1250 });
1251 return Double.longBitsToDouble(bits);
1252 }
1253
1254 @Override
1255 public Double64Vector with(int i, double e) {
1256 if (i < 0 || i >= LENGTH) {
1257 throw new IllegalArgumentException("Index " + i + " must be zero or positive, and less than " + LENGTH);
1258 }
1259 return VectorIntrinsics.insert(
1260 Double64Vector.class, double.class, LENGTH,
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);
|