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; 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); 1431 super(reorder); 1432 } 1433 1434 public DoubleMaxShuffle(int[] reorder) { 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); 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 DoubleMaxShuffle rearrange(VectorShuffle<Double> o) { 1487 DoubleMaxShuffle s = (DoubleMaxShuffle) 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 DoubleMaxShuffle(r); 1493 } 1494 } 1495 1496 // VectorSpecies 1497 1498 @Override 1499 public VectorSpecies<Double> species() { 1500 return SPECIES; 1501 } 1502 } | 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 @ForceInline 1171 public DoubleMaxVector 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<Double> PermMask = VectorShuffle.shuffleIota(SPECIES, L - j); 1178 return this.rearrange(PermMask); 1179 } 1180 } 1181 1182 @Override 1183 @ForceInline 1184 public DoubleMaxVector 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<Double> PermMask = VectorShuffle.shuffleIota(SPECIES, j); 1191 return this.rearrange(PermMask); 1192 } 1193 } 1194 1195 @Override 1196 @ForceInline 1197 @SuppressWarnings("unchecked") 1198 public DoubleMaxVector 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 DoubleMaxShuffle Iota = (DoubleMaxShuffle)(VectorShuffle.shuffleIota(SPECIES, L-j)); 1206 VectorMask<Double> BlendMask = Iota.toVector().lessThan(DoubleMaxVector.broadcast(SPECIES, (double)(L-j))); 1207 Iota = (DoubleMaxShuffle)(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 DoubleMaxVector 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 DoubleMaxShuffle Iota = (DoubleMaxShuffle)(VectorShuffle.shuffleIota(SPECIES, j)); 1223 VectorMask<Double> BlendMask = Iota.toVector().greaterThanEq(DoubleMaxVector.broadcast(SPECIES, (double)(j))); 1224 Iota = (DoubleMaxShuffle)(VectorShuffle.shuffleIota(SPECIES, j)); 1225 return ZERO.blend(this.rearrange(Iota),BlendMask); 1226 } 1227 } 1228 1229 @Override 1230 @ForceInline 1231 public DoubleMaxVector rearrange(Vector<Double> v, 1232 VectorShuffle<Double> s, VectorMask<Double> m) { 1233 return this.rearrange(s).blend(v.rearrange(s), m); 1234 } 1235 1236 @Override 1237 @ForceInline 1238 public DoubleMaxVector rearrange(VectorShuffle<Double> o1) { 1239 Objects.requireNonNull(o1); 1240 DoubleMaxShuffle s = (DoubleMaxShuffle)o1; 1241 1242 return VectorIntrinsics.rearrangeOp( 1243 DoubleMaxVector.class, DoubleMaxShuffle.class, double.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 DoubleMaxShuffle(int[] reorder) { 1450 super(reorder); 1451 } 1452 1453 public DoubleMaxShuffle(int[] reorder, int i) { 1454 super(reorder, i); 1455 } 1456 1457 public DoubleMaxShuffle(IntUnaryOperator f) { 1458 super(f); 1459 } 1460 1461 @Override 1462 public VectorSpecies<Double> species() { 1463 return SPECIES; 1464 } 1465 1466 private DoubleVector toVector_helper() { 1467 double[] va = new double[SPECIES.length()]; 1468 for (int i = 0; i < va.length; i++) { 1469 va[i] = (double) lane(i); 1470 } 1471 return DoubleVector.fromArray(SPECIES, va, 0); 1472 } 1473 1474 @Override 1475 @ForceInline 1476 public DoubleVector toVector() { 1477 return VectorIntrinsics.shuffleToVector(DoubleMaxVector.class, double.class, DoubleMaxShuffle.class, this, 1478 SPECIES.length(), 1479 (s) -> (((DoubleMaxShuffle)(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 DoubleMaxShuffle rearrange(VectorShuffle<Double> o) { 1510 DoubleMaxShuffle s = (DoubleMaxShuffle) 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 DoubleMaxShuffle(r); 1516 } 1517 } 1518 1519 // VectorSpecies 1520 1521 @Override 1522 public VectorSpecies<Double> species() { 1523 return SPECIES; 1524 } 1525 } |