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.SparseSquareMatrix Class Reference

Represents a sparse, square matrix. More...

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

Public Member Functions

 SparseSquareMatrix (int dimension)
 Initializes a new sparse, square matrix. More...
 
override RowVector Row (int r)
 Gets a copy of the specified row.
Parameters
rThe (zero-based) row index.
Returns
An independent copy of the specified row.
More...
 
override ColumnVector Column (int c)
 Gets a copy of the specified column.
Parameters
cThe (zero-based) column index.
Returns
An independent copy of the specified column.
More...
 
SparseSquareMatrix Copy ()
 Copies the matrix. More...
 
ColumnVector Solve (ColumnVector rhs)
 Solves Ax = b using iterative methods. More...
 
- Public Member Functions inherited from Meta.Numerics.Matrices.AnySquareMatrix
virtual double Trace ()
 Computes the trace of the square 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 ∞-norm of the matrix. More...
 
virtual double FrobeniusNorm ()
 Computes the Frobenius-norm of the matrix. 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 SparseSquareMatrix operator* (double alpha, SparseSquareMatrix A)
 Multiplies a sparse matrix by a real scalar. More...
 
static ColumnVector operator* (SparseSquareMatrix A, ColumnVector v)
 Multiplies a column vector by a sparse matrix. More...
 
static RowVector operator* (RowVector v, SparseSquareMatrix A)
 Multiplies a sparse matrix by a row vector. 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]
 
override double this[int r, int c] [get, set]
 
int FillCount [get]
 Gets the number of non-zero matrix entries. More...
 
double FillFraction [get]
 Gets the fraction of matrix entries that are non-zero. 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 Member Functions

SparseMatrixElement GetElement (int r, int c)
 
SparseMatrixElement SetElement (int r, int c, double value)
 

Private Attributes

int dimension
 
SparseMatrixElement[] rows
 
SparseMatrixElement[] columns
 
int fill
 

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 sparse, square matrix.

Many applications give rise to very large matrices which consist mostly of zero elements.

When working with sparse matrices, it is important to keep in mind that many operations do not respect sparsity. For example, the product of two sparse matrices is not necessarily sparse, nor is the inverse of a sparse matrix.

Constructor & Destructor Documentation

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

Initializes a new sparse, square matrix.

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

Member Function Documentation

SparseMatrixElement Meta.Numerics.Matrices.SparseSquareMatrix.GetElement ( int  r,
int  c 
)
inlineprivate
SparseMatrixElement Meta.Numerics.Matrices.SparseSquareMatrix.SetElement ( int  r,
int  c,
double  value 
)
inlineprivate
override RowVector Meta.Numerics.Matrices.SparseSquareMatrix.Row ( int  r)
inlinevirtual

Gets a copy of the specified row.

Parameters
rThe (zero-based) row index.
Returns
An independent copy of the specified row.

Reimplemented from Meta.Numerics.Matrices.AnyRectangularMatrix.

Referenced by Test.SparseSquareMatrixTest.SparseSquareMatrixRowsAndColumns().

override ColumnVector Meta.Numerics.Matrices.SparseSquareMatrix.Column ( int  c)
inlinevirtual

Gets a copy of the specified column.

Parameters
cThe (zero-based) column index.
Returns
An independent copy of the specified column.

Reimplemented from Meta.Numerics.Matrices.AnyRectangularMatrix.

Referenced by Test.SparseSquareMatrixTest.SparseSquareMatrixRowsAndColumns().

SparseSquareMatrix Meta.Numerics.Matrices.SparseSquareMatrix.Copy ( )
inline

Copies the matrix.

Returns
An independent copy of the matrix.

Referenced by Meta.Numerics.Matrices.SparseSquareMatrix.operator*(), and Test.SparseSquareMatrixTest.SparseSquareMatrixCopy().

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

Multiplies a sparse matrix by a real scalar.

Parameters
alphaThe scalar value.
AThe sparse matrix.
Returns
The product sparse matrix.

References Meta.Numerics.Matrices.SparseSquareMatrix.Copy(), Meta.Numerics.Matrices.SparseSquareMatrix.dimension, and Meta.Numerics.Matrices.SparseSquareMatrix.rows.

static ColumnVector Meta.Numerics.Matrices.SparseSquareMatrix.operator* ( SparseSquareMatrix  A,
ColumnVector  v 
)
inlinestatic

Multiplies a column vector by a sparse matrix.

Parameters
AThe matrix.
vThe column vector.
Returns
The product column vector.

References Meta.Numerics.Matrices.VectorBase.Dimension, Meta.Numerics.Matrices.SparseSquareMatrix.Dimension, and Meta.Numerics.Matrices.SparseSquareMatrix.rows.

static RowVector Meta.Numerics.Matrices.SparseSquareMatrix.operator* ( RowVector  v,
SparseSquareMatrix  A 
)
inlinestatic

Multiplies a sparse matrix by a row vector.

Parameters
AThe matrix.
vThe row vector.
Returns
The product row vector.

References Meta.Numerics.Matrices.SparseSquareMatrix.columns, Meta.Numerics.Matrices.VectorBase.Dimension, and Meta.Numerics.Matrices.SparseSquareMatrix.Dimension.

ColumnVector Meta.Numerics.Matrices.SparseSquareMatrix.Solve ( ColumnVector  rhs)
inline

Solves Ax = b using iterative methods.

Parameters
rhsThe right-hand side vector b.
Returns
The solution vector x.

In general, neither the inverse nor any decomposition of a sparse matrix is itself sparse. Therefore, to solve large, sparse linear systems, iterative methods are employed. An iterative method begins with an approximate or guessed solution vector and progresses toward an improved solution. Iterative methods are often successful at converging to a sufficiently accurate solution vector, but this is not guaranteed. If this method fails to converge, it throws a NonconvergenceException.

Exceptions
ArgumentNullExceptionrhs is null.
DimensionMismatchExceptionrhs 's dimension does not equal the matrix's dimension.
NonconvergenceExceptionThe method did not converge to a solution.

References Meta.Numerics.Matrices.VectorBase.Dimension, Meta.Numerics.Matrices.AnyRectangularMatrix.FrobeniusNorm(), and Meta.Numerics.Matrices.ColumnVector.Transpose().

Referenced by Test.SparseSquareMatrixTest.SparseSquareMatrixPotential(), and Test.SparseSquareMatrixTest.SparseSquareMatrixSolutionAgreement().

Member Data Documentation

int Meta.Numerics.Matrices.SparseSquareMatrix.dimension
private
SparseMatrixElement [] Meta.Numerics.Matrices.SparseSquareMatrix.rows
private
SparseMatrixElement [] Meta.Numerics.Matrices.SparseSquareMatrix.columns
private
int Meta.Numerics.Matrices.SparseSquareMatrix.fill
private

Property Documentation

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

int Meta.Numerics.Matrices.SparseSquareMatrix.FillCount
get
double Meta.Numerics.Matrices.SparseSquareMatrix.FillFraction
get

Gets the fraction of matrix entries that are non-zero.

Referenced by Test.SparseSquareMatrixTest.SparseSquareMatrixManipulation().


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