diff --git a/docs/cppmat_var_diagonal.rst b/docs/cppmat_var_diagonal.rst index 30be90a..0850f7e 100644 --- a/docs/cppmat_var_diagonal.rst +++ b/docs/cppmat_var_diagonal.rst @@ -12,7 +12,7 @@ cppmat::diagonal::matrix Square, diagonal, matrix, whereby only the diagonal components are stored: -.. code-block:: cpp +.. code-block:: none [ X ; X ; @@ -39,3 +39,14 @@ Square, diagonal, matrix, whereby only the diagonal components are stored: return 0; } + +Storage +------- + +The storage order is as follows: + +.. code-block:: none + + [ 0 ; + 1 ; + 2 ] diff --git a/docs/cppmat_var_symmetric.rst b/docs/cppmat_var_symmetric.rst index fdce5e0..789dca2 100644 --- a/docs/cppmat_var_symmetric.rst +++ b/docs/cppmat_var_symmetric.rst @@ -12,7 +12,7 @@ cppmat::symmetric::matrix Square, symmetric, matrix, whereby only the upper-diagonal components are stored: -.. code-block:: cpp +.. code-block:: none [ X, X, X ; X, X ; @@ -38,3 +38,21 @@ Square, symmetric, matrix, whereby only the upper-diagonal components are stored return 0; } + +Storage +------- + +The storage order is as follows: + +.. code-block:: none + + [ 0, 1, 2 ; + 3, 4 ; + 5 ] + +For an ``NxN`` matrix (square by definition), the component ``(i,j)`` can be extracted by + +.. code-block:: cpp + + if (i <= j) i*N - (i-1)*i/2 + j - i; + else j*N - (j-1)*j/2 + i - j;