Class SparseMatrix
Class defining a sparse matrix.
Inherited Members
Namespace: BRIDGES.LinearAlgebra.Matrices
Assembly: BRIDGES.dll
Syntax
public abstract class SparseMatrix : Matrix, IGroupAction<Matrix, double>, IGroupAction<SparseMatrix, double>
Constructors
| Improve this Doc View SourceSparseMatrix(Int32, Int32)
Initialises a new instance of the SparseMatrix class.
Declaration
protected SparseMatrix(int rowCount, int columnCount)
Parameters
Type | Name | Description |
---|---|---|
Int32 | rowCount | Number of rows of the SparseMatrix. |
Int32 | columnCount | Number of columns of the SparseMatrix. |
Properties
| Improve this Doc View SourceItem[Int32]
Gets or sets the non-zero value of this sparse matrix at a given index.
Declaration
public abstract double this[int index] { get; set; }
Parameters
Type | Name | Description |
---|---|---|
Int32 | index | Index of the non-zero value to get. |
Property Value
Type | Description |
---|---|
Double | The non-zero value of this sparse matrix at the given index. |
NonZerosCount
Gets the number of non-zero values in this sparse matrix.
Declaration
public abstract int NonZerosCount { get; }
Property Value
Type | Description |
---|---|
Int32 |
Methods
| Improve this Doc View SourceAdd(SparseMatrix, SparseMatrix)
Computes the addition of two SparseMatrix.
Declaration
public static SparseMatrix Add(SparseMatrix left, SparseMatrix right)
Parameters
Type | Name | Description |
---|---|---|
SparseMatrix | left | Left SparseMatrix for the addition. |
SparseMatrix | right | Right SparseMatrix for the addition. |
Returns
Type | Description |
---|---|
SparseMatrix | The SparseMatrix resulting from the addition. |
Divide(SparseMatrix, Double)
Computes the scalar division of a SparseMatrix with a
Declaration
public static SparseMatrix Divide(SparseMatrix operand, double divisor)
Parameters
Type | Name | Description |
---|---|---|
SparseMatrix | operand | SparseMatrix to divide. |
Double | divisor |
Returns
Type | Description |
---|---|
SparseMatrix | The new SparseMatrix resulting from the scalar division. |
Multiply(SparseMatrix, SparseMatrix)
Computes the multiplication of two SparseMatrix.
Declaration
public static SparseMatrix Multiply(SparseMatrix left, SparseMatrix right)
Parameters
Type | Name | Description |
---|---|---|
SparseMatrix | left | Left SparseMatrix for the multiplication. |
SparseMatrix | right | Right SparseMatrix for the multiplication. |
Returns
Type | Description |
---|---|
SparseMatrix | The SparseMatrix resulting from the multiplication. |
Multiply(SparseMatrix, DenseVector)
Computes the right multiplication of a SparseMatrix with a DenseVector : A·V
.
Declaration
public static DenseVector Multiply(SparseMatrix matrix, DenseVector vector)
Parameters
Type | Name | Description |
---|---|---|
SparseMatrix | matrix | SparseMatrix to multiply on the right. |
DenseVector | vector | DenseVector to multiply with. |
Returns
Type | Description |
---|---|
DenseVector | The new DenseVector resulting from the multiplication. |
Multiply(SparseMatrix, SparseVector)
Computes the right multiplication of a SparseMatrix with a SparseVector : A·V
.
Declaration
public static SparseVector Multiply(SparseMatrix matrix, SparseVector vector)
Parameters
Type | Name | Description |
---|---|---|
SparseMatrix | matrix | SparseMatrix to multiply on the right. |
SparseVector | vector | SparseVector to multiply with. |
Returns
Type | Description |
---|---|
SparseVector | The new SparseVector resulting from the multiplication. |
Multiply(SparseMatrix, Vector)
Computes the right multiplication of a SparseMatrix with a Vector : A·V
.
Declaration
public static Vector Multiply(SparseMatrix matrix, Vector vector)
Parameters
Type | Name | Description |
---|---|---|
SparseMatrix | matrix | SparseMatrix to multiply on the right. |
Vector | vector | Vector to multiply with. |
Returns
Type | Description |
---|---|
Vector | The new Vector resulting from the multiplication. |
Multiply(SparseMatrix, Double)
Computes the right scalar multiplication of a SparseMatrix with a
Declaration
public static SparseMatrix Multiply(SparseMatrix operand, double factor)
Parameters
Type | Name | Description |
---|---|---|
SparseMatrix | operand | SparseMatrix to multiply on the right. |
Double | factor |
Returns
Type | Description |
---|---|
SparseMatrix | The new SparseMatrix resulting from the right scalar multiplication. |
Multiply(Double, SparseMatrix)
Computes the left scalar multiplication of a SparseMatrix with a
Declaration
public static SparseMatrix Multiply(double factor, SparseMatrix operand)
Parameters
Type | Name | Description |
---|---|---|
Double | factor | |
SparseMatrix | operand | SparseMatrix to multiply on the left. |
Returns
Type | Description |
---|---|
SparseMatrix | The new SparseMatrix resulting from the left scalar multiplication. |
NonZeros()
Provides an enumerable collection to iterate on the non-zero entries of the SparseMatrix non-zero entries.
Declaration
public abstract IEnumerable<(int rowIndex, int columnIndex, double value)> NonZeros()
Returns
Type | Description |
---|---|
IEnumerable<(, , )<Int32, Int32, Double>> | The enumerable collection containing row index, the column index and the value of the SparseMatrix non-zero entries. |
Subtract(SparseMatrix, SparseMatrix)
Computes the subtraction of two SparseMatrix.
Declaration
public static SparseMatrix Subtract(SparseMatrix left, SparseMatrix right)
Parameters
Type | Name | Description |
---|---|---|
SparseMatrix | left | Left SparseMatrix to subtract. |
SparseMatrix | right | Right SparseMatrix to subtract with. |
Returns
Type | Description |
---|---|
SparseMatrix | The SparseMatrix resulting from the subtraction. |
ToArray()
Translates this matrix into its bi-dimensional array representation.
Declaration
public override double[, ] ToArray()
Returns
Type | Description |
---|---|
Double[,] | The bi-dimensional array representing the matrix. |
Overrides
| Improve this Doc View SourceTranspose(SparseMatrix)
Transposes the SparseMatrix
Declaration
public static SparseMatrix Transpose(SparseMatrix matrix)
Parameters
Type | Name | Description |
---|---|---|
SparseMatrix | matrix | SparseMatrix to tranpose. |
Returns
Type | Description |
---|---|
SparseMatrix | The new SparseMatrix, transposed of the initial one. |
TransposeMultiply(SparseMatrix, DenseVector)
Computes the right multiplication of a SparseMatrix with a DenseVector : A·V
.
Declaration
public static DenseVector TransposeMultiply(SparseMatrix matrix, DenseVector vector)
Parameters
Type | Name | Description |
---|---|---|
SparseMatrix | matrix | SparseMatrix to multiply on the right. |
DenseVector | vector | DenseVector to multiply with. |
Returns
Type | Description |
---|---|
DenseVector | The new DenseVector resulting from the multiplication. |
TransposeMultiply(SparseMatrix, SparseVector)
Computes the right multiplication of a SparseMatrix with a SparseVector : A·V
.
Declaration
public static SparseVector TransposeMultiply(SparseMatrix matrix, SparseVector vector)
Parameters
Type | Name | Description |
---|---|---|
SparseMatrix | matrix | SparseMatrix to multiply on the right. |
SparseVector | vector | SparseVector to multiply with. |
Returns
Type | Description |
---|---|
SparseVector | The new SparseVector resulting from the multiplication. |
TransposeMultiply(SparseMatrix, Vector)
Computes the right multiplication of a transposed SparseMatrix with a Vector : At·V
.
Declaration
public static Vector TransposeMultiply(SparseMatrix matrix, Vector vector)
Parameters
Type | Name | Description |
---|---|---|
SparseMatrix | matrix | SparseMatrix to transpose then multiply on the right. |
Vector | vector | Vector to multiply with. |
Returns
Type | Description |
---|---|
Vector | The new Vector resulting from the multiplication. |
TransposeMultiplySelf(SparseMatrix)
Computes the left multiplication of a SparseMatrix with its transposition : At·A
.
Declaration
public static SparseMatrix TransposeMultiplySelf(SparseMatrix operand)
Parameters
Type | Name | Description |
---|---|---|
SparseMatrix | operand | SparseMatrix for the operation. |
Returns
Type | Description |
---|---|
SparseMatrix | The new SparseMatrix resulting from the operation. |
Operators
| Improve this Doc View SourceAddition(SparseMatrix, DenseMatrix)
Computes the right addition of a SparseMatrix with a DenseMatrix on the right.
Declaration
public static DenseMatrix operator +(SparseMatrix left, DenseMatrix right)
Parameters
Type | Name | Description |
---|---|---|
SparseMatrix | left | Left SparseMatrix for the addition. |
DenseMatrix | right | Right DenseMatrix for the addition. |
Returns
Type | Description |
---|---|
DenseMatrix | The new DenseMatrix resulting from the addition. |
Addition(SparseMatrix, Matrix)
Computes the right addition of a SparseMatrix with a Matrix on the right.
Declaration
public static Matrix operator +(SparseMatrix left, Matrix right)
Parameters
Type | Name | Description |
---|---|---|
SparseMatrix | left | Left SparseMatrix for the addition. |
Matrix | right | Right Matrix for the addition. |
Returns
Type | Description |
---|---|
Matrix | The new Matrix resulting from the addition. |
Addition(SparseMatrix, SparseMatrix)
Computes the addition of two SparseMatrix.
Declaration
public static SparseMatrix operator +(SparseMatrix left, SparseMatrix right)
Parameters
Type | Name | Description |
---|---|---|
SparseMatrix | left | Left SparseMatrix for the addition. |
SparseMatrix | right | Right SparseMatrix for the addition. |
Returns
Type | Description |
---|---|
SparseMatrix | The SparseMatrix resulting from the addition. |
Division(SparseMatrix, Double)
Computes the scalar division of a SparseMatrix with a
Declaration
public static SparseMatrix operator /(SparseMatrix operand, double divisor)
Parameters
Type | Name | Description |
---|---|---|
SparseMatrix | operand | SparseMatrix to divide. |
Double | divisor |
Returns
Type | Description |
---|---|
SparseMatrix | The new SparseMatrix resulting from the scalar division. |
Multiply(SparseMatrix, DenseMatrix)
Computes the right multiplication of a SparseMatrix with a DenseMatrix.
Declaration
public static DenseMatrix operator *(SparseMatrix left, DenseMatrix right)
Parameters
Type | Name | Description |
---|---|---|
SparseMatrix | left | Left SparseMatrix for the multiplication. |
DenseMatrix | right | Right DenseMatrix for the multiplication. |
Returns
Type | Description |
---|---|
DenseMatrix | The new DenseMatrix resulting from the multiplication. |
Multiply(SparseMatrix, Matrix)
Computes the right multiplication of a SparseMatrix with a Matrix.
Declaration
public static Matrix operator *(SparseMatrix left, Matrix right)
Parameters
Type | Name | Description |
---|---|---|
SparseMatrix | left | Left SparseMatrix for the multiplication. |
Matrix | right | Right Matrix for the multiplication. |
Returns
Type | Description |
---|---|
Matrix | The new Matrix resulting from the multiplication. |
Multiply(SparseMatrix, SparseMatrix)
Computes the multiplication of two SparseMatrix.
Declaration
public static SparseMatrix operator *(SparseMatrix left, SparseMatrix right)
Parameters
Type | Name | Description |
---|---|---|
SparseMatrix | left | Left SparseMatrix for the multiplication. |
SparseMatrix | right | Right SparseMatrix for the multiplication. |
Returns
Type | Description |
---|---|
SparseMatrix | The SparseMatrix resulting from the multiplication. |
Multiply(SparseMatrix, DenseVector)
Computes the right multiplication of a SparseMatrix with a DenseVector : A·V
.
Declaration
public static DenseVector operator *(SparseMatrix matrix, DenseVector vector)
Parameters
Type | Name | Description |
---|---|---|
SparseMatrix | matrix | SparseMatrix to multiply on the right. |
DenseVector | vector | DenseVector to multiply with. |
Returns
Type | Description |
---|---|
DenseVector | The new DenseVector resulting from the multiplication. |
Multiply(SparseMatrix, SparseVector)
Computes the right multiplication of a SparseMatrix with a SparseVector : A·V
.
Declaration
public static SparseVector operator *(SparseMatrix matrix, SparseVector vector)
Parameters
Type | Name | Description |
---|---|---|
SparseMatrix | matrix | SparseMatrix to multiply on the right. |
SparseVector | vector | SparseVector to multiply with. |
Returns
Type | Description |
---|---|
SparseVector | The new SparseVector resulting from the multiplication. |
Multiply(SparseMatrix, Vector)
Computes the right multiplication of a SparseMatrix with a Vector : A·V
.
Declaration
public static Vector operator *(SparseMatrix matrix, Vector vector)
Parameters
Type | Name | Description |
---|---|---|
SparseMatrix | matrix | SparseMatrix to multiply on the right. |
Vector | vector | Vector to multiply with. |
Returns
Type | Description |
---|---|
Vector | The new Vector resulting from the multiplication. |
Multiply(SparseMatrix, Double)
Computes the right scalar multiplication of a SparseMatrix with a
Declaration
public static SparseMatrix operator *(SparseMatrix operand, double factor)
Parameters
Type | Name | Description |
---|---|---|
SparseMatrix | operand | SparseMatrix to multiply on the right. |
Double | factor |
Returns
Type | Description |
---|---|
SparseMatrix | The new SparseMatrix resulting from the right scalar multiplication. |
Multiply(Double, SparseMatrix)
Computes the left scalar multiplication of a SparseMatrix with a
Declaration
public static SparseMatrix operator *(double factor, SparseMatrix operand)
Parameters
Type | Name | Description |
---|---|---|
Double | factor | |
SparseMatrix | operand | SparseMatrix to multiply on the left. |
Returns
Type | Description |
---|---|
SparseMatrix | The new SparseMatrix resulting from the left scalar multiplication. |
Subtraction(SparseMatrix, DenseMatrix)
Computes the subtraction of a SparseMatrix with a DenseMatrix.
Declaration
public static DenseMatrix operator -(SparseMatrix left, DenseMatrix right)
Parameters
Type | Name | Description |
---|---|---|
SparseMatrix | left | Left SparseMatrix to subtract. |
DenseMatrix | right | Right DenseMatrix to subtract with. |
Returns
Type | Description |
---|---|
DenseMatrix | The new DenseMatrix resulting from the subtraction. |
Subtraction(SparseMatrix, Matrix)
Computes the subtraction of a SparseMatrix with a Matrix.
Declaration
public static Matrix operator -(SparseMatrix left, Matrix right)
Parameters
Type | Name | Description |
---|---|---|
SparseMatrix | left | Left SparseMatrix to subtract. |
Matrix | right | Right Matrix to subtract with. |
Returns
Type | Description |
---|---|
Matrix | The new Matrix resulting from the subtraction. |
Subtraction(SparseMatrix, SparseMatrix)
Computes the subtraction of two SparseMatrix.
Declaration
public static SparseMatrix operator -(SparseMatrix left, SparseMatrix right)
Parameters
Type | Name | Description |
---|---|---|
SparseMatrix | left | Left SparseMatrix to subtract. |
SparseMatrix | right | Right SparseMatrix to subtract with. |
Returns
Type | Description |
---|---|
SparseMatrix | The SparseMatrix resulting from the subtraction. |
UnaryNegation(SparseMatrix)
Computes the opposite of the SparseMatrix.
Declaration
public static SparseMatrix operator -(SparseMatrix operand)
Parameters
Type | Name | Description |
---|---|---|
SparseMatrix | operand | SparseMatrix whose opposite is to be computed. |
Returns
Type | Description |
---|---|
SparseMatrix | The SparseMatrix, opposite of the initial one. |
Explicit Interface Implementations
| Improve this Doc View SourceIGroupAction<SparseMatrix, Double>.Divide(Double)
Computes the right scalar division of the current element.
Declaration
SparseMatrix IGroupAction<SparseMatrix, double>.Divide(double divisor)
Parameters
Type | Name | Description |
---|---|---|
Double | divisor |
Returns
Type | Description |
---|---|
SparseMatrix | The new element resulting from the scalar dividion. |
IGroupAction<SparseMatrix, Double>.Multiply(Double)
Computes the right scalar multiplication of the current element.
Declaration
SparseMatrix IGroupAction<SparseMatrix, double>.Multiply(double factor)
Parameters
Type | Name | Description |
---|---|---|
Double | factor |
Returns
Type | Description |
---|---|
SparseMatrix | The new element resulting from the scalar multiplication. |