Hi there! Are you looking for the official Deno documentation? Try docs.deno.com for all your Deno learning needs.

Matrix

import { Matrix } from "https://git.sr.ht/~ruivieira/deno-experiments/blob/master/mentat/linalg/core.ts";

Creates a "matrix" from an existing array-like object with optional dimensions

class Matrix {
constructor(
array: Array<any> | Float64Array,
rows: number,
cols: number,
);
cols: number;
data: Float64Array;
dim: number;
rows: number;
 
add(other: Matrix): Matrix;
addColumn(col: Vector | Array<number> | Float64Array);
asNestedArray(): Array<Array<number>>;
bsolve(b: Vector, options?: any): Vector;
bsolve_inplace(b: Vector, options?: any): Vector;
chol(): Matrix;
chol_inplace(): Matrix;
col(j: number): Vector;
copy(): Matrix;
decrement(other: Matrix): Matrix;
det(): number;
diagonal(): Vector;
dist(other: Matrix): number;
dist2(other: Matrix): number;
dot(other: Matrix | Vector): number;
fsolve(b: Vector): Vector;
fsolve_inplace(b: Vector): Vector;
increment(other: Matrix): Matrix;
llt_inverse(): Matrix;
lu(): LUResult;
lu_inverse(): Matrix;
map(f: Function): Matrix;
multiply(other: Matrix | Vector): Matrix | Vector;
neg(): Matrix;
negate(): Matrix;
norm(): number;
norm2(): number;
rebuild(f: Function): Matrix;
row(i: number): Vector;
scale(scalar: number): Matrix;
setCol(j: number, col: Vector | Array<number> | Float64Array): Matrix;
setRow(i: number, row: Vector | Array<number> | Float64Array): Matrix;
subtract(other: Matrix): Matrix;
sum(): number;
svd(): SVDResult;
swap_rows(i: number, k: number): Matrix;
toString(precision: number): string;
trace(): number;
transpose(): Matrix;
}

§Constructors

§
new Matrix(array: Array<any> | Float64Array, rows: number, cols: number)
[src]

§Properties

§
cols: number
[src]
§
data: Float64Array
[src]
§
dim: number
[src]
§
rows: number
[src]

§Methods

§
add(other: Matrix): Matrix
[src]

Add two matrices and return sum

@param other
@return
§
addColumn(col: Vector | Array<number> | Float64Array)
[src]
§
asNestedArray(): Array<Array<number>>
[src]
§
bsolve(b: Vector, options?: any): Vector
[src]

Solves Ux = b using backward substitution

@param b

rhs

@param options

{transpose: false}

@return
§
bsolve_inplace(b: Vector, options?: any): Vector
[src]

Solves Ux = b using backward substitution, updates b

@param b

rhs

@param options

{transpose: false}

@return
§
chol(): Matrix
[src]

Cholesky A = LL^T decomposition (returns copy)

@return
§
chol_inplace(): Matrix
[src]

Cholesky A = LL^T decomposition (in-place)

@return

[description]

§
col(j: number): Vector
[src]

Get column j as as column vector

@param j

column index

@return
§
copy(): Matrix
[src]

Returns a copy of a "matrix"

@return
§
decrement(other: Matrix): Matrix
[src]

Decrement matrix (in place)

@param other
@return
§
det(): number
[src]

Computes determinant using upper triangulation

@return

NaN if uninvertible

§
diagonal(): Vector
[src]

Get diagonal as a column vector

@return
§
dist(other: Matrix): number
[src]

Compute euclidian distance

@param other
@return

euclidian distance

§
dist2(other: Matrix): number
[src]

Compute squared euclidian distance

@param other
@return

square euclidian distance

§
dot(other: Matrix | Vector): number
[src]

Generalized dot product (sum of element-wise multiplication)

@param other

another "matrix" of same size

@return
§
fsolve(b: Vector): Vector
[src]

Solves Lx = b using foward substitution

@param b

rhs

@return
§
fsolve_inplace(b: Vector): Vector
[src]

Solves Lx = b using foward substitution, updates b

@param b

rhs

@return
§
increment(other: Matrix): Matrix
[src]

Increment matrix (in place)

@param other
@return
§
llt_inverse(): Matrix
[src]

Computes the matrix inverse using LL^T decomposition

@return

A^-1

§

Computes PA = LU decomposition

@return

{L, U, P}

§
lu_inverse(): Matrix
[src]

Computes the matrix inverse using PA = LU decomposition

@return

A^-1

§
map(f: Function): Matrix
[src]

cwise map function onto matrix copy

@param f

arguments (A[i], i)

@return
§
multiply(other: Matrix | Vector): Matrix | Vector
[src]

Matrix multiplication (naive implementation)

@param other
@return
§

Negates the matrix. All elements will be multiplied by -1.

§
negate(): Matrix
[src]

cwise negate matrix copy

@return
§
norm(): number
[src]

Element-wise 2-norm (Frobenius-norm for matrices)

@return
§
norm2(): number
[src]

Element-wise squared norm

@return
§
rebuild(f: Function): Matrix
[src]

(in place) Each element is replaced by a function applied to the element index

@param f

takes ([i, [j]]) as arguments

@return
§
row(i: number): Vector
[src]

Get row i as a row vector

@param i

row index

@return
§
scale(scalar: number): Matrix
[src]

Multiply by scalar and return copy

@param scalar
@return
§
setCol(j: number, col: Vector | Array<number> | Float64Array): Matrix
[src]
§
setRow(i: number, row: Vector | Array<number> | Float64Array): Matrix
[src]
§
subtract(other: Matrix): Matrix
[src]

Subtract two matrices and return difference

@param other
@return
§
sum(): number
[src]

Sum of all elements

@return
§
swap_rows(i: number, k: number): Matrix
[src]

Swap rows i and k

@param i

row index

@param k

row index

@return

(for chaining)

§
toString(precision: number): string
[src]

String representation

@param precision

(optional)

@return
§
trace(): number
[src]

Trace of a "matrix," i.e. sum along diagonal

@return
§
transpose(): Matrix
[src]

Matrix transpose (copy)

@return