Home Reference Source
public class | source

LinearAlgebra

Class for linear algebra for Matrix class.

  • These methods can be used in the Matrix method chain.
  • This class cannot be called directly.

Static Method Summary

Static Public Methods
public static

Condition number of the matrix

public static

Determinant.

public static

eig(mat: KMatrixInputData): {V: Matrix, D: Matrix}

Eigendecomposition of symmetric matrix.

public static

Inner product/Dot product.

public static

Inverse matrix of this matrix.

public static

Solving a system of linear equations to be Ax = B

public static

lu(mat: KMatrixInputData): {L: Matrix, U: Matrix}

LU decomposition.

public static

lup(mat: KMatrixInputData): {P: Matrix, L: Matrix, U: Matrix}

LUP decomposition.

public static

p-norm.

public static

Pseudo-inverse matrix.

public static

qr(mat: KMatrixInputData): {Q: Matrix, R: Matrix}

QR decomposition.

public static

Rank.

public static

Inverse condition number.

public static

svd(mat: KMatrixInputData): {U: Matrix, S: Matrix, V: Matrix}

Singular Value Decomposition (SVD).

public static

Trace of a matrix.

public static

Tridiagonalization of symmetric matrix.

Static Public Methods

public static cond(mat: KMatrixInputData, p: KMatrixInputData): number source

Condition number of the matrix

Params:

NameTypeAttributeDescription
mat KMatrixInputData
p KMatrixInputData
  • optional
  • default: 2

Return:

number

public static det(mat: KMatrixInputData): Matrix source

Determinant.

Params:

NameTypeAttributeDescription
mat KMatrixInputData

Return:

Matrix

|A|

public static eig(mat: KMatrixInputData): {V: Matrix, D: Matrix} source

Eigendecomposition of symmetric matrix.

  • Don't support complex numbers.
  • VDV'=A.
  • V is orthonormal matrix. and columns of V are the right eigenvectors.
  • D is a matrix containing the eigenvalues on the diagonal component.

Params:

NameTypeAttributeDescription
mat KMatrixInputData

A

Return:

{V: Matrix, D: Matrix}

{D, V}

TODO:

  • 対称行列しか対応できていないので、対称行列ではないものはQR分解を用いた手法に切り替える予定。

public static inner(A: KMatrixInputData, B: KMatrixInputData, dimension: KMatrixInputData): Matrix source

Inner product/Dot product.

Params:

NameTypeAttributeDescription
A KMatrixInputData
B KMatrixInputData
dimension KMatrixInputData
  • optional
  • default: 1

Dimension of matrix used for calculation. (1 or 2)

Return:

Matrix

A・B

public static inv(mat: KMatrixInputData): Matrix source

Inverse matrix of this matrix.

Params:

NameTypeAttributeDescription
mat KMatrixInputData

A

Return:

Matrix

A^-1

public static linsolve(mat: KMatrixInputData, number: KMatrixInputData): Matrix source

Solving a system of linear equations to be Ax = B

Params:

NameTypeAttributeDescription
mat KMatrixInputData

A

number KMatrixInputData

B

Return:

Matrix

x

TODO:

  • 安定化のためQR分解を用いた手法に切り替える。あるいはlup分解を使用した関数に作り替える。

public static lu(mat: KMatrixInputData): {L: Matrix, U: Matrix} source

LU decomposition.

  • L*U=A
  • L is lower triangular matrix.
  • U is upper triangular matrix.

Params:

NameTypeAttributeDescription
mat KMatrixInputData

A

Return:

{L: Matrix, U: Matrix}

{L, U}

public static lup(mat: KMatrixInputData): {P: Matrix, L: Matrix, U: Matrix} source

LUP decomposition.

  • P'LU=A
  • P is permutation matrix.
  • L is lower triangular matrix.
  • U is upper triangular matrix.

Params:

NameTypeAttributeDescription
mat KMatrixInputData

A

Return:

{P: Matrix, L: Matrix, U: Matrix}

{L, U, P}

public static norm(mat: KMatrixInputData, p: KMatrixInputData): number source

p-norm.

Params:

NameTypeAttributeDescription
mat KMatrixInputData
p KMatrixInputData
  • optional
  • default: 2

Return:

number

public static pinv(mat: KMatrixInputData): Matrix source

Pseudo-inverse matrix.

Params:

NameTypeAttributeDescription
mat KMatrixInputData

A

Return:

Matrix

A^+

public static qr(mat: KMatrixInputData): {Q: Matrix, R: Matrix} source

QR decomposition.

  • Q*R=A
  • Q is orthonormal matrix.
  • R is upper triangular matrix.

Params:

NameTypeAttributeDescription
mat KMatrixInputData

A

Return:

{Q: Matrix, R: Matrix}

{Q, R}

public static rank(mat: KMatrixInputData, tolerance: KMatrixInputData): number source

Rank.

Params:

NameTypeAttributeDescription
mat KMatrixInputData
tolerance KMatrixInputData
  • optional

Calculation tolerance of calculation.

Return:

number

rank(A)

public static rcond(mat: KMatrixInputData): number source

Inverse condition number.

Params:

NameTypeAttributeDescription
mat KMatrixInputData

Return:

number

public static svd(mat: KMatrixInputData): {U: Matrix, S: Matrix, V: Matrix} source

Singular Value Decomposition (SVD).

  • USV'=A
  • U and V are orthonormal matrices.
  • S is a matrix with singular values in the diagonal.

Params:

NameTypeAttributeDescription
mat KMatrixInputData

A

Return:

{U: Matrix, S: Matrix, V: Matrix}

USV'=A

public static trace(mat: KMatrixInputData): Complex source

Trace of a matrix. Sum of diagonal elements.

Params:

NameTypeAttributeDescription
mat KMatrixInputData

Return:

Complex

public static tridiagonalize(mat: KMatrixInputData): {P: Matrix, H: Matrix} source

Tridiagonalization of symmetric matrix.

  • Don't support complex numbers.
  • PHP'=A
  • P is orthonormal matrix.
  • H is tridiagonal matrix.
  • The eigenvalues of H match the eigenvalues of A.

Params:

NameTypeAttributeDescription
mat KMatrixInputData

A

Return:

{P: Matrix, H: Matrix}

{P, H}