100 101 abstract void forEach(VectorMask<Short> 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 ShortVector zero(VectorSpecies<Short> species) { 115 return VectorIntrinsics.broadcastCoerced((Class<ShortVector>) species.vectorType(), short.class, species.length(), 116 0, species, 117 ((bits, s) -> ((ShortSpecies)s).op(i -> (short)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 */ | 100 101 abstract void forEach(VectorMask<Short> 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 ShortVector zero(VectorSpecies<Short> species) { 115 return VectorIntrinsics.broadcastCoerced((Class<ShortVector>) species.vectorType(), short.class, species.length(), 116 0, species, 117 ((bits, s) -> ((ShortSpecies)s).op(i -> (short)bits))); 118 } 119 120 @ForceInline 121 @SuppressWarnings("unchecked") 122 static VectorShuffle<Short> shuffleIotaHelper(VectorSpecies<Short> species, int step) { 123 switch (species.bitSize()) { 124 case 64: return VectorIntrinsics.shuffleIota(short.class, Short64Vector.Short64Shuffle.class, species, 125 64 / Short.SIZE, step, 126 (val, l) -> new Short64Vector.Short64Shuffle(i -> ((i + val) & (l-1)))); 127 case 128: return VectorIntrinsics.shuffleIota(short.class, Short128Vector.Short128Shuffle.class, species, 128 128/ Short.SIZE, step, 129 (val, l) -> new Short128Vector.Short128Shuffle(i -> ((i + val) & (l-1)))); 130 case 256: return VectorIntrinsics.shuffleIota(short.class, Short256Vector.Short256Shuffle.class, species, 131 256/ Short.SIZE, step, 132 (val, l) -> new Short256Vector.Short256Shuffle(i -> ((i + val) & (l-1)))); 133 case 512: return VectorIntrinsics.shuffleIota(short.class, Short512Vector.Short512Shuffle.class, species, 134 512 / Short.SIZE, step, 135 (val, l) -> new Short512Vector.Short512Shuffle(i -> ((i + val) & (l-1)))); 136 default: throw new IllegalArgumentException(Integer.toString(species.bitSize())); 137 } 138 } 139 140 /** 141 * Loads a vector from a byte array starting at an offset. 142 * <p> 143 * Bytes are composed into primitive lane elements according to the 144 * native byte order of the underlying platform 145 * <p> 146 * This method behaves as if it returns the result of calling the 147 * byte buffer, offset, and mask accepting 148 * {@link #fromByteBuffer(VectorSpecies, ByteBuffer, int, VectorMask) method} as follows: 149 * <pre>{@code 150 * return fromByteBuffer(species, ByteBuffer.wrap(a), offset, VectorMask.allTrue()); 151 * }</pre> 152 * 153 * @param species species of desired vector 154 * @param a the byte array 155 * @param offset the offset into the array 156 * @return a vector loaded from a byte array 157 * @throws IndexOutOfBoundsException if {@code i < 0} or 158 * {@code offset > a.length - (species.length() * species.elementSize() / Byte.SIZE)} 159 */ |