Assignment of Matrices

Matrix assignment uses statements like "A=B;" where A and B are matrices. The operator is the function given by the code

void VMatrix::operator= (VMatrix &ROp)
{
    Garbage("operator =");
    ROp.Garbage("operator =");
    Replace( ROp );
    Dispatch->Cleanstack();
}
The operands are checked for validity. The left operand has its header replaced. Then, any intermediate stack matrices are removed from the stack.

Cleanstack() will be discussed in the chapter on the matrix stack. Basically it serves to dispose of the intermediate results of a repeated calculation. Suppose you use the statement c=a+b+d . The sum b+d is calculated, then added to a, and the result is assigned to c. The intermediate calculation of b+d is still on the heap in the stack. Cleanstack() removes b+d and a+(b+d) from the stack.