# Invasive replacement operators

These operators are member functions that modify the current value of the object.

In the following examples, A is usually the value (*this). All operators return *this.

XXXMatrix& operator = (const XXXMatrix& src)

Example: A = B;
This is the assignment operator: make A into a matrix that is a copy of B. If A already has allocated data storage, then the size of this data storage is compared to the size of B. If they are equal, then the dimensions of A are simply set to those of B and the entries copied. If they are not equal, the data storage is freed and reallocated before copying.

XXXMatrix& operator = (xxx value)

Example: A = value;
Assign each entry of A to have the given value. Memory management is handled as in the previous operator.

XXXMatrix& operator += (const XXXMatrix& src)

Example: A += B;
Perform the operation A.entry(i) += B.entry(i) for each entry in A. A and B must have the same dimensions.

XXXMatrix& operator += (xxx value)

Example: A += value;
Add the scalar value to each entry in the matrix.

XXXMatrix& operator -= (const XXXMatrix& src)

Example: A -= B;
Perform the operation A.entry(i) -= B.entry(i) for each entry in A. A and B must have the same dimensions.

XXXMatrix& operator -= (xxx value)

Example: A -= value;
Subtract the scalar value from each entry in the matrix.

XXXMatrix& operator *= (const XXXMatrix& src)

Example: A *= B;
Perform the operation A.entry(i) *= B.entry(i) for each entry in A. A and B must have the same dimensions.
Note: this is an element-wise operation and is not equivalent to A = A * B.

XXXMatrix& operator *= (xxx value)

Example: A *= value;
Multiply each entry of the matrix by the scalar value.

XXXMatrix& operator /= (const XXXMatrix& src)

Example: A /= B;
Perform the operation A.entry(i) /= B.entry(i) for each entry in A. A and B must have the same dimensions.

XXXMatrix& operator /= (xxx value)

Example: A /= value
Divide each entry of the matrix by the scalar value. The scalar value must be non-zero.

XXXMatrix& identity()

Example: A.identity();
Change A to be an identity matrix so that each entry on the diagonal is 1 and all off-diagonal entries are 0.