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.get(i);
183 }
184 return (Vector) ByteVector.fromArray((VectorSpecies<Byte>) s, a, 0);
185 } else if (stype == short.class) {
186 short[] a = new short[limit];
187 for (int i = 0; i < limit; i++) {
188 a[i] = (short) this.get(i);
189 }
190 return (Vector) ShortVector.fromArray((VectorSpecies<Short>) s, a, 0);
191 } else if (stype == int.class) {
192 int[] a = new int[limit];
193 for (int i = 0; i < limit; i++) {
194 a[i] = (int) this.get(i);
195 }
196 return (Vector) IntVector.fromArray((VectorSpecies<Integer>) s, a, 0);
197 } else if (stype == long.class) {
198 long[] a = new long[limit];
199 for (int i = 0; i < limit; i++) {
200 a[i] = (long) this.get(i);
201 }
202 return (Vector) LongVector.fromArray((VectorSpecies<Long>) s, a, 0);
203 } else if (stype == float.class) {
204 float[] a = new float[limit];
205 for (int i = 0; i < limit; i++) {
206 a[i] = (float) this.get(i);
207 }
208 return (Vector) FloatVector.fromArray((VectorSpecies<Float>) s, a, 0);
209 } else if (stype == double.class) {
210 double[] a = new double[limit];
211 for (int i = 0; i < limit; i++) {
212 a[i] = (double) this.get(i);
213 }
214 return (Vector) DoubleVector.fromArray((VectorSpecies<Double>) s, a, 0);
215 } else {
216 throw new UnsupportedOperationException("Bad lane type for casting.");
217 }
218 }
219
220 @Override
221 @ForceInline
222 @SuppressWarnings("unchecked")
223 public <F> Vector<F> reinterpret(VectorSpecies<F> s) {
224 Objects.requireNonNull(s);
225
226 if(s.elementType().equals(double.class)) {
227 return (Vector<F>) reshape((VectorSpecies<Double>)s);
228 }
229 if(s.bitSize() == bitSize()) {
230 return reinterpretType(s);
231 }
232
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;
1226
1227 return VectorIntrinsics.rearrangeOp(
1228 DoubleMaxVector.class, DoubleMaxShuffle.class, double.class, LENGTH,
1229 this, s,
1230 (v1, s_) -> v1.uOp((i, a) -> {
1231 int ei = s_.getElement(i);
1232 return v1.get(ei);
1233 }));
1234 }
1235
1236 @Override
1237 @ForceInline
1238 public DoubleMaxVector blend(Vector<Double> o1, VectorMask<Double> o2) {
1239 Objects.requireNonNull(o1);
1240 Objects.requireNonNull(o2);
1241 DoubleMaxVector v = (DoubleMaxVector)o1;
1242 DoubleMaxMask m = (DoubleMaxMask)o2;
1243
1244 return VectorIntrinsics.blend(
1245 DoubleMaxVector.class, DoubleMaxMask.class, double.class, LENGTH,
1246 this, v, m,
1247 (v1, v2, m_) -> v1.bOp(v2, (i, a, b) -> m_.getElement(i) ? b : a));
1248 }
1249
1250 // Accessors
1251
1252 @Override
1253 public double get(int i) {
1254 if (i < 0 || i >= LENGTH) {
1255 throw new IllegalArgumentException("Index " + i + " must be zero or positive, and less than " + LENGTH);
1256 }
1257 long bits = (long) VectorIntrinsics.extract(
1258 DoubleMaxVector.class, double.class, LENGTH,
1259 this, i,
1260 (vec, ix) -> {
1261 double[] vecarr = vec.getElements();
1262 return (long)Double.doubleToLongBits(vecarr[ix]);
1263 });
1264 return Double.longBitsToDouble(bits);
1265 }
1266
1267 @Override
1268 public DoubleMaxVector with(int i, double e) {
1269 if (i < 0 || i >= LENGTH) {
1270 throw new IllegalArgumentException("Index " + i + " must be zero or positive, and less than " + LENGTH);
1271 }
1272 return VectorIntrinsics.insert(
1273 DoubleMaxVector.class, double.class, LENGTH,
1435 super(reorder);
1436 }
1437
1438 public DoubleMaxShuffle(int[] reorder, int i) {
1439 super(reorder, i);
1440 }
1441
1442 public DoubleMaxShuffle(IntUnaryOperator f) {
1443 super(f);
1444 }
1445
1446 @Override
1447 public VectorSpecies<Double> species() {
1448 return SPECIES;
1449 }
1450
1451 @Override
1452 public DoubleVector toVector() {
1453 double[] va = new double[SPECIES.length()];
1454 for (int i = 0; i < va.length; i++) {
1455 va[i] = (double) getElement(i);
1456 }
1457 return DoubleVector.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);
|
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];
187 for (int i = 0; i < limit; i++) {
188 a[i] = (short) this.lane(i);
189 }
190 return (Vector) ShortVector.fromArray((VectorSpecies<Short>) s, a, 0);
191 } else if (stype == int.class) {
192 int[] a = new int[limit];
193 for (int i = 0; i < limit; i++) {
194 a[i] = (int) this.lane(i);
195 }
196 return (Vector) IntVector.fromArray((VectorSpecies<Integer>) s, a, 0);
197 } else if (stype == long.class) {
198 long[] a = new long[limit];
199 for (int i = 0; i < limit; i++) {
200 a[i] = (long) this.lane(i);
201 }
202 return (Vector) LongVector.fromArray((VectorSpecies<Long>) s, a, 0);
203 } else if (stype == float.class) {
204 float[] a = new float[limit];
205 for (int i = 0; i < limit; i++) {
206 a[i] = (float) this.lane(i);
207 }
208 return (Vector) FloatVector.fromArray((VectorSpecies<Float>) s, a, 0);
209 } else if (stype == double.class) {
210 double[] a = new double[limit];
211 for (int i = 0; i < limit; i++) {
212 a[i] = (double) this.lane(i);
213 }
214 return (Vector) DoubleVector.fromArray((VectorSpecies<Double>) s, a, 0);
215 } else {
216 throw new UnsupportedOperationException("Bad lane type for casting.");
217 }
218 }
219
220 @Override
221 @ForceInline
222 @SuppressWarnings("unchecked")
223 public <F> Vector<F> reinterpret(VectorSpecies<F> s) {
224 Objects.requireNonNull(s);
225
226 if(s.elementType().equals(double.class)) {
227 return (Vector<F>) reshape((VectorSpecies<Double>)s);
228 }
229 if(s.bitSize() == bitSize()) {
230 return reinterpretType(s);
231 }
232
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;
1226
1227 return VectorIntrinsics.rearrangeOp(
1228 DoubleMaxVector.class, DoubleMaxShuffle.class, double.class, LENGTH,
1229 this, s,
1230 (v1, s_) -> v1.uOp((i, a) -> {
1231 int ei = s_.lane(i);
1232 return v1.lane(ei);
1233 }));
1234 }
1235
1236 @Override
1237 @ForceInline
1238 public DoubleMaxVector blend(Vector<Double> o1, VectorMask<Double> o2) {
1239 Objects.requireNonNull(o1);
1240 Objects.requireNonNull(o2);
1241 DoubleMaxVector v = (DoubleMaxVector)o1;
1242 DoubleMaxMask m = (DoubleMaxMask)o2;
1243
1244 return VectorIntrinsics.blend(
1245 DoubleMaxVector.class, DoubleMaxMask.class, double.class, LENGTH,
1246 this, v, m,
1247 (v1, v2, m_) -> v1.bOp(v2, (i, a, b) -> m_.lane(i) ? b : a));
1248 }
1249
1250 // Accessors
1251
1252 @Override
1253 public double lane(int i) {
1254 if (i < 0 || i >= LENGTH) {
1255 throw new IllegalArgumentException("Index " + i + " must be zero or positive, and less than " + LENGTH);
1256 }
1257 long bits = (long) VectorIntrinsics.extract(
1258 DoubleMaxVector.class, double.class, LENGTH,
1259 this, i,
1260 (vec, ix) -> {
1261 double[] vecarr = vec.getElements();
1262 return (long)Double.doubleToLongBits(vecarr[ix]);
1263 });
1264 return Double.longBitsToDouble(bits);
1265 }
1266
1267 @Override
1268 public DoubleMaxVector with(int i, double e) {
1269 if (i < 0 || i >= LENGTH) {
1270 throw new IllegalArgumentException("Index " + i + " must be zero or positive, and less than " + LENGTH);
1271 }
1272 return VectorIntrinsics.insert(
1273 DoubleMaxVector.class, double.class, LENGTH,
1435 super(reorder);
1436 }
1437
1438 public DoubleMaxShuffle(int[] reorder, int i) {
1439 super(reorder, i);
1440 }
1441
1442 public DoubleMaxShuffle(IntUnaryOperator f) {
1443 super(f);
1444 }
1445
1446 @Override
1447 public VectorSpecies<Double> species() {
1448 return SPECIES;
1449 }
1450
1451 @Override
1452 public DoubleVector toVector() {
1453 double[] va = new double[SPECIES.length()];
1454 for (int i = 0; i < va.length; i++) {
1455 va[i] = (double) lane(i);
1456 }
1457 return DoubleVector.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);
|