3.2. Elementwise Operations

VSIPL++ provides a number of operations that operate on the elements of views (Vector, Matrix, or Tensor objects) independently.

3.2.1. Assignment Operators

Two types of assignment operators are supported: assignment of a view to another view of the same size and dimensionality (that is, assignment of a Vector to a Vector, a Matrix to a Matrix, or a Tensor to a Tensor), and assignment of a scalar value to a view.

A = B
Assigns the values of the elements of B to the corresponding elements of A.
A = b
Assigns the value of the scalar b to all of the elements of A.

Note that the assignment operator always produces a copy of the values being assigned; it does not produce a reference to the same data. To create a view referencing data in an existing view, create a subview instead (see section 2.4.6).

Other assignment operators are also supported for both types of assignment. For the case of assigning a view to another view, these operators are:

A += B
Adds the elements of B to the elements of A.
A -= B
Subtracts the elements of B from the elements of A.
A *= B
Multiplies the elements of A by the elements of B.
A /= B
Divides the elements of A by the elements of B.
A &= B
Assigns the boolean "and" of A andB to the elements of A.
A |= B
Assigns the boolean "or" of A andB to the elements of A.
A ^= B
Assigns the boolean "exclusive or" of A and B to the elements of A.

The assignment operators for assigning a scalar value to a view are equivalent. Here, A += b adds the value of b to each element of A, and the other assignment operators are defined analogously for the scalar-valued case.