Assignment
Two assignment operators are used in the following example:
#include <rw/math/mtharray.h>
int main()
{
RWMathArray<double> X(3,3,3,3,rwUninitialized);
RWMathArray<double> Y(3,3,3,3,rwUninitialized);
X = 5; // (1)
Y = X; // (2)
}
The assignment operators are:
(1)RWMathArray<T>& RWMathArray<T>::operator=(T);
(2)RWMathArray<T>& RWMathArray<T>::operator=(const RWMathArray<T>&);
Assignment operator (1) is used when the right hand side evaluates to T, perhaps through type conversion. This operator is defined so that it copies the value of its argument into all elements of the array. You can think of it as copying the value of the right hand side across the equal sign and into all the elements on the left hand side.
Assignment operator
(2) is used when the right-hand side evaluates to
RWMathArray<T>, perhaps through type conversion. (In this case, any type conversion would be a "Rogue Wave defined" conversion.) Again, the elements on the right-hand side are copied across the equal sign and into the elements on the left hand side, element by element. The two arrays on each side of the equal sign must have the same number of dimensions and the same number of elements in each dimension. This is sometimes called requiring that they
conform.
These same assignment operators exist for all the vector, matrix, and array types.
Note that vectors, matrices, and arrays can generally be treated the same as built-in types like double. The syntax is natural and intuitive. There is, however, one subtle difference that we explain in the next section.