cppmat::diagonal

cppmat::diagonal::matrix

[var_diagonal_matrix.h, var_diagonal_matrix.hpp]

Square, diagonal, matrix, whereby only the diagonal components are stored:

[ X       ;
     X    ;
        X ]

The remaining components are imposed to be zero. This offers memory advantages, but also computational advantages as the library is fed with additional knowledge of the matrix.

#include <cppmat/cppmat.h>

int main()
{
    cppmat::diagonal::matrix<double> A(3,3);

    A(0,0) = ...

    // A(0,1) = ... -> not allowed
    // ... = A(0,1) -> allowed, returns zero

    ...

    std::cout << A << std::endl;

    return 0;
}

Storage

The storage order is as follows:

[ 0       ;
     1    ;
        2 ]