public abstract class IntVector extends Vector<Integer>
IntVector
relies on preview features of the Java platform: IntVector
refers to one or more preview APIs: MemorySegment
.Vector
representing an ordered immutable sequence of int
values.Modifier and Type | Field | Description |
---|---|---|
static final VectorSpecies |
SPECIES_128 |
Species representing IntVector s of VectorShape.S_128_BIT . |
static final VectorSpecies |
SPECIES_256 |
Species representing IntVector s of VectorShape.S_256_BIT . |
static final VectorSpecies |
SPECIES_512 |
Species representing IntVector s of VectorShape.S_512_BIT . |
static final VectorSpecies |
SPECIES_64 |
Species representing IntVector s of VectorShape.S_64_BIT . |
static final VectorSpecies |
SPECIES_MAX |
Species representing IntVector s of VectorShape.S_Max_BIT . |
static final VectorSpecies |
SPECIES_PREFERRED |
Preferred species for IntVector s. |
Modifier and Type | Method | Description |
---|---|---|
final IntVector |
abs() |
Returns the absolute value of this vector. |
final IntVector |
add |
Adds this vector to the broadcast of an input scalar. |
final IntVector |
add |
Adds this vector to the broadcast of an input scalar, selecting lane elements controlled by a mask. |
final IntVector |
add |
Adds this vector to a second input vector. |
final IntVector |
add |
Adds this vector to a second input vector, selecting lanes under the control of a mask. |
abstract IntVector |
addIndex |
Adds the lanes of this vector to their corresponding lane numbers, scaled by a given constant. |
final IntVector |
and |
Computes the bitwise logical conjunction ( & ) of this vector and a scalar. |
final IntVector |
and |
Computes the bitwise logical conjunction ( & ) of this vector and a second input vector. |
final IntVector |
bitwiseBlend |
Blends together the bits of a vector and a scalar under the control of another scalar, which supplies mask bits. |
final IntVector |
bitwiseBlend |
Blends together the bits of a vector and a scalar under the control of another vector, which supplies mask bits. |
final IntVector |
bitwiseBlend |
Blends together the bits of two vectors under the control of a scalar, which supplies mask bits. |
final IntVector |
bitwiseBlend |
Blends together the bits of two vectors under the control of a third, which supplies mask bits. |
final IntVector |
blend |
Replaces selected lanes of this vector with a scalar value under the control of a mask. |
final IntVector |
blend |
Replaces selected lanes of this vector with a scalar value under the control of a mask. |
abstract IntVector |
blend |
Replaces selected lanes of this vector with corresponding lanes from a second input vector under the control of a mask. |
abstract IntVector |
broadcast |
Returns a vector of the same species as this one where all lane elements are set to the primitive value e . |
abstract IntVector |
broadcast |
Returns a vector of the same species as this one where all lane elements are set to the primitive value e . |
static IntVector |
broadcast |
Returns a vector of the given species where all lane elements are set to the primitive value e . |
static IntVector |
broadcast |
Returns a vector of the given species where all lane elements are set to the primitive value e . |
final <F> Vector |
castShape |
Convenience method for converting a vector from one lane type to another, reshaping as needed when lane sizes change. |
final <F> Vector |
check |
Checks that this vector has the given element type, and returns this vector unchanged. |
final <F> Vector |
check |
Checks that this vector has the given species, and returns this vector unchanged. |
abstract VectorMask |
compare |
Tests this vector by comparing it with an input scalar, according to the given comparison operation. |
final VectorMask |
compare |
Tests this vector by comparing it with an input scalar, according to the given comparison operation, in lanes selected by a mask. |
abstract VectorMask |
compare |
Tests this vector by comparing it with an input scalar, according to the given comparison operation. |
final VectorMask |
compare |
Tests this vector by comparing it with an input scalar, according to the given comparison operation, in lanes selected by a mask. |
abstract VectorMask |
compare |
Tests this vector by comparing it with another input vector, according to the given comparison operation. |
abstract IntVector |
compress |
Compresses the lane elements of this vector selecting lanes under the control of a specific mask. |
final <F> Vector |
convert |
Convert this vector to a vector of the same shape and a new element type, converting lane values from the current ETYPE to a new lane type (called FTYPE here) according to the indicated conversion. |
abstract <F> Vector |
convertShape |
Converts this vector to a vector of the given species, shape and element type, converting lane values from the current ETYPE to a new lane type (called FTYPE here) according to the indicated conversion. |
final IntVector |
div |
Divides this vector by the broadcast of an input scalar. |
final IntVector |
div |
Divides this vector by the broadcast of an input scalar, selecting lane elements controlled by a mask. |
final IntVector |
div |
Divides this vector by a second input vector. |
final IntVector |
div |
Divides this vector by a second input vector under the control of a mask. |
final VectorMask |
eq |
Tests if this vector is equal to an input scalar. |
final VectorMask |
eq |
Tests if this vector is equal to another input vector. |
final boolean |
equals |
Indicates whether this vector is identical to some other object. |
abstract IntVector |
expand |
Expands the lane elements of this vector under the control of a specific mask. |
static IntVector |
fromArray |
Loads a vector from an array of type int[] starting at an offset. |
static IntVector |
fromArray |
Gathers a new vector composed of elements from an array of type int[] , using indexes obtained by adding a fixed offset to a series of secondary offsets from an index map. |
static IntVector |
fromArray |
Gathers a new vector composed of elements from an array of type int[] , under the control of a mask, and using indexes obtained by adding a fixed offset to a series of secondary offsets from an index map. |
static IntVector |
fromArray |
Loads a vector from an array of type int[] starting at an offset and using a mask. |
static IntVector |
fromMemorySegment |
Loads a vector from a memory segmentPREVIEW starting at an offset into the memory segment. |
static IntVector |
fromMemorySegment |
Loads a vector from a memory segmentPREVIEW starting at an offset into the memory segment and using a mask. |
protected final Object |
getPayload() |
|
final int |
hashCode() |
Returns a hash code value for the vector. |
final void |
intoArray |
Stores this vector into an array of type int[] starting at an offset. |
final void |
intoArray |
Scatters this vector into an array of type int[] using indexes obtained by adding a fixed offset to a series of secondary offsets from an index map. |
final void |
intoArray |
Scatters this vector into an array of type int[] , under the control of a mask, and using indexes obtained by adding a fixed offset to a series of secondary offsets from an index map. |
final void |
intoArray |
Stores this vector into an array of type int[] starting at offset and using a mask. |
final void |
intoMemorySegment |
Stores this vector into a memory segmentPREVIEW starting at an offset using explicit byte order. |
final void |
intoMemorySegment |
Stores this vector into a memory segmentPREVIEW starting at an offset using explicit byte order and a mask. |
abstract int |
lane |
Gets the lane element at lane index i
|
final IntVector |
lanewise |
Combines the lane values of this vector with the value of a broadcast scalar. |
final IntVector |
lanewise |
Combines the lane values of this vector with the value of a broadcast scalar, with selection of lane elements controlled by a mask. |
final IntVector |
lanewise |
Combines the lane values of this vector with the value of a broadcast scalar. |
final IntVector |
lanewise |
Combines the corresponding lane values of this vector with those of a second input vector, with selection of lane elements controlled by a mask. |
abstract IntVector |
lanewise |
Combines the corresponding lane values of this vector with those of a second input vector. |
abstract IntVector |
lanewise |
Combines the corresponding lane values of this vector with those of a second input vector, with selection of lane elements controlled by a mask. |
final IntVector |
lanewise |
Combines the lane values of this vector with the values of two broadcast scalars. |
final IntVector |
lanewise |
Combines the lane values of this vector with the values of two broadcast scalars, with selection of lane elements controlled by a mask. |
final IntVector |
lanewise |
Combines the lane values of this vector with the values of another vector and a broadcast scalar. |
final IntVector |
lanewise |
Combines the lane values of this vector with the values of another vector and a broadcast scalar, with selection of lane elements controlled by a mask. |
final IntVector |
lanewise |
Combines the lane values of this vector with the values of another vector and a broadcast scalar. |
final IntVector |
lanewise |
Combines the lane values of this vector with the values of another vector and a broadcast scalar, with selection of lane elements controlled by a mask. |
abstract IntVector |
lanewise |
Combines the corresponding lane values of this vector with the lanes of a second and a third input vector. |
abstract IntVector |
lanewise |
Combines the corresponding lane values of this vector with the lanes of a second and a third input vector, with selection of lane elements controlled by a mask. |
abstract IntVector |
lanewise |
Operates on the lane values of this vector. |
abstract IntVector |
lanewise |
Operates on the lane values of this vector, with selection of lane elements controlled by a mask. |
final VectorMask |
lt |
Tests if this vector is less than an input scalar. |
final VectorMask |
lt |
Tests if this vector is less than another input vector. |
final VectorMask |
maskAll |
Returns a mask of same species as this vector, where each lane is set or unset according to given single boolean, which is broadcast to all lanes. |
final IntVector |
max |
Computes the larger of this vector and the broadcast of an input scalar. |
final IntVector |
max |
Computes the larger of this vector and a second input vector. |
final IntVector |
min |
Computes the smaller of this vector and the broadcast of an input scalar. |
final IntVector |
min |
Computes the smaller of this vector and a second input vector. |
final IntVector |
mul |
Multiplies this vector by the broadcast of an input scalar. |
final IntVector |
mul |
Multiplies this vector by the broadcast of an input scalar, selecting lane elements controlled by a mask. |
final IntVector |
mul |
Multiplies this vector by a second input vector. |
final IntVector |
mul |
Multiplies this vector by a second input vector under the control of a mask. |
final IntVector |
neg() |
Negates this vector. |
final IntVector |
not() |
Computes the bitwise logical complement ( ~ ) of this vector. |
final IntVector |
or |
Computes the bitwise logical disjunction ( | ) of this vector and a scalar. |
final IntVector |
or |
Computes the bitwise logical disjunction ( | ) of this vector and a second input vector. |
abstract IntVector |
rearrange |
Rearranges the lane elements of this vector, selecting lanes under the control of a specific shuffle. |
abstract IntVector |
rearrange |
Rearranges the lane elements of two vectors, selecting lanes under the control of a specific shuffle, using both normal and exceptional indexes in the shuffle to steer data. |
abstract IntVector |
rearrange |
Rearranges the lane elements of this vector, selecting lanes under the control of a specific shuffle and a mask. |
abstract int |
reduceLanes |
Returns a value accumulated from all the lanes of this vector. |
abstract int |
reduceLanes |
Returns a value accumulated from selected lanes of this vector, controlled by a mask. |
final ByteVector |
reinterpretAsBytes() |
Views this vector as a vector of the same shape and contents but a lane type of byte , where the bytes are extracted from the lanes according to little-endian order. |
DoubleVector |
reinterpretAsDoubles() |
Reinterprets this vector as a vector of the same shape and contents but a lane type of double , where the lanes are assembled from successive bytes according to little-endian order. |
FloatVector |
reinterpretAsFloats() |
Reinterprets this vector as a vector of the same shape and contents but a lane type of float , where the lanes are assembled from successive bytes according to little-endian order. |
IntVector |
reinterpretAsInts() |
Reinterprets this vector as a vector of the same shape and contents but a lane type of int , where the lanes are assembled from successive bytes according to little-endian order. |
LongVector |
reinterpretAsLongs() |
Reinterprets this vector as a vector of the same shape and contents but a lane type of long , where the lanes are assembled from successive bytes according to little-endian order. |
ShortVector |
reinterpretAsShorts() |
Reinterprets this vector as a vector of the same shape and contents but a lane type of short , where the lanes are assembled from successive bytes according to little-endian order. |
abstract IntVector |
selectFrom |
Using index values stored in the lanes of this vector, assemble values stored in second vector v . |
abstract IntVector |
selectFrom |
Using index values stored in the lanes of this vector, assemble values stored in second vector, under the control of a mask. |
abstract IntVector |
slice |
Slices a segment of adjacent lanes, starting at a given origin lane in the current vector. |
abstract IntVector |
slice |
Slices a segment of adjacent lanes, starting at a given origin lane in the current vector, and continuing (as needed) into an immediately following vector. |
final IntVector |
slice |
Slices a segment of adjacent lanes under the control of a mask, starting at a given origin lane in the current vector, and continuing (as needed) into an immediately following vector. |
final VectorSpecies |
species() |
Returns the species of this vector. |
final IntVector |
sub |
Subtracts an input scalar from this vector. |
final IntVector |
sub |
Subtracts an input scalar from this vector under the control of a mask. |
final IntVector |
sub |
Subtracts a second input vector from this vector. |
final IntVector |
sub |
Subtracts a second input vector from this vector under the control of a mask. |
abstract VectorMask |
test |
Tests the lanes of this vector according to the given operation. |
abstract VectorMask |
test |
Test selected lanes of this vector, according to the given operation. |
final int[] |
toArray() |
Returns an array of type int[] containing all the lane values. |
final double[] |
toDoubleArray() |
Returns a double[] array containing all the lane values, converted to the type double . |
final int[] |
toIntArray() |
Returns an int[] array containing all the lane values, converted to the type int . |
final long[] |
toLongArray() |
Returns a long[] array containing all the lane values, converted to the type long . |
final String |
toString() |
Returns a string representation of this vector, of the form "[0,1,2...]" , reporting the lane values of this vector, in lane order. |
abstract IntVector |
unslice |
Reverses a slice(), inserting the current vector as a slice within a "background" input of zero lane values. |
abstract IntVector |
unslice |
Reverses a slice(), inserting the current vector as a slice within another "background" input vector, which is regarded as one or the other input to a hypothetical subsequent slice() operation. |
abstract IntVector |
unslice |
Reverses a slice(), inserting (under the control of a mask) the current vector as a slice within another "background" input vector, which is regarded as one or the other input to a hypothetical subsequent slice() operation. |
final FloatVector |
viewAsFloatingLanes() |
Views this vector as a vector of the same shape, length, and contents, but a lane type that is a floating-point type. |
final IntVector |
viewAsIntegralLanes() |
Views this vector as a vector of the same shape, length, and contents, but a lane type that is not a floating-point type. |
abstract IntVector |
withLane |
Replaces the lane element of this vector at lane index i with value e . |
static IntVector |
zero |
Returns a vector of the given species where all lane elements are set to zero, the default primitive value. |
bitSize, byteSize, compare, elementSize, elementType, length, reduceLanesToLong, reduceLanesToLong, reinterpretShape, shape, toShuffle
public static final VectorSpecies<Integer> SPECIES_64
IntVector
s of VectorShape.S_64_BIT
.public static final VectorSpecies<Integer> SPECIES_128
IntVector
s of VectorShape.S_128_BIT
.public static final VectorSpecies<Integer> SPECIES_256
IntVector
s of VectorShape.S_256_BIT
.public static final VectorSpecies<Integer> SPECIES_512
IntVector
s of VectorShape.S_512_BIT
.public static final VectorSpecies<Integer> SPECIES_MAX
IntVector
s of VectorShape.S_Max_BIT
.public static final VectorSpecies<Integer> SPECIES_PREFERRED
IntVector
s. A preferred species is a species of maximal bit-size for the platform.public static IntVector zero(VectorSpecies<Integer> species)
species
- species of the desired zero vectorpublic abstract IntVector broadcast(int e)
e
. The contents of the current vector are discarded; only the species is relevant to this operation. This method returns the value of this expression: IntVector.broadcast(this.species(), e)
.
broadcast()
in the supertype Vector
, this method does not need to validate its argument, and cannot throw IllegalArgumentException
. This method is therefore preferable to the supertype method.e
- the value to broadcaste
public static IntVector broadcast(VectorSpecies<Integer> species, int e)
e
.species
- species of the desired vectore
- the value to broadcaste
public abstract IntVector broadcast(long e)
e
. The contents of the current vector are discarded; only the species is relevant to this operation. This method returns the value of this expression: EVector.broadcast(this.species(), (ETYPE)e)
, where EVector
is the vector class specific to this vector's element type ETYPE
.
The long
value e
must be accurately representable by the ETYPE
of this vector's species, so that e==(long)(ETYPE)e
. If this rule is violated the problem is not detected statically, but an IllegalArgumentException
is thrown at run-time. Thus, this method somewhat weakens the static type checking of immediate constants and other scalars, but it makes up for this by improving the expressiveness of the generic API. Note that an e
value in the range [-128..127]
is always acceptable, since every ETYPE
will accept every byte
value.
broadcast
in class Vector<Integer>
IntVector
, the more strongly typed method is typically selected. It can be explicitly selected using a cast: v.broadcast((int)e)
. The two expressions will produce numerically identical results.e
- the value to broadcaste
public static IntVector broadcast(VectorSpecies<Integer> species, long e)
e
. The long
value must be accurately representable by the ETYPE
of the vector species, so that e==(long)(ETYPE)e
.species
- species of the desired vectore
- the value to broadcaste
IllegalArgumentException
- if the given long
value cannot be represented by the vector's ETYPE
public abstract IntVector lanewise(VectorOperators.Unary op)
public abstract IntVector lanewise(VectorOperators.Unary op, VectorMask<Integer> m)
public abstract IntVector lanewise(VectorOperators.Binary op, Vector<Integer> v)
public abstract IntVector lanewise(VectorOperators.Binary op, Vector<Integer> v, VectorMask<Integer> m)
public final IntVector lanewise(VectorOperators.Binary op, int e)
this.lanewise(op, this.broadcast(e))
.op
- the operation used to process lane valuese
- the input scalarUnsupportedOperationException
- if this vector does not support the requested operationpublic final IntVector lanewise(VectorOperators.Binary op, int e, VectorMask<Integer> m)
this.lanewise(op, this.broadcast(e), m)
.op
- the operation used to process lane valuese
- the input scalarm
- the mask controlling lane selectionUnsupportedOperationException
- if this vector does not support the requested operationpublic final IntVector lanewise(VectorOperators.Binary op, long e)
this.lanewise(op, this.broadcast(e))
. lanewise
in class Vector<Integer>
IntVector
, the more strongly typed method is typically selected. It can be explicitly selected using a cast: v.lanewise(op,(int)e)
. The two expressions will produce numerically identical results.op
- the operation used to combine lane valuese
- the input scalarpublic final IntVector lanewise(VectorOperators.Binary op, long e, VectorMask<Integer> m)
this.lanewise(op, this.broadcast(e), m)
. lanewise
in class Vector<Integer>
IntVector
, the more strongly typed method is typically selected. It can be explicitly selected using a cast: v.lanewise(op,(int)e,m)
. The two expressions will produce numerically identical results.op
- the operation used to combine lane valuese
- the input scalarm
- the mask controlling lane selectionpublic abstract IntVector lanewise(VectorOperators.Ternary op, Vector<Integer> v1, Vector<Integer> v2)
public abstract IntVector lanewise(VectorOperators.Ternary op, Vector<Integer> v1, Vector<Integer> v2, VectorMask<Integer> m)
public final IntVector lanewise(VectorOperators.Ternary op, int e1, int e2)
this.lanewise(op, this.broadcast(e1), this.broadcast(e2))
.op
- the operation used to combine lane valuese1
- the first input scalare2
- the second input scalarUnsupportedOperationException
- if this vector does not support the requested operationpublic final IntVector lanewise(VectorOperators.Ternary op, int e1, int e2, VectorMask<Integer> m)
this.lanewise(op, this.broadcast(e1), this.broadcast(e2), m)
.op
- the operation used to combine lane valuese1
- the first input scalare2
- the second input scalarm
- the mask controlling lane selectionUnsupportedOperationException
- if this vector does not support the requested operationpublic final IntVector lanewise(VectorOperators.Ternary op, Vector<Integer> v1, int e2)
this.lanewise(op, v1, this.broadcast(e2))
.op
- the operation used to combine lane valuesv1
- the other input vectore2
- the input scalarUnsupportedOperationException
- if this vector does not support the requested operationpublic final IntVector lanewise(VectorOperators.Ternary op, Vector<Integer> v1, int e2, VectorMask<Integer> m)
this.lanewise(op, v1, this.broadcast(e2), m)
.op
- the operation used to combine lane valuesv1
- the other input vectore2
- the input scalarm
- the mask controlling lane selectionUnsupportedOperationException
- if this vector does not support the requested operationpublic final IntVector lanewise(VectorOperators.Ternary op, int e1, Vector<Integer> v2)
this.lanewise(op, this.broadcast(e1), v2)
.op
- the operation used to combine lane valuese1
- the input scalarv2
- the other input vectorUnsupportedOperationException
- if this vector does not support the requested operationpublic final IntVector lanewise(VectorOperators.Ternary op, int e1, Vector<Integer> v2, VectorMask<Integer> m)
this.lanewise(op, this.broadcast(e1), v2, m)
.op
- the operation used to combine lane valuese1
- the input scalarv2
- the other input vectorm
- the mask controlling lane selectionUnsupportedOperationException
- if this vector does not support the requested operationpublic final IntVector add(Vector<Integer> v)
+
) to each pair of corresponding lane values. This method is also equivalent to the expression lanewise
(
ADD
, v)
. As a full-service named operation, this method comes in masked and unmasked overloadings, and (in subclasses) also comes in scalar-broadcast overloadings (both masked and unmasked).
public final IntVector add(int e)
+
) to each lane. This method is also equivalent to the expression lanewise
(
ADD
, e)
.e
- the input scalarpublic final IntVector add(Vector<Integer> v, VectorMask<Integer> m)
+
) to each pair of corresponding lane values. For any lane unset in the mask, the primitive operation is suppressed and this vector retains the original value stored in that lane. This method is also equivalent to the expression lanewise
(
ADD
, v, m)
. As a full-service named operation, this method comes in masked and unmasked overloadings, and (in subclasses) also comes in scalar-broadcast overloadings (both masked and unmasked).
public final IntVector add(int e, VectorMask<Integer> m)
+
) to each lane. This method is also equivalent to the expression lanewise
(
ADD
, s, m)
.e
- the input scalarm
- the mask controlling lane selectionpublic final IntVector sub(Vector<Integer> v)
-
) to each pair of corresponding lane values. This method is also equivalent to the expression lanewise
(
SUB
, v)
. As a full-service named operation, this method comes in masked and unmasked overloadings, and (in subclasses) also comes in scalar-broadcast overloadings (both masked and unmasked).
public final IntVector sub(int e)
-
) to each lane. This method is also equivalent to the expression lanewise
(
SUB
, e)
.e
- the input scalarpublic final IntVector sub(Vector<Integer> v, VectorMask<Integer> m)
-
) to each pair of corresponding lane values. For any lane unset in the mask, the primitive operation is suppressed and this vector retains the original value stored in that lane. This method is also equivalent to the expression lanewise
(
SUB
, v, m)
. As a full-service named operation, this method comes in masked and unmasked overloadings, and (in subclasses) also comes in scalar-broadcast overloadings (both masked and unmasked).
public final IntVector sub(int e, VectorMask<Integer> m)
-
) to each lane. This method is also equivalent to the expression lanewise
(
SUB
, s, m)
.e
- the input scalarm
- the mask controlling lane selectionpublic final IntVector mul(Vector<Integer> v)
*
) to each pair of corresponding lane values. This method is also equivalent to the expression lanewise
(
MUL
, v)
. As a full-service named operation, this method comes in masked and unmasked overloadings, and (in subclasses) also comes in scalar-broadcast overloadings (both masked and unmasked).
public final IntVector mul(int e)
*
) to each lane. This method is also equivalent to the expression lanewise
(
MUL
, e)
.e
- the input scalarpublic final IntVector mul(Vector<Integer> v, VectorMask<Integer> m)
*
) to each pair of corresponding lane values. For any lane unset in the mask, the primitive operation is suppressed and this vector retains the original value stored in that lane. This method is also equivalent to the expression lanewise
(
MUL
, v, m)
. As a full-service named operation, this method comes in masked and unmasked overloadings, and (in subclasses) also comes in scalar-broadcast overloadings (both masked and unmasked).
public final IntVector mul(int e, VectorMask<Integer> m)
*
) to each lane. This method is also equivalent to the expression lanewise
(
MUL
, s, m)
.e
- the input scalarm
- the mask controlling lane selectionpublic final IntVector div(Vector<Integer> v)
/
) to each pair of corresponding lane values. This method is also equivalent to the expression lanewise
(
DIV
, v)
. As a full-service named operation, this method comes in masked and unmasked overloadings, and (in subclasses) also comes in scalar-broadcast overloadings (both masked and unmasked).
public final IntVector div(int e)
/
) to each lane. This method is also equivalent to the expression lanewise
(
DIV
, e)
.
ArithmeticException
will be thrown.e
- the input scalarpublic final IntVector div(Vector<Integer> v, VectorMask<Integer> m)
/
) to each pair of corresponding lane values. For any lane unset in the mask, the primitive operation is suppressed and this vector retains the original value stored in that lane. This method is also equivalent to the expression lanewise
(
DIV
, v, m)
. As a full-service named operation, this method comes in masked and unmasked overloadings, and (in subclasses) also comes in scalar-broadcast overloadings (both masked and unmasked).
public final IntVector div(int e, VectorMask<Integer> m)
/
) to each lane. This method is also equivalent to the expression lanewise
(
DIV
, s, m)
.
ArithmeticException
will be thrown.e
- the input scalarm
- the mask controlling lane selectionpublic final IntVector min(Vector<Integer> v)
public final IntVector min(int e)
Math.min()
to each pair of corresponding lane values. This method is also equivalent to the expression lanewise
(
MIN
, e)
.e
- the input scalarpublic final IntVector max(Vector<Integer> v)
Math.max()
to each pair of corresponding lane values. This method is also equivalent to the expression lanewise
(
MAX
, v)
. This is not a full-service named operation like add()
. A masked version of this operation is not directly available but may be obtained via the masked version of lanewise
. Subclasses define an additional scalar-broadcast overloading of this method.
public final IntVector max(int e)
Math.max()
to each pair of corresponding lane values. This method is also equivalent to the expression lanewise
(
MAX
, e)
.e
- the input scalarpublic final IntVector and(Vector<Integer> v)
&
) of this vector and a second input vector. This is a lane-wise binary operation which applies the the primitive bitwise "and" operation (&
) to each pair of corresponding lane values. This method is also equivalent to the expression lanewise
(
AND
, v)
. This is not a full-service named operation like add
. A masked version of this operation is not directly available but may be obtained via the masked version of lanewise
.
v
- a second input vector&
of this vector and the second input vectorpublic final IntVector and(int e)
&
) of this vector and a scalar. This is a lane-wise binary operation which applies the the primitive bitwise "and" operation (&
) to each pair of corresponding lane values. This method is also equivalent to the expression lanewise
(
AND
, e)
.e
- an input scalar&
of this vector and scalarpublic final IntVector or(Vector<Integer> v)
|
) of this vector and a second input vector. This is a lane-wise binary operation which applies the the primitive bitwise "or" operation (|
) to each pair of corresponding lane values. This method is also equivalent to the expression lanewise
(
AND
, v)
. This is not a full-service named operation like add
. A masked version of this operation is not directly available but may be obtained via the masked version of lanewise
.
v
- a second input vector|
of this vector and the second input vectorpublic final IntVector or(int e)
|
) of this vector and a scalar. This is a lane-wise binary operation which applies the the primitive bitwise "or" operation (|
) to each pair of corresponding lane values. This method is also equivalent to the expression lanewise
(
OR
, e)
.e
- an input scalar|
of this vector and scalarpublic final IntVector neg()
public final IntVector abs()
public final IntVector not()
~
) of this vector. This is a lane-wise binary operation which applies the the primitive bitwise "not" operation (~
) to each lane value. This method is also equivalent to the expression lanewise
(
NOT
)
. This is not a full-service named operation like add
. A masked version of this operation is not directly available but may be obtained via the masked version of lanewise
.
~
of this vectorpublic final VectorMask<Integer> eq(Vector<Integer> v)
==
) to each pair of corresponding lane values. The result is the same as compare(VectorOperators.EQ, v)
. public final VectorMask<Integer> eq(int e)
==
) to each lane. The result is the same as compare(VectorOperators.Comparison.EQ, e)
.e
- the input scalare
public final VectorMask<Integer> lt(Vector<Integer> v)
<
) to each lane. The result is the same as compare(VectorOperators.LT, v)
. public final VectorMask<Integer> lt(int e)
<
) to each lane. The result is the same as compare(VectorOperators.LT, e)
.e
- the input scalarpublic abstract VectorMask<Integer> test(VectorOperators.Test op)
public abstract VectorMask<Integer> test(VectorOperators.Test op, VectorMask<Integer> m)
test(op).and(m)
. public abstract VectorMask<Integer> compare(VectorOperators.Comparison op, Vector<Integer> v)
public abstract VectorMask<Integer> compare(VectorOperators.Comparison op, int e)
The result is the same as compare(op, broadcast(species(), e))
. That is, the scalar may be regarded as broadcast to a vector of the same species, and then compared against the original vector, using the selected comparison operation.
op
- the operation used to compare lane valuese
- the input scalarpublic final VectorMask<Integer> compare(VectorOperators.Comparison op, int e, VectorMask<Integer> m)
compare(op,s).and(m)
.op
- the operation used to compare lane valuese
- the input scalarm
- the mask controlling lane selectionpublic abstract VectorMask<Integer> compare(VectorOperators.Comparison op, long e)
The result is the same as this.compare(op, this.broadcast(e))
. That is, the scalar may be regarded as broadcast to a vector of the same species, and then compared against the original vector, using the selected comparison operation.
public final VectorMask<Integer> compare(VectorOperators.Comparison op, long e, VectorMask<Integer> m)
compare(op,e).and(m)
. compare
in class Vector<Integer>
op
- the operation used to compare lane valuese
- the input scalarm
- the mask controlling lane selectionpublic abstract IntVector blend(Vector<Integer> v, VectorMask<Integer> m)
Vector<E> a = ...;
VectorSpecies<E> species = a.species();
Vector<E> b = ...;
b.check(species);
VectorMask<E> m = ...;
ETYPE[] ar = a.toArray();
for (int i = 0; i < ar.length; i++) {
if (m.laneIsSet(i)) {
ar[i] = b.lane(i);
}
}
return EVector.fromArray(s, ar, 0);
public abstract IntVector addIndex(int scale)
N
, computes the scaled index value N*scale
and adds it to the value already in lane N
of the current vector. The scale must not be so large, and the element size must not be so small, that that there would be an overflow when computing any of the N*scale
or VLENGTH*scale
, when the result is represented using the vector lane type ETYPE
.
The following pseudocode illustrates this behavior:
Vector<E> a = ...;
VectorSpecies<E> species = a.species();
ETYPE[] ar = a.toArray();
for (int i = 0; i < ar.length; i++) {
long d = (long)i * scale;
if (d != (ETYPE) d) throw ...;
ar[i] += (ETYPE) d;
}
long d = (long)ar.length * scale;
if (d != (ETYPE) d) throw ...;
return EVector.fromArray(s, ar, 0);
public final IntVector blend(int e, VectorMask<Integer> m)
blend(broadcast(e),m)
.e
- the input scalar, containing the replacement lane valuem
- the mask controlling lane selection of the scalarpublic final IntVector blend(long e, VectorMask<Integer> m)
blend(broadcast(e),m)
.public abstract IntVector slice(int origin, Vector<Integer> v1)
origin
lane in the current vector, and continuing (as needed) into an immediately following vector. The block of VLENGTH
lanes is extracted into its own vector and returned. This is a cross-lane operation that shifts lane elements to the front, from the current vector and the second vector. Both vectors can be viewed as a combined "background" of length 2*VLENGTH
, from which a slice is extracted. The lane numbered N
in the output vector is copied from lane origin+N
of the input vector, if that lane exists, else from lane origin+N-VLENGTH
of the second vector (which is guaranteed to exist).
The origin
value must be in the inclusive range 0..VLENGTH
. As limiting cases, v.slice(0,w)
and v.slice(VLENGTH,w)
return v
and w
, respectively.
origin
- the first input lane to transfer into the slicev1
- a second vector logically concatenated with the first, before the slice is taken (if omitted it defaults to zero)VLENGTH
lanes, taken from this vector starting at the indicated origin, and continuing (as needed) into the second vectorpublic final IntVector slice(int origin, Vector<Integer> w, VectorMask<Integer> m)
origin
lane in the current vector, and continuing (as needed) into an immediately following vector. The block of VLENGTH
lanes is extracted into its own vector and returned. The resulting vector will be zero in all lanes unset in the given mask. Lanes set in the mask will contain data copied from selected lanes of this
or v1
. This is a cross-lane operation that shifts lane elements to the front, from the current vector and the second vector. Both vectors can be viewed as a combined "background" of length 2*VLENGTH
, from which a slice is extracted. The returned result is equal to the expression broadcast(0).blend(slice(origin,v1),m)
.
slice
in class Vector<Integer>
origin
- the first input lane to transfer into the slicew
- a second vector logically concatenated with the first, before the slice is taken (if omitted it defaults to zero)m
- the mask controlling lane selection into the resulting vectorVLENGTH
lanes, taken from this vector starting at the indicated origin, and continuing (as needed) into the second vectorpublic abstract IntVector slice(int origin)
origin
lane in the current vector. A block of VLENGTH
lanes, possibly padded with zero lanes, is extracted into its own vector and returned. This is a convenience method which slices from a single vector against an extended background of zero lanes. It is equivalent to slice
(origin,
broadcast
(0))
. It may also be viewed simply as a cross-lane shift from later to earlier lanes, with zeroes filling in the vacated lanes at the end of the vector. In this view, the shift count is origin
. origin
- the first input lane to transfer into the sliceVLENGTH-origin
input lanes, placed starting in the first lane of the output, padded at the end with zeroespublic abstract IntVector unslice(int origin, Vector<Integer> w, int part)
slice()
operation. This is a cross-lane operation that permutes the lane elements of the current vector toward the back and inserts them into a logical pair of background vectors. Only one of the pair will be returned, however. The background is formed by duplicating the second input vector. (However, the output will never contain two duplicates from the same input lane.) The lane numbered N
in the input vector is copied into lane origin+N
of the first background vector, if that lane exists, else into lane origin+N-VLENGTH
of the second background vector (which is guaranteed to exist). The first or second background vector, updated with the inserted slice, is returned. The part
number of zero or one selects the first or second updated background vector.
The origin
value must be in the inclusive range 0..VLENGTH
. As limiting cases, v.unslice(0,w,0)
and v.unslice(VLENGTH,w,1)
both return v
, while v.unslice(0,w,1)
and v.unslice(VLENGTH,w,0)
both return w
.
unslice
in class Vector<Integer>
origin
- the first output lane to receive the slicew
- the background vector that (as two copies) will receive the inserted slicepart
- the part number of the result (either zero or one)w
, updated by inserting this vector at the indicated originpublic abstract IntVector unslice(int origin, Vector<Integer> w, int part, VectorMask<Integer> m)
slice()
operation. This is a cross-lane operation that permutes the lane elements of the current vector forward and inserts its lanes (when selected by the mask) into a logical pair of background vectors. As with the unmasked version of this method, only one of the pair will be returned, as selected by the part
number. For each lane N
selected by the mask, the lane value is copied into lane origin+N
of the first background vector, if that lane exists, else into lane origin+N-VLENGTH
of the second background vector (which is guaranteed to exist). Background lanes retain their original values if the corresponding input lanes N
are unset in the mask. The first or second background vector, updated with set lanes of the inserted slice, is returned. The part
number of zero or one selects the first or second updated background vector.
unslice
in class Vector<Integer>
origin
- the first output lane to receive the slicew
- the background vector that (as two copies) will receive the inserted slice, if they are set in m
part
- the part number of the result (either zero or one)m
- the mask controlling lane selection from the current vectorw
, updated by inserting selected lanes of this vector at the indicated originpublic abstract IntVector unslice(int origin)
unslice()
methods, this method only returns the first of the pair of background vectors. This is a convenience method which returns the result of unslice
(origin,
broadcast
(0), 0)
. It may also be viewed simply as a cross-lane shift from earlier to later lanes, with zeroes filling in the vacated lanes at the beginning of the vector. In this view, the shift count is origin
. public abstract IntVector rearrange(VectorShuffle<Integer> m)
N
of the shuffle, and for each lane source index I=s.laneSource(N)
in the shuffle, the output lane N
obtains the value from the input vector at lane I
. public abstract IntVector rearrange(VectorShuffle<Integer> s, VectorMask<Integer> m)
N
of the shuffle, and for each lane source index I=s.laneSource(N)
in the shuffle, the output lane N
obtains the value from the input vector at lane I
if the mask is set. Otherwise the output lane N
is set to zero. This method returns the value of this pseudocode:
Vector<E> r = this.rearrange(s.wrapIndexes());
VectorMask<E> valid = s.laneIsValid();
if (m.andNot(valid).anyTrue()) throw ...;
return broadcast(0).blend(r, m);
public abstract IntVector rearrange(VectorShuffle<Integer> s, Vector<Integer> v)
v
). For each lane N
of the shuffle, and for each lane source index I=s.laneSource(N)
in the shuffle, the output lane N
obtains the value from the first vector at lane I
if I>=0
. Otherwise, the exceptional index I
is wrapped by adding VLENGTH
to it and used to index the second vector, at index I+VLENGTH
. This method returns the value of this pseudocode:
Vector<E> r1 = this.rearrange(s.wrapIndexes());
// or else: r1 = this.rearrange(s, s.laneIsValid());
Vector<E> r2 = v.rearrange(s.wrapIndexes());
return r2.blend(r1,s.laneIsValid());
public abstract IntVector compress(VectorMask<Integer> m)
N
of the mask, if the mask at lane N
is set, the element at lane N
of input vector is selected and stored into the output vector contiguously starting from the lane 0
. All the upper remaining lanes, if any, of the output vector are set to zero. public abstract IntVector expand(VectorMask<Integer> m)
N
of the mask, if the mask at lane N
is set, the next contiguous element of input vector starting from lane 0
is selected and stored into the output vector at lane N
. All the remaining lanes, if any, of the output vector are set to zero. public abstract IntVector selectFrom(Vector<Integer> v)
v
. The second vector thus serves as a table, whose elements are selected by indexes in the current vector. This is a cross-lane operation that rearranges the lane elements of the argument vector, under the control of this vector. For each lane N
of this vector, and for each lane value I=this.lane(N)
in this vector, the output lane N
obtains the value from the argument vector at lane I
. In this way, the result contains only values stored in the argument vector v
, but presented in an order which depends on the index values in this
. The result is the same as the expression v.rearrange(this.toShuffle())
. selectFrom
in class Vector<Integer>
v
- the vector supplying the result valuesv
public abstract IntVector selectFrom(Vector<Integer> s, VectorMask<Integer> m)
v
. The second vector thus serves as a table, whose elements are selected by indexes in the current vector. Lanes that are unset in the mask receive a zero rather than a value from the table. This is a cross-lane operation that rearranges the lane elements of the argument vector, under the control of this vector and the mask. The result is the same as the expression v.rearrange(this.toShuffle(), m)
. selectFrom
in class Vector<Integer>
s
- the vector supplying the result valuesm
- the mask controlling selection from v
v
public final IntVector bitwiseBlend(Vector<Integer> bits, Vector<Integer> mask)
(a&~c)|(b&c)
to each lane. This method is also equivalent to the expression lanewise
(
BITWISE_BLEND
, bits, mask)
.bits
- input bits to blend into the current vectormask
- a bitwise mask to enable blending of the input bitspublic final IntVector bitwiseBlend(int bits, int mask)
(a&~c)|(b&c)
to each lane. This method is also equivalent to the expression lanewise
(
BITWISE_BLEND
, bits, mask)
.bits
- input bits to blend into the current vectormask
- a bitwise mask to enable blending of the input bitspublic final IntVector bitwiseBlend(int bits, Vector<Integer> mask)
(a&~c)|(b&c)
to each lane. This method is also equivalent to the expression lanewise
(
BITWISE_BLEND
, bits, mask)
.bits
- input bits to blend into the current vectormask
- a bitwise mask to enable blending of the input bitspublic final IntVector bitwiseBlend(Vector<Integer> bits, int mask)
(a&~c)|(b&c)
to each lane. This method is also equivalent to the expression lanewise
(
BITWISE_BLEND
, bits, mask)
.bits
- input bits to blend into the current vectormask
- a bitwise mask to enable blending of the input bitspublic abstract int reduceLanes(VectorOperators.Associative op)
A few reduction operations do not support arbitrary reordering of their operands, yet are included here because of their usefulness.
FIRST_NONZERO
, the reduction returns the value from the lowest-numbered non-zero lane. op
- the operation used to combine lane valuesUnsupportedOperationException
- if this vector does not support the requested operationpublic abstract int reduceLanes(VectorOperators.Associative op, VectorMask<Integer> m)
If no elements are selected, an operation-specific identity value is returned.
ADD
, XOR
, OR
, or FIRST_NONZERO
, then the identity value is zero, the default int
value. MUL
, then the identity value is one. AND
, then the identity value is minus one (all bits set). MAX
, then the identity value is Integer.MIN_VALUE
. MIN
, then the identity value is Integer.MAX_VALUE
. A few reduction operations do not support arbitrary reordering of their operands, yet are included here because of their usefulness.
FIRST_NONZERO
, the reduction returns the value from the lowest-numbered non-zero lane. op
- the operation used to combine lane valuesm
- the mask controlling lane selectionUnsupportedOperationException
- if this vector does not support the requested operationpublic abstract int lane(int i)
i
i
- the lane indexi
IllegalArgumentException
- if the index is is out of range (< 0 || >= length()
)public abstract IntVector withLane(int i, int e)
i
with value e
. This is a cross-lane operation and behaves as if it returns the result of blending this vector with an input vector that is the result of broadcasting e
and a mask that has only one lane set at lane index i
.i
- the lane index of the lane element to be replacede
- the value to be placedi
with value e
.IllegalArgumentException
- if the index is is out of range (< 0 || >= length()
)public final int[] toArray()
int[]
containing all the lane values. The array length is the same as the vector length. The array elements are stored in lane order. This method behaves as if it stores this vector into an allocated array (using intoArray
) and returns the array as follows:
int[] a = new int[this.length()];
this.intoArray(a, 0);
return a;
public final int[] toIntArray()
int[]
array containing all the lane values, converted to the type int
. The array length is the same as the vector length. The array elements are converted as if by casting and stored in lane order. This operation may fail if the vector element type is
float
or double
, when lanes contain fractional or out-of-range values. If any vector lane value is not representable as an int
, an exception is thrown. This is an alias for toArray()
When this method is used on used on vectors of type IntVector
, there will be no loss of range or precision.toIntArray
in class Vector<Integer>
int[]
array containing the lane values of this vectorpublic final long[] toLongArray()
long[]
array containing all the lane values, converted to the type long
. The array length is the same as the vector length. The array elements are converted as if by casting and stored in lane order. This operation may fail if the vector element type is
float
or double
, when lanes contain fractional or out-of-range values. If any vector lane value is not representable as a long
, an exception is thrown. toLongArray
in class Vector<Integer>
IntVector
, there will be no loss of precision or range, and so no UnsupportedOperationException
will be thrown.long[]
array containing the lane values of this vectorpublic final double[] toDoubleArray()
double[]
array containing all the lane values, converted to the type double
. The array length is the same as the vector length. The array elements are converted as if by casting and stored in lane order. This operation can lose precision if the vector element type is long
. toDoubleArray
in class Vector<Integer>
IntVector
, there will be no loss of precision.double[]
array containing the lane values of this vector, possibly rounded to representable double
valuespublic static IntVector fromArray(VectorSpecies<Integer> species, int[] a, int offset)
int[]
starting at an offset. For each vector lane, where N
is the vector lane index, the array element at index offset + N
is placed into the resulting vector at lane index N
.species
- species of desired vectora
- the arrayoffset
- the offset into the arrayIndexOutOfBoundsException
- if offset+N < 0
or offset+N >= a.length
for any lane N
in the vectorpublic static IntVector fromArray(VectorSpecies<Integer> species, int[] a, int offset, VectorMask<Integer> m)
int[]
starting at an offset and using a mask. Lanes where the mask is unset are filled with the default value of int
(zero). For each vector lane, where N
is the vector lane index, if the mask lane at index N
is set then the array element at index offset + N
is placed into the resulting vector at lane index N
, otherwise the default element value is placed into the resulting vector at lane index N
.species
- species of desired vectora
- the arrayoffset
- the offset into the arraym
- the mask controlling lane selectionIndexOutOfBoundsException
- if offset+N < 0
or offset+N >= a.length
for any lane N
in the vector where the mask is setpublic static IntVector fromArray(VectorSpecies<Integer> species, int[] a, int offset, int[] indexMap, int mapOffset)
int[]
, using indexes obtained by adding a fixed offset
to a series of secondary offsets from an index map. The index map is a contiguous sequence of VLENGTH
elements in a second array of int
s, starting at a given mapOffset
. For each vector lane, where N
is the vector lane index, the lane is loaded from the array element a[f(N)]
, where f(N)
is the index mapping expression offset + indexMap[mapOffset + N]]
.
species
- species of desired vectora
- the arrayoffset
- the offset into the array, may be negative if relative indexes in the index map compensate to produce a value within the array boundsindexMap
- the index mapmapOffset
- the offset into the index mapIndexOutOfBoundsException
- if mapOffset+N < 0
or if mapOffset+N >= indexMap.length
, or if f(N)=offset+indexMap[mapOffset+N]
is an invalid index into a
, for any lane N
in the vectorpublic static IntVector fromArray(VectorSpecies<Integer> species, int[] a, int offset, int[] indexMap, int mapOffset, VectorMask<Integer> m)
int[]
, under the control of a mask, and using indexes obtained by adding a fixed offset
to a series of secondary offsets from an index map. The index map is a contiguous sequence of VLENGTH
elements in a second array of int
s, starting at a given mapOffset
. For each vector lane, where N
is the vector lane index, if the lane is set in the mask, the lane is loaded from the array element a[f(N)]
, where f(N)
is the index mapping expression offset + indexMap[mapOffset + N]]
. Unset lanes in the resulting vector are set to zero.
species
- species of desired vectora
- the arrayoffset
- the offset into the array, may be negative if relative indexes in the index map compensate to produce a value within the array boundsindexMap
- the index mapmapOffset
- the offset into the index mapm
- the mask controlling lane selectionIndexOutOfBoundsException
- if mapOffset+N < 0
or if mapOffset+N >= indexMap.length
, or if f(N)=offset+indexMap[mapOffset+N]
is an invalid index into a
, for any lane N
in the vector where the mask is setpublic static IntVector fromMemorySegment(VectorSpecies<Integer> species, MemorySegmentPREVIEW ms, long offset, ByteOrder bo)
This method behaves as if it returns the result of calling fromMemorySegment()
PREVIEW as follows:
var m = species.maskAll(true);
return fromMemorySegment(species, ms, offset, bo, m);
species
- species of desired vectorms
- the memory segmentoffset
- the offset into the memory segmentbo
- the intended byte orderIndexOutOfBoundsException
- if offset+N*4 < 0
or offset+N*4 >= ms.byteSize()
for any lane N
in the vectorIllegalArgumentException
- if the memory segment is a heap segment that is not backed by a byte[]
array.IllegalStateException
- if the memory segment's session is not alive, or if access occurs from a thread other than the thread owning the session.public static IntVector fromMemorySegment(VectorSpecies<Integer> species, MemorySegmentPREVIEW ms, long offset, ByteOrder bo, VectorMask<Integer> m)
int
(zero). Bytes are composed into primitive lane elements according to the specified byte order. The vector is arranged into lanes according to memory ordering. The following pseudocode illustrates the behavior:
var slice = ms.asSlice(offset);
int[] ar = new int[species.length()];
for (int n = 0; n < ar.length; n++) {
if (m.laneIsSet(n)) {
ar[n] = slice.getAtIndex(ValuaLayout.JAVA_INT.withByteAlignment(1), n);
}
}
IntVector r = IntVector.fromArray(species, ar, 0);
species
- species of desired vectorms
- the memory segmentoffset
- the offset into the memory segmentbo
- the intended byte orderm
- the mask controlling lane selectionIndexOutOfBoundsException
- if offset+N*4 < 0
or offset+N*4 >= ms.byteSize()
for any lane N
in the vector where the mask is setIllegalArgumentException
- if the memory segment is a heap segment that is not backed by a byte[]
array.IllegalStateException
- if the memory segment's session is not alive, or if access occurs from a thread other than the thread owning the session.public final void intoArray(int[] a, int offset)
int[]
starting at an offset. For each vector lane, where N
is the vector lane index, the lane element at index N
is stored into the array element a[offset+N]
.
a
- the array, of type int[]
offset
- the offset into the arrayIndexOutOfBoundsException
- if offset+N < 0
or offset+N >= a.length
for any lane N
in the vectorpublic final void intoArray(int[] a, int offset, VectorMask<Integer> m)
int[]
starting at offset and using a mask. For each vector lane, where N
is the vector lane index, the lane element at index N
is stored into the array element a[offset+N]
. If the mask lane at N
is unset then the corresponding array element a[offset+N]
is left unchanged.
Array range checking is done for lanes where the mask is set. Lanes where the mask is unset are not stored and do not need to correspond to legitimate elements of a
. That is, unset lanes may correspond to array indexes less than zero or beyond the end of the array.
a
- the array, of type int[]
offset
- the offset into the arraym
- the mask controlling lane storageIndexOutOfBoundsException
- if offset+N < 0
or offset+N >= a.length
for any lane N
in the vector where the mask is setpublic final void intoArray(int[] a, int offset, int[] indexMap, int mapOffset)
int[]
using indexes obtained by adding a fixed offset
to a series of secondary offsets from an index map. The index map is a contiguous sequence of VLENGTH
elements in a second array of int
s, starting at a given mapOffset
. For each vector lane, where N
is the vector lane index, the lane element at index N
is stored into the array element a[f(N)]
, where f(N)
is the index mapping expression offset + indexMap[mapOffset + N]]
.
a
- the arrayoffset
- an offset to combine with the index map offsetsindexMap
- the index mapmapOffset
- the offset into the index mapIndexOutOfBoundsException
- if mapOffset+N < 0
or if mapOffset+N >= indexMap.length
, or if f(N)=offset+indexMap[mapOffset+N]
is an invalid index into a
, for any lane N
in the vectorpublic final void intoArray(int[] a, int offset, int[] indexMap, int mapOffset, VectorMask<Integer> m)
int[]
, under the control of a mask, and using indexes obtained by adding a fixed offset
to a series of secondary offsets from an index map. The index map is a contiguous sequence of VLENGTH
elements in a second array of int
s, starting at a given mapOffset
. For each vector lane, where N
is the vector lane index, if the mask lane at index N
is set then the lane element at index N
is stored into the array element a[f(N)]
, where f(N)
is the index mapping expression offset + indexMap[mapOffset + N]]
.
a
- the arrayoffset
- an offset to combine with the index map offsetsindexMap
- the index mapmapOffset
- the offset into the index mapm
- the maskIndexOutOfBoundsException
- if mapOffset+N < 0
or if mapOffset+N >= indexMap.length
, or if f(N)=offset+indexMap[mapOffset+N]
is an invalid index into a
, for any lane N
in the vector where the mask is setpublic final void intoMemorySegment(MemorySegmentPREVIEW ms, long offset, ByteOrder bo)
Bytes are extracted from primitive lane elements according to the specified byte ordering. The lanes are stored according to their memory ordering.
This method behaves as if it calls intoMemorySegment()
PREVIEW as follows:
var m = maskAll(true);
intoMemorySegment(ms, offset, bo, m);
intoMemorySegment
in class Vector<Integer>
ms
- the memory segmentoffset
- the offset into the memory segmentbo
- the intended byte orderpublic final void intoMemorySegment(MemorySegmentPREVIEW ms, long offset, ByteOrder bo, VectorMask<Integer> m)
Bytes are extracted from primitive lane elements according to the specified byte ordering. The lanes are stored according to their memory ordering.
The following pseudocode illustrates the behavior, where JAVA_E
is the layout of the primitive element type, ETYPE
is the primitive element type, and EVector
is the primitive vector type for this vector:
ETYPE[] a = this.toArray();
var slice = ms.asSlice(offset)
for (int n = 0; n < a.length; n++) {
if (m.laneIsSet(n)) {
slice.setAtIndex(ValueLayout.JAVA_E.withBitAlignment(8), n);
}
}
intoMemorySegment
in class Vector<Integer>
ms
- the memory segmentoffset
- the offset into the memory segmentbo
- the intended byte orderm
- the mask controlling lane selectionpublic final ByteVector reinterpretAsBytes()
byte
, where the bytes are extracted from the lanes according to little-endian order. It is a convenience method for the expression reinterpretShape(species().withLanes(byte.class))
. It may be considered an inverse to the various methods which consolidate bytes into larger lanes within the same vector, such as Vector.reinterpretAsInts()
. reinterpretAsBytes
in class Vector<Integer>
ByteVector
with the same shape and information contentpublic final IntVector viewAsIntegralLanes()
VSHAPE
or VLENGTH
, and there is no change to the bitwise contents of the vector. If the vector's ETYPE
is already an integral type, the same vector is returned unchanged. This method returns the value of this expression: convert(conv,0)
, where conv
is VectorOperators.Conversion.ofReinterpret(E.class,F.class)
, and F
is the non-floating-point type of the same size as E
. viewAsIntegralLanes
in class Vector<Integer>
public final FloatVector viewAsFloatingLanes()
VSHAPE
or VLENGTH
, and there is no change to the bitwise contents of the vector. If the vector's ETYPE
is already a float-point type, the same vector is returned unchanged. If the vector's element size does not match any floating point type size, an IllegalArgumentException
is thrown. This method returns the value of this expression: convert(conv,0)
, where conv
is VectorOperators.Conversion.ofReinterpret(E.class,F.class)
, and F
is the floating-point type of the same size as E
, if any. viewAsFloatingLanes
in class Vector<Integer>
public final String toString()
"[0,1,2...]"
, reporting the lane values of this vector, in lane order. The string is produced as if by a call to Arrays.toString()
, as appropriate to the int
array returned by this.toArray()
.public final boolean equals(Object obj)
The comparison of lane values is produced as if by a call to Arrays.equals()
, as appropriate to the arrays returned by toArray()
on both vectors.
public final int hashCode()
public final VectorSpecies<Integer> species()
Vector
public final <F> Vector<F> check(VectorSpecies<F> species)
Vector
species == species()
? this
: throw new ClassCastException()
.public final <F> Vector<F> check(Class<F> elementType)
elementType == species().elementType()
? this
: throw new ClassCastException()
. public final VectorMask<Integer> maskAll(boolean bit)
This method returns the value of this expression: species().maskAll(bit)
.
public ShortVector reinterpretAsShorts()
short
, where the lanes are assembled from successive bytes according to little-endian order. It is a convenience method for the expression reinterpretShape(species().withLanes(short.class))
. It may be considered an inverse to Vector.reinterpretAsBytes()
. reinterpretAsShorts
in class Vector<E>
ShortVector
with the same shape and information contentpublic IntVector reinterpretAsInts()
int
, where the lanes are assembled from successive bytes according to little-endian order. It is a convenience method for the expression reinterpretShape(species().withLanes(int.class))
. It may be considered an inverse to Vector.reinterpretAsBytes()
. reinterpretAsInts
in class Vector<E>
IntVector
with the same shape and information contentpublic LongVector reinterpretAsLongs()
long
, where the lanes are assembled from successive bytes according to little-endian order. It is a convenience method for the expression reinterpretShape(species().withLanes(long.class))
. It may be considered an inverse to Vector.reinterpretAsBytes()
. reinterpretAsLongs
in class Vector<E>
LongVector
with the same shape and information contentpublic FloatVector reinterpretAsFloats()
float
, where the lanes are assembled from successive bytes according to little-endian order. It is a convenience method for the expression reinterpretShape(species().withLanes(float.class))
. It may be considered an inverse to Vector.reinterpretAsBytes()
. reinterpretAsFloats
in class Vector<E>
FloatVector
with the same shape and information contentpublic DoubleVector reinterpretAsDoubles()
double
, where the lanes are assembled from successive bytes according to little-endian order. It is a convenience method for the expression reinterpretShape(species().withLanes(double.class))
. It may be considered an inverse to Vector.reinterpretAsBytes()
. reinterpretAsDoubles
in class Vector<E>
DoubleVector
with the same shape and information contentpublic final <F> Vector<F> convert(VectorOperators.Conversion<Integer,F> conv, int part)
ETYPE
to a new lane type (called FTYPE
here) according to the indicated conversion. This is a lane-wise shape-invariant operation which copies ETYPE
values from the input vector to corresponding FTYPE
values in the result. Depending on the selected conversion, this operation may either expand or contract its logical result, in which case a non-zero part
number can further control the selection and steering of the logical result into the physical output vector. Each specific conversion is described by a conversion constant in the class VectorOperators
. Each conversion operator has a specified domain type and range type. The domain type must exactly match the lane type of the input vector, while the range type determines the lane type of the output vectors.
A conversion operator may be classified as (respectively) in-place, expanding, or contracting, depending on whether the bit-size of its domain type is (respectively) equal, less than, or greater than the bit-size of its range type.
Independently, conversion operations can also be classified as reinterpreting or value-transforming, depending on whether the conversion copies representation bits unchanged, or changes the representation bits in order to retain (part or all of) the logical value of the input value.
If a reinterpreting conversion contracts, it will truncate the upper bits of the input. If it expands, it will pad upper bits of the output with zero bits, when there are no corresponding input bits.
An expanding conversion such as S2I
(short
value to int
) takes a scalar value and represents it in a larger format (always with some information redundancy). A contracting conversion such as D2F
(double
value to float
) takes a scalar value and represents it in a smaller format (always with some information loss). Some in-place conversions may also include information loss, such as L2D
(long
value to double
) or F2I
(float
value to int
). Reinterpreting in-place conversions are not lossy, unless the bitwise value is somehow not legal in the output type. Converting the bit-pattern of a NaN
may discard bits from the NaN
's significand.
This classification is important, because, unless otherwise documented, conversion operations never change vector shape, regardless of how they may change lane sizes. Therefore an expanding conversion cannot store all of its results in its output vector, because the output vector has fewer lanes of larger size, in order to have the same overall bit-size as its input. Likewise, a contracting conversion must store its relatively small results into a subset of the lanes of the output vector, defaulting the unused lanes to zero.
As an example, a conversion from byte
to long
(M=8
) will discard 87.5% of the input values in order to convert the remaining 12.5% into the roomy long
lanes of the output vector. The inverse conversion will convert back all of the large results, but will waste 87.5% of the lanes in the output vector. In-place conversions (M=1
) deliver all of their results in one output vector, without wasting lanes.
To manage the details of these expansions and contractions, a non-zero part
parameter selects partial results from expansions, or steers the results of contractions into corresponding locations, as follows:
M
: part
must be in the range [0..M-1]
, and selects the block of VLENGTH/M
input lanes starting at the origin lane at part*VLENGTH/M
. The VLENGTH/M
output lanes represent a partial slice of the whole logical result of the conversion, filling the entire physical output vector.
M
: part
must be in the range [-M+1..0]
, and steers all VLENGTH
input lanes into the output located at the origin lane -part*VLENGTH
. There is a total of VLENGTH*M
output lanes, and those not holding converted input values are filled with zeroes. A group of such output vectors, with logical result parts steered to disjoint blocks, can be reassembled using the bitwise or or (for floating point) the FIRST_NONZERO
operator.
M=1
): part
must be zero. Both vectors have the same VLENGTH
. The result is always positioned at the origin lane of zero. This method is a restricted version of the more general but less frequently used shape-changing method convertShape()
. The result of this method is the same as the expression this.convertShape(conv, rsp, this.broadcast(part))
, where the output species is rsp=this.species().withLanes(FTYPE.class)
.
convert
in class Vector<E>
F
- the boxed element type of the speciesconv
- the desired scalar conversion to apply lane-wisepart
- the part number of the result, or zero if neither expanding nor contractingpublic final <F> Vector<F> castShape(VectorSpecies<F> toSpecies, int part)
convertShape(conv,rsp,part)
, where conv
is VectorOperators.Conversion.ofCast(E.class,F.class)
. If the old and new species have different shape, this is a shape-changing operation, and may have special implementation costs.
castShape
in class Vector<E>
F
- the boxed element type of the output speciestoSpecies
- the desired output speciespart
- the part number of the result, or zero if neither expanding nor contractingpublic abstract <F> Vector<F> convertShape(VectorOperators.Conversion<Integer,F> conv, VectorSpecies<F> rsp, int part)
ETYPE
to a new lane type (called FTYPE
here) according to the indicated conversion. This is a lane-wise operation which copies ETYPE
values from the input vector to corresponding FTYPE
values in the result. If the old and new species have the same shape, the behavior is exactly the same as the simpler, shape-invariant method convert()
. In such cases, the simpler method convert()
should be used, to make code easier to reason about. Otherwise, this is a shape-changing operation, and may have special implementation costs.
As a combined effect of shape changes and lane size changes, the input and output species may have different lane counts, causing expansion or contraction. In this case a non-zero part
parameter selects partial results from an expanded logical result, or steers the results of a contracted logical result into a physical output vector of the required output species.
The following pseudocode illustrates the behavior of this method for in-place, expanding, and contracting conversions. (This pseudocode also applies to the shape-invariant method, but with shape restrictions on the output species.) Note that only one of the three code paths is relevant to any particular combination of conversion operator and shapes.
FTYPE scalar_conversion_op(ETYPE s);
EVector a = ...;
VectorSpecies<F> rsp = ...;
int part = ...;
VectorSpecies<E> dsp = a.species();
int domlen = dsp.length();
int ranlen = rsp.length();
FTYPE[] logical = new FTYPE[domlen];
for (int i = 0; i < domlen; i++) {
logical[i] = scalar_conversion_op(a.lane(i));
}
FTYPE[] physical;
if (domlen == ranlen) { // in-place
assert part == 0; //else AIOOBE
physical = logical;
} else if (domlen > ranlen) { // expanding
int M = domlen / ranlen;
assert 0 <= part && part < M; //else AIOOBE
int origin = part * ranlen;
physical = Arrays.copyOfRange(logical, origin, origin + ranlen);
} else { // (domlen < ranlen) // contracting
int M = ranlen / domlen;
assert 0 >= part && part > -M; //else AIOOBE
int origin = -part * domlen;
System.arraycopy(logical, 0, physical, origin, domlen);
}
return FVector.fromArray(ran, physical, 0);
convertShape
in class Vector<E>
F
- the boxed element type of the output speciesconv
- the desired scalar conversion to apply lane-wisersp
- the desired output speciespart
- the part number of the result, or zero if neither expanding nor contractingprotected final Object getPayload()
© 1993, 2023, Oracle and/or its affiliates. All rights reserved.
Documentation extracted from Debian's OpenJDK Development Kit package.
Licensed under the GNU General Public License, version 2, with the Classpath Exception.
Various third party code in OpenJDK is licensed under different licenses (see Debian package).
Java and OpenJDK are trademarks or registered trademarks of Oracle and/or its affiliates.
https://docs.oracle.com/en/java/javase/21/docs/api/jdk.incubator.vector/jdk/incubator/vector/IntVector.html
IntVector
when preview features are enabled.