nuget server logo nuget api documents
↑

API Docs / Microsoft.VisualBasic.Math.Core / NumericMatrix

NumericMatrix

Full name Microsoft.VisualBasic.Math.LinearAlgebra.Matrix.NumericMatrix Assembly Microsoft.VisualBasic.Math.Core Members 108

.NET GeneralMatrix class.

The .NET GeneralMatrix Class provides the fundamental operations of numerical linear algebra. Various constructors create Matrices from two dimensional arrays of double precision floating point numbers. Various "gets" and "sets" provide access to submatrices and matrix elements. Several methods implement basic matrix arithmetic, including matrix addition and multiplication, matrix norms, and element-by-element array operations. Methods for reading and printing matrices are also included. All the operations in this version of the GeneralMatrix Class involve real matrices. Complex matrices may be handled in a future version.

Five fundamental matrix decompositions, which consist of pairs or triples of matrices, permutation vectors, and the like, produce results in five decomposition classes. These decompositions are accessed by the GeneralMatrix class to compute solutions of simultaneous linear equations, determinants, inverses and other matrix functions.

The five decompositions are:

Example of use:

Solve a linear system A x = b and compute the residual norm, ||b - A x||.

 double[][] vals;
 GeneralMatrix A = New NumericMatrix(vals);
 GeneralMatrix b = GeneralMatrix.Random(3,1);
 GeneralMatrix x = A.Solve(b);
 GeneralMatrix r = A.Multiply(x).Subtract(b);
 double rnorm = r.NormInf();

00 Remarks

Access the internal two-dimensional array. Pointer to the two-dimensional array of matrix elements. this numeric matrix object consist with a collection of Vector as rows.

01 Syntax

Microsoft.VisualBasic.Math.LinearAlgebra.Matrix.NumericMatrix

02 Methods

NameOverloadsSummary
.ctor 8 make the matrix value copy
Block 1
Number 1 获取仅包含有一个元素的矩阵对象
Create 2 Construct a matrix from a copy of a 2-D array.
Copy 1 Make a deep copy of a matrix
GetMatrix 4 Get a submatrix.
SetMatrix 4 Set a submatrix.
Transpose 1 Matrix transpose.
Norm1 1 One norm
Norm2 1 Two norm
NormInf 1 Infinity norm
NormF 1 Frobenius norm
op_UnaryNegation 1 Unary minus
Add 1 C = A + B
AddEquals 1 A = A + B
Subtract 2 C = A - B
Power 1 C = x ^ y
SubtractEquals 1 A = A - B
ArrayMultiply 1 Element-by-element multiplication, C = A.*B
ArrayMultiplyEquals 1 Element-by-element multiplication in place, A = A.*B
ArrayRightDivide 1 Element-by-element right division, C = A./B
ArrayRightDivideEquals 1 Element-by-element right division in place, A = A./B
ArrayLeftDivide 1 Element-by-element left division, C = A.\B
ArrayLeftDivideEquals 1 Element-by-element left division in place, A = A.\B
Multiply 3 Linear algebraic matrix multiplication, A * B Jama.Matrix.times
max 2
Min 1 minCoeff, get min value in current matrix
MultiplyEquals 1 Multiply a matrix by a scalar in place, A = s*A
op_Addition 1 Addition of matrices
op_Subtraction 1 Subtraction of matrices
op_Multiply 6 Element-by-element multiplication of two matrices
op_Division 1 Element-by-element right division
LUD 1 LU Decomposition
QRD 1 QR Decomposition
chol 1 Cholesky Decomposition
SVD 1 Singular Value Decomposition
Eigen 1 Eigenvalue Decomposition
Solve 1 Solve A*X = B
SolveTranspose 1 Solve X*A = B, which is also A'*X' = B'
Inverse 1 Matrix inverse or pseudoinverse
Determinant 1 GeneralMatrix determinant
Rank 1 GeneralMatrix rank
Condition 1 Matrix condition (2 norm)
Trace 1 Matrix trace.
Identity 2 Generate identity matrix
CheckMatrixDimensions 1 Check if size(A) == size(B)
Dispose 2 Do not make this method virtual.
Finalize 1 This destructor will run only if the Dispose method does not get called.
Resize 1 调整矩阵的大小,并保留原有的数据
Clone 1 Clone the GeneralMatrix object.
ArrayPack 1 Copy the internal two-dimensional array.
One 1 fill numeric value 1 to matrix with dimension size [columnDimension x rowDimension]
Gauss 1 create a random matrix with dimension size [columnDimension x rowDimension]
random 1 create a random matrix with dimension size [columnDimension x rowDimension]
DotProduct 1 矩阵乘积(matrix product,也叫matmul product):A 的列数必须和 B 的行数相等
Abs 1
Log 1
DotMultiply 1
RowWise 1
ColWise 1
op_Exponent 1
op_Equality 1
op_Inequality 1
Diagonal 1
ToString 1
GetRectangularArray 1
ConvertJaggedToRectangularFlexible 1
op_Implicit 1
RowApply 1
RowVectors 1
Zero 1

