C# Class numl.Math.LinearAlgebra.MatrixExtensions

A matrix extensions.
Exibir arquivo Open project: sethjuarez/numl Class Usage Examples

Public Methods

Method Description
Cholesky ( this m ) : Matrix

A Matrix extension method that choleskies the given m.

Correlation ( this source, VectorType t = VectorType.Col ) : Matrix

A Matrix extension method that correlations.

Covariance ( this source, VectorType t = VectorType.Col ) : Matrix

A Matrix extension method that covariances.

CovarianceDiag ( this source, VectorType t = VectorType.Col ) : Vector

A Matrix extension method that covariance diagram.

Det ( this m ) : double

computes matrix determinant NOTE: currently using cholesky factorization to save time so non symmetric positive semi-definite matrices will cause problems...

Diag ( this m ) : Vector

A Matrix extension method that diagrams the given m.

Each ( this m, double>.Func fnElementWiseOp ) : Matrix

Performs an element-wise operation on the input Matrix.

Each ( this m, Func fnElementWiseOp ) : Matrix

Performs an element wise operation on the input Matrix.

Each ( this m1, Matrix m2, Func fnElementWiseOp ) : Matrix

Performs an element-wise operation on the input Matrices.

Eigs ( this m ) : Matrix>.Tuple

A Matrix extension method that eigs the given m.

Extract ( this m, int x, int y, int width, int height, bool safe = true ) : Matrix

A Matrix extension method that extracts this object.

Indices ( this source, bool>.Func f ) : IEnumerable

Enumerates indices in this collection.

Indices ( this source, bool>.Func f, VectorType t ) : IEnumerable

Enumerates indices in this collection.

Max ( this source, VectorType t ) : Vector

Returns a vector of the maximum values for each row/column.

Max ( this source ) : double

A Matrix extension method that determines the maximum of the given parameters.

Mean ( this source, VectorType t ) : Vector

A Matrix extension method that determines the mean of the given parameters.

Median ( this source, VectorType t ) : Vector

Returns a vector of the median values for each row or column.

Min ( this source, VectorType t ) : Vector

Returns a vector of the minimum values for each row/column.

Min ( this source ) : double

A Matrix extension method that determines the minimum of the given parameters.

Norm ( this m ) : double

A Matrix extension method that normals.

Norm ( this m, double p ) : double

A Matrix extension method that normals.

Reverse ( this source, VectorType t = VectorType.Row ) : IEnumerable

Enumerates reverse in this collection.

Round ( this m, int decimals ) : Matrix

A Matrix extension method that rounds.

SVD ( this m ) : Tuple

A Matrix extension method that svds the given m.

Slice ( this m, IEnumerable indices ) : Matrix

A Matrix extension method that slices.

Slice ( this m, IEnumerable indices, VectorType t ) : Matrix

A Matrix extension method that slices.

Slice ( this m, int minIndex, int maxIndex, VectorType t = VectorType.Row ) : Matrix

Slices the input matrix using starting and stopping positions.

Sort ( this m, double>.Func keySelector, VectorType t, bool isAscending = true ) : Matrix

Sorts the given Matrix by the specified row or column and returns the new Matrix.

Sort ( this m, double>.Func keySelector, VectorType t, bool isAscending, Vector &indices ) : Matrix

Sorts the given Matrix by the specified row or column index and returns the new Matrix along with the original indices.

Stack ( this m, Matrix t ) : Matrix

A Matrix extension method that stacks.

Stats ( this m ) : Matrix[]

A Matrix extension method that statistics.

Stats ( this m, VectorType t ) : Matrix[]

A Matrix extension method that statistics.

StdDev ( this source, VectorType t ) : Vector

Computes the standard deviation of the given matrix

Sum ( this m, VectorType t ) : Vector

Computes the sum of either the rows or columns of a matrix and returns a vector.

Sum ( Matrix m, int i, VectorType t ) : double

Computes the sum of either the rows or columns of a matrix and returns a vector.

Sum ( this m ) : double

Computes the entire sum of every element in the Matrix.

ToBinary ( this m, bool>.Func fnPredicate, double trueValue = 1.0, double falseValue = 0.0 ) : Matrix

Converts a matrix to a binary indicator matrix based on the specified predicate.

Trace ( this m ) : double

Computes the trace of a matrix.

Unshape ( this m ) : Vector

