Struct MatrixView

A matrix-like view of the contents of an array.

struct MatrixView(T, Storage stor = Storage.General, Triangle tri = Triangle.Upper) ;

In order to be compatible with LAPACK routines, the following matrix representations (i.e., memory layouts) are supported.

Constructors

NameDescription
this Wraps a MatrixView with m rows around the given array.
this Wraps 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:

Fields

NameTypeDescription
array T[]The array that is wrapped by this MatrixView.
cols size_tThe number of columns in the matrix.
rows size_tThe number of rows in the matrix.

Methods

NameDescription
opIndex Returns (a reference to) the element at row i, column j.
opIndexAssign Assigns a value to the element at row i, column j.

Aliases

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

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 e
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, http://www.netlib.org/lapack/lug/node121.html