< prev index next >

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

Print this page




  95     interface FUnCon {
  96         void apply(int i, long a);
  97     }
  98 
  99     abstract void forEach(FUnCon f);
 100 
 101     abstract void forEach(VectorMask<Long> m, FUnCon f);
 102 
 103     // Static factories
 104 
 105     /**
 106      * Returns a vector where all lane elements are set to the default
 107      * primitive value.
 108      *
 109      * @param species species of desired vector
 110      * @return a zero vector of given species
 111      */
 112     @ForceInline
 113     @SuppressWarnings("unchecked")
 114     public static LongVector zero(VectorSpecies<Long> species) {
 115         return VectorIntrinsics.broadcastCoerced((Class<LongVector>) species.boxType(), long.class, species.length(),
 116                                                  0, species,
 117                                                  ((bits, s) -> ((LongSpecies)s).op(i -> (long)bits)));
 118     }
 119 
 120     /**
 121      * Loads a vector from a byte array starting at an offset.
 122      * <p>
 123      * Bytes are composed into primitive lane elements according to the
 124      * native byte order of the underlying platform
 125      * <p>
 126      * This method behaves as if it returns the result of calling the
 127      * byte buffer, offset, and mask accepting
 128      * {@link #fromByteBuffer(VectorSpecies, ByteBuffer, int, VectorMask) method} as follows:
 129      * <pre>{@code
 130      * return fromByteBuffer(species, ByteBuffer.wrap(a), offset, VectorMask.allTrue());
 131      * }</pre>
 132      *
 133      * @param species species of desired vector
 134      * @param a the byte array
 135      * @param offset the offset into the array
 136      * @return a vector loaded from a byte array
 137      * @throws IndexOutOfBoundsException if {@code i < 0} or
 138      * {@code offset > a.length - (species.length() * species.elementSize() / Byte.SIZE)}
 139      */
 140     @ForceInline
 141     @SuppressWarnings("unchecked")
 142     public static LongVector fromByteArray(VectorSpecies<Long> species, byte[] a, int offset) {
 143         Objects.requireNonNull(a);
 144         offset = VectorIntrinsics.checkIndex(offset, a.length, species.bitSize() / Byte.SIZE);
 145         return VectorIntrinsics.load((Class<LongVector>) species.boxType(), long.class, species.length(),
 146                                      a, ((long) offset) + Unsafe.ARRAY_BYTE_BASE_OFFSET,
 147                                      a, offset, species,
 148                                      (c, idx, s) -> {
 149                                          ByteBuffer bbc = ByteBuffer.wrap(c, idx, a.length - idx).order(ByteOrder.nativeOrder());
 150                                          LongBuffer tb = bbc.asLongBuffer();
 151                                          return ((LongSpecies)s).op(i -> tb.get());
 152                                      });
 153     }
 154 
 155     /**
 156      * Loads a vector from a byte array starting at an offset and using a
 157      * mask.
 158      * <p>
 159      * Bytes are composed into primitive lane elements according to the
 160      * native byte order of the underlying platform.
 161      * <p>
 162      * This method behaves as if it returns the result of calling the
 163      * byte buffer, offset, and mask accepting
 164      * {@link #fromByteBuffer(VectorSpecies, ByteBuffer, int, VectorMask) method} as follows:
 165      * <pre>{@code


 183 
 184     /**
 185      * Loads a vector from an array starting at offset.
 186      * <p>
 187      * For each vector lane, where {@code N} is the vector lane index, the
 188      * array element at index {@code offset + N} is placed into the
 189      * resulting vector at lane index {@code N}.
 190      *
 191      * @param species species of desired vector
 192      * @param a the array
 193      * @param offset the offset into the array
 194      * @return the vector loaded from an array
 195      * @throws IndexOutOfBoundsException if {@code offset < 0}, or
 196      * {@code offset > a.length - species.length()}
 197      */
 198     @ForceInline
 199     @SuppressWarnings("unchecked")
 200     public static LongVector fromArray(VectorSpecies<Long> species, long[] a, int offset){
 201         Objects.requireNonNull(a);
 202         offset = VectorIntrinsics.checkIndex(offset, a.length, species.length());
 203         return VectorIntrinsics.load((Class<LongVector>) species.boxType(), long.class, species.length(),
 204                                      a, (((long) offset) << ARRAY_SHIFT) + Unsafe.ARRAY_LONG_BASE_OFFSET,
 205                                      a, offset, species,
 206                                      (c, idx, s) -> ((LongSpecies)s).op(n -> c[idx + n]));
 207     }
 208 
 209 
 210     /**
 211      * Loads a vector from an array starting at offset and using a mask.
 212      * <p>
 213      * For each vector lane, where {@code N} is the vector lane index,
 214      * if the mask lane at index {@code N} is set then the array element at
 215      * index {@code offset + N} is placed into the resulting vector at lane index
 216      * {@code N}, otherwise the default element value is placed into the
 217      * resulting vector at lane index {@code N}.
 218      *
 219      * @param species species of desired vector
 220      * @param a the array
 221      * @param offset the offset into the array
 222      * @param m the mask
 223      * @return the vector loaded from an array


 249      * @throws IndexOutOfBoundsException if {@code i_offset < 0}, or
 250      * {@code i_offset > indexMap.length - species.length()},
 251      * or for any vector lane index {@code N} the result of
 252      * {@code a_offset + indexMap[i_offset + N]} is {@code < 0} or {@code >= a.length}
 253      */
 254     @ForceInline
 255     @SuppressWarnings("unchecked")
 256     public static LongVector fromArray(VectorSpecies<Long> species, long[] a, int a_offset, int[] indexMap, int i_offset) {
 257         Objects.requireNonNull(a);
 258         Objects.requireNonNull(indexMap);
 259 
 260         if (species.length() == 1) {
 261           return LongVector.fromArray(species, a, a_offset + indexMap[i_offset]);
 262         }
 263 
 264         // Index vector: vix[0:n] = k -> a_offset + indexMap[i_offset + k]
 265         IntVector vix = IntVector.fromArray(IntVector.species(species.indexShape()), indexMap, i_offset).add(a_offset);
 266 
 267         vix = VectorIntrinsics.checkIndex(vix, a.length);
 268 
 269         return VectorIntrinsics.loadWithMap((Class<LongVector>) species.boxType(), long.class, species.length(),
 270                                             IntVector.species(species.indexShape()).boxType(), a, Unsafe.ARRAY_LONG_BASE_OFFSET, vix,
 271                                             a, a_offset, indexMap, i_offset, species,
 272                                             (long[] c, int idx, int[] iMap, int idy, VectorSpecies<Long> s) ->
 273                                                 ((LongSpecies)s).op(n -> c[idx + iMap[idy+n]]));
 274         }
 275 
 276     /**
 277      * Loads a vector from an array using indexes obtained from an index
 278      * map and using a mask.
 279      * <p>
 280      * For each vector lane, where {@code N} is the vector lane index,
 281      * if the mask lane at index {@code N} is set then the array element at
 282      * index {@code a_offset + indexMap[i_offset + N]} is placed into the resulting vector
 283      * at lane index {@code N}.
 284      *
 285      * @param species species of desired vector
 286      * @param a the array
 287      * @param a_offset the offset into the array, may be negative if relative
 288      * indexes in the index map compensate to produce a value within the
 289      * array bounds
 290      * @param m the mask


 319      *   return fromByteBuffer(b, offset, VectorMask.allTrue())
 320      * }</pre>
 321      *
 322      * @param species species of desired vector
 323      * @param bb the byte buffer
 324      * @param offset the offset into the byte buffer
 325      * @return a vector loaded from a byte buffer
 326      * @throws IndexOutOfBoundsException if the offset is {@code < 0},
 327      * or {@code > b.limit()},
 328      * or if there are fewer than
 329      * {@code species.length() * species.elementSize() / Byte.SIZE} bytes
 330      * remaining in the byte buffer from the given offset
 331      */
 332     @ForceInline
 333     @SuppressWarnings("unchecked")
 334     public static LongVector fromByteBuffer(VectorSpecies<Long> species, ByteBuffer bb, int offset) {
 335         if (bb.order() != ByteOrder.nativeOrder()) {
 336             throw new IllegalArgumentException();
 337         }
 338         offset = VectorIntrinsics.checkIndex(offset, bb.limit(), species.bitSize() / Byte.SIZE);
 339         return VectorIntrinsics.load((Class<LongVector>) species.boxType(), long.class, species.length(),
 340                                      U.getReference(bb, BYTE_BUFFER_HB), U.getLong(bb, BUFFER_ADDRESS) + offset,
 341                                      bb, offset, species,
 342                                      (c, idx, s) -> {
 343                                          ByteBuffer bbc = c.duplicate().position(idx).order(ByteOrder.nativeOrder());
 344                                          LongBuffer tb = bbc.asLongBuffer();
 345                                          return ((LongSpecies)s).op(i -> tb.get());
 346                                      });
 347     }
 348 
 349     /**
 350      * Loads a vector from a {@link ByteBuffer byte buffer} starting at an
 351      * offset into the byte buffer and using a mask.
 352      * <p>
 353      * This method behaves as if the byte buffer is viewed as a primitive
 354      * {@link java.nio.Buffer buffer} for the primitive element type,
 355      * according to the native byte order of the underlying platform, and
 356      * the returned vector is loaded with a mask from a primitive array
 357      * obtained from the primitive buffer.
 358      * The following pseudocode expresses the behaviour, where
 359      * {@code EBuffer} is the primitive buffer type, {@code e} is the


 383      * {@code offset >= b.limit() - (N * species.elementSize() / Byte.SIZE)}
 384      */
 385     @ForceInline
 386     public static LongVector fromByteBuffer(VectorSpecies<Long> species, ByteBuffer bb, int offset, VectorMask<Long> m) {
 387         return zero(species).blend(fromByteBuffer(species, bb, offset), m);
 388     }
 389 
 390     /**
 391      * Returns a vector where all lane elements are set to the primitive
 392      * value {@code e}.
 393      *
 394      * @param species species of the desired vector
 395      * @param e the value
 396      * @return a vector of vector where all lane elements are set to
 397      * the primitive value {@code e}
 398      */
 399     @ForceInline
 400     @SuppressWarnings("unchecked")
 401     public static LongVector broadcast(VectorSpecies<Long> species, long e) {
 402         return VectorIntrinsics.broadcastCoerced(
 403             (Class<LongVector>) species.boxType(), long.class, species.length(),
 404             e, species,
 405             ((bits, sp) -> ((LongSpecies)sp).op(i -> (long)bits)));
 406     }
 407 
 408     /**
 409      * Returns a vector where each lane element is set to given
 410      * primitive values.
 411      * <p>
 412      * For each vector lane, where {@code N} is the vector lane index, the
 413      * the primitive value at index {@code N} is placed into the resulting
 414      * vector at lane index {@code N}.
 415      *
 416      * @param species species of the desired vector
 417      * @param es the given primitive values
 418      * @return a vector where each lane element is set to given primitive
 419      * values
 420      * @throws IndexOutOfBoundsException if {@code es.length < species.length()}
 421      */
 422     @ForceInline
 423     @SuppressWarnings("unchecked")
 424     public static LongVector scalars(VectorSpecies<Long> species, long... es) {
 425         Objects.requireNonNull(es);
 426         int ix = VectorIntrinsics.checkIndex(0, es.length, species.length());
 427         return VectorIntrinsics.load((Class<LongVector>) species.boxType(), long.class, species.length(),
 428                                      es, Unsafe.ARRAY_LONG_BASE_OFFSET,
 429                                      es, ix, species,
 430                                      (c, idx, sp) -> ((LongSpecies)sp).op(n -> c[idx + n]));
 431     }
 432 
 433     /**
 434      * Returns a vector where the first lane element is set to the primtive
 435      * value {@code e}, all other lane elements are set to the default
 436      * value.
 437      *
 438      * @param species species of the desired vector
 439      * @param e the value
 440      * @return a vector where the first lane element is set to the primitive
 441      * value {@code e}
 442      */
 443     @ForceInline
 444     public static final LongVector single(VectorSpecies<Long> species, long e) {
 445         return zero(species).with(0, e);
 446     }
 447 


 785     @Override
 786     public abstract LongVector rearrange(Vector<Long> v,
 787                                                       VectorShuffle<Long> s, VectorMask<Long> m);
 788 
 789     /**
 790      * {@inheritDoc}
 791      */
 792     @Override
 793     public abstract LongVector rearrange(VectorShuffle<Long> m);
 794 
 795     /**
 796      * {@inheritDoc}
 797      */
 798     @Override
 799     public abstract LongVector reshape(VectorSpecies<Long> s);
 800 
 801     /**
 802      * {@inheritDoc}
 803      */
 804     @Override
 805     public abstract LongVector rotateEL(int i);
 806 
 807     /**
 808      * {@inheritDoc}
 809      */
 810     @Override
 811     public abstract LongVector rotateER(int i);
 812 
 813     /**
 814      * {@inheritDoc}
 815      */
 816     @Override
 817     public abstract LongVector shiftEL(int i);
 818 
 819     /**
 820      * {@inheritDoc}
 821      */
 822     @Override
 823     public abstract LongVector shiftER(int i);
 824 
 825 
 826 
 827     /**
 828      * Bitwise ANDs this vector with an input vector.
 829      * <p>
 830      * This is a lane-wise binary operation which applies the primitive bitwise AND
 831      * operation ({@code &}) to each lane.
 832      *
 833      * @param v the input vector
 834      * @return the bitwise AND of this vector with the input vector
 835      */
 836     public abstract LongVector and(Vector<Long> v);
 837 
 838     /**
 839      * Bitwise ANDs this vector with the broadcast of an input scalar.
 840      * <p>
 841      * This is a lane-wise binary operation which applies the primitive bitwise AND
 842      * operation ({@code &}) to each lane.
 843      *


 982      *
 983      * @return the bitwise NOT of this vector
 984      */
 985     public abstract LongVector not();
 986 
 987     /**
 988      * Bitwise NOTs this vector, selecting lane elements controlled by a mask.
 989      * <p>
 990      * This is a lane-wise unary operation which applies the primitive bitwise NOT
 991      * operation ({@code ~}) to each lane.
 992      *
 993      * @param m the mask controlling lane selection
 994      * @return the bitwise NOT of this vector
 995      */
 996     public abstract LongVector not(VectorMask<Long> m);
 997 
 998     /**
 999      * Logically left shifts this vector by the broadcast of an input scalar.
1000      * <p>
1001      * This is a lane-wise binary operation which applies the primitive logical left shift
1002      * operation ({@code <<}) to each lane.

1003      *
1004      * @param s the input scalar; the number of the bits to left shift
1005      * @return the result of logically left shifting left this vector by the
1006      * broadcast of an input scalar
1007      */
1008     public abstract LongVector shiftL(int s);
1009 
1010     /**
1011      * Logically left shifts this vector by the broadcast of an input scalar,
1012      * selecting lane elements controlled by a mask.
1013      * <p>
1014      * This is a lane-wise binary operation which applies the primitive logical left shift
1015      * operation ({@code <<}) to each lane.

1016      *
1017      * @param s the input scalar; the number of the bits to left shift
1018      * @param m the mask controlling lane selection
1019      * @return the result of logically left shifting this vector by the
1020      * broadcast of an input scalar
1021      */
1022     public abstract LongVector shiftL(int s, VectorMask<Long> m);
1023 
1024     /**
1025      * Logically left shifts this vector by an input vector.
1026      * <p>
1027      * This is a lane-wise binary operation which applies the primitive logical left shift
1028      * operation ({@code <<}) to each lane.

1029      *
1030      * @param v the input vector
1031      * @return the result of logically left shifting this vector by the input
1032      * vector
1033      */
1034     public abstract LongVector shiftL(Vector<Long> v);
1035 
1036     /**
1037      * Logically left shifts this vector by an input vector, selecting lane
1038      * elements controlled by a mask.
1039      * <p>
1040      * This is a lane-wise binary operation which applies the primitive logical left shift
1041      * operation ({@code <<}) to each lane.

1042      *
1043      * @param v the input vector
1044      * @param m the mask controlling lane selection
1045      * @return the result of logically left shifting this vector by the input
1046      * vector
1047      */
1048     public LongVector shiftL(Vector<Long> v, VectorMask<Long> m) {
1049         return bOp(v, m, (i, a, b) -> (long) (a << b));
1050     }
1051 
1052     // logical, or unsigned, shift right
1053 
1054     /**
1055      * Logically right shifts (or unsigned right shifts) this vector by the
1056      * broadcast of an input scalar.
1057      * <p>
1058      * This is a lane-wise binary operation which applies the primitive logical right shift
1059      * operation ({@code >>>}) to each lane.

1060      *
1061      * @param s the input scalar; the number of the bits to right shift
1062      * @return the result of logically right shifting this vector by the
1063      * broadcast of an input scalar
1064      */
1065     public abstract LongVector shiftR(int s);
1066 
1067     /**
1068      * Logically right shifts (or unsigned right shifts) this vector by the
1069      * broadcast of an input scalar, selecting lane elements controlled by a
1070      * mask.
1071      * <p>
1072      * This is a lane-wise binary operation which applies the primitive logical right shift
1073      * operation ({@code >>>}) to each lane.

1074      *
1075      * @param s the input scalar; the number of the bits to right shift
1076      * @param m the mask controlling lane selection
1077      * @return the result of logically right shifting this vector by the
1078      * broadcast of an input scalar
1079      */
1080     public abstract LongVector shiftR(int s, VectorMask<Long> m);
1081 
1082     /**
1083      * Logically right shifts (or unsigned right shifts) this vector by an
1084      * input vector.
1085      * <p>
1086      * This is a lane-wise binary operation which applies the primitive logical right shift
1087      * operation ({@code >>>}) to each lane.

1088      *
1089      * @param v the input vector
1090      * @return the result of logically right shifting this vector by the
1091      * input vector
1092      */
1093     public abstract LongVector shiftR(Vector<Long> v);
1094 
1095     /**
1096      * Logically right shifts (or unsigned right shifts) this vector by an
1097      * input vector, selecting lane elements controlled by a mask.
1098      * <p>
1099      * This is a lane-wise binary operation which applies the primitive logical right shift
1100      * operation ({@code >>>}) to each lane.

1101      *
1102      * @param v the input vector
1103      * @param m the mask controlling lane selection
1104      * @return the result of logically right shifting this vector by the
1105      * input vector
1106      */
1107     public LongVector shiftR(Vector<Long> v, VectorMask<Long> m) {
1108         return bOp(v, m, (i, a, b) -> (long) (a >>> b));
1109     }
1110 
1111     /**
1112      * Arithmetically right shifts (or signed right shifts) this vector by the
1113      * broadcast of an input scalar.
1114      * <p>
1115      * This is a lane-wise binary operation which applies the primitive arithmetic right
1116      * shift operation ({@code >>}) to each lane.

1117      *
1118      * @param s the input scalar; the number of the bits to right shift
1119      * @return the result of arithmetically right shifting this vector by the
1120      * broadcast of an input scalar
1121      */
1122     public abstract LongVector aShiftR(int s);
1123 
1124     /**
1125      * Arithmetically right shifts (or signed right shifts) this vector by the
1126      * broadcast of an input scalar, selecting lane elements controlled by a
1127      * mask.
1128      * <p>
1129      * This is a lane-wise binary operation which applies the primitive arithmetic right
1130      * shift operation ({@code >>}) to each lane.

1131      *
1132      * @param s the input scalar; the number of the bits to right shift
1133      * @param m the mask controlling lane selection
1134      * @return the result of arithmetically right shifting this vector by the
1135      * broadcast of an input scalar
1136      */
1137     public abstract LongVector aShiftR(int s, VectorMask<Long> m);
1138 
1139     /**
1140      * Arithmetically right shifts (or signed right shifts) this vector by an
1141      * input vector.
1142      * <p>
1143      * This is a lane-wise binary operation which applies the primitive arithmetic right
1144      * shift operation ({@code >>}) to each lane.

1145      *
1146      * @param v the input vector
1147      * @return the result of arithmetically right shifting this vector by the
1148      * input vector
1149      */
1150     public abstract LongVector aShiftR(Vector<Long> v);
1151 
1152     /**
1153      * Arithmetically right shifts (or signed right shifts) this vector by an
1154      * input vector, selecting lane elements controlled by a mask.
1155      * <p>
1156      * This is a lane-wise binary operation which applies the primitive arithmetic right
1157      * shift operation ({@code >>}) to each lane.

1158      *
1159      * @param v the input vector
1160      * @param m the mask controlling lane selection
1161      * @return the result of arithmetically right shifting this vector by the
1162      * input vector
1163      */
1164     public LongVector aShiftR(Vector<Long> v, VectorMask<Long> m) {
1165         return bOp(v, m, (i, a, b) -> (long) (a >> b));
1166     }
1167 
1168     /**
1169      * Rotates left this vector by the broadcast of an input scalar.
1170      * <p>
1171      * This is a lane-wise binary operation which applies the operation
1172      * {@link Long#rotateLeft} to each lane and where
1173      * lane elements of this vector apply to the first argument, and lane
1174      * elements of the broadcast vector apply to the second argument (the
1175      * rotation distance).
1176      *
1177      * @param s the input scalar; the number of the bits to rotate left
1178      * @return the result of rotating left this vector by the broadcast of an
1179      * input scalar
1180      */
1181     @ForceInline
1182     public final LongVector rotateL(int s) {
1183         return shiftL(s).or(shiftR(-s));
1184     }
1185 
1186     /**
1187      * Rotates left this vector by the broadcast of an input scalar, selecting
1188      * lane elements controlled by a mask.
1189      * <p>
1190      * This is a lane-wise binary operation which applies the operation
1191      * {@link Long#rotateLeft} to each lane and where
1192      * lane elements of this vector apply to the first argument, and lane
1193      * elements of the broadcast vector apply to the second argument (the
1194      * rotation distance).
1195      *
1196      * @param s the input scalar; the number of the bits to rotate left
1197      * @param m the mask controlling lane selection
1198      * @return the result of rotating left this vector by the broadcast of an
1199      * input scalar
1200      */
1201     @ForceInline
1202     public final LongVector rotateL(int s, VectorMask<Long> m) {
1203         return shiftL(s, m).or(shiftR(-s, m), m);
1204     }
1205 
1206     /**
1207      * Rotates right this vector by the broadcast of an input scalar.
1208      * <p>
1209      * This is a lane-wise binary operation which applies the operation
1210      * {@link Long#rotateRight} to each lane and where
1211      * lane elements of this vector apply to the first argument, and lane
1212      * elements of the broadcast vector apply to the second argument (the
1213      * rotation distance).
1214      *
1215      * @param s the input scalar; the number of the bits to rotate right
1216      * @return the result of rotating right this vector by the broadcast of an
1217      * input scalar
1218      */
1219     @ForceInline
1220     public final LongVector rotateR(int s) {
1221         return shiftR(s).or(shiftL(-s));
1222     }
1223 
1224     /**
1225      * Rotates right this vector by the broadcast of an input scalar, selecting
1226      * lane elements controlled by a mask.
1227      * <p>
1228      * This is a lane-wise binary operation which applies the operation
1229      * {@link Long#rotateRight} to each lane and where
1230      * lane elements of this vector apply to the first argument, and lane
1231      * elements of the broadcast vector apply to the second argument (the
1232      * rotation distance).
1233      *
1234      * @param s the input scalar; the number of the bits to rotate right
1235      * @param m the mask controlling lane selection
1236      * @return the result of rotating right this vector by the broadcast of an
1237      * input scalar
1238      */
1239     @ForceInline
1240     public final LongVector rotateR(int s, VectorMask<Long> m) {
1241         return shiftR(s, m).or(shiftL(-s, m), m);
1242     }
1243 
1244     /**
1245      * {@inheritDoc}
1246      */
1247     @Override
1248     public abstract void intoByteArray(byte[] a, int ix);
1249 
1250     /**
1251      * {@inheritDoc}
1252      */
1253     @Override
1254     public abstract void intoByteArray(byte[] a, int ix, VectorMask<Long> m);
1255 
1256     /**
1257      * {@inheritDoc}
1258      */
1259     @Override
1260     public abstract void intoByteBuffer(ByteBuffer bb, int ix);
1261 


1563      * or for any vector lane index {@code N} where the mask at lane
1564      * {@code N} is set the result of {@code a_offset + indexMap[i_offset + N]} is
1565      * {@code < 0} or {@code >= a.length}
1566      */
1567     public abstract void intoArray(long[] a, int a_offset, VectorMask<Long> m, int[] indexMap, int i_offset);
1568     // Species
1569 
1570     /**
1571      * {@inheritDoc}
1572      */
1573     @Override
1574     public abstract VectorSpecies<Long> species();
1575 
1576     /**
1577      * Class representing {@link LongVector}'s of the same {@link VectorShape VectorShape}.
1578      */
1579     static final class LongSpecies extends AbstractSpecies<Long> {
1580         final Function<long[], LongVector> vectorFactory;
1581 
1582         private LongSpecies(VectorShape shape,
1583                           Class<?> boxType,
1584                           Class<?> maskType,
1585                           Function<long[], LongVector> vectorFactory,
1586                           Function<boolean[], VectorMask<Long>> maskFactory,
1587                           Function<IntUnaryOperator, VectorShuffle<Long>> shuffleFromArrayFactory,
1588                           fShuffleFromArray<Long> shuffleFromOpFactory) {
1589             super(shape, long.class, Long.SIZE, boxType, maskType, maskFactory,
1590                   shuffleFromArrayFactory, shuffleFromOpFactory);
1591             this.vectorFactory = vectorFactory;
1592         }
1593 
1594         interface FOp {
1595             long apply(int i);
1596         }
1597 
1598         LongVector op(FOp f) {
1599             long[] res = new long[length()];
1600             for (int i = 0; i < length(); i++) {
1601                 res[i] = f.apply(i);
1602             }
1603             return vectorFactory.apply(res);
1604         }
1605 
1606         LongVector op(VectorMask<Long> o, FOp f) {
1607             long[] res = new long[length()];
1608             boolean[] mbits = ((AbstractMask<Long>)o).getBits();
1609             for (int i = 0; i < length(); i++) {




  95     interface FUnCon {
  96         void apply(int i, long a);
  97     }
  98 
  99     abstract void forEach(FUnCon f);
 100 
 101     abstract void forEach(VectorMask<Long> m, FUnCon f);
 102 
 103     // Static factories
 104 
 105     /**
 106      * Returns a vector where all lane elements are set to the default
 107      * primitive value.
 108      *
 109      * @param species species of desired vector
 110      * @return a zero vector of given species
 111      */
 112     @ForceInline
 113     @SuppressWarnings("unchecked")
 114     public static LongVector zero(VectorSpecies<Long> species) {
 115         return VectorIntrinsics.broadcastCoerced((Class<LongVector>) species.vectorType(), long.class, species.length(),
 116                                                  0, species,
 117                                                  ((bits, s) -> ((LongSpecies)s).op(i -> (long)bits)));
 118     }
 119 
 120     /**
 121      * Loads a vector from a byte array starting at an offset.
 122      * <p>
 123      * Bytes are composed into primitive lane elements according to the
 124      * native byte order of the underlying platform
 125      * <p>
 126      * This method behaves as if it returns the result of calling the
 127      * byte buffer, offset, and mask accepting
 128      * {@link #fromByteBuffer(VectorSpecies, ByteBuffer, int, VectorMask) method} as follows:
 129      * <pre>{@code
 130      * return fromByteBuffer(species, ByteBuffer.wrap(a), offset, VectorMask.allTrue());
 131      * }</pre>
 132      *
 133      * @param species species of desired vector
 134      * @param a the byte array
 135      * @param offset the offset into the array
 136      * @return a vector loaded from a byte array
 137      * @throws IndexOutOfBoundsException if {@code i < 0} or
 138      * {@code offset > a.length - (species.length() * species.elementSize() / Byte.SIZE)}
 139      */
 140     @ForceInline
 141     @SuppressWarnings("unchecked")
 142     public static LongVector fromByteArray(VectorSpecies<Long> species, byte[] a, int offset) {
 143         Objects.requireNonNull(a);
 144         offset = VectorIntrinsics.checkIndex(offset, a.length, species.bitSize() / Byte.SIZE);
 145         return VectorIntrinsics.load((Class<LongVector>) species.vectorType(), long.class, species.length(),
 146                                      a, ((long) offset) + Unsafe.ARRAY_BYTE_BASE_OFFSET,
 147                                      a, offset, species,
 148                                      (c, idx, s) -> {
 149                                          ByteBuffer bbc = ByteBuffer.wrap(c, idx, a.length - idx).order(ByteOrder.nativeOrder());
 150                                          LongBuffer tb = bbc.asLongBuffer();
 151                                          return ((LongSpecies)s).op(i -> tb.get());
 152                                      });
 153     }
 154 
 155     /**
 156      * Loads a vector from a byte array starting at an offset and using a
 157      * mask.
 158      * <p>
 159      * Bytes are composed into primitive lane elements according to the
 160      * native byte order of the underlying platform.
 161      * <p>
 162      * This method behaves as if it returns the result of calling the
 163      * byte buffer, offset, and mask accepting
 164      * {@link #fromByteBuffer(VectorSpecies, ByteBuffer, int, VectorMask) method} as follows:
 165      * <pre>{@code


 183 
 184     /**
 185      * Loads a vector from an array starting at offset.
 186      * <p>
 187      * For each vector lane, where {@code N} is the vector lane index, the
 188      * array element at index {@code offset + N} is placed into the
 189      * resulting vector at lane index {@code N}.
 190      *
 191      * @param species species of desired vector
 192      * @param a the array
 193      * @param offset the offset into the array
 194      * @return the vector loaded from an array
 195      * @throws IndexOutOfBoundsException if {@code offset < 0}, or
 196      * {@code offset > a.length - species.length()}
 197      */
 198     @ForceInline
 199     @SuppressWarnings("unchecked")
 200     public static LongVector fromArray(VectorSpecies<Long> species, long[] a, int offset){
 201         Objects.requireNonNull(a);
 202         offset = VectorIntrinsics.checkIndex(offset, a.length, species.length());
 203         return VectorIntrinsics.load((Class<LongVector>) species.vectorType(), long.class, species.length(),
 204                                      a, (((long) offset) << ARRAY_SHIFT) + Unsafe.ARRAY_LONG_BASE_OFFSET,
 205                                      a, offset, species,
 206                                      (c, idx, s) -> ((LongSpecies)s).op(n -> c[idx + n]));
 207     }
 208 
 209 
 210     /**
 211      * Loads a vector from an array starting at offset and using a mask.
 212      * <p>
 213      * For each vector lane, where {@code N} is the vector lane index,
 214      * if the mask lane at index {@code N} is set then the array element at
 215      * index {@code offset + N} is placed into the resulting vector at lane index
 216      * {@code N}, otherwise the default element value is placed into the
 217      * resulting vector at lane index {@code N}.
 218      *
 219      * @param species species of desired vector
 220      * @param a the array
 221      * @param offset the offset into the array
 222      * @param m the mask
 223      * @return the vector loaded from an array


 249      * @throws IndexOutOfBoundsException if {@code i_offset < 0}, or
 250      * {@code i_offset > indexMap.length - species.length()},
 251      * or for any vector lane index {@code N} the result of
 252      * {@code a_offset + indexMap[i_offset + N]} is {@code < 0} or {@code >= a.length}
 253      */
 254     @ForceInline
 255     @SuppressWarnings("unchecked")
 256     public static LongVector fromArray(VectorSpecies<Long> species, long[] a, int a_offset, int[] indexMap, int i_offset) {
 257         Objects.requireNonNull(a);
 258         Objects.requireNonNull(indexMap);
 259 
 260         if (species.length() == 1) {
 261           return LongVector.fromArray(species, a, a_offset + indexMap[i_offset]);
 262         }
 263 
 264         // Index vector: vix[0:n] = k -> a_offset + indexMap[i_offset + k]
 265         IntVector vix = IntVector.fromArray(IntVector.species(species.indexShape()), indexMap, i_offset).add(a_offset);
 266 
 267         vix = VectorIntrinsics.checkIndex(vix, a.length);
 268 
 269         return VectorIntrinsics.loadWithMap((Class<LongVector>) species.vectorType(), long.class, species.length(),
 270                                             IntVector.species(species.indexShape()).vectorType(), a, Unsafe.ARRAY_LONG_BASE_OFFSET, vix,
 271                                             a, a_offset, indexMap, i_offset, species,
 272                                             (long[] c, int idx, int[] iMap, int idy, VectorSpecies<Long> s) ->
 273                                                 ((LongSpecies)s).op(n -> c[idx + iMap[idy+n]]));
 274         }
 275 
 276     /**
 277      * Loads a vector from an array using indexes obtained from an index
 278      * map and using a mask.
 279      * <p>
 280      * For each vector lane, where {@code N} is the vector lane index,
 281      * if the mask lane at index {@code N} is set then the array element at
 282      * index {@code a_offset + indexMap[i_offset + N]} is placed into the resulting vector
 283      * at lane index {@code N}.
 284      *
 285      * @param species species of desired vector
 286      * @param a the array
 287      * @param a_offset the offset into the array, may be negative if relative
 288      * indexes in the index map compensate to produce a value within the
 289      * array bounds
 290      * @param m the mask


 319      *   return fromByteBuffer(b, offset, VectorMask.allTrue())
 320      * }</pre>
 321      *
 322      * @param species species of desired vector
 323      * @param bb the byte buffer
 324      * @param offset the offset into the byte buffer
 325      * @return a vector loaded from a byte buffer
 326      * @throws IndexOutOfBoundsException if the offset is {@code < 0},
 327      * or {@code > b.limit()},
 328      * or if there are fewer than
 329      * {@code species.length() * species.elementSize() / Byte.SIZE} bytes
 330      * remaining in the byte buffer from the given offset
 331      */
 332     @ForceInline
 333     @SuppressWarnings("unchecked")
 334     public static LongVector fromByteBuffer(VectorSpecies<Long> species, ByteBuffer bb, int offset) {
 335         if (bb.order() != ByteOrder.nativeOrder()) {
 336             throw new IllegalArgumentException();
 337         }
 338         offset = VectorIntrinsics.checkIndex(offset, bb.limit(), species.bitSize() / Byte.SIZE);
 339         return VectorIntrinsics.load((Class<LongVector>) species.vectorType(), long.class, species.length(),
 340                                      U.getReference(bb, BYTE_BUFFER_HB), U.getLong(bb, BUFFER_ADDRESS) + offset,
 341                                      bb, offset, species,
 342                                      (c, idx, s) -> {
 343                                          ByteBuffer bbc = c.duplicate().position(idx).order(ByteOrder.nativeOrder());
 344                                          LongBuffer tb = bbc.asLongBuffer();
 345                                          return ((LongSpecies)s).op(i -> tb.get());
 346                                      });
 347     }
 348 
 349     /**
 350      * Loads a vector from a {@link ByteBuffer byte buffer} starting at an
 351      * offset into the byte buffer and using a mask.
 352      * <p>
 353      * This method behaves as if the byte buffer is viewed as a primitive
 354      * {@link java.nio.Buffer buffer} for the primitive element type,
 355      * according to the native byte order of the underlying platform, and
 356      * the returned vector is loaded with a mask from a primitive array
 357      * obtained from the primitive buffer.
 358      * The following pseudocode expresses the behaviour, where
 359      * {@code EBuffer} is the primitive buffer type, {@code e} is the


 383      * {@code offset >= b.limit() - (N * species.elementSize() / Byte.SIZE)}
 384      */
 385     @ForceInline
 386     public static LongVector fromByteBuffer(VectorSpecies<Long> species, ByteBuffer bb, int offset, VectorMask<Long> m) {
 387         return zero(species).blend(fromByteBuffer(species, bb, offset), m);
 388     }
 389 
 390     /**
 391      * Returns a vector where all lane elements are set to the primitive
 392      * value {@code e}.
 393      *
 394      * @param species species of the desired vector
 395      * @param e the value
 396      * @return a vector of vector where all lane elements are set to
 397      * the primitive value {@code e}
 398      */
 399     @ForceInline
 400     @SuppressWarnings("unchecked")
 401     public static LongVector broadcast(VectorSpecies<Long> species, long e) {
 402         return VectorIntrinsics.broadcastCoerced(
 403             (Class<LongVector>) species.vectorType(), long.class, species.length(),
 404             e, species,
 405             ((bits, sp) -> ((LongSpecies)sp).op(i -> (long)bits)));
 406     }
 407 
 408     /**
 409      * Returns a vector where each lane element is set to given
 410      * primitive values.
 411      * <p>
 412      * For each vector lane, where {@code N} is the vector lane index, the
 413      * the primitive value at index {@code N} is placed into the resulting
 414      * vector at lane index {@code N}.
 415      *
 416      * @param species species of the desired vector
 417      * @param es the given primitive values
 418      * @return a vector where each lane element is set to given primitive
 419      * values
 420      * @throws IndexOutOfBoundsException if {@code es.length < species.length()}
 421      */
 422     @ForceInline
 423     @SuppressWarnings("unchecked")
 424     public static LongVector scalars(VectorSpecies<Long> species, long... es) {
 425         Objects.requireNonNull(es);
 426         int ix = VectorIntrinsics.checkIndex(0, es.length, species.length());
 427         return VectorIntrinsics.load((Class<LongVector>) species.vectorType(), long.class, species.length(),
 428                                      es, Unsafe.ARRAY_LONG_BASE_OFFSET,
 429                                      es, ix, species,
 430                                      (c, idx, sp) -> ((LongSpecies)sp).op(n -> c[idx + n]));
 431     }
 432 
 433     /**
 434      * Returns a vector where the first lane element is set to the primtive
 435      * value {@code e}, all other lane elements are set to the default
 436      * value.
 437      *
 438      * @param species species of the desired vector
 439      * @param e the value
 440      * @return a vector where the first lane element is set to the primitive
 441      * value {@code e}
 442      */
 443     @ForceInline
 444     public static final LongVector single(VectorSpecies<Long> species, long e) {
 445         return zero(species).with(0, e);
 446     }
 447 


 785     @Override
 786     public abstract LongVector rearrange(Vector<Long> v,
 787                                                       VectorShuffle<Long> s, VectorMask<Long> m);
 788 
 789     /**
 790      * {@inheritDoc}
 791      */
 792     @Override
 793     public abstract LongVector rearrange(VectorShuffle<Long> m);
 794 
 795     /**
 796      * {@inheritDoc}
 797      */
 798     @Override
 799     public abstract LongVector reshape(VectorSpecies<Long> s);
 800 
 801     /**
 802      * {@inheritDoc}
 803      */
 804     @Override
 805     public abstract LongVector rotateLanesLeft(int i);
 806 
 807     /**
 808      * {@inheritDoc}
 809      */
 810     @Override
 811     public abstract LongVector rotateLanesRight(int i);
 812 
 813     /**
 814      * {@inheritDoc}
 815      */
 816     @Override
 817     public abstract LongVector shiftLanesLeft(int i);
 818 
 819     /**
 820      * {@inheritDoc}
 821      */
 822     @Override
 823     public abstract LongVector shiftLanesRight(int i);
 824 
 825 
 826 
 827     /**
 828      * Bitwise ANDs this vector with an input vector.
 829      * <p>
 830      * This is a lane-wise binary operation which applies the primitive bitwise AND
 831      * operation ({@code &}) to each lane.
 832      *
 833      * @param v the input vector
 834      * @return the bitwise AND of this vector with the input vector
 835      */
 836     public abstract LongVector and(Vector<Long> v);
 837 
 838     /**
 839      * Bitwise ANDs this vector with the broadcast of an input scalar.
 840      * <p>
 841      * This is a lane-wise binary operation which applies the primitive bitwise AND
 842      * operation ({@code &}) to each lane.
 843      *


 982      *
 983      * @return the bitwise NOT of this vector
 984      */
 985     public abstract LongVector not();
 986 
 987     /**
 988      * Bitwise NOTs this vector, selecting lane elements controlled by a mask.
 989      * <p>
 990      * This is a lane-wise unary operation which applies the primitive bitwise NOT
 991      * operation ({@code ~}) to each lane.
 992      *
 993      * @param m the mask controlling lane selection
 994      * @return the bitwise NOT of this vector
 995      */
 996     public abstract LongVector not(VectorMask<Long> m);
 997 
 998     /**
 999      * Logically left shifts this vector by the broadcast of an input scalar.
1000      * <p>
1001      * This is a lane-wise binary operation which applies the primitive logical left shift
1002      * operation ({@code <<}) to each lane to left shift the
1003      * element by shift value as specified by the input scalar.
1004      *
1005      * @param s the input scalar; the number of the bits to left shift
1006      * @return the result of logically left shifting left this vector by the
1007      * broadcast of an input scalar
1008      */
1009     public abstract LongVector shiftLeft(int s);
1010 
1011     /**
1012      * Logically left shifts this vector by the broadcast of an input scalar,
1013      * selecting lane elements controlled by a mask.
1014      * <p>
1015      * This is a lane-wise binary operation which applies the primitive logical left shift
1016      * operation ({@code <<}) to each lane to left shift the
1017      * element by shift value as specified by the input scalar.
1018      *
1019      * @param s the input scalar; the number of the bits to left shift
1020      * @param m the mask controlling lane selection
1021      * @return the result of logically left shifting left this vector by the
1022      * broadcast of an input scalar
1023      */
1024     public abstract LongVector shiftLeft(int s, VectorMask<Long> m);
1025 
1026     /**
1027      * Logically left shifts this vector by an input vector.
1028      * <p>
1029      * This is a lane-wise binary operation which applies the primitive logical left shift
1030      * operation ({@code <<}) to each lane. For each lane of this vector, the
1031      * shift value is the corresponding lane of input vector.
1032      *
1033      * @param v the input vector
1034      * @return the result of logically left shifting this vector by the input
1035      * vector
1036      */
1037     public abstract LongVector shiftLeft(Vector<Long> v);
1038 
1039     /**
1040      * Logically left shifts this vector by an input vector, selecting lane
1041      * elements controlled by a mask.
1042      * <p>
1043      * This is a lane-wise binary operation which applies the primitive logical left shift
1044      * operation ({@code <<}) to each lane. For each lane of this vector, the
1045      * shift value is the corresponding lane of input vector.
1046      *
1047      * @param v the input vector
1048      * @param m the mask controlling lane selection
1049      * @return the result of logically left shifting this vector by the input
1050      * vector
1051      */
1052     public LongVector shiftLeft(Vector<Long> v, VectorMask<Long> m) {
1053         return blend(shiftLeft(v), m);
1054     }
1055 
1056     // logical, or unsigned, shift right
1057 
1058      /**
1059      * Logically right shifts (or unsigned right shifts) this vector by the
1060      * broadcast of an input scalar.
1061      * <p>
1062      * This is a lane-wise binary operation which applies the primitive logical right shift
1063      * operation ({@code >>>}) to each lane to logically right shift the
1064      * element by shift value as specified by the input scalar.
1065      *
1066      * @param s the input scalar; the number of the bits to right shift
1067      * @return the result of logically right shifting this vector by the
1068      * broadcast of an input scalar
1069      */
1070     public abstract LongVector shiftRight(int s);
1071 
1072      /**
1073      * Logically right shifts (or unsigned right shifts) this vector by the
1074      * broadcast of an input scalar, selecting lane elements controlled by a
1075      * mask.
1076      * <p>
1077      * This is a lane-wise binary operation which applies the primitive logical right shift
1078      * operation ({@code >>}) to each lane to logically right shift the
1079      * element by shift value as specified by the input scalar.
1080      *
1081      * @param s the input scalar; the number of the bits to right shift
1082      * @param m the mask controlling lane selection
1083      * @return the result of logically right shifting this vector by the
1084      * broadcast of an input scalar
1085      */
1086     public abstract LongVector shiftRight(int s, VectorMask<Long> m);
1087 
1088     /**
1089      * Logically right shifts (or unsigned right shifts) this vector by an
1090      * input vector.
1091      * <p>
1092      * This is a lane-wise binary operation which applies the primitive logical right shift
1093      * operation ({@code >>>}) to each lane. For each lane of this vector, the
1094      * shift value is the corresponding lane of input vector.
1095      *
1096      * @param v the input vector
1097      * @return the result of logically right shifting this vector by the
1098      * input vector
1099      */
1100     public abstract LongVector shiftRight(Vector<Long> v);
1101 
1102     /**
1103      * Logically right shifts (or unsigned right shifts) this vector by an
1104      * input vector, selecting lane elements controlled by a mask.
1105      * <p>
1106      * This is a lane-wise binary operation which applies the primitive logical right shift
1107      * operation ({@code >>>}) to each lane. For each lane of this vector, the
1108      * shift value is the corresponding lane of input vector.
1109      *
1110      * @param v the input vector
1111      * @param m the mask controlling lane selection
1112      * @return the result of logically right shifting this vector by the
1113      * input vector
1114      */
1115     public LongVector shiftRight(Vector<Long> v, VectorMask<Long> m) {
1116         return blend(shiftRight(v), m);
1117     }
1118 
1119     /**
1120      * Arithmetically right shifts (or signed right shifts) this vector by the
1121      * broadcast of an input scalar.
1122      * <p>
1123      * This is a lane-wise binary operation which applies the primitive arithmetic right
1124      * shift operation ({@code >>}) to each lane to arithmetically
1125      * right shift the element by shift value as specified by the input scalar.
1126      *
1127      * @param s the input scalar; the number of the bits to right shift
1128      * @return the result of arithmetically right shifting this vector by the
1129      * broadcast of an input scalar
1130      */
1131     public abstract LongVector shiftArithmeticRight(int s);
1132 
1133     /**
1134      * Arithmetically right shifts (or signed right shifts) this vector by the
1135      * broadcast of an input scalar, selecting lane elements controlled by a
1136      * mask.
1137      * <p>
1138      * This is a lane-wise binary operation which applies the primitive arithmetic right
1139      * shift operation ({@code >>}) to each lane to arithmetically
1140      * right shift the element by shift value as specified by the input scalar.
1141      *
1142      * @param s the input scalar; the number of the bits to right shift
1143      * @param m the mask controlling lane selection
1144      * @return the result of arithmetically right shifting this vector by the
1145      * broadcast of an input scalar
1146      */
1147     public abstract LongVector shiftArithmeticRight(int s, VectorMask<Long> m);
1148 
1149     /**
1150      * Arithmetically right shifts (or signed right shifts) this vector by an
1151      * input vector.
1152      * <p>
1153      * This is a lane-wise binary operation which applies the primitive arithmetic right
1154      * shift operation ({@code >>}) to each lane. For each lane of this vector, the
1155      * shift value is the corresponding lane of input vector.
1156      *
1157      * @param v the input vector
1158      * @return the result of arithmetically right shifting this vector by the
1159      * input vector
1160      */
1161     public abstract LongVector shiftArithmeticRight(Vector<Long> v);
1162 
1163     /**
1164      * Arithmetically right shifts (or signed right shifts) this vector by an
1165      * input vector, selecting lane elements controlled by a mask.
1166      * <p>
1167      * This is a lane-wise binary operation which applies the primitive arithmetic right
1168      * shift operation ({@code >>}) to each lane. For each lane of this vector, the
1169      * shift value is the corresponding lane of input vector.
1170      *
1171      * @param v the input vector
1172      * @param m the mask controlling lane selection
1173      * @return the result of arithmetically right shifting this vector by the
1174      * input vector
1175      */
1176     public LongVector shiftArithmeticRight(Vector<Long> v, VectorMask<Long> m) {
1177         return blend(shiftArithmeticRight(v), m);
1178     }
1179 
1180     /**
1181      * Rotates left this vector by the broadcast of an input scalar.
1182      * <p>
1183      * This is a lane-wise binary operation which applies the operation
1184      * {@link Long#rotateLeft} to each lane and where
1185      * lane elements of this vector apply to the first argument, and lane
1186      * elements of the broadcast vector apply to the second argument (the
1187      * rotation distance).
1188      *
1189      * @param s the input scalar; the number of the bits to rotate left
1190      * @return the result of rotating left this vector by the broadcast of an
1191      * input scalar
1192      */
1193     @ForceInline
1194     public final LongVector rotateLeft(int s) {
1195         return shiftLeft(s).or(shiftRight(-s));
1196     }
1197 
1198     /**
1199      * Rotates left this vector by the broadcast of an input scalar, selecting
1200      * lane elements controlled by a mask.
1201      * <p>
1202      * This is a lane-wise binary operation which applies the operation
1203      * {@link Long#rotateLeft} to each lane and where
1204      * lane elements of this vector apply to the first argument, and lane
1205      * elements of the broadcast vector apply to the second argument (the
1206      * rotation distance).
1207      *
1208      * @param s the input scalar; the number of the bits to rotate left
1209      * @param m the mask controlling lane selection
1210      * @return the result of rotating left this vector by the broadcast of an
1211      * input scalar
1212      */
1213     @ForceInline
1214     public final LongVector rotateLeft(int s, VectorMask<Long> m) {
1215         return shiftLeft(s, m).or(shiftRight(-s, m), m);
1216     }
1217 
1218     /**
1219      * Rotates right this vector by the broadcast of an input scalar.
1220      * <p>
1221      * This is a lane-wise binary operation which applies the operation
1222      * {@link Long#rotateRight} to each lane and where
1223      * lane elements of this vector apply to the first argument, and lane
1224      * elements of the broadcast vector apply to the second argument (the
1225      * rotation distance).
1226      *
1227      * @param s the input scalar; the number of the bits to rotate right
1228      * @return the result of rotating right this vector by the broadcast of an
1229      * input scalar
1230      */
1231     @ForceInline
1232     public final LongVector rotateRight(int s) {
1233         return shiftRight(s).or(shiftLeft(-s));
1234     }
1235 
1236     /**
1237      * Rotates right this vector by the broadcast of an input scalar, selecting
1238      * lane elements controlled by a mask.
1239      * <p>
1240      * This is a lane-wise binary operation which applies the operation
1241      * {@link Long#rotateRight} to each lane and where
1242      * lane elements of this vector apply to the first argument, and lane
1243      * elements of the broadcast vector apply to the second argument (the
1244      * rotation distance).
1245      *
1246      * @param s the input scalar; the number of the bits to rotate right
1247      * @param m the mask controlling lane selection
1248      * @return the result of rotating right this vector by the broadcast of an
1249      * input scalar
1250      */
1251     @ForceInline
1252     public final LongVector rotateRight(int s, VectorMask<Long> m) {
1253         return shiftRight(s, m).or(shiftLeft(-s, m), m);
1254     }
1255 
1256     /**
1257      * {@inheritDoc}
1258      */
1259     @Override
1260     public abstract void intoByteArray(byte[] a, int ix);
1261 
1262     /**
1263      * {@inheritDoc}
1264      */
1265     @Override
1266     public abstract void intoByteArray(byte[] a, int ix, VectorMask<Long> m);
1267 
1268     /**
1269      * {@inheritDoc}
1270      */
1271     @Override
1272     public abstract void intoByteBuffer(ByteBuffer bb, int ix);
1273 


1575      * or for any vector lane index {@code N} where the mask at lane
1576      * {@code N} is set the result of {@code a_offset + indexMap[i_offset + N]} is
1577      * {@code < 0} or {@code >= a.length}
1578      */
1579     public abstract void intoArray(long[] a, int a_offset, VectorMask<Long> m, int[] indexMap, int i_offset);
1580     // Species
1581 
1582     /**
1583      * {@inheritDoc}
1584      */
1585     @Override
1586     public abstract VectorSpecies<Long> species();
1587 
1588     /**
1589      * Class representing {@link LongVector}'s of the same {@link VectorShape VectorShape}.
1590      */
1591     static final class LongSpecies extends AbstractSpecies<Long> {
1592         final Function<long[], LongVector> vectorFactory;
1593 
1594         private LongSpecies(VectorShape shape,
1595                           Class<?> vectorType,
1596                           Class<?> maskType,
1597                           Function<long[], LongVector> vectorFactory,
1598                           Function<boolean[], VectorMask<Long>> maskFactory,
1599                           Function<IntUnaryOperator, VectorShuffle<Long>> shuffleFromArrayFactory,
1600                           fShuffleFromArray<Long> shuffleFromOpFactory) {
1601             super(shape, long.class, Long.SIZE, vectorType, maskType, maskFactory,
1602                   shuffleFromArrayFactory, shuffleFromOpFactory);
1603             this.vectorFactory = vectorFactory;
1604         }
1605 
1606         interface FOp {
1607             long apply(int i);
1608         }
1609 
1610         LongVector op(FOp f) {
1611             long[] res = new long[length()];
1612             for (int i = 0; i < length(); i++) {
1613                 res[i] = f.apply(i);
1614             }
1615             return vectorFactory.apply(res);
1616         }
1617 
1618         LongVector op(VectorMask<Long> o, FOp f) {
1619             long[] res = new long[length()];
1620             boolean[] mbits = ((AbstractMask<Long>)o).getBits();
1621             for (int i = 0; i < length(); i++) {


< prev index next >