ETYPE,
the element type of a vector
VectorMask represents an ordered immutable sequence of boolean
values.
A VectorMask and Vector of the same
element type
(ETYPE) and shape have the same number of lanes,
and are therefore compatible (specifically, their vector species are compatible).
Some vector operations accept (compatible) masks to control the selection and operation of lane elements of input vectors.
The number of values in the sequence is referred to as the VectorMask
length. The length also corresponds to the number of
VectorMask lanes. The lane element at lane index N (from 0,
inclusive, to length, exclusive) corresponds to the N + 1'th
value in the sequence.
A lane is said to be set if the lane element is true,
otherwise a lane is said to be unset if the lane element is
false.
VectorMask declares a limited set of unary, binary and reduction operations.
VectorMask<E> a = ...;
boolean[] ar = new boolean[a.length()];
for (int i = 0; i < a.length(); i++) {
ar[i] = scalar_unary_op(a.laneIsSet(i));
}
VectorMask<E> r = VectorMask.fromArray(a.vectorSpecies(), ar, 0);
VectorMask<E> a = ...;
VectorMask<E> b = ...;
boolean[] ar = new boolean[a.length()];
for (int i = 0; i < a.length(); i++) {
ar[i] = scalar_binary_op(a.laneIsSet(i), b.laneIsSet(i));
}
VectorMask<E> r = VectorMask.fromArray(a.vectorSpecies(), ar, 0);
Mask<E> a = ...;
int acc = zero_for_scalar_binary_op; // 0, or 1 for &
for (int i = 0; i < a.length(); i++) {
acc = scalar_binary_op(acc, a.laneIsSet(i) ? 1 : 0); // & | +
}
return acc; // maybe boolean (acc != 0)
VectorMask, along with Vector, is a
value-based
class.
With VectorMask, identity-sensitive operations such as ==
may yield unpredictable results, or reduced performance. Oddly
enough, v.equals(w) is likely to be
faster than v==w, since equals is not
an identity sensitive method. (Neither is toString nor
hashCode.)
Also, vector mask objects can be stored in locals and parameters and as
static final constants, but storing them in other Java
fields or in array elements, while semantically valid, may incur
performance penalties.
| Access | Constructor and Description |
|---|---|
| pack-priv |
| Modifier and Type | Method and Description |
|---|---|
| public abstract boolean | Returns: true if all the mask lanes are set, otherwise
false.Returns |
| public abstract VectorMask | Returns: the result of logically conjoining the two input masksthe second input mask m)Computes the logical intersection (as |
| public abstract VectorMask | Returns: the result of logically subtracting the second mask from this maskthe second input mask m)Logically subtracts a second input mask
from this mask (as |
| public abstract boolean | Returns: true if any of the mask lanes are set, otherwise
false.Returns |
| public abstract < the boxed element type of the species F> VectorMask | Returns: a mask converted by shape and element typevector species for the desired mask species)Converts this mask to a mask of the given species of
element type |
| public abstract < the boxed element type of the required lane type F> VectorMask | |
| public abstract < the boxed element type of the required species F> VectorMask | Returns: the same maskvector species required for this mask species)Checks that this mask has the given species, and returns this mask unchanged. |
| pack-priv abstract < the boxed element type of the required species F> VectorMask | Returns: the same maskthe class required for this mask maskClass, Vector<F> its species required for this mask vector)Checks that this mask has the same class with the given mask class, and it has the same species with given vector's species, and returns this mask unchanged. |
| public abstract VectorMask | |
| public abstract VectorMask | Returns: a mask showing where the two input masks were equalthe input mask m)Determines logical equivalence of this mask
to a second input mask (as boolean |
| public final boolean | Returns: whether this vector is identical to some other objectOverrides java. Indicates whether this mask is identical to some other object. |
| public abstract int | Returns: the index of the first mask lane that is set, orVLENGTHReturns the index of the first mask lane that is set. |
| public static < the boxed element type E> VectorMask | Returns: the mask loaded from theboolean arrayvector species for the desired mask species, boolean[] the bits, int boolean arraythe offset into the array offset)Loads a mask from a |
| public static < the boxed element type E> VectorMask | Returns: a mask where each lane is set or unset according to the bits in the given integer valuevector species for the desired mask species, long the given mask bits, as a 64-bit signed integer bits)Returns a mask where each lane is set or unset according to the bits in the given bitmask, starting with the least significant bit, and continuing up to the sign bit. |
| public static < the boxed element type E> VectorMask | Returns: a mask where each lane is set or unset according to the givenboolean valuevector species for the desired mask species, boolean... the given bits)boolean valuesReturns a mask where each lane is set or unset according to given
|
| public final int | Returns: a hash code value for this maskOverrides java. Returns a hash code value for the mask, based on the mask bit settings and the vector species. |
| public abstract VectorMask | Returns: the original mask, with out-of-range lanes unsetthe starting index offset, int the upper-bound (exclusive) of index range limit)Removes lanes numbered |
| public abstract VectorMask | Returns: the original mask, with out-of-range lanes unsetthe starting index offset, long the upper-bound (exclusive) of index range limit)Removes lanes numbered |
| public abstract void | intoArray(boolean[]
the array, of type boolean[] a, int the offset into the array offset)Stores this mask into a |
| public abstract boolean | Returns: true if the lane at indexi is set, otherwise falsethe lane index i)Tests if the lane at index |
| public abstract int | Returns: the index of the last mask lane that is set, or-1Returns the index of the last mask lane that is set. |
| public final int | |
| public abstract VectorMask | |
| public abstract VectorMask | Returns: the result of logically disjoining the two input masksthe input mask m)Computes the logical union (as |
| public abstract boolean[] | Returns: an array containing the lane elements of this vectorReturns an |
| public abstract long | Returns: the lane elements of this mask packed into along
value.Returns the lane elements of this mask packed into a |
| public final String | Returns: a string of the form"Mask[T.TT...]"Overrides java. Returns a string representation of this mask, of the form
|
| public abstract Vector | Returns: a vector representation of this maskReturns a vector representation of this mask, the lane bits of which are set or unset in correspondence to the mask bits. |
| public abstract int | Returns: the number of mask lanes that are set.Returns the number of mask lanes that are set. |
| public abstract VectorSpecies | Returns: the vector species of this maskReturns the vector species to which this mask applies. |
| public abstract VectorMask | Returns: the result of logically disjunctively disjoining the two input masksthe input mask m)Determines logical symmetric difference
(as |
| VectorMask | back to summary |
|---|---|
| pack-priv VectorMask(boolean[] bits) | |
| allTrue | back to summary |
|---|---|
| public abstract boolean allTrue() Returns
| |
| and | back to summary |
|---|---|
| public abstract VectorMask Computes the logical intersection (as
This is a lane-wise binary operation which applies
the logical
| |
| andNot | back to summary |
|---|---|
| public abstract VectorMask Logically subtracts a second input mask
from this mask (as
This is a lane-wise binary operation which applies
the logical
| |
| anyTrue | back to summary |
|---|---|
| public abstract boolean anyTrue() Returns
| |
| cast | back to summary |
|---|---|
| public abstract <F> VectorMask Converts this mask to a mask of the given species of
element type
For each mask lane, where
| |
| check | back to summary |
|---|---|
| public abstract <F> VectorMask Checks that this mask applies to vectors with the given element type,
and returns this mask unchanged.
The effect is similar to this pseudocode:
| |
| check | back to summary |
|---|---|
| public abstract <F> VectorMask Checks that this mask has the given species,
and returns this mask unchanged.
The effect is similar to this pseudocode:
| |
| check | back to summary |
|---|---|
| pack-priv abstract <F> VectorMask Checks that this mask has the same class with the given mask class,
and it has the same species with given vector's species,
and returns this mask unchanged.
The effect is similar to this pseudocode:
| |
| compress | back to summary |
|---|---|
| public abstract VectorMask Compresses set lanes from this mask.
Returns a mask which is a series of
| |
| eq | back to summary |
|---|---|
| public abstract VectorMask Determines logical equivalence of this mask
to a second input mask (as boolean
This is a lane-wise binary operation tests each
corresponding pair of mask bits for equality.
It is also equivalent to the logical
| |
| equals | back to summary |
|---|---|
| public final boolean equals(Object obj) Overrides java. Indicates whether this mask is identical to some other object. Two masks are identical only if they have the same species and same source indexes, in the same order. | |
| firstTrue | back to summary |
|---|---|
| public abstract int firstTrue() Returns the index of the first mask lane that is set.
Returns
| |
| fromArray | back to summary |
|---|---|
| public static <E> VectorMask Loads a mask from a
For each mask lane, where
| |
| fromLong | back to summary |
|---|---|
| public static <E> VectorMask Returns a mask where each lane is set or unset according to the bits in the given bitmask, starting with the least significant bit, and continuing up to the sign bit.
For each mask lane, where
If the given species has fewer than 64 lanes, the high
| |
| fromValues | back to summary |
|---|---|
| public static <E> VectorMask Returns a mask where each lane is set or unset according to given
For each mask lane, where The given species must have a number of lanes that is compatible with the given array.
| |
| hashCode | back to summary |
|---|---|
| public final int hashCode() Overrides java. Returns a hash code value for the mask, based on the mask bit settings and the vector species.
| |
| indexInRange | back to summary |
|---|---|
| public abstract VectorMask Removes lanes numbered In all cases the series of set and unset lanes is assigned
as if by using infinite precision or API Note This method performs a SIMD emulation of the check performed by
A mask which is a series of
| |
| indexInRange | back to summary |
|---|---|
| public abstract VectorMask Removes lanes numbered In all cases the series of set and unset lanes is assigned
as if by using infinite precision or API Note This method performs a SIMD emulation of the check performed by
A mask which is a series of
| |
| intoArray | back to summary |
|---|---|
| public abstract void intoArray(boolean[] a, int offset) Stores this mask into a
For each mask lane, where
| |
| laneIsSet | back to summary |
|---|---|
| public abstract boolean laneIsSet(int i) Tests if the lane at index
| |
| lastTrue | back to summary |
|---|---|
| public abstract int lastTrue() Returns the index of the last mask lane that is set.
Returns
| |
| length | back to summary |
|---|---|
| public final int length() Returns the number of mask lanes. This mask applies to vectors of the same number of lanes, and the same species.
| |
| not | back to summary |
|---|---|
| public abstract VectorMask Logically negates this mask.
This is a lane-wise binary operation which applies
the logical
| |
| or | back to summary |
|---|---|
| public abstract VectorMask Computes the logical union (as
This is a lane-wise binary operation which applies
the logical
| |
| toArray | back to summary |
|---|---|
| public abstract boolean[] toArray() Returns an
This method behaves as if it stores
this mask into an allocated array
(using
| |
| toLong | back to summary |
|---|---|
| public abstract long toLong() Returns the lane elements of this mask packed into a
The lane elements are packed in the order of least significant bit
to most significant bit.
For each mask lane where
| |
| toString | back to summary |
|---|---|
| public final String toString() Overrides java. Returns a string representation of this mask, of the form
| |
| toVector | back to summary |
|---|---|
| public abstract Vector Returns a vector representation of this mask, the
lane bits of which are set or unset in correspondence
to the mask bits.
For each mask lane, where The vector returned is the same as would be computed by
API Note For the sake of static type checking, users may wish to check the resulting vector against the expected integral lane type or species. If the mask is for a float-point species, then the resulting vector will have the same shape and lane size, but an integral type. If the mask is for an integral species, the resulting vector will be of exactly that species.
| |
| trueCount | back to summary |
|---|---|
| public abstract int trueCount() Returns the number of mask lanes that are set.
| |
| vectorSpecies | back to summary |
|---|---|
| public abstract VectorSpecies Returns the vector species to which this mask applies. This mask applies to vectors of the same species, and the same number of lanes.
| |
| xor | back to summary |
|---|---|
| public abstract VectorMask Determines logical symmetric difference
(as
This is a lane-wise binary operation which applies
the logical
| |