section 7C1
unary operators

home

Two standard unary operations are:

For example, this program:

#include "SOME_DIRECTORY/mat_gen_dim.h"
using namespace mat_gen_dim;

form const frm {blt{1,3},blt{2,6}};

int main () {
    std::cout.setf (std::ios::fixed, std::ios::floatfield);
    std::cout.precision (2);

    cout << "\n\n -- negate a matrix";
    var_matrix<double> mat_a3 {sub_matrix_linear (frm,0.0)};
    cout << "\n mat_a3 before: " << mat_a3;

    var_matrix<double> mat_z3 {-mat_a3};

    cout << "\n mat_a3 after: " << mat_a3;
    cout << "\n mat_z3 == what is returned: " << mat_z3;

    return 0;
}
yields this output:
 -- negate a matrix
 mat_a3 before: 
    ( 1 2 ) = 0.12    ( 1 3 ) = 0.13    ( 1 4 ) = 0.14    ( 1 5 ) = 0.15
    ( 2 2 ) = 0.22    ( 2 3 ) = 0.23    ( 2 4 ) = 0.24    ( 2 5 ) = 0.25
 mat_a3 after: 
    ( 1 2 ) = 0.12    ( 1 3 ) = 0.13    ( 1 4 ) = 0.14    ( 1 5 ) = 0.15
    ( 2 2 ) = 0.22    ( 2 3 ) = 0.23    ( 2 4 ) = 0.24    ( 2 5 ) = 0.25
 mat_z3 == what is returned: 
    ( 1 2 ) = -0.12    ( 1 3 ) = -0.13    ( 1 4 ) = -0.14    ( 1 5 ) = -0.15
    ( 2 2 ) = -0.22    ( 2 3 ) = -0.23    ( 2 4 ) = -0.24    ( 2 5 ) = -0.25