The RowCount
and ColumnCount properties returns the number of rows and
columns in the matrix.
The ElementOrder
property specifies the order in which elements are stored. Possible values are
ColumnMajor , RowMajor, and
NotApplicable. These are enumerated by the
MatrixElementOrder
enumeration type.
ColumnMajor order means that, whenever possible,
the elements in the same column of a matrix are stored in a contiguous block of memory.
Likewise, RowMajor order means that elements in the same row are
stored contiguously. Most algorithms have been optimized for column-major order.
Conversions are performed as necessary.
For some matrix types, the element order is meaningless.
In this case, the value is NotApplicable.
The ToArray
method returns an array containing the elements of the matrix.
The desired element order can be specified as a
MatrixElementOrder
value. The default is ColumnMajor.
This method always returns a new array.
The following example illustrates these properties:
var m = Matrix.Create(2, 2, new[] { 1.0, 2.0, 4.0, 8.0 },
MatrixElementOrder.RowMajor);
var rowCount = m.RowCount;
var columnCount = m.ColumnCount;
var elements = m.ToArray();
var elementsByRow = m.ToArray(MatrixElementOrder.RowMajor);
Dim m = Matrix.Create(2, 2, New Double() {1.0, 2.0, 4.0, 8.0},
MatrixElementOrder.RowMajor)
Dim rowCount = m.RowCount
Dim columnCount = m.ColumnCount
Dim elements = m.ToArray()
Dim elementsByRow = m.ToArray(MatrixElementOrder.RowMajor)
No code example is currently available or this language may not be supported.
let m = Matrix.Create(2, 2, [| 1.0; 2.0; 4.0; 8.0 |],
MatrixElementOrder.RowMajor)
let rowCount = m.RowCount
let columnCount = m.ColumnCount
let elements = m.ToArray()
let elementsByRow = m.ToArray(MatrixElementOrder.RowMajor)
Most common mathematical properties of matrices are costly to compute,
in particular for large matrices. Because of this,
these properties have been implemented as methods.
The norm of a matrix is a measure for the size of a matrix. Unlike vector norms,
matrix norms are often hard to calculate. The easiest to calculate is
the Frobenius-norm, defined as the square root of the sum of the squares
of the elements of a matrix. The
FrobeniusNorm
method returns the Frobenius norm.
The one-norm of a matrix is defined as the maximum of the sum of the absolute values
of the elements in each column. It is available through the
OneNorm
method.
The infinity-norm of a matrix is defined as the maximum of the sum
of the absolute values of the elements in each row. It is available through the
InfinityNorm
method.
The two-norm of a matrix is defined as the largest increase in the length
(two-norm) of a vector when it is multiplied by the matrix. This corresponds
to the largest singular value of the matrix. It is available through the
TwoNorm method.
The trace of a matrix is the sum of the diagonal elements. It is available through the
Trace
method.
var m = Matrix.Create(2, 2, new[] { 1.0, 2.0, 4.0, 8.0 },
MatrixElementOrder.RowMajor);
var rowCount = m.RowCount;
var columnCount = m.ColumnCount;
var elements = m.ToArray();
var elementsByRow = m.ToArray(MatrixElementOrder.RowMajor);
Dim m = Matrix.Create(2, 2, New Double() {1.0, 2.0, 4.0, 8.0},
MatrixElementOrder.RowMajor)
Dim rowCount = m.RowCount
Dim columnCount = m.ColumnCount
Dim elements = m.ToArray()
Dim elementsByRow = m.ToArray(MatrixElementOrder.RowMajor)
No code example is currently available or this language may not be supported.
let m = Matrix.Create(2, 2, [| 1.0; 2.0; 4.0; 8.0 |],
MatrixElementOrder.RowMajor)
let rowCount = m.RowCount
let columnCount = m.ColumnCount
let elements = m.ToArray()
let elementsByRow = m.ToArray(MatrixElementOrder.RowMajor)
Other properties, such as the inverse, transpose, and determinant are covered
in the section on Solving Systems Of Linear Equations.