03 Properties

NameOverloadsSummary
ColumnPackedCopy 1 Make a one-dimensional column packed copy of the internal array.
RowPackedCopy 1 Make a one-dimensional row packed copy of the internal array.
RowDimension 1 Get row dimension.
ColumnDimension 1 Get column dimension.
Dimension 1 get [n,m] shape data
Item 4 column projection via column index
DiagonalVector 1

04 Fields

NameOverloadsSummary
m 1 Row and column dimensions.
n 1 Row and column dimensions.

05 Members

method .ctor overload 4 #
#ctor(Double())

Create a new (column) RealMatrix using {@code v} as the data for the unique column of the created matrix. The input array Is copied.

Remarks

20230815 创建一个只有一列数据的矩阵,矩阵的行数 等于v的元素数量

Parameters
NameTypeDescription
vDouble()

Column vector holding data for new matrix.

method .ctor overload 8 #
#ctor(Int32, Int32)

Construct an m-by-n matrix of zeros. m is row number and n is column number

Remarks

m is row number and n is column number

Parameters
NameTypeDescription
mInt32

Number of rows.

nInt32

Number of colums.

method .ctor overload 7 #
#ctor(Int32, Int32, Double)

Construct an m-by-n constant matrix.

Parameters
NameTypeDescription
mInt32

Number of rows.

nInt32

Number of colums.

sDouble

Fill the matrix with this scalar value.

method .ctor overload 5 #
#ctor(Double()(), Boolean)

Construct a matrix from a 2-D array.

Parameters
NameTypeDescription
ADouble()()

Two-dimensional array of doubles.

tBoolean

the given raw data parameter A is in columns required transpose of the matrix.

method .ctor overload 2 #
#ctor(IEnumerable(Of Double()))

create a new numeric matrix based on a given collection of the row data vectors

Parameters
NameTypeDescription
rowsIEnumerable(Of Double())

-

method .ctor overload 6 #
#ctor(Double()(), Int32, Int32)

Construct a matrix quickly without checking arguments.

Parameters
NameTypeDescription
ADouble()()

Two-dimensional array of doubles.

mInt32

Number of rows.

nInt32

Number of colums.

method .ctor #

make the matrix value copy

Parameters
NameTypeDescription
mNumericMatrix

-

method .ctor overload 3 #
#ctor(Double(), Int32)

Construct a matrix from a one-dimensional packed array

Parameters
NameTypeDescription
valsDouble()

One-dimensional array of doubles, packed by columns (ala Fortran).

mInt32

Number of rows.

method Block #
Block(Int32, Int32, Int32, Int32)
Parameters
NameTypeDescription
iInt32

the start location, col, x

jInt32

the start location, row, y

pInt32

the size of the block, nrows

qInt32

the size of the block, ncols

method Number #
Number

获取仅包含有一个元素的矩阵对象

method Create #
Create(Double()())

Construct a matrix from a copy of a 2-D array.

Parameters
NameTypeDescription
ADouble()()

Two-dimensional array of doubles.

method Copy #
Copy

Make a deep copy of a matrix

Remarks

this function will break the array class reference between the matrix instance

method GetMatrix #
GetMatrix(Int32, Int32, Int32, Int32)

Get a submatrix.

Parameters
NameTypeDescription
i0Int32

Initial row index

i1Int32

Final row index

j0Int32

Initial column index

j1Int32

Final column index

Returns

A(i0:i1,j0:j1)

method GetMatrix overload 4 #
GetMatrix(Int32(), Int32())

Get a submatrix.

Parameters
NameTypeDescription
rInt32()

Array of row indices.

cInt32()

Array of column indices.

Returns

A(r(:),c(:))

method GetMatrix overload 2 #
GetMatrix(Int32, Int32, Int32())

Get a submatrix.

Parameters
NameTypeDescription
i0Int32

Initial row index

i1Int32

Final row index

cInt32()

Array of column indices.

Returns

A(i0:i1,c(:))

method GetMatrix overload 3 #
GetMatrix(Int32(), Int32, Int32)

Get a submatrix.

Parameters
NameTypeDescription
rInt32()

Array of row indices.

j0Int32

Initial column index

j1Int32

Final column index

Returns

A(r(:),j0:j1)

method SetMatrix #
SetMatrix(Int32, Int32, Int32, Int32, GeneralMatrix)

Set a submatrix.

Parameters
NameTypeDescription
i0Int32

Initial row index

i1Int32

Final row index

j0Int32

Initial column index

j1Int32

Final column index

XGeneralMatrix

A(i0:i1,j0:j1)

method SetMatrix overload 4 #
SetMatrix(Int32(), Int32(), GeneralMatrix)

Set a submatrix.

Parameters
NameTypeDescription
rInt32()

Array of row indices.

cInt32()

Array of column indices.

XGeneralMatrix

A(r(:),c(:))

method SetMatrix overload 3 #
SetMatrix(Int32(), Int32, Int32, GeneralMatrix)

Set a submatrix.

Parameters
NameTypeDescription
rInt32()

Array of row indices.

j0Int32

Initial column index

j1Int32

Final column index

XGeneralMatrix

A(r(:),j0:j1)

method SetMatrix overload 2 #
SetMatrix(Int32, Int32, Int32(), GeneralMatrix)

Set a submatrix.

Parameters
NameTypeDescription
i0Int32

Initial row index

i1Int32

Final row index

cInt32()

Array of column indices.

XGeneralMatrix

A(i0:i1,c(:))

method Transpose #
Transpose

Matrix transpose.

Remarks

make a value copy of the matrix

Returns

A'

method Norm1 #
Norm1

One norm

Returns

maximum column sum.

method Norm2 #
Norm2

Two norm

Returns

maximum singular value.

method NormInf #
NormInf

Infinity norm

Returns

maximum row sum.

method NormF #
NormF

Frobenius norm

Returns

sqrt of sum of squares of all elements.

method op_UnaryNegation #
op_UnaryNegation(NumericMatrix)

Unary minus

Returns

-A

method Add #

C = A + B

Parameters
NameTypeDescription
BGeneralMatrix

another matrix

Returns

A + B

method AddEquals #
AddEquals(GeneralMatrix)

A = A + B

Parameters
NameTypeDescription
BGeneralMatrix

another matrix

Returns

A + B

method Subtract #
Subtract(GeneralMatrix)

C = A - B

Parameters
NameTypeDescription
BGeneralMatrix

another matrix

Returns

A - B

method Subtract overload 2 #
Subtract(Double)

C = A - B

Parameters
NameTypeDescription
BDouble

a numeric value

Returns

A - B

method Power #
Power(Double)

C = x ^ y

Parameters
NameTypeDescription
yDouble

power

Returns

x ^ y

method SubtractEquals #
SubtractEquals(GeneralMatrix)

A = A - B

Parameters
NameTypeDescription
BGeneralMatrix

another matrix

Returns

A - B

method ArrayMultiply #
ArrayMultiply(GeneralMatrix)

Element-by-element multiplication, C = A.*B

Parameters
NameTypeDescription
BGeneralMatrix

another matrix

Returns

A.*B

method ArrayMultiplyEquals #
ArrayMultiplyEquals(GeneralMatrix)

Element-by-element multiplication in place, A = A.*B

Parameters
NameTypeDescription
BGeneralMatrix

another matrix

Returns

A.*B

method ArrayRightDivide #
ArrayRightDivide(GeneralMatrix)

Element-by-element right division, C = A./B

Parameters
NameTypeDescription
BGeneralMatrix

another matrix

Returns

A./B

method ArrayRightDivideEquals #
ArrayRightDivideEquals(GeneralMatrix)

Element-by-element right division in place, A = A./B

Parameters
NameTypeDescription
BGeneralMatrix

another matrix

Returns

A./B

method ArrayLeftDivide #
ArrayLeftDivide(GeneralMatrix)

Element-by-element left division, C = A.\B

Parameters
NameTypeDescription
BGeneralMatrix

another matrix

Returns

A.\B

method ArrayLeftDivideEquals #
ArrayLeftDivideEquals(GeneralMatrix)

Element-by-element left division in place, A = A.\B

Parameters
NameTypeDescription
BGeneralMatrix

another matrix

Returns

A.\B

method Multiply overload 3 #
Multiply(Double)

Multiply a matrix by a scalar, C = s*A

Parameters
NameTypeDescription
sDouble

scalar

Returns

s*A

method Multiply overload 2 #
Multiply(Vector)

Multiply a matrix by a scalar, C = s*A

Returns

s*A

method Multiply #
Multiply(NumericMatrix)

Linear algebraic matrix multiplication, A * B

Jama.Matrix.times

Parameters
NameTypeDescription
BNumericMatrix

another matrix

Returns

Matrix product, A * B

method max overload 2 #
max(Int32, Int32)

maxCoeff, get max value in current matrix

method Min #
Min(Int32, Int32)

minCoeff, get min value in current matrix

Parameters
NameTypeDescription
rowInt32

-

colInt32

-

method MultiplyEquals #
MultiplyEquals(Double)

Multiply a matrix by a scalar in place, A = s*A

Parameters
NameTypeDescription
sDouble

scalar

Returns

replace A by s*A

method op_Addition #

Addition of matrices

Parameters
NameTypeDescription
m1NumericMatrix

-

m2GeneralMatrix

-

method op_Subtraction #
op_Subtraction(NumericMatrix, GeneralMatrix)

Subtraction of matrices

Parameters
NameTypeDescription
m1NumericMatrix

-

m2GeneralMatrix

-

method op_Multiply overload 2 #

Element-by-element multiplication of two matrices

Parameters
NameTypeDescription
m1NumericMatrix

-

m2GeneralMatrix

-

method op_Multiply #

Element-by-element multiplication of two matrices

Parameters
NameTypeDescription
m1GeneralMatrix

-

m2NumericMatrix

-

method op_Multiply overload 3 #

Element-by-element multiplication of two matrices

Parameters
NameTypeDescription
m1NumericMatrix

-

m2NumericMatrix

-

method op_Multiply overload 6 #
op_Multiply(Double, NumericMatrix)

Multiplication of matrices

Parameters
NameTypeDescription
m2Double

-

method op_Multiply overload 4 #
op_Multiply(NumericMatrix, Double)

Multiplication of matrices

Parameters
NameTypeDescription
m2NumericMatrix

-

method op_Multiply overload 5 #
op_Multiply(Vector, NumericMatrix)

Multiplication of matrices

Parameters
NameTypeDescription
m2Vector

-

method op_Division #

Element-by-element right division

Parameters
NameTypeDescription
m1NumericMatrix

-

m2NumericMatrix

-

method LUD #
LUD

LU Decomposition

Returns

LUDecomposition

method QRD #
QRD

QR Decomposition

Returns

QRDecomposition

method chol #
chol

Cholesky Decomposition

Returns

CholeskyDecomposition

method SVD #
SVD

Singular Value Decomposition

Returns

SingularValueDecomposition

method Eigen #
Eigen

Eigenvalue Decomposition

Returns

EigenvalueDecomposition

method Solve #

Solve A*X = B

Parameters
NameTypeDescription
BGeneralMatrix

right hand side

Returns

solution if A is square, least squares solution otherwise

method SolveTranspose #
SolveTranspose(GeneralMatrix)

Solve XA = B, which is also A'X' = B'

Parameters
NameTypeDescription
BGeneralMatrix

right hand side

Returns

solution if A is square, least squares solution otherwise.

method Inverse #
Inverse

Matrix inverse or pseudoinverse

Remarks

solve identity

Returns

inverse(A) if A is square, pseudoinverse otherwise.

method Determinant #
Determinant

GeneralMatrix determinant

Returns

determinant

method Rank #
Rank

GeneralMatrix rank

Returns

effective numerical rank, obtained from SVD.

method Condition #
Condition

Matrix condition (2 norm)

Returns

ratio of largest to smallest singular value.

method Trace #
Trace

Matrix trace.

Returns

sum of the diagonal elements.

method Identity #
Identity(Int32, Int32)

Generate identity matrix

Parameters
NameTypeDescription
mInt32

Number of rows.

nInt32

Number of colums.

Returns

An m-by-n matrix with ones on the diagonal and zeros elsewhere.

method Identity overload 2 #
Identity(Int32)

Create [m,m] identity matrix

Parameters
NameTypeDescription
mInt32

-

method CheckMatrixDimensions #
CheckMatrixDimensions(GeneralMatrix)

Check if size(A) == size(B) *

Remarks

m == m andalso n == n

method Dispose #
Dispose

Do not make this method virtual. A derived class should not be able to override this method.

method Dispose overload 2 #
Dispose(Boolean)

Dispose(bool disposing) executes in two distinct scenarios. If disposing equals true, the method has been called directly or indirectly by a user's code. Managed and unmanaged resources can be disposed. If disposing equals false, the method has been called by the runtime from inside the finalizer and you should not reference other objects. Only unmanaged resources can be disposed.

Parameters
NameTypeDescription
disposingBoolean

-

method Finalize #
Finalize

This destructor will run only if the Dispose method does not get called. It gives your base class the opportunity to finalize. Do not provide destructors in types derived from this class.

method Resize #
Resize(Int32, Int32)

调整矩阵的大小,并保留原有的数据

Parameters
NameTypeDescription
mInt32

-

nInt32

-

method Clone #
Clone

Clone the GeneralMatrix object.

method ArrayPack #
ArrayPack(Boolean)

Copy the internal two-dimensional array.

Returns

Two-dimensional array copy of matrix elements.

method One #
One(Int32, Int32)

fill numeric value 1 to matrix with dimension size [columnDimension x rowDimension]

Parameters
NameTypeDescription
columnDimensionInt32

-

rowDimensionInt32

-

method Gauss #
Gauss(Int32, Int32)

create a random matrix with dimension size [columnDimension x rowDimension]

Remarks

element data range that generats inside the matrix is [-1,1]

Parameters
NameTypeDescription
columnDimensionInt32

-

rowDimensionInt32

-

method random #
random(Int32, Int32, Double, Double)

create a random matrix with dimension size [columnDimension x rowDimension]

Parameters
NameTypeDescription
columnDimensionInt32

-

rowDimensionInt32

-

method DotProduct #
DotProduct(GeneralMatrix)

矩阵乘积(matrix product,也叫matmul product):A 的列数必须和 B 的行数相等

Parameters
NameTypeDescription
BGeneralMatrix

-

property ColumnPackedCopy #
ColumnPackedCopy

Make a one-dimensional column packed copy of the internal array.

Returns

Matrix elements packed in a one-dimensional array by columns.

property RowPackedCopy #
RowPackedCopy

Make a one-dimensional row packed copy of the internal array.

Returns

Matrix elements packed in a one-dimensional array by rows.

property RowDimension #
RowDimension

Get row dimension.

Returns

m, the number of rows.

property ColumnDimension #
ColumnDimension

Get column dimension.

Returns

n, the number of columns.

property Dimension #
Dimension

get [n,m] shape data

Returns

the width is the number of columns(n) and the height is the number of rows(m)

property Item overload 3 #
Item(Int32, Int32)

Get a single element.

Parameters
NameTypeDescription
iInt32

Row index.

jInt32

Column index.

Returns

A(i,j)

property Item overload 4 #
Item(UInt32, UInt32)

Get a single element.

Parameters
NameTypeDescription
iUInt32

Row index.

jUInt32

Column index.

Returns

A(i,j)

property Item #
Item(IEnumerable(Of Int32))

column projection via column index

Remarks

select column values for each row for create a new matrix

Parameters
NameTypeDescription
indicesIEnumerable(Of Int32)

-

property Item overload 2 #
Item(Int32, Boolean)

get/set data vector by row or by column

Parameters
NameTypeDescription
iInt32

-

byRowBoolean

-

field m #
m

Row and column dimensions. @serial row dimension.

field n #
n

Row and column dimensions. @serial column dimension.

property DiagonalVector #
DiagonalVector
method Create overload 2 #
Create(Int32, Int32)
method Abs #
Abs()
method Log #
Log(Double)
method DotMultiply #
DotMultiply(Vector)
method max #
max(Int32)
method RowWise #
RowWise()
method ColWise #
ColWise()
method op_Exponent #
op_Exponent(NumericMatrix, Double)
method op_Equality #
op_Equality(NumericMatrix, Double)
method op_Inequality #
op_Inequality(NumericMatrix, Double)
method Diagonal #
Diagonal(Int32, Int32, Double)
method ToString #
ToString()
method GetRectangularArray #
GetRectangularArray(GeneralMatrix)
method ConvertJaggedToRectangularFlexible #
ConvertJaggedToRectangularFlexible(Double()())
method op_Implicit #
op_Implicit(Double())
method RowApply #
RowApply(Func(Of Double(), Int32, T))
method RowVectors #
RowVectors()
method Zero #
Zero(Int32, Int32)