178 @ForceInline
179 public static ByteVector fromByteArray(ByteSpecies species, byte[] a, int ix, Mask<Byte> m) {
180 return zero(species).blend(fromByteArray(species, a, ix), m);
181 }
182
183 /**
184 * Loads a vector from an array starting at offset.
185 * <p>
186 * For each vector lane, where {@code N} is the vector lane index, the
187 * array element at index {@code i + N} is placed into the
188 * resulting vector at lane index {@code N}.
189 *
190 * @param species species of desired vector
191 * @param a the array
192 * @param i the offset into the array
193 * @return the vector loaded from an array
194 * @throws IndexOutOfBoundsException if {@code i < 0}, or
195 * {@code i > a.length - this.length()}
196 */
197 @ForceInline
198 @SuppressWarnings("unchecked")
199 public static ByteVector fromArray(ByteSpecies species, byte[] a, int i){
200 Objects.requireNonNull(a);
201 i = VectorIntrinsics.checkIndex(i, a.length, species.length());
202 return VectorIntrinsics.load((Class<ByteVector>) species.boxType(), byte.class, species.length(),
203 a, (((long) i) << ARRAY_SHIFT) + Unsafe.ARRAY_BYTE_BASE_OFFSET,
204 a, i, species,
205 (c, idx, s) -> ((ByteSpecies)s).op(n -> c[idx + n]));
206 }
207
208
209 /**
210 * Loads a vector from an array starting at offset and using a mask.
211 * <p>
212 * For each vector lane, where {@code N} is the vector lane index,
213 * if the mask lane at index {@code N} is set then the array element at
214 * index {@code i + N} is placed into the resulting vector at lane index
215 * {@code N}, otherwise the default element value is placed into the
216 * resulting vector at lane index {@code N}.
217 *
218 * @param species species of desired vector
219 * @param a the array
220 * @param i the offset into the array
221 * @param m the mask
222 * @return the vector loaded from an array
223 * @throws IndexOutOfBoundsException if {@code i < 0}, or
224 * for any vector lane index {@code N} where the mask at lane {@code N}
225 * is set {@code i > a.length - N}
226 */
227 @ForceInline
228 public static ByteVector fromArray(ByteSpecies species, byte[] a, int i, Mask<Byte> m) {
229 return zero(species).blend(fromArray(species, a, i), m);
230 }
231
232 /**
233 * Loads a vector from an array using indexes obtained from an index
234 * map.
235 * <p>
236 * For each vector lane, where {@code N} is the vector lane index, the
237 * array element at index {@code i + indexMap[j + N]} is placed into the
238 * resulting vector at lane index {@code N}.
239 *
240 * @param species species of desired vector
241 * @param a the array
242 * @param i the offset into the array, may be negative if relative
243 * indexes in the index map compensate to produce a value within the
244 * array bounds
245 * @param indexMap the index map
246 * @param j the offset into the index map
247 * @return the vector loaded from an array
248 * @throws IndexOutOfBoundsException if {@code j < 0}, or
249 * {@code j > indexMap.length - this.length()},
250 * or for any vector lane index {@code N} the result of
251 * {@code i + indexMap[j + N]} is {@code < 0} or {@code >= a.length}
252 */
253 public static ByteVector fromArray(ByteSpecies species, byte[] a, int i, int[] indexMap, int j) {
254 return species.op(n -> a[i + indexMap[j + n]]);
255 }
256 /**
257 * Loads a vector from an array using indexes obtained from an index
258 * map and using a mask.
259 * <p>
260 * For each vector lane, where {@code N} is the vector lane index,
261 * if the mask lane at index {@code N} is set then the array element at
262 * index {@code i + indexMap[j + N]} is placed into the resulting vector
263 * at lane index {@code N}.
264 *
265 * @param species species of desired vector
266 * @param a the array
267 * @param i the offset into the array, may be negative if relative
268 * indexes in the index map compensate to produce a value within the
269 * array bounds
270 * @param m the mask
271 * @param indexMap the index map
272 * @param j the offset into the index map
273 * @return the vector loaded from an array
274 * @throws IndexOutOfBoundsException if {@code j < 0}, or
275 * {@code j > indexMap.length - this.length()},
|
178 @ForceInline
179 public static ByteVector fromByteArray(ByteSpecies species, byte[] a, int ix, Mask<Byte> m) {
180 return zero(species).blend(fromByteArray(species, a, ix), m);
181 }
182
183 /**
184 * Loads a vector from an array starting at offset.
185 * <p>
186 * For each vector lane, where {@code N} is the vector lane index, the
187 * array element at index {@code i + N} is placed into the
188 * resulting vector at lane index {@code N}.
189 *
190 * @param species species of desired vector
191 * @param a the array
192 * @param i the offset into the array
193 * @return the vector loaded from an array
194 * @throws IndexOutOfBoundsException if {@code i < 0}, or
195 * {@code i > a.length - this.length()}
196 */
197 @ForceInline
198 public static ByteVector fromArray(ByteSpecies species, byte[] a, int i) {
199 Objects.requireNonNull(a);
200 i = VectorIntrinsics.checkIndex(i, a.length, species.length());
201 return fromArrayWithoutCheck(species, a, i);
202 }
203
204 @ForceInline
205 @SuppressWarnings("unchecked")
206 static ByteVector fromArrayWithoutCheck(ByteSpecies species, byte[] a, int i) {
207 return VectorIntrinsics.load((Class<ByteVector>) species.boxType(), byte.class, species.length(),
208 a, (((long) i) << ARRAY_SHIFT) + Unsafe.ARRAY_BYTE_BASE_OFFSET,
209 a, i, species,
210 (c, idx, s) -> ((ByteSpecies)s).op(n -> c[idx + n]));
211 }
212
213 /**
214 * Loads a vector from an array starting at offset and using a mask.
215 * <p>
216 * For each vector lane, where {@code N} is the vector lane index,
217 * if the mask lane at index {@code N} is set then the array element at
218 * index {@code i + N} is placed into the resulting vector at lane index
219 * {@code N}, otherwise the default element value is placed into the
220 * resulting vector at lane index {@code N}.
221 *
222 * @param species species of desired vector
223 * @param a the array
224 * @param i the offset into the array
225 * @param m the mask
226 * @return the vector loaded from an array
227 * @throws IndexOutOfBoundsException if {@code i < 0}, or
228 * for any vector lane index {@code N} where the mask at lane {@code N}
229 * is set {@code i > a.length - N}
230 */
231 @ForceInline
232 public static ByteVector fromArray(ByteSpecies species, byte[] a, int i, Mask<Byte> m) {
233 Objects.requireNonNull(a);
234 if (i + species.length() <= a.length) {
235 return zero(species).blend(fromArrayWithoutCheck(species, a, i), m);
236 } else {
237 return species.op(m, n -> a[i + n]);
238 }
239 }
240
241 /**
242 * Loads a vector from an array using indexes obtained from an index
243 * map.
244 * <p>
245 * For each vector lane, where {@code N} is the vector lane index, the
246 * array element at index {@code i + indexMap[j + N]} is placed into the
247 * resulting vector at lane index {@code N}.
248 *
249 * @param species species of desired vector
250 * @param a the array
251 * @param i the offset into the array, may be negative if relative
252 * indexes in the index map compensate to produce a value within the
253 * array bounds
254 * @param indexMap the index map
255 * @param j the offset into the index map
256 * @return the vector loaded from an array
257 * @throws IndexOutOfBoundsException if {@code j < 0}, or
258 * {@code j > indexMap.length - this.length()},
259 * or for any vector lane index {@code N} the result of
260 * {@code i + indexMap[j + N]} is {@code < 0} or {@code >= a.length}
261 */
262 public static ByteVector fromArray(ByteSpecies species, byte[] a, int i, int[] indexMap, int j) {
263 return species.op(n -> a[i + indexMap[j + n]]);
264 }
265
266 /**
267 * Loads a vector from an array using indexes obtained from an index
268 * map and using a mask.
269 * <p>
270 * For each vector lane, where {@code N} is the vector lane index,
271 * if the mask lane at index {@code N} is set then the array element at
272 * index {@code i + indexMap[j + N]} is placed into the resulting vector
273 * at lane index {@code N}.
274 *
275 * @param species species of desired vector
276 * @param a the array
277 * @param i the offset into the array, may be negative if relative
278 * indexes in the index map compensate to produce a value within the
279 * array bounds
280 * @param m the mask
281 * @param indexMap the index map
282 * @param j the offset into the index map
283 * @return the vector loaded from an array
284 * @throws IndexOutOfBoundsException if {@code j < 0}, or
285 * {@code j > indexMap.length - this.length()},
|