Class: SparseMatrix

eclairjs/mllib/linalg. SparseMatrix

new SparseMatrix(numRows, numCols, colPtrs, rowIndices, values, isTransposed)

Parameters:
Name Type Description
numRows number
numCols number
colPtrs Array.<number>
rowIndices Array.<number>
values Array.<number>
isTransposed boolean
Source:

Extends

Methods

(static) fromCOO(numRows, numCols, entries) → {module:eclairjs/mllib/linalg.SparseMatrix}

Generate a `SparseMatrix` from Coordinate List (COO) format. Input must be an array of (i, j, value) tuples. Entries that have duplicate values of i and j are added together. Tuples where value is equal to zero will be omitted.
Parameters:
Name Type Description
numRows number number of rows of the matrix
numCols number number of columns of the matrix
entries Iterable Array of (i, j, value) tuples
Source:
Returns:
The corresponding `SparseMatrix`
Type
module:eclairjs/mllib/linalg.SparseMatrix

(static) spdiag(vector) → {module:eclairjs/mllib/linalg.SparseMatrix}

Generate a diagonal matrix in `SparseMatrix` format from the supplied values.
Parameters:
Name Type Description
vector module:eclairjs/mllib/linalg.Vector a `Vector` that will form the values on the diagonal of the matrix `values` on the diagonal
Source:
Returns:
Square `SparseMatrix` with size `values.length` x `values.length` and non-zero
Type
module:eclairjs/mllib/linalg.SparseMatrix

(static) speye(n) → {module:eclairjs/mllib/linalg.SparseMatrix}

Generate an Identity Matrix in `SparseMatrix` format.
Parameters:
Name Type Description
n number number of rows and columns of the matrix
Source:
Returns:
`SparseMatrix` with size `n` x `n` and values of ones on the diagonal
Type
module:eclairjs/mllib/linalg.SparseMatrix

(static) sprand(numRows, numCols, density, rng) → {module:eclairjs/mllib/linalg.SparseMatrix}

Generate a `SparseMatrix` consisting of `i.i.d`. uniform random numbers. The number of non-zero elements equal the ceiling of `numRows` x `numCols` x `density`
Parameters:
Name Type Description
numRows number number of rows of the matrix
numCols number number of columns of the matrix
density number the desired density for the matrix
rng Random a random number generator
Source:
Returns:
`SparseMatrix` with size `numRows` x `numCols` and values in U(0, 1)
Type
module:eclairjs/mllib/linalg.SparseMatrix

(static) sprandn(numRows, numCols, density, rng) → {module:eclairjs/mllib/linalg.SparseMatrix}

Generate a `SparseMatrix` consisting of `i.i.d`. gaussian random numbers.
Parameters:
Name Type Description
numRows number number of rows of the matrix
numCols number number of columns of the matrix
density number the desired density for the matrix
rng Random a random number generator
Source:
Returns:
`SparseMatrix` with size `numRows` x `numCols` and values in N(0, 1)
Type
module:eclairjs/mllib/linalg.SparseMatrix

$init$() → (nullable) {?}

Inherited From:
Source:
Returns:
Type
?

apply(i, j) → {number}

Parameters:
Name Type Description
i number
j number
Overrides:
Source:
Returns:
Type
number

copy() → {module:eclairjs/mllib/linalg.SparseMatrix}

Overrides:
Source:
Returns:
Type
module:eclairjs/mllib/linalg.SparseMatrix

equals(o) → {boolean}

Parameters:
Name Type Description
o object
Source:
Returns:
Type
boolean

multiply0(y) → {module:eclairjs/mllib/linalg.DenseMatrix}

Parameters:
Name Type Description
y module:eclairjs/mllib/linalg.DenseMatrix
Inherited From:
Source:
Returns:
Type
module:eclairjs/mllib/linalg.DenseMatrix

multiply1(y) → {module:eclairjs/mllib/linalg.DenseVector}

Parameters:
Name Type Description
y module:eclairjs/mllib/linalg.DenseVector
Inherited From:
Source:
Returns:
Type
module:eclairjs/mllib/linalg.DenseVector

multiply2(y) → {module:eclairjs/mllib/linalg.DenseVector}

Parameters:
Name Type Description
y module:eclairjs/mllib/linalg.Vector
Inherited From:
Source:
Returns:
Type
module:eclairjs/mllib/linalg.DenseVector

numActives() → {number}

Overrides:
Source:
Returns:
Type
number

numCols() → {number}

Inherited From:
Source:
Returns:
Type
number

numNonzeros() → {number}

Overrides:
Source:
Returns:
Type
number

numRows() → {number}

Inherited From:
Source:
Returns:
Type
number

toArray() → {Array.<number>}

Inherited From:
Source:
Returns:
Type
Array.<number>

toDense() → {module:eclairjs/mllib/linalg.DenseMatrix}

Generate a `DenseMatrix` from the given `SparseMatrix`. The new matrix will have isTransposed set to false.
Source:
Returns:
Type
module:eclairjs/mllib/linalg.DenseMatrix

toString(maxLinesopt, maxLineWidthopt) → {string}

Parameters:
Name Type Attributes Description
maxLines integer <optional>
maxLineWidth integer <optional>
Inherited From:
Source:
Returns:
Type
string

transpose() → {module:eclairjs/mllib/linalg.SparseMatrix}

Overrides:
Source:
Returns:
Type
module:eclairjs/mllib/linalg.SparseMatrix