Function matrix
A convenience function that allocates memory for a matrix (using the GC), optionally sets the values of the matrix elements, and returns a MatrixView of the allocated memory.
MatrixView!T matrix(T)
(
size_t rows,
size_t cols
) pure;
MatrixView!T matrix(T)
(
size_t rows,
size_t cols,
T init
) pure;
MatrixView!(T,stor,tri) matrix(T, Storage stor, Triangle tri = Triangle .Upper)
(
size_t n,
T init = T .init
) pure
if (stor == Storage .Triangular);
Examples
// 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);