![]() |
Blaze 3.9
|
Via the left-shift operator (i.e. operator<<()) and the right-shift operator (i.e. operator>>()) it is possible to perform an elementwise shift of a dense vector:
Note that it is necessary that both operands have exactly the same dimensions. Violating this precondition results in an exception. Also note that it is only possible to shift vectors with the same transpose flag:
Furthermore, it is possible to use different element types in the two vector operands, but shifting two vectors with the same element type is favorable due to possible vectorization of the operation:
The left-shift operator (i.e. operator<<()) and the right-shift operator (i.e. operator>>()) can also be used to perform an elementwise shift of a dense matrix:
Note that it is necessary that both operands have exactly the same dimensions. Violating this precondition results in an exception. It is possible to use any combination of row-major and column-major matrices. Note however that in favor of performance using two matrices with the same storage order is favorable. The same argument holds for the element type: While it is possible to use matrices with different element type, using two matrices with the same element type potentially leads to better performance due to vectorization of the operation.
It is also possible to uniformly shift all elements of a dense vector or dense matrix by means of a scalar, which has the same effect as shifting by means of a uniform vector or matrix (see UniformVector and UniformMatrix). In Blaze it is possible to use all built-in/fundamental data types except bool as scalar values. Examples:
Previous: Bitwise Operations Next: Bitwise AND