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