< prev index next >

src/jdk.incubator.vector/share/classes/jdk/incubator/vector/X-Vector.java.template

Print this page




 108      * Returns a vector where all lane elements are set to the default
 109      * primitive value.
 110      *
 111      * @param species species of desired vector
 112      * @return a zero vector of given species
 113      */
 114     @ForceInline
 115     @SuppressWarnings("unchecked")
 116     public static $abstractvectortype$ zero(VectorSpecies<$Boxtype$> species) {
 117 #if[FP]
 118         return VectorIntrinsics.broadcastCoerced((Class<$Type$Vector>) species.vectorType(), $type$.class, species.length(),
 119                                                  $Type$.$type$To$Bitstype$Bits(0.0f), species,
 120                                                  ((bits, s) -> (($Type$Species)s).op(i -> $Type$.$bitstype$BitsTo$Type$(($bitstype$)bits))));
 121 #else[FP]
 122         return VectorIntrinsics.broadcastCoerced((Class<$Type$Vector>) species.vectorType(), $type$.class, species.length(),
 123                                                  0, species,
 124                                                  ((bits, s) -> (($Type$Species)s).op(i -> ($type$)bits)));
 125 #end[FP]
 126     }
 127 




















 128     /**
 129      * Loads a vector from a byte array starting at an offset.
 130      * <p>
 131      * Bytes are composed into primitive lane elements according to the
 132      * native byte order of the underlying platform
 133      * <p>
 134      * This method behaves as if it returns the result of calling the
 135      * byte buffer, offset, and mask accepting
 136      * {@link #fromByteBuffer(VectorSpecies, ByteBuffer, int, VectorMask) method} as follows:
 137      * <pre>{@code
 138      * return fromByteBuffer(species, ByteBuffer.wrap(a), offset, VectorMask.allTrue());
 139      * }</pre>
 140      *
 141      * @param species species of desired vector
 142      * @param a the byte array
 143      * @param offset the offset into the array
 144      * @return a vector loaded from a byte array
 145      * @throws IndexOutOfBoundsException if {@code i < 0} or
 146      * {@code offset > a.length - (species.length() * species.elementSize() / Byte.SIZE)}
 147      */




 108      * Returns a vector where all lane elements are set to the default
 109      * primitive value.
 110      *
 111      * @param species species of desired vector
 112      * @return a zero vector of given species
 113      */
 114     @ForceInline
 115     @SuppressWarnings("unchecked")
 116     public static $abstractvectortype$ zero(VectorSpecies<$Boxtype$> species) {
 117 #if[FP]
 118         return VectorIntrinsics.broadcastCoerced((Class<$Type$Vector>) species.vectorType(), $type$.class, species.length(),
 119                                                  $Type$.$type$To$Bitstype$Bits(0.0f), species,
 120                                                  ((bits, s) -> (($Type$Species)s).op(i -> $Type$.$bitstype$BitsTo$Type$(($bitstype$)bits))));
 121 #else[FP]
 122         return VectorIntrinsics.broadcastCoerced((Class<$Type$Vector>) species.vectorType(), $type$.class, species.length(),
 123                                                  0, species,
 124                                                  ((bits, s) -> (($Type$Species)s).op(i -> ($type$)bits)));
 125 #end[FP]
 126     }
 127 
 128     @ForceInline
 129     @SuppressWarnings("unchecked")
 130     static VectorShuffle<$Boxtype$> shuffleIotaHelper(VectorSpecies<$Boxtype$> species, int step) {
 131         switch (species.bitSize()) {
 132             case 64: return VectorIntrinsics.shuffleIota($type$.class, $Type$64Vector.$Type$64Shuffle.class, species,
 133                                                         64 / $Boxtype$.SIZE, step,
 134                                                         (val, l) -> new $Type$64Vector.$Type$64Shuffle(i -> ((i + val) & (l-1))));
 135             case 128: return VectorIntrinsics.shuffleIota($type$.class, $Type$128Vector.$Type$128Shuffle.class, species,
 136                                                         128/ $Boxtype$.SIZE, step,
 137                                                         (val, l) -> new $Type$128Vector.$Type$128Shuffle(i -> ((i + val) & (l-1))));
 138             case 256: return VectorIntrinsics.shuffleIota($type$.class, $Type$256Vector.$Type$256Shuffle.class, species,
 139                                                         256/ $Boxtype$.SIZE, step,
 140                                                         (val, l) -> new $Type$256Vector.$Type$256Shuffle(i -> ((i + val) & (l-1))));
 141             case 512: return VectorIntrinsics.shuffleIota($type$.class, $Type$512Vector.$Type$512Shuffle.class, species,
 142                                                         512 / $Boxtype$.SIZE, step,
 143                                                         (val, l) -> new $Type$512Vector.$Type$512Shuffle(i -> ((i + val) & (l-1))));
 144             default: throw new IllegalArgumentException(Integer.toString(species.bitSize()));
 145         }
 146     }
 147 
 148     /**
 149      * Loads a vector from a byte array starting at an offset.
 150      * <p>
 151      * Bytes are composed into primitive lane elements according to the
 152      * native byte order of the underlying platform
 153      * <p>
 154      * This method behaves as if it returns the result of calling the
 155      * byte buffer, offset, and mask accepting
 156      * {@link #fromByteBuffer(VectorSpecies, ByteBuffer, int, VectorMask) method} as follows:
 157      * <pre>{@code
 158      * return fromByteBuffer(species, ByteBuffer.wrap(a), offset, VectorMask.allTrue());
 159      * }</pre>
 160      *
 161      * @param species species of desired vector
 162      * @param a the byte array
 163      * @param offset the offset into the array
 164      * @return a vector loaded from a byte array
 165      * @throws IndexOutOfBoundsException if {@code i < 0} or
 166      * {@code offset > a.length - (species.length() * species.elementSize() / Byte.SIZE)}
 167      */


< prev index next >