# Matrix<T> Class

Represents a matrix, a two-dimensional array of real numbers.

## Definition

Namespace: Extreme.Mathematics
Assembly: Extreme.Numerics (in Extreme.Numerics.dll) Version: 8.1.23
C#
``````public abstract class Matrix<T> : LinearOperator<T>,
IFormattable, IDisposable, ISummarizable, IEquatable<Matrix<T>>,
IDataFrame, IStructuralEquatable, IStructuralComparable
``````
Inheritance
Object  →  LinearOperator<T>  →  Matrix<T>
Derived
More
Implements
IDataFrame, ISummarizable, IStructuralComparable, IStructuralEquatable, IDisposable, IEquatable<Matrix<T>>, IFormattable

T

## Remarks

Matrix<T> is the abstract base class for representing matrices, two-dimensional arrays of numbers. An application can perform operations on matrices using instances of the Matrix<T> class, while descendant classes implement specialized algorithms for specific types of matrices.

The matrix class provides methods and properties for all the common operations on matrices, including arithmetic operations, calculating norms and solving systems of simultaneous linear equations. Various methods allow you to access individual elements as well as rows and columns and submatrices.

Since Matrix<T> is an abstract base class and cannot be instantiated directly. Instead, use one of its derived classes. These are:

ClassDescription
DenseMatrix<T>Represents a general, dense, square or rectangular matrix.
triangular matrixRepresents an upper or lower-triangular matrix, a matrix whose elements below or above the main diagonal are zero.
symmetric matrixRepresents a square matrix whose elements are symmetrical around the main diagonal.

Note that the specialized classes exploit certain structural properties to perform many calculations more quickly than the general algorithms implemented by Matrix<T>.

Matrix<T> provides an indexer property. For convenient access to the rows or columns of a matrix or parts thereof, use the [o:GetRow] and [o:GetColumn] methods.

Overloaded versions of the major arithmetic operators are provided for languages that support them. For languages that don't support operator overloading, equivalent static methods are supplied.

Many matrix decompositions exist, serving a variety of purposes. Each of them has its own class. In this release the LU decomposition and the QR decomposition are supported. For positive-definite symmetric matrices, the CholeskyDecomposition<T> is available.

## Constructors

 Matrix(SerializationInfo, StreamingContext) Constructs a new matrix from serialization values. Matrix(Int32, Int32, ArrayAttributes) Constructs a new matrix of the specified dimensions using the specified values array.

## Properties

 CanReshape Gets whether the matrix can be reshaped into a vector or a matrix. ColumnCount Gets the number of columns in the matrix. (Inherited from LinearOperator) ColumnIndex Gets or sets the index of labels for the columns of the matrix. (Inherited from LinearOperator)Preliminary Columns Gets the ColumnCollection for this instance. ColumnwiseComponents Enumerates the elements of the matrix column by column. ElementOrder Gets a value indicating the order in which the matrix elements are stored. ElementType Gets the element type of the matrix. (Inherited from LinearOperator) IsHermitian Gets a value that indicates if the matrix is Hermitian about the main diagonal. IsImmutable Gets whether the elements of the matrix are immutable. IsLowerTriangular Gets a value that indicates if all elements of the matrix above the main diagonal are zero. IsReadOnly Gets whether the matrix can be written to. IsSparse Gets a value that indicates whether the matrix is sparse. IsSymmetrical Gets a value that indicates if the matrix is symmetrical about the main diagonal. IsUnitDiagonal Gets a value indicating whether all diagonal elements of this instance are equal to 1. IsUpperTriangular Gets a value that indicates if all elements of the matrix below the main diagonal are zero. Item[Func, Int32] Gets or sets the elements of a column of the matrix that meet the specified condition. Item[IEnumerable, Range] Gets or sets the elements of a matrix with the specified row indexes and column range. Item[IEnumerable, IEnumerable] Gets or sets the elements of a matrix with the specified row and column indexes. Item[IEnumerable, Int32] Gets or sets the elements of a column with the specified indexes. Item[IEnumerable, Range] Gets or sets the elements of a matrix with the specified row indexes and column range. Item[Index, Index] Gets or sets the specified element in this matrix. Item[Index, Range] Gets or sets the elements of a row of this matrix. Item[Int32, Range] Gets or sets the elements of a row of this matrix. Item[Int32, Vector] Gets or sets the elements of a row of this matrix. Item[Int32, IEnumerable] Gets or sets the elements of a row with the specified indexes. Item[Int32, Func] Gets or sets the elements of a row of the matrix that meet the specified condition. Item[Int32, Int32] Gets or sets the specified element in this matrix. Item[Range, Range] Gets or sets the elements of a sub-matrix of this matrix. Item[Range, IEnumerable] Gets or sets the elements of a matrix with the specified row range and column indexes. Item[Range, Int32] Gets or sets the elements of a column of this matrix. Item[Range, IEnumerable] Gets or sets the elements of a matrix with the specified row range and column indexes. Item[Range, Index] Gets or sets the elements of a column of this matrix. Item[Range, Range] Gets or sets the elements of a sub-matrix of this matrix. Item[Vector, Int32] Gets or sets the elements of a column of this matrix. MatrixDiagonal Gets a value indicating whether all diagonal elements of this instance are structurally equal to 1. MatrixTriangle Gets a value that indicates whether a triangular matrix is upper or lower triangular. NonzeroComponents Gets a collection of the nonzero elements of the matrix. Obsolete. NonzeroElements Gets a collection of the nonzero elements of the matrix. Precedence Infrastructure. This property supports the Numerical Libraries for .NET infrastructure and is not intended to be used directly from your code. RowCount Gets the number of rows in the matrix. (Inherited from LinearOperator) RowIndex Gets or sets the index of labels for the rows of the matrix. (Inherited from LinearOperator)Preliminary Rows Gets the RowCollection for this instance. RowwiseComponents Enumerates the elements of the matrix column by column. Structure Gets a value that indicates the structure of the sparse matrix. WritableComponents Enumerates the writable elements of the matrix column by column.