IGLib
1.7.2
The IGLib base library EXTENDED - with other lilbraries and applications.
|
Represents a sparse, square matrix. More...
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.
| |||
override ColumnVector | Column (int c) | ||
Gets a copy of the specified column.
| |||
SparseSquareMatrix | Copy () | ||
Copies the matrix. More... | |||
ColumnVector | Solve (ColumnVector rhs) | ||
Solves Ax = b using iterative methods. More... | |||
![]() | |||
virtual double | Trace () | ||
Computes the trace of the square matrix. More... | |||
![]() | |||
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... | |||
![]() | |||
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 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 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... | |
![]() | |
abstract int | Dimension [get] |
Gets or sets the dimension of the square matrix. More... | |
override int | RowCount [get] |
override int | ColumnCount [get] |
![]() | |
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 | |
![]() | |
AnyRectangularMatrix () | |
![]() | |
AnyMatrix () | |
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.
|
inline |
Initializes a new sparse, square matrix.
dimension | The dimension of the matrix, which must be positive. |
|
inlineprivate |
|
inlineprivate |
|
inlinevirtual |
Gets a copy of the specified row.
r | The (zero-based) row index. |
Reimplemented from Meta.Numerics.Matrices.AnyRectangularMatrix.
Referenced by Test.SparseSquareMatrixTest.SparseSquareMatrixRowsAndColumns().
|
inlinevirtual |
Gets a copy of the specified column.
c | The (zero-based) column index. |
Reimplemented from Meta.Numerics.Matrices.AnyRectangularMatrix.
Referenced by Test.SparseSquareMatrixTest.SparseSquareMatrixRowsAndColumns().
|
inline |
Copies the matrix.
Referenced by Meta.Numerics.Matrices.SparseSquareMatrix.operator*(), and Test.SparseSquareMatrixTest.SparseSquareMatrixCopy().
|
inlinestatic |
Multiplies a sparse matrix by a real scalar.
alpha | The scalar value. |
A | The sparse matrix. |
References Meta.Numerics.Matrices.SparseSquareMatrix.Copy(), Meta.Numerics.Matrices.SparseSquareMatrix.dimension, and Meta.Numerics.Matrices.SparseSquareMatrix.rows.
|
inlinestatic |
Multiplies a column vector by a sparse matrix.
A | The matrix. |
v | The column vector. |
References Meta.Numerics.Matrices.VectorBase.Dimension, Meta.Numerics.Matrices.SparseSquareMatrix.Dimension, and Meta.Numerics.Matrices.SparseSquareMatrix.rows.
|
inlinestatic |
Multiplies a sparse matrix by a row vector.
A | The matrix. |
v | The row vector. |
References Meta.Numerics.Matrices.SparseSquareMatrix.columns, Meta.Numerics.Matrices.VectorBase.Dimension, and Meta.Numerics.Matrices.SparseSquareMatrix.Dimension.
|
inline |
Solves Ax = b using iterative methods.
rhs | The right-hand side vector b. |
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.
ArgumentNullException | rhs is null. |
DimensionMismatchException | rhs 's dimension does not equal the matrix's dimension. |
NonconvergenceException | The 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().
|
private |
Referenced by Meta.Numerics.Matrices.SparseSquareMatrix.operator*().
|
private |
Referenced by Meta.Numerics.Matrices.SparseSquareMatrix.operator*().
|
private |
Referenced by Meta.Numerics.Matrices.SparseSquareMatrix.operator*().
|
private |
|
get |
|
getset |
|
get |
Gets the number of non-zero matrix entries.
Referenced by Test.SparseSquareMatrixTest.SparseSquareMatrixCopy(), and Test.SparseSquareMatrixTest.SparseSquareMatrixManipulation().
|
get |
Gets the fraction of matrix entries that are non-zero.
Referenced by Test.SparseSquareMatrixTest.SparseSquareMatrixManipulation().