Unrolls the matrix into an n x 1 vector.

VStack ( this m, Matrix t ) : Matrix

A Matrix extension method that stacks.

Method Details

Cholesky() public static method

A Matrix extension method that choleskies the given m.
public static Cholesky ( this m ) : Matrix
m this Matrix.
return Matrix

Correlation() public static method

A Matrix extension method that correlations.
public static Correlation ( this source, VectorType t = VectorType.Col ) : Matrix
source this The source to act on.
t VectorType (Optional) Row or Column sum.
return Matrix

Covariance() public static method

A Matrix extension method that covariances.
public static Covariance ( this source, VectorType t = VectorType.Col ) : Matrix
source this The source to act on.
t VectorType (Optional) Row or Column sum.
return Matrix

CovarianceDiag() public static method

A Matrix extension method that covariance diagram.
public static CovarianceDiag ( this source, VectorType t = VectorType.Col ) : Vector
source this The source to act on.
t VectorType (Optional) Row or Column sum.
return Vector

Det() public static method

computes matrix determinant NOTE: currently using cholesky factorization to save time so non symmetric positive semi-definite matrices will cause problems...
public static Det ( this m ) : double
m this Matrix.
return double

Diag() public static method

A Matrix extension method that diagrams the given m.
public static Diag ( this m ) : Vector
m this Matrix.
return Vector

Each() public static method

Performs an element-wise operation on the input Matrix.
public static Each ( this m, double>.Func fnElementWiseOp ) : Matrix
m this Matrix.
fnElementWiseOp double>.Func Function to apply.
return Matrix

Each() public static method

Performs an element wise operation on the input Matrix.
public static Each ( this m, Func fnElementWiseOp ) : Matrix
m this Matrix.
fnElementWiseOp Func Function to apply to each cell specified by the value and cell coordinates.
return Matrix

Each() public static method

Performs an element-wise operation on the input Matrices.
public static Each ( this m1, Matrix m2, Func fnElementWiseOp ) : Matrix
m1 this First Matrix.
m2 Matrix Second Matrix.
fnElementWiseOp Func Operation to perform on the value from the first and second matrices.
return Matrix

Eigs() public static method

A Matrix extension method that eigs the given m.
public static Eigs ( this m ) : Matrix>.Tuple
m this Matrix.
return Matrix>.Tuple

Extract() public static method

A Matrix extension method that extracts this object.
public static Extract ( this m, int x, int y, int width, int height, bool safe = true ) : Matrix
m this Matrix.
x int The x coordinate.
y int The y coordinate.
width int The width.
height int The height.
safe bool (Optional) true to safe.
return Matrix

Indices() public static method

Enumerates indices in this collection.
public static Indices ( this source, bool>.Func f ) : IEnumerable
source this The source to act on.
f bool>.Func The Func<Vector,bool> to process.
return IEnumerable

Indices() public static method

Enumerates indices in this collection.
public static Indices ( this source, bool>.Func f, VectorType t ) : IEnumerable
source this The source to act on.
f bool>.Func The Func<Vector,bool> to process.
t VectorType Row or Column sum.
return IEnumerable

Max() public static method

Returns a vector of the maximum values for each row/column.
public static Max ( this source, VectorType t ) : Vector
source this
t VectorType
return Vector

Max() public static method

A Matrix extension method that determines the maximum of the given parameters.
public static Max ( this source ) : double
source this The source to act on.
return double

Mean() public static method

A Matrix extension method that determines the mean of the given parameters.
public static Mean ( this source, VectorType t ) : Vector
source this The source to act on.
t VectorType Row or Column sum.
return Vector

Median() public static method

Returns a vector of the median values for each row or column.
public static Median ( this source, VectorType t ) : Vector
source this
t VectorType
return Vector

Min() public static method

Returns a vector of the minimum values for each row/column.
public static Min ( this source, VectorType t ) : Vector
source this
t VectorType
return Vector

Min() public static method

A Matrix extension method that determines the minimum of the given parameters.
public static Min ( this source ) : double
source this The source to act on.
return double

Norm() public static method

A Matrix extension method that normals.
public static Norm ( this m ) : double
m this Matrix.
return double

Norm() public static method

A Matrix extension method that normals.
public static Norm ( this m, double p ) : double
m this Matrix.
p double The double to process.
return double

Reverse() public static method

Enumerates reverse in this collection.
public static Reverse ( this source, VectorType t = VectorType.Row ) : IEnumerable
source this The source to act on.
t VectorType (Optional) Row or Column sum.
return IEnumerable

Round() public static method

A Matrix extension method that rounds.
public static Round ( this m, int decimals ) : Matrix
m this Matrix.
decimals int (Optional) the decimals.
return Matrix

SVD() public static method

A Matrix extension method that svds the given m.
public static SVD ( this m ) : Tuple
m this Matrix.
return Tuple

Slice() public static method

A Matrix extension method that slices.
public static Slice ( this m, IEnumerable indices ) : Matrix
m this Matrix.
indices IEnumerable The indices.
return Matrix

Slice() public static method

A Matrix extension method that slices.
public static Slice ( this m, IEnumerable indices, VectorType t ) : Matrix
m this Matrix.
indices IEnumerable The indices.
t VectorType Row or Column sum.
return Matrix

Slice() public static method

Slices the input matrix using starting and stopping positions.
public static Slice ( this m, int minIndex, int maxIndex, VectorType t = VectorType.Row ) : Matrix
m this Source matrix.
minIndex int Minimum index to slice from.
maxIndex int Maximum index to slice.
t VectorType
return Matrix

Sort() public static method

Sorts the given Matrix by the specified row or column and returns the new Matrix.
public static Sort ( this m, double>.Func keySelector, VectorType t, bool isAscending = true ) : Matrix
m this The Matrix
keySelector double>.Func Property selector to sort by.
t VectorType Specifies whether to sort horizontally () or vertically ().
isAscending bool Determines whether to sort ascending or descending (Default: True)
return Matrix

Sort() public static method

Sorts the given Matrix by the specified row or column index and returns the new Matrix along with the original indices.
public static Sort ( this m, double>.Func keySelector, VectorType t, bool isAscending, Vector &indices ) : Matrix
m this The Matrix
keySelector double>.Func Property selector to sort by.
t VectorType Specifies whether to sort horizontally () or vertically ().
isAscending bool Determines whether to sort ascending or descending (Default: True)
indices Vector Vector of the original () indices before the sort operation.
return Matrix

Stack() public static method

A Matrix extension method that stacks.
public static Stack ( this m, Matrix t ) : Matrix
m this Matrix.
t Matrix Row or Column sum.
return Matrix

Stats() public static method

A Matrix extension method that statistics.
public static Stats ( this m ) : Matrix[]
m this Matrix.
return Matrix[]

Stats() public static method

A Matrix extension method that statistics.
public static Stats ( this m, VectorType t ) : Matrix[]
m this Matrix.
t VectorType Row or Column sum.
return Matrix[]

StdDev() public static method

Computes the standard deviation of the given matrix
public static StdDev ( this source, VectorType t ) : Vector
source this
t VectorType Return a Row or Column vector
return Vector

Sum() public static method

Computes the sum of either the rows or columns of a matrix and returns a vector.
public static Sum ( this m, VectorType t ) : Vector
m this Matrix.
t VectorType Row or Column sum.
return Vector

Sum() public static method

Computes the sum of either the rows or columns of a matrix and returns a vector.
public static Sum ( Matrix m, int i, VectorType t ) : double
m Matrix Matrix.
i int Zero-based index of the.
t VectorType Row or Column sum.
return double

Sum() public static method

Computes the entire sum of every element in the Matrix.
public static Sum ( this m ) : double
m this Matrix.
return double

ToBinary() public static method

Converts a matrix to a binary indicator matrix based on the specified predicate.
public static ToBinary ( this m, bool>.Func fnPredicate, double trueValue = 1.0, double falseValue = 0.0 ) : Matrix
m this Matrix.
fnPredicate bool>.Func Function to test each Value.
trueValue double (Optional) Value to set when condition () returns True
falseValue double (Optional) Value to set when condition () returns False
return Matrix

Trace() public static method

Computes the trace of a matrix.
public static Trace ( this m ) : double
m this Matrix.
return double

Unshape() public static method

Unrolls the matrix into an n x 1 vector.
public static Unshape ( this m ) : Vector
m this
return Vector

VStack() public static method

A Matrix extension method that stacks.
public static VStack ( this m, Matrix t ) : Matrix
m this Matrix.
t Matrix Row or Column sum.
return Matrix