Matrix class

Type Parameters

  • T = number

Constructors

Accessors

Methods

[iterator] abs add addAt adjoint and andAt argmax argmin at balancing balancingSinkhornKnopp bidiag bidiagHouseholder bitand bitandAt bitnot bitor bitorAt bitxor bitxorAt block broadcastOperate ceil cholesky choleskyBanachiewicz choleskyCrout choleskyGaussian col concat convolute copy cov det diag div divAt dot eigen eigenInverseIteration eigenJacobi eigenPowerIteration eigenSimultaneousIteration eigenValues eigenValuesBiSection eigenValuesLR eigenValuesQR eigenVectors equals every exp fill flip floor forEach gram hessenberg hessenbergArnoldi idiv idivAt imod imodAt inv invLowerTriangular invLU invRowReduction invUpperTriangular isAlternating isDiag isHermitian isIdentity isLowerTriangular isNilpotent isNormal isOrthogonal isRegular isSkewHermitian isSquare isSymmetric isTriangular isub isubAt isUnitary isUpperTriangular isZero kron leftShift log lu map max mean median min mod modAt modifiedCholesky mult multAt negative norm normEntrywise normFrobenius normInduced normMax normNuclear normSchatten normSpectral not operateAt or orAt power prod pseudoInv pseudoInvBenIsraelCohen pseudoInvNaive pseudoInvQR pseudoInvSVD qr qrGramSchmidt qrHouseholder quantile rank rankFactorization reduce reducedRowEchelonForm remove removeIf repeat reshape resize round row sample schur schurQR set shuffle signedRightShift singularValuePowerIteration singularValues slice solve solveGaussSeidel solveJacobi solveLowerTriangular solveSOR solveUpperTriangular some sort spectralRadius sqrt std sub subAt sum svd svdEigen svdGolubKahan swap tDot toArray toScaler toString trace transpose tridiag tridiagHouseholder tridiagLanczos unique unsignedRightShift variance add and bitand bitor bitxor concat diag div eye fromArray map mod mult ones or randint randn random repeat resize sub zeros

Constructors

  • Type Parameters

    • T = number

    Parameters

    • rows: number

      Number of rows

    • cols: number

      Number of columns

    • Optionalvalues: T | T[] | T[][]

      Initial values

    Returns Matrix<T>

  • Type Parameters

    • T = number

    Parameters

    • size: [number, number]

      Sizes for each dimension

    • Optionalvalues: T | T[] | T[][]

      Initial values

    Returns Matrix<T>

Accessors

  • get cols(): number
  • Number of columns of the matrix.

    Returns number

  • get dimension(): number
  • Dimension of the matrix.

    Returns number

  • get length(): number
  • Number of all elements in the matrix.

    Returns number

  • get rows(): number
  • Number of rows of the matrix.

    Returns number

  • get sizes(): number[]
  • Sizes of the matrix.

    Returns number[]

  • get t(): Matrix<T>
  • Transpose matrix.

    Returns Matrix<T>

  • get value(): T[]
  • Elements in the matrix.

    Returns T[]

Methods

  • Iterate over the elements.

    Returns Generator<T>

  • Set all elements to their absolute values.

    Returns void

  • Add a value or matrix.

    Parameters

    Returns void

  • Add a value to the position.

    Parameters

    • r: number

      Index of the row to add the value to

    • c: number

      Index of the column to add the value to

    • v: number

      Value to add

    Returns number

    Old value

  • Returns adjoint matrix.

    Returns Matrix<T>

    Adjoint matrix

  • Take a logical AND with a value or matrix.

    Parameters

    • o: number | Tensor | Matrix<unknown>

      Value to take a logical AND

    Returns void

  • Take logical AND with a value to the position.

    Parameters

    • r: number

      Index of the row to take a logical AND with

    • c: number

      Index of the column to take a logical AND with

    • v: number

      Value to take a logical AND

    Returns T

    Old value

  • Returns maximum indexes along the axis.

    Parameters

    • axis: number

      Axis to be reduced

    Returns Matrix

    Argmax values

  • Returns minimum indexes along the axis.

    Parameters

    • axis: number

      Axis to be reduced

    Returns Matrix

    Argmin values

  • Returns a value at the position.

    Parameters

    • r: number

      Row index

    • c: number

      Column index

    Returns T

    Value at the position

  • Returns a value at the position.

    Parameters

    • index: [number, number]

      Index values

    Returns T

    Value at the position

  • Returns a doubly stochastic matrix.

    Returns [number[], Matrix, number[]]

    Doubly stochastic matrix

  • Returns a doubly stochastic matrix by Sinkhorn-Knopp algorithm.

    Returns [number[], Matrix, number[]]

    Doubly stochastic matrix

  • Returns a bidiagonal matrix.

    Returns Matrix

    Bidiagonal matrix

  • Returns a bidiagonal matrix by Householder method.

    Parameters

    • Optionalreturn_uv: false

      Returns orthogonal matrixes

    Returns Matrix

    Bidiagonal matrix, or Bidiagonal matrix and orthogonal matrixes

  • Returns a bidiagonal matrix by Householder method.

    Parameters

    • return_uv: true

      Returns orthogonal matrixes

    Returns [Matrix, Matrix, Matrix]

    Bidiagonal matrix, or Bidiagonal matrix and orthogonal matrixes

  • Take a bitwise AND with a value or matrix.

    Parameters

    Returns void

  • Take bitwise AND with a value to the position.

    Parameters

    • r: number

      Index of the row to take a bitwise AND with

    • c: number

      Index of the column to take a bitwise AND with

    • v: number

      Value to take a bitwise AND

    Returns T

    Old value

  • Set all elements to their bitwise NOT values.

    Returns void

  • Take a bitwise OR with a value or matrix.

    Parameters

    Returns void

  • Take bitwise OR with a value to the position.

    Parameters

    • r: number

      Index of the row to take a bitwise OR with

    • c: number

      Index of the column to take a bitwise OR with

    • v: number

      Value to take a bitwise OR

    Returns T

    Old value

  • Take a bitwise XOR with a value or matrix.

    Parameters

    Returns void

  • Take bitwise XOR with a value to the position.

    Parameters

    • r: number

      Index of the row to take a bitwise XOR with

    • c: number

      Index of the column to take a bitwise XOR with

    • v: number

      Value to take a bitwise XOR

    Returns T

    Old value

  • Returns the sub-matrix corresponding to position.

    Parameters

    • Optionalrows_from: number

      Start row index

    • Optionalcols_from: number

      Start column index

    • Optionalrows_to: number

      End row index(exclusive)

    • Optionalcols_to: number

      End column index(exclusive)

    Returns Matrix<T>

    Sub matrix

  • Apply function for all elements with broadcasting.

    Type Parameters

    • U_1

    Parameters

    Returns void

  • Set all elements to their ceil values.

    Returns void

  • Returns a cholesky decomposition.

    Returns Matrix

    Cholesky decomposition matrix

  • Returns a cholesky decomposition by Banachiewicz algorithm.

    Returns Matrix

    Cholesky decomposition matrix

  • Returns a cholesky decomposition by Crout algorithm.

    Returns Matrix

    Cholesky decomposition matrix

  • Returns a cholesky decomposition by Gaussian algorithm.

    Returns Matrix

    Cholesky decomposition matrix

  • Returns a col matrix at c.

    Parameters

    • c: number | number[] | boolean[]

      Indexes of columns, or an array of boolean values where the column to be selected is true.

    Returns Matrix<T>

    Column selected matrix

  • Concatenate this and m.

    Parameters

    • m: Matrix<T>

      Concatenate matrix

    • Optionalaxis: number

      Axis to be concatenated

    Returns void

  • Convoluted by a kernel.

    Parameters

    • kernel: number[][]

      Kernel matrix

    • Optionalnormalize: boolean

      Normalize kernel or not

    Returns void

  • Returns a copy of this matrix.

    Parameters

    • Optionaldst: Matrix<T>

      Destination matrix

    Returns Matrix<T>

    Copied matrix

  • Returns a covariance matrix.

    Parameters

    • Optionalddof: number

      Delta Degrees of Freedom

    Returns Matrix

    Covariance matrix

  • Returns a determinant.

    Returns number

    Determinant value

  • Returns diagonal elements.

    Returns number[]

    Diagonal values

  • Divides by a value element-wise.

    Parameters

    Returns void

  • Divides the value at the position by a value.

    Parameters

    • r: number

      Index of the row to divide the value by

    • c: number

      Index of the column to divide the value by

    • v: number

      Value to divide

    Returns number

    Old value

  • Returns a matrix product value.

    Parameters

    Returns Matrix

    Producted matrix

  • Returns eigenvalues and eigenvectors.

    Returns [number[], Matrix]

    Eigenvalues and eigenvectors. Eigenvectors correspond to each column of the matrix.

  • Returns the nearest eigenvalue and its eigenvector to the specified value.

    Parameters

    • Optionalev: number

      Target value

    • OptionalmaxIteration: number

      Maximum iteration

    Returns [number, Matrix]

    Eigenvalue and eigenvector

  • Returns eigenvalues and eigenvectors.

    Parameters

    • OptionalmaxIteration: number

      Maximum iteration

    Returns [number[], Matrix]

    Eigenvalues and eigenvectors. Eigenvectors correspond to each column of the matrix.

  • Returns the maximum eigenvalue and its eigenvector.

    Parameters

    • OptionalmaxIteration: number

      Maximum iteration

    Returns [number, Matrix]

    Maximum eigenvalue and its eigenvector

  • Returns the k highest eigenvalues and its eigenvectors.

    Parameters

    • k: number

      Number of calculated eigenvalues

    • OptionalmaxIteration: number

      Maximum iteration

    Returns [number[], Matrix]

    The k highest eigenvalues and its eigenvectors. Eigenvectors correspond to each column of the matrix.

  • Returns eigenvalues.

    Returns number[]

    Eigenvalues

  • Returns eigenvalues by Bi-section.

    Returns number[]

    Eigenvalues

  • Returns eigenvalues by LU decomposition.

    Parameters

    • OptionalmaxIteration: number

      Maximum iteration

    Returns number[]

    Eigenvalues

  • Returns eigenvalues by QR decomposition.

    Parameters

    • OptionalmaxIteration: number

      Maximum iteration

    Returns number[]

    Eigenvalues

  • Returns eigenvectors.

    Returns Matrix

    Eigenvectors. Eigenvectors correspond to each column of the matrix.

  • Returns this matrix is equals to the others.

    Parameters

    • other: any

      Check tensor

    • Optionaltol: number

      Tolerance to be recognized as the same

    Returns boolean

    true if equal

  • Determines whether all the members of a matrix satisfy the specified test.

    Parameters

    • cb: (arg0: T, arg1: number[], arg2: Matrix<T>) => boolean

      Check function

    Returns boolean

    Reduced value or matrix

  • Determines whether all the members of a matrix satisfy the specified test.

    Parameters

    • cb: (arg0: T, arg1: number[], arg2: Matrix<T>) => boolean

      Check function

    • axis: 0 | 1

      Axis to be reduced

    Returns Matrix<boolean>

    Reduced value or matrix

  • Determines whether all the members of a matrix satisfy the specified test.

    Parameters

    • cb: (arg0: T, arg1: number[], arg2: Matrix<T>) => boolean

      Check function

    • axis: number

      Axis to be reduced

    Returns boolean | Matrix<boolean>

    Reduced value or matrix

  • Returns a exponential matrix

    Returns Matrix

    Exponential matrix

  • Fill in all the elements with the value.

    Parameters

    • value: T

      Filled value

    Returns void

  • Flip values along the axis.

    Parameters

    • Optionalaxis: number

      Axis to be flipped

    Returns void

  • Set all elements to their floored values.

    Returns void

  • Iterate over all the elements.

    Parameters

    • cb: (arg0: T, arg1: number[], arg2: Matrix<T>) => any

      Callback function

    Returns void

  • Returns a gram matrix.

    Returns Matrix

    Gram matrix

  • Returns a hessenberg matrix.

    Returns Matrix

    Hessenberg matrix

  • Returns a hessenberg matrix.

    Parameters

    • Optionalk: number

      Number of iterations

    Returns Matrix

    Hessenberg matrix

  • Divides a value by this matrix element-wise.

    Parameters

    Returns void

  • Divides a value by the value at the position.

    Parameters

    • r: number

      Index of the row whose value is to be divided

    • c: number

      Index of the column whose value is to be divided

    • v: number

      Value to be divided

    Returns number

    Old value

  • Take a remainder divided a value by this matrix element-wise.

    Parameters

    Returns void

  • Take a remainder divided a value by the value at the position.

    Parameters

    • r: number

      Index of the row whose value is to be divided

    • c: number

      Index of the column whose value is to be divided

    • v: number

      Value to be divided

    Returns number

    Old value

  • Returns a inverse matrix.

    Returns Matrix

    Inversed matrix

  • Returns a inverse matrix for lower triangular matrix.

    Returns Matrix

    Inversed matrix

  • Returns a inverse matrix by LU decompositioin.

    Returns Matrix

    Inversed matrix

  • Returns a inverse matrix by row reduction.

    Returns Matrix

    Inversed matrix

  • Returns a inverse matrix for upper triangular matrix.

    Returns Matrix

    Inversed matrix

  • Returns if this is alternating matrix or not.

    Parameters

    • Optionaltol: number

      Tolerance within which sign-reversed values are recognized as the same

    Returns boolean

    true if this is alternating matrix

  • Returns if this is diagonal matrix or not.

    Parameters

    • Optionaltol: number

      Tolerance to be recognized as 0

    Returns boolean

    true if this is diagonal matrix

  • Returns if this is hermitian matrix or not.

    Parameters

    • Optionaltol: number

      Tolerance to be recognized as the same

    Returns boolean

    true if this is hermitian matrix

  • Returns if this is identity matrix or not.

    Parameters

    • Optionaltol: number

      Tolerance to be recognized as 0 or 1

    Returns boolean

    true if this is identity matrix

  • Returns if this is lower triangular matrix or not.

    Parameters

    • Optionaltol: number

      Tolerance to be recognized as 0

    Returns boolean

    true if this is lower triangular matrix

  • Returns if this is nilpotent matrix or not.

    Parameters

    • Optionaltol: number

      Tolerance to be recognized as 0

    Returns boolean

    true if this is nilpotent matrix

  • Returns if this is normal matrix or not.

    Parameters

    • Optionaltol: number

      Tolerance to be recognized as the same

    Returns boolean

    true if this is normal matrix

  • Returns if this is orthogonal matrix or not.

    Parameters

    • Optionaltol: number

      Tolerance to be recognized as 0 or 1

    Returns boolean

    true if this is orthogonal matrix

  • Returns if this is regular matrix or not.

    Parameters

    • Optionaltol: number

      Tolerance to recognize the determinant as 0

    Returns boolean

    true if this is regular matrix

  • Returns if this is skew-hermitian matrix or not.

    Parameters

    • Optionaltol: number

      Tolerance within which sign-reversed values are recognized as the same

    Returns boolean

    true if this is skew-hermitian matrix

  • Returns if this is square matrix or not.

    Returns boolean

    true if this is square matrix

  • Returns if this is symmetric matrix or not.

    Parameters

    • Optionaltol: number

      Tolerance to be recognized as the same

    Returns boolean

    true if this is symmetric matrix

  • Returns if this is triangular matrix or not.

    Parameters

    • Optionaltol: number

      Tolerance to be recognized as 0

    Returns boolean

    true if this is triangular matrix

  • Subtract this matrix from a value or matrix.

    Parameters

    Returns void

  • Subtract the value at the position from a value.

    Parameters

    • r: number

      Index of the row whose value is to be subtracted

    • c: number

      Index of the column whose value is to be subtracted

    • v: number

      Value to be subtracted

    Returns number

    Old value

  • Returns if this is unitary matrix or not.

    Parameters

    • Optionaltol: number

      Tolerance to be recognized as 0 or 1

    Returns boolean

    true if this is unitary matrix

  • Returns if this is upper triangular matrix or not.

    Parameters

    • Optionaltol: number

      Tolerance to be recognized as 0

    Returns boolean

    true if this is upper triangular matrix

  • Returns if this is zero matrix or not.

    Parameters

    • Optionaltol: number

      Tolerance to be recognized as 0

    Returns boolean

    true if this is zero matrix

  • Returns kronecker producted value.

    Parameters

    Returns Matrix

    Kronecker producted matrix

  • Set all elements to their left shift values.

    Parameters

    • n: number

      Shift amount

    Returns void

  • Returns a logarithm matrix

    Returns Matrix

    Logarithm matrix

  • Returns a LU decomposition.

    Returns [Matrix, Matrix]

    Lower triangular matrix and upper triangular matrix

  • Iterate over all the elements and replace the value.

    Parameters

    • cb: (arg0: T, arg1: number[], arg2: Matrix<T>) => T

      Mapping function

    Returns void

  • Returns maximum value of all element.

    Returns number

    Maximum value

  • Returns maximum values along the axis.

    Parameters

    • axis: 0 | 1

      Axis to be reduced

    Returns Matrix

    Maximum values

  • Returns maximum values along the axis.

    Parameters

    • axis: number

      Axis to be reduced. If negative, returns the maximum value of the all element.

    Returns number | Matrix

    Maximum values

  • Returns mean of all element.

    Returns number

    Mean value

  • Returns means along the axis.

    Parameters

    • axis: 0 | 1

      Axis to be reduced

    Returns Matrix

    Mean values

  • Returns means along the axis.

    Parameters

    • axis: number

      Axis to be reduced. If negative, returns a mean value of the all element.

    Returns number | Matrix

    Mean values

  • Returns median of all element.

    Returns number

    Median value

  • Returns medians along the axis.

    Parameters

    • axis: 0 | 1

      Axis to be reduced

    Returns Matrix

    Median values

  • Returns medians along the axis.

    Parameters

    • axis: number

      Axis to be reduced. If negative, returns a median of the all element.

    Returns number | Matrix

    Median values

  • Returns minimum value of all element.

    Returns number

    Minimum value

  • Returns minimum values along the axis.

    Parameters

    • axis: 0 | 1

      Axis to be reduced

    Returns Matrix

    Minimum values

  • Returns minimum values along the axis.

    Parameters

    • axis: number

      Axis to be reduced. If negative, returns the minimum value of the all element.

    Returns number | Matrix

    Minimum values

  • Take a remainder divided by a value element-wise.

    Parameters

    Returns void

  • Take a remainder divided the value at the position by a value.

    Parameters

    • r: number

      Index of the row to divide the value by

    • c: number

      Index of the column to divide the value by

    • v: number

      Value to divide

    Returns number

    Old value

  • Returns a modified cholosky decomposition.

    Returns [Matrix, number[]]

    Cholesky decomposition matrix and diagonal matrix

  • Multiplies by a value element-wise.

    Parameters

    Returns void

  • Multiplies a value to the position.

    Parameters

    • r: number

      Index of the row to multiply the value by

    • c: number

      Index of the column to multiply the value by

    • v: number

      Value to multiply

    Returns number

    Old value

  • Multiply all elements by -1 in-place.

    Returns void

  • Returns a p-norm.

    Parameters

    • Optionalp: number

      p-norm

    Returns number

    Entry-wise norm

  • Returns a entry-wise norm

    Parameters

    • Optionalp: number

      p-norm

    Returns number

    Entry-wise norm

  • Returns frobenius norm.

    Returns number

    Frobenius norm

  • Returns induced norm.

    Parameters

    • Optionalp: number

      p-norm

    Returns number

    Induced norm

  • Returns max norm.

    Returns number

    Max norm

  • Returns nuclear norm.

    Returns number

    Nuclear norm

  • Returns schatten norm.

    Parameters

    • Optionalp: number

      p-norm

    Returns number

    Schatten norm

  • Returns spectral norm.

    Returns number

    Spectral norm

  • Set all elements to their logical NOT values.

    Returns void

  • Apply function to the position.

    Parameters

    • r: number

      Index of the row to apply function to

    • c: number

      Index of the column to apply function to

    • Optionalfn: (arg0: T) => T

      Applied function

    Returns T

    Old value

  • Apply function to the position.

    Parameters

    • index: [number, number]

      Index to apply function to

    • fn: (arg0: T) => T

      Applied function

    Returns T

    Old value

  • Take a logical OR with a value or matrix.

    Parameters

    • o: number | Tensor | Matrix<unknown>

      Value to take a logical OR

    Returns void

  • Take logical OR with a value to the position.

    Parameters

    • r: number

      Index of the row to take a logical OR with

    • c: number

      Index of the column to take a logical OR with

    • v: number

      Value to take a logical OR

    Returns T

    Old value

  • Returns a power of this matrix.

    Parameters

    • p: number

      Power exponent value

    Returns Matrix

    Powered matrix

  • Returns producted value of all element.

    Returns number

    Producted value

  • Returns producted values along the axis.

    Parameters

    • axis: 0 | 1

      Axis to be reduced

    Returns Matrix

    Producted values

  • Returns producted values along the axis.

    Parameters

    • axis: number

      Axis to be reduced. If negative, returns a producted value of the all element.

    Returns number | Matrix

    Producted values

  • Returns a pseudo inverse matrix.

    Returns Matrix

    pseudo inverse matrix

  • Returns a Moore–Penrose inverse matrix by Ben-Israel and Cohen iterative method.

    Returns Matrix

    Moore–Penrose inverse matrix

  • Returns a pseudo inverse matrix.

    Returns Matrix

    pseudo inverse matrix

  • Returns a Moore–Penrose inverse matrix by QR decomposition.

    Returns Matrix

    Moore–Penrose inverse matrix

  • Returns a Moore–Penrose inverse matrix by SVD decomposition.

    Returns Matrix

    Moore–Penrose inverse matrix

  • Returns a QR decomposition.

    Returns [Matrix, Matrix]

    Orthogonal matrix and upper triangular matrix

  • Returns a QR decomposition by Gram-Schmidt method.

    Returns [Matrix, Matrix]

    Orthogonal matrix and upper triangular matrix

  • Returns a QR decomposition by Householder method.

    Returns [Matrix, Matrix]

    Orthogonal matrix and upper triangular matrix

  • Returns quantile value of all element.

    Parameters

    • q: number

      Partition rate

    Returns number

    Quantile value

  • Returns quantile values along the axis.

    Parameters

    • q: number

      Partition rate

    • axis: 0 | 1

      Axis to be reduced

    Returns Matrix

    Quantile values

  • Returns quantile values along the axis.

    Parameters

    • q: number

      Partition rate

    • axis: number

      Axis to be reduced. If negative, returns the quantile value of the all element.

    Returns number | Matrix

    Quantile values

  • Returns a rank of this matrix.

    Parameters

    • Optionaltol: number

      Tolerance to be recognized as the same

    Returns number

    Rank of this matrix

  • Returns rank factorization.

    Returns [Matrix, Matrix]

    Rank factorization matrix

  • Returns a matrix reduced along all element with the callback function.

    Type Parameters

    • U

    Parameters

    • cb: (arg0: U, arg1: T, arg2: number[], arg3: Matrix<T>) => U

      Reducing function

    • Optionalinit: U

      Initial value

    Returns U

    Reduced value

  • Returns a matrix reduced along the axis with the callback function.

    Type Parameters

    • U

    Parameters

    • cb: (arg0: U, arg1: T, arg2: number[], arg3: Matrix<T>) => U

      Reducing function

    • init: U

      Initial value

    • axis: 0 | 1

      Axis to be reduced

    • Optionalkeepdims: boolean

      Keep dimensions or not. If null, negative axis retuns number and other axis returns Matrix.

    Returns Matrix<U>

    Reduced matrix

  • Returns a matrix reduced along the axis with the callback function.

    Type Parameters

    • U

    Parameters

    • cb: (arg0: U, arg1: T, arg2: number[], arg3: Matrix<T>) => U

      Reducing function

    • init: U

      Initial value

    • axis: number | number[]

      Axis to be reduced. If negative, reduce along all elements.

    • Optionalkeepdims: boolean

      Keep dimensions or not. If null, negative axis retuns number and other axis returns Matrix.

    Returns U | Matrix<U>

    Reduced matrix or value

  • Calculate reduced row echelon form in-place.

    Parameters

    • Optionaltol: number

      Tolerance to be recognized as 0

    Returns void

  • Remove specified indexes.

    Parameters

    • idx: number | number[]

      Remove index

    • Optionalaxis: number

      Axis to be removed

    Returns void

  • Remove specified indexes.

    Parameters

    • cond: (arg0: Matrix<T>) => boolean

      Remove condition function. Remove if it returns true

    • Optionalaxis: number

      Axis to be removed

    Returns void

  • Repeat the elements n times along the axis this.

    Parameters

    • n: number

      Repeated count

    • Optionalaxis: number

      Axis to be repeated

    Returns void

    No return

  • Repeat the elements n times along the axis this.

    Parameters

    • n: number[]

      Repeated counts for each axis

    Returns void

    No return

  • Reshape this.

    Parameters

    • rows: number

      New row size

    • cols: number

      New column size

    Returns any

  • Reshape this.

    Parameters

    • sizes: [number, number]

      New sizes for each dimension

    Returns any

  • Resize this matrix.

    Parameters

    • rows: number

      New row size

    • cols: number

      New column size

    • Optionalinit: T

      Value of the extended region

    Returns any

  • Resize this matrix.

    Parameters

    • size: [number, number]

      New sizes for each dimension

    • Optionalinit: T

      Value of the extended region

    Returns any

  • Set all elements to their rounded values.

    Returns void

  • Returns a row matrix at r.

    Parameters

    • r: number | number[] | boolean[]

      Indexes of rows, or an array of boolean values where the row to be selected is true.

    Returns Matrix<T>

    Row selected matrix

  • Returns a matrix that sampled along the axis.

    Parameters

    • n: number

      Sampled size

    • Optionalaxis: number

      Axis to be sampled

    • Optionalduplicate: boolean

      Allow duplicate index or not

    Returns [Matrix<T>, number[]]

    Sampled matrix and its original indexes

  • Returns schur decomposition.

    Returns [Matrix, Matrix]

    Schur decomposition matrix

  • Returns schur decomposition by QR decomposition.

    Parameters

    • Optionalshift: "no" | "single"

      Shifting type

    Returns [Matrix, Matrix]

    Schur decomposition matrix

  • Set a value at the position.

    Parameters

    • r: number

      Row index

    • c: number

      Column index

    • value: Matrix<T> | T

      The value to be set

    Returns T

    Old value

  • Set a value at the position.

    Parameters

    • r: [number, number]

      Index values

    • value: Matrix<T> | T

      The value to be set

    Returns T

    Old value

  • Shuffle values along the axis.

    Parameters

    • Optionalaxis: number

      Axis to be shuffled

    Returns number[]

    Original index.

  • Set all elements to their right shift values.

    Parameters

    • n: number

      Shift amount

    Returns void

  • Returns the maximum singular value.

    Parameters

    • OptionalmaxIteration: number

      Maximum iteration

    Returns number

    Maximum singular value

  • Returns singular values.

    Returns number[]

    Singular values

  • Returns sliced matrix.

    Parameters

    • from: number

      Start index

    • to: number

      End index

    • Optionalaxis: number

      Axis to be sliced

    Returns Matrix<T>

    Sliced matrix

  • Returns a solved value A of a equation XA=B.

    Parameters

    • b: Matrix

      Dependent variable values

    Returns Matrix

    Solved matrix

  • Returns a solved value with Gauss-Seidel method.

    Parameters

    • b: Matrix

      Dependent variable values

    • OptionalmaxIteration: number

      Maximum iteration

    Returns Matrix

    Solved matrix

  • Returns a solved value with Jacobi method.

    Parameters

    • b: Matrix

      Dependent variable values

    • OptionalmaxIteration: number

      Maximum iteration

    Returns Matrix

    Solved matrix

  • Returns a solved value for lower triangular matrix.

    Parameters

    • b: Matrix

      Dependent variable values

    Returns Matrix

    Solved matrix

  • Returns a solved value with Successive Over-Relaxation method.

    Parameters

    • b: Matrix

      Dependent variable values

    • w: Matrix

      Relaxation factor

    • OptionalmaxIteration: number

      Maximum iteration

    Returns Matrix

    Solved matrix

  • Returns a solved value for upper triangular matrix.

    Parameters

    • b: Matrix

      Dependent variable values

    Returns Matrix

    Solved matrix

  • Determines whether the specified callback function returns true for any element of a matrix.

    Parameters

    • cb: (arg0: T, arg1: number[], arg2: Matrix<T>) => boolean

      Check function

    Returns boolean

    Reduced value or matrix

  • Determines whether the specified callback function returns true for any element of a matrix.

    Parameters

    • cb: (arg0: T, arg1: number[], arg2: Matrix<T>) => boolean

      Check function

    • axis: 0 | 1

      Axis to be reduced

    Returns Matrix<boolean>

    Reduced value or matrix

  • Determines whether the specified callback function returns true for any element of a matrix.

    Parameters

    • cb: (arg0: T, arg1: number[], arg2: Matrix<T>) => boolean

      Check function

    • axis: number

      Axis to be reduced

    Returns boolean | Matrix<boolean>

    Reduced value or matrix

  • Sort values along the axis.

    Parameters

    • Optionalaxis: number

      Axis to be sorted

    Returns number[]

    Original index.

  • Returns a spectral radius.

    Returns number

    Spectral radius

  • Returns a square root of this matrix.

    Returns Matrix

    Squared matrix

  • Returns standard deviation of all element.

    Returns number

    Standard deviation value

  • Returns standard deviations along the axis.

    Parameters

    • axis: 0 | 1

      Axis to be reduced

    • Optionalddof: number

      Delta Degrees of Freedom

    Returns Matrix

    Standard deviation values

  • Returns standard deviations along the axis.

    Parameters

    • axis: number

      Axis to be reduced. If negative, returns a standard deviation of the all element.

    • Optionalddof: number

      Delta Degrees of Freedom

    Returns number | Matrix

    Standard deviation values

  • Subtract a value or matrix.

    Parameters

    Returns void

  • Subtract a value from the value at the position.

    Parameters

    • r: number

      Index of the row to subtract the value to

    • c: number

      Index of the column to subtract the value to

    • v: number

      Value to subtract

    Returns number

    Old value

  • Returns summation value of all element.

    Returns number

    Summation value

  • Returns summation values along the axis.

    Parameters

    • axis: 0 | 1

      Axis to be reduced

    Returns Matrix

    Summation values

  • Returns summation values along the axis.

    Parameters

    • axis: number

      Axis to be reduced. If negative, returns a summation value of the all element.

    Returns number | Matrix

    Summation values

  • Returns a singular value decomposition.

    Returns [Matrix, number[], Matrix]

    Unitary matrix and singular values

  • Returns a singular value decomposition by eigen decomposition.

    Returns [Matrix, number[], Matrix]

    Unitary matrix and singular values

  • Returns a singular value decomposition by Golub-Kahan method.

    Returns [Matrix, number[], Matrix]

    Unitary matrix and singular values

  • Swap the index a and b along the axis.

    Parameters

    • a: number

      First index

    • b: number

      Second index

    • Optionalaxis: number

      Axis to be swapped

    Returns void

  • Returns a matrix product of the transposed matrix of this and input.

    Parameters

    Returns Matrix

    Producted matrix

  • Returns a nested array represented this matrix.

    Returns T[][]

    Nested array

  • Returns the only element.

    Returns T

    The only element

  • Returns a string represented this matrix.

    Returns string

    String represented this matrix

  • Returns a trace.

    Returns number

    Trace value

  • Returns transpose matrix.

    Returns Matrix<T>

    Transposed matrix

  • Returns a tridiagonal matrix.

    Returns Matrix

    Tridiagonal matrix

  • Returns a tridiagonal matrix.

    Parameters

    • Optionalreturn_u: false

      Returns orthogonal matrix

    Returns Matrix

    Tridiagonal matrix, or Tridiagonal matrix and orthogonal matrix

  • Returns a tridiagonal matrix.

    Parameters

    • return_u: true

      Returns orthogonal matrix

    Returns [Matrix, Matrix]

    Tridiagonal matrix, or Tridiagonal matrix and orthogonal matrix

  • Returns a tridiagonal matrix.

    Parameters

    • Optionalk: number

      Number of iterations

    Returns Matrix

    Tridiagonal matrix

  • Make it unique in the specified axis.

    Parameters

    • Optionalaxis: number

      Axis to be uniqued

    • Optionaltol: number

      Tolerance to be recognized as the same

    Returns number[]

    Selected indexes

  • Set all elements to their unsigned right shift values.

    Parameters

    • n: number

      Shift amount

    Returns void

  • Returns variance of all element.

    Returns number

    Variance value

  • Returns variances along the axis.

    Parameters

    • axis: 0 | 1

      Axis to be reduced.

    • Optionalddof: number

      Delta Degrees of Freedom

    Returns Matrix

    Variance values

  • Returns variances along the axis.

    Parameters

    • axis: number

      Axis to be reduced. If negative, returns a variance of the all element.

    • Optionalddof: number

      Delta Degrees of Freedom

    Returns number | Matrix

    Variance values

  • Returns a matrix that add two values.

    Parameters

    Returns Matrix

    Added matrix

  • Returns a matrix that takes logical AND two values.

    Parameters

    • a: number | Matrix<unknown>

      Left value

    • b: number | Matrix<unknown>

      Right value

    Returns Matrix

    Logical AND matrix

  • Returns a matrix that takes bitwise AND two values.

    Parameters

    Returns Matrix

    Bitwise AND matrix

  • Returns a matrix that takes bitwise OR two values.

    Parameters

    Returns Matrix

    Bitwise OR matrix

  • Returns a matrix that takes bitwise XOR two values.

    Parameters

    Returns Matrix

    Bitwise XOR matrix

  • Returns a matrix concatenated this and m.

    Type Parameters

    • T_6
    • U_3

    Parameters

    • a: Matrix<T_6>

      Original matrix

    • b: Matrix<U_3>

      Concatenate matrix

    • Optionalaxis: number

      Axis to be concatenated

    Returns Matrix<T_6 | U_3>

    Concatenated matrix

  • Returns a matrix that divides by two values element-wise.

    Parameters

    Returns Matrix

    Divided matrix

  • Returns a identity matrix.

    Parameters

    • rows: number

      Number of rows

    • cols: number

      Number of columns

    • Optionalinit: number

      Diagonal values

    Returns Matrix

    Identity matrix

  • Returns a identity matrix.

    Parameters

    • size: [number, number]

      Sizes for each dimension

    • Optionalinit: number

      Diagonal values

    Returns Matrix

    Identity matrix

  • Returns a matrix that replace all the elements.

    Type Parameters

    • T_3
    • U_2

    Parameters

    Returns Matrix<U_2>

    Mapped matrix

  • Returns a matrix that takes a remainder divided by two values element-wise.

    Parameters

    Returns Matrix

    Remainder matrix

  • Returns a matrix that multiplies by two values element-wise.

    Parameters

    Returns Matrix

    Multiplied matrix

  • Returns a matrix filled with 1.

    Parameters

    • rows: number

      Number of rows

    • cols: number

      Number of columns

    Returns Matrix

    Matrix filled with 1

  • Returns a matrix filled with 1.

    Parameters

    • size: [number, number]

      Sizes for each dimension

    Returns Matrix

    Matrix filled with 1

  • Returns a matrix that takes logical OR two values.

    Parameters

    • a: number | Matrix<unknown>

      Left value

    • b: number | Matrix<unknown>

      Right value

    Returns Matrix

    Logical OR matrix

  • Returns a matrix initialized uniform random integer values.

    Parameters

    • rows: number

      Number of rows

    • cols: number

      Number of columns

    • Optionalmin: number

      Minimum value of the Matrix (include)

    • Optionalmax: number

      Maximum value of the Matrix (include)

    Returns Matrix

    Matrix initialized uniform random values

  • Returns a matrix initialized uniform random integer values.

    Parameters

    • size: [number, number]

      Sizes for each dimension

    • Optionalmin: number

      Minimum value of the Matrix (include)

    • Optionalmax: number

      Maximum value of the Matrix (include)

    Returns Matrix

    Matrix initialized uniform random values

  • Returns a matrix initialized normal random values.

    Parameters

    • rows: number

      Number of rows

    • cols: number

      Number of columns

    • Optionalmyu: number | number[]

      Mean value(s) of each columns

    • Optionalsigma: number | number[][]

      Variance value or covariance matrix of each columns

    Returns Matrix

    Matrix initialized normal random values

  • Returns a matrix initialized normal random values.

    Parameters

    • rows: [number, number]

      Sizes for each dimension

    • Optionalmyu: number | number[]

      Mean value(s) of each columns

    • Optionalsigma: number | number[][]

      Variance value or covariance matrix of each columns

    Returns Matrix

    Matrix initialized normal random values

  • Returns a matrix initialized uniform random values.

    Parameters

    • rows: number

      Number of rows

    • cols: number

      Number of columns

    • Optionalmin: number

      Minimum value of the Matrix (include)

    • Optionalmax: number

      Maximum value of the Matrix (exclude)

    Returns Matrix

    Matrix initialized uniform random values

  • Returns a matrix initialized uniform random values.

    Parameters

    • size: [number, number]

      Sizes for each dimension

    • Optionalmin: number

      Minimum value of the Matrix (include)

    • Optionalmax: number

      Maximum value of the Matrix (exclude)

    Returns Matrix

    Matrix initialized uniform random values

  • Returns a matrix that repeat the elements n times along the axis.

    Type Parameters

    • T_5

    Parameters

    • mat: Matrix<T_5>

      Original matrix

    • n: number

      Repeated count

    • Optionalaxis: number

      Axis to be repeated

    Returns Matrix<T_5>

    Repeated matrix

  • Returns a matrix that repeat the elements n times along the axis.

    Type Parameters

    • T_5

    Parameters

    • mat: Matrix<T_5>

      Original matrix

    • n: number[]

      Repeated counts for each axis

    Returns Matrix<T_5>

    Repeated matrix

  • Return resized matrix.

    Type Parameters

    • T_4

    Parameters

    • mat: Matrix<T_4>

      Original matrix

    • rows: number

      New row size

    • cols: number

      New column size

    • Optionalinit: T_4

      Value of the extended region

    Returns Matrix<T_4>

    Resized matrix

  • Return resized matrix.

    Type Parameters

    • T_4

    Parameters

    • mat: Matrix<T_4>

      Original matrix

    • rows: [number, number]

      New sizes for each dimension

    • Optionalinit: T_4

      Value of the extended region

    Returns Matrix<T_4>

    Resized matrix

  • Returns a matrix that subtract two values.

    Parameters

    Returns Matrix

    Subtracted matrix

  • Returns a matrix filled with 0.

    Parameters

    • rows: number

      Number of rows

    • cols: number

      Number of columns

    Returns Matrix

    Matrix filled with 0

  • Returns a matrix filled with 0.

    Parameters

    • size: [number, number]

      Sizes for each dimension

    Returns Matrix

    Matrix filled with 0