IGLib  1.7.2
The IGLib base library EXTENDED - with other lilbraries and applications.
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Events Macros
Meta.Numerics.Matrices.SymmetricMatrix Class Reference

Represents a symmetric matrix. More...

+ Inheritance diagram for Meta.Numerics.Matrices.SymmetricMatrix:
+ Collaboration diagram for Meta.Numerics.Matrices.SymmetricMatrix:

Public Member Functions

 SymmetricMatrix (int dimension)
 Initializes a new symmetric matrix. More...
 
override void Fill (Func< int, int, double > f)
 
SymmetricMatrix Copy ()
 Copies the matrix. More...
 
override double Trace ()
 Computes the trace of the matrix. More...
 
SymmetricMatrix Inverse ()
 Computes the inverse of the matrix. More...
 
CholeskyDecomposition CholeskyDecomposition ()
 Returns the Cholesky decomposition of the matrix. More...
 
RealEigensystem Eigensystem ()
 Computes the eigenvalues and eigenvectors of the matrix. More...
 
double[] Eigenvalues ()
 Computes the eigenvalues of the matrix. More...
 
- Public Member Functions inherited from Meta.Numerics.Matrices.AnyRectangularMatrix
virtual double OneNorm ()
 Computes the 1-norm of the matrix. More...
 
virtual double InfinityNorm ()
 Computes the &#x221E;-norm of the matrix. More...
 
virtual double FrobeniusNorm ()
 Computes the Frobenius-norm of the matrix. More...
 
virtual ColumnVector Column (int c)
 Gets a copy of the specified column. More...
 
virtual RowVector Row (int r)
 Gets a copy of the specified row. More...
 
virtual SymmetricMatrix MultiplySelfByTranspose ()
 Computes the product of the matrix and its transpose. More...
 
virtual SymmetricMatrix MultiplyTransposeBySelf ()
 Computes the product of the matrix's transpose and itself. More...
 
bool Equals (AnyRectangularMatrix other)
 Determines whether the given matrix equals the current matrix. More...
 
override bool Equals (object obj)
 Determines whether the given object is an equal matrix. More...
 
override int GetHashCode ()
 Not a valid operation. More...
 
- Public Member Functions inherited from Meta.Numerics.Matrices.AnyMatrix< T >
virtual void Fill (Func< int, int, T > f)
 Sets all matrix entries according to a supplied fill function. More...
 
virtual T[,] ToArray ()
 Copies the matrix into an array. More...
 

Static Public Member Functions

static SymmetricMatrix operator+ (SymmetricMatrix A, SymmetricMatrix B)
 Adds two symmetric matrices. More...
 
static SymmetricMatrix operator- (SymmetricMatrix A, SymmetricMatrix B)
 Subtracts two symmetric matrices. More...
 
static SymmetricMatrix operator* (double alpha, SymmetricMatrix A)
 Multiplies a symmetric matrix by a real factor. More...
 
static SymmetricMatrix operator- (SymmetricMatrix A)
 Negates a symmetric matrix. More...
 
- Static Public Member Functions inherited from Meta.Numerics.Matrices.AnySquareMatrix
static SquareMatrix operator+ (AnySquareMatrix A, AnySquareMatrix B)
 Adds any two real, square matrices. More...
 
static SquareMatrix operator- (AnySquareMatrix A, AnySquareMatrix B)
 Subtracts any two real, square matrices. More...
 
static SquareMatrix operator* (AnySquareMatrix A, AnySquareMatrix B)
 Multiplies any two real, square matrices. More...
 
- Static Public Member Functions inherited from Meta.Numerics.Matrices.AnyRectangularMatrix
static RectangularMatrix operator+ (AnyRectangularMatrix A, AnyRectangularMatrix B)
 Adds any two real, rectangular matrices. More...
 
static RectangularMatrix operator- (AnyRectangularMatrix A, AnyRectangularMatrix B)
 Subtracts any two real, rectangular matrices. More...
 
static RectangularMatrix operator* (AnyRectangularMatrix A, AnyRectangularMatrix B)
 Multiplies any two real, rectangular matrices. More...
 
static RectangularMatrix operator* (double alpha, AnyRectangularMatrix A)
 Multiplies any real, rectangular matrix by a real constant. More...
 
static ColumnVector operator* (AnyRectangularMatrix A, ColumnVector v)
 Multiplies any real, rectangular matrix with a real column vector. More...
 
static bool operator== (AnyRectangularMatrix A, AnyRectangularMatrix B)
 Determines whether two matrices are equal. More...
 
static bool operator!= (AnyRectangularMatrix A, AnyRectangularMatrix B)
 Determines whether two matrices are not equal. More...
 

Properties

override int Dimension [get]
 Gets the dimension of the matrix. More...
 
override double this[int r, int c] [get, set]
 Gets or sets an element of the matrix. More...
 
- Properties inherited from Meta.Numerics.Matrices.AnySquareMatrix
abstract int Dimension [get]
 Gets or sets the dimension of the square matrix. More...
 
override int RowCount [get]
 
override int ColumnCount [get]
 
- Properties inherited from Meta.Numerics.Matrices.AnyMatrix< T >
abstract int RowCount [get]
 Gets the number of matrix rows. More...
 
abstract int ColumnCount [get]
 Gets the number of matrix columns. More...
 
abstract T this[int r, int c] [get, set]
 Gets or sets the value of a matrix entry. More...
 
bool IsReadOnly [get, set]
 Gets a flag indicating whether the matrix is read-only. More...
 

Private Attributes

int dimension
 
double[][] values
 

Additional Inherited Members

- Protected Member Functions inherited from Meta.Numerics.Matrices.AnyRectangularMatrix
 AnyRectangularMatrix ()
 
- Protected Member Functions inherited from Meta.Numerics.Matrices.AnyMatrix< T >
 AnyMatrix ()
 

Detailed Description

Represents a symmetric matrix.

Constructor & Destructor Documentation

Meta.Numerics.Matrices.SymmetricMatrix.SymmetricMatrix ( int  dimension)
inline

Initializes a new symmetric matrix.

Parameters
dimensionThe dimension of the matrix, which must be positive.

Member Function Documentation

override void Meta.Numerics.Matrices.SymmetricMatrix.Fill ( Func< int, int, double >  f)
inline

SymmetricMatrix Meta.Numerics.Matrices.SymmetricMatrix.Copy ( )
inline
override double Meta.Numerics.Matrices.SymmetricMatrix.Trace ( )
inlinevirtual

Computes the trace of the matrix.

Returns
The trace of the matrix tr(M).

Reimplemented from Meta.Numerics.Matrices.AnySquareMatrix.

Referenced by Test.SymmetricMatrixTest.SymmetricHilbertMatrixEigenvalues(), and Test.SymmetricMatrixTest.SymmetricRandomMatrixEigenvectors().

SymmetricMatrix Meta.Numerics.Matrices.SymmetricMatrix.Inverse ( )
inline
CholeskyDecomposition Meta.Numerics.Matrices.SymmetricMatrix.CholeskyDecomposition ( )
inline

Returns the Cholesky decomposition of the matrix.

Returns
The Cholesky decomposition of the matrix, or null if the matrix is not positive definite.

A Cholesky decomposition is a special decomposition that is possible only for positive definite matrices. (A positive definite matrix M has xTMx > 0 for any vector x. Equivilently, M is positive definite if all its eigenvalues are positive.)

The Cholesky decomposition represents M = C CT, where C is lower-left triangular (and thus CT is upper-right triangular. It is basically an LU decomposition where the L and U factors are related by transposition. Since the M is produced by multiplying C "by itself", the matrix C is sometimes call the "square root" of M.

Cholesky decomposition is an O(N3) operation. It is about a factor of two faster than LU decomposition, so it is a faster way to obtain inverses, determinates, etc. if you know that M is positive definite.

The fastest way to test whether your matrix is positive definite is attempt a Cholesky decomposition. If this method returns null, M is not positive definite.

See also
Meta.Numerics.Matrices.CholeskyDecomposition

Referenced by Test.SymmetricMatrixTest.CatalanHankelMatrixDeterminant(), Test.MultivariateSampleTest.CreateMultivariateNormalSample(), Meta.Numerics.Statistics.UncertainMeasurementSample< T >.FitToFunction(), Meta.Numerics.Statistics.Distributions.WeibullDistribution.FitToSample(), Meta.Numerics.Statistics.Distributions.BetaDistribution.FitToSample(), Meta.Numerics.Statistics.Distributions.GammaDistribution.FitToSample(), Test.MultiIntegrateTest.GaussianIntegrals(), Meta.Numerics.Statistics.MultivariateSample.LinearRegression_Internal(), Meta.Numerics.Statistics.Sample.MaximumLikelihoodFit(), Test.SymmetricMatrixTest.SymmetricMatrixDecomposition(), and Test.SymmetricMatrixTest.SymmetricRandomMatrixCholeskyDecomposition().

RealEigensystem Meta.Numerics.Matrices.SymmetricMatrix.Eigensystem ( )
inline

Computes the eigenvalues and eigenvectors of the matrix.

Returns
A representation of the eigenvalues and eigenvectors of the matrix.

For a generic vector v and matrix M, Mv = u will point in some direction with no particular relationship to v. The eigenvectors of a matrix M are vectors z that satisfy Mz = &#x3BB;z, i.e. multiplying an eigenvector by a matrix reproduces the same vector, up to a prortionality constant &#x3BB; called the eigenvalue.

For v to be an eigenvector of M with eigenvalue &#x3BB;, (M - &#x3BB;I)z = 0. But for a matrix to anihilate any non-zero vector, that matrix must have determinant, so det(M - &#x3BB;I)=0. For a matrix of order N, this is an equation for the roots of a polynomial of order N. Since an order-N polynomial always has exactly N roots, an order-N matrix always has exactly N eigenvalues.

An alternative way of expressing the same relationship is to say that the eigenvalues of a matrix are its diagonal elements when the matrix is expressed in a basis that diagonalizes it. That is, given Z such that Z-1MZ = D, where D is diagonal, the columns of Z are the eigenvectors of M and the diagonal elements of D are the eigenvalues.

Note that the eigenvectors of a matrix are not entirely unique. Given an eigenvector z, any scaled vector &#x3B1;z is an eigenvector with the same eigenvalue, so eigenvectors are at most unique up to a rescaling. If an eigenvalue is degenerate, i.e. there are two or more linearly independent eigenvectors with the same eigenvalue, then any linear combination of the eigenvectors is also an eigenvector with that eigenvalue, and in fact any set of vectors that span the same subspace could be taken as the eigenvector set corresponding to that eigenvalue.

The eigenvectors of a symmetric matrix are always orthogonal and the eigenvalues are always real. The transformation matrix Z is thus orthogonal (Z-1 = ZT).

Finding the eigenvalues and eigenvectors of a symmetric matrix is an O(N3) operation.

If you require only the eigenvalues, not the eigenvectors, of the matrix, the Eigenvalues method will produce them faster than this method.

Referenced by Test.SymmetricMatrixTest.SymmetricRandomMatrixEigenvectors().

double [] Meta.Numerics.Matrices.SymmetricMatrix.Eigenvalues ( )
inline

Computes the eigenvalues of the matrix.

Returns
An array containing the matrix eigenvalues.

If you require only the eigenvalues of the matrix, not its eigenvectors, this method will return them faster than the Eigensystem method. If you do need the eigenvectors as well as the eigenvalues, use the Eigensystem method instead.

Referenced by Test.SymmetricMatrixTest.SymmetricHilbertMatrixEigenvalues().

static SymmetricMatrix Meta.Numerics.Matrices.SymmetricMatrix.operator+ ( SymmetricMatrix  A,
SymmetricMatrix  B 
)
inlinestatic

Adds two symmetric matrices.

Parameters
AThe first matrix.
BThe second matrix.
Returns
The sum A + B .

References Meta.Numerics.Matrices.SymmetricMatrix.dimension, and Meta.Numerics.Matrices.SymmetricMatrix.values.

static SymmetricMatrix Meta.Numerics.Matrices.SymmetricMatrix.operator- ( SymmetricMatrix  A,
SymmetricMatrix  B 
)
inlinestatic

Subtracts two symmetric matrices.

Parameters
AThe first matrix.
BThe second matrix.
Returns
The difference A - B .

References Meta.Numerics.Matrices.SymmetricMatrix.dimension, and Meta.Numerics.Matrices.SymmetricMatrix.values.

static SymmetricMatrix Meta.Numerics.Matrices.SymmetricMatrix.operator* ( double  alpha,
SymmetricMatrix  A 
)
inlinestatic

Multiplies a symmetric matrix by a real factor.

Parameters
alphaThe factor.
AThe matrix.
Returns
The product of the matrix and the factor.

References Meta.Numerics.Matrices.SymmetricMatrix.dimension, Meta.Numerics.Matrices.SymmetricMatrix.Dimension, and Meta.Numerics.Matrices.SymmetricMatrix.values.

static SymmetricMatrix Meta.Numerics.Matrices.SymmetricMatrix.operator- ( SymmetricMatrix  A)
inlinestatic

Negates a symmetric matrix.

Parameters
AThe matrix.
Returns
The matrix -A.

References Meta.Numerics.Matrices.SymmetricMatrix.dimension, Meta.Numerics.Matrices.SymmetricMatrix.Dimension, and Meta.Numerics.Matrices.SymmetricMatrix.values.

Member Data Documentation

Property Documentation

override double Meta.Numerics.Matrices.SymmetricMatrix.this[int r, int c]
getset

Gets or sets an element of the matrix.

Parameters
rThe (zero-based) row number.
cThe (zero-based) column number.
Returns
The value of the specified matrix entry Mr c.

The set operation preserves the symmetry of the matrix; when entry Mr c is changed, entry Mc r is updated automatically.


The documentation for this class was generated from the following file: