This module contains the MatrixView class as well as some functions related to it.

Lars Tandle Kyllingstad

Boost License 1.0

enum Storage ;
Various matrix representations.

General (dense) matrices

Packed storage of triangular matrices

Packed storage of symmetric matrices

enum Triangle ;
In packed storage (triangular, symmetric, and Hermitian matrices), one can choose to store either the upper or lower triangle.

Store upper triangle

Store lower triangle

MatrixView!(T) matrix (T)(size_t rows, size_t cols);
MatrixView!(T) matrix (T)(size_t rows, size_t cols, T init);
MatrixView!(T,stor,tri) matrix (T, Storage stor, Triangle tri = Triangle.Upper)(size_t n, T init = T.init);
A convenience function that allocates heap memory for a matrix , optionally sets the values of the matrix elements, and returns a MatrixView of the allocated memory.

    // Allocate general dense 3x4 matrix:
    auto denseMatrix = matrix!real(3, 4);

    // Allocate dense 3x2 zero-filled matrix:
    auto denseZeroMatrix = matrix!real(3, 2, 0.0L);

    // Allocate lower triangular 3x3 matrix:
    auto loMatrix = matrix!(real, Storage.Triangular, Triangle.Lower)(3);

    // Allocate upper triangular 2x2 matrix where the upper
    // triangular elements are set to 3.14.
    auto upMatrix = matrix!(real, Storage.Triangular)(2, 3.14L);

MatrixView!(T,stor,tri) copy (T, Storage stor, Triangle tri)(const MatrixView!(T,stor,tri) m);
A convenience function that creates a copy of the input matrix.

struct MatrixView (T,Storage stor = Storage.General,Triangle tri = Triangle.Upper);
This struct provides a matrix-like view of the contents of an array. In order to be compatible with LAPACK routines, it supports the following matrix representations (i.e. memory layouts).

General matrices:
The elements of dense matrices are stored in column-major order. This means that if the wrapped array contains the elements
    a b c d e f g h i j k l
then a 3x4 dense matrix view of this array looks like this:
    a d g j
    b e h k
    c f i l

Triangular matrices:
Triangular matrices are required to be square. If the wrapped array contains the six elements
    a b c d e f
then the resulting 3x3 upper and lower triangular matrix views will look like this, respectively:
    a b d         a 0 0
    0 c e   and   b d 0
    0 0 f         c e f

Symmetric matrices:
Symmetric matrices are stored in the same way as triangular matrices. This means that for the array above, the corresponding symmetric matrix view will be
    a b d       a b c
    b c e   or  b d c
    d e f       c e f
depending on whether the upper or lower triangle is stored.

Hermitian matrices:
Hermitian matrices are not implemented yet.

See Also:
LAPACK User's Guide: Matrix storage schemes,

T[] array ;
The array that is wrapped by this MatrixView.

size_t rows ;
The number of rows in the matrix.

size_t cols ;
The number of columns in the matrix.

alias leading ;
The leading (row) dimension. Included to support matrix slicing, currently just an alias to rows.

__ctor ;
Wrap a MatrixView with m rows around the given array.

For general matrices, the number of columns in the matrix is set to a.length/m, whereas for triangular and symmetric matrices the number of columns is set equal to the number of rows.

__ctor ;
Wrap a MatrixView with m rows and n columns around the given array. For a given set of a, m, and n, the following must be true for a general matrix:
        a.length >= m*n
For triangular and symmetric matrices, there are two constraints:
        m == n
        a.length >= (n*n + n)/2
These conditions are only checked in non-release builds.

pure nothrow T opIndex (size_t i, size_t j);
Return (a reference to) the element at row i, column j.

For convenience, this method returns values by reference. This means that one can do stuff like this:
        m[1,2] += 3.14;
Unfortunately, it also means that in a triangular matrix one can change the zero element (which is common for all zero elements).
        assert ((m[1,0] == 0.0)  &&  m[2,0] == 0.0);
        m[1,0] += 3.14;
        assert (m[2,0] == 3.14);    // passes
You are hereby warned.

nothrow T opIndexAssign (T value, size_t i, size_t j);
Assign a value to the element at row i, column j.

Unlike opIndex(), this method checks that zero elements in a triangular matrix aren't assigned to, but only in non-release builds.

template isMatrixView (MatrixT)
template isMatrixView (MatrixT,ElemT)
template isMatrixView (MatrixT,Storage stor)
template isMatrixView (MatrixT,ElemT,Storage stor)
Evaluates to true if the given type is an instantiation of MatrixView. Optionally test the element type and/or storage scheme.

Page was generated with on Sat Jun 25 02:35:10 2011