Class: Matrix

Sushi.Matrix

Initialize a matrix with shape of (rows, cols). If array is given, set the member variable data with given array, otherwise data is not created untill Sushi.Matrix.prototype.syncData is called.

Constructor

new Matrix(rows, cols, dataopt)

Parameters:
Name Type Attributes Description
rows int The number of rows.
cols int The number of cols.
data Float32Array <optional>
Values.

Members

(static) CL

Sushi CL Member variables
Properties:
Name Type Description
buffers int The number of buffers allocated by WebCL.
platform_info string The platform information of WebCL.
device_info string The device information of WebCL.

cols :int

The number of cols.
Type:
  • int

data :Float32Array

Values. Since this may occasionally be not allocated, it is necessary to call Sushi.Matrix.prototype.syncData beforehand.
Type:
  • Float32Array

row_wise :bool

Whether data is stored row-wise or not.
Type:
  • bool

rows :int

The number of rows.
Type:
  • int

Methods

(static) add(mat1, mat2, outputopt) → {Sushi.Matrix}

Add arguments element-wise.
Parameters:
Name Type Attributes Description
mat1 Sushi.Matrix
mat2 Sushi.Matrix
output Sushi.Matrix <optional>
If output is given, reuse it for output.
Returns:
mat1 + mat2
Type
Sushi.Matrix

(static) argmax(mat) → {Sushi.Matrix.Position}

Get index of the maximum values in mat.
Parameters:
Name Type Description
mat Sushi.Matrix
Returns:
Type
Sushi.Matrix.Position

(static) argmaxEachCol(mat, outputopt) → {Sushi.Matrix}

Get row indices of the maximum value for each column.
Parameters:
Name Type Attributes Description
mat Sushi.Matrix
output Sushi.Matrix <optional>
If output is given, reuse it for output.
Returns:
Type
Sushi.Matrix

(static) argmaxEachRow(mat, outputopt) → {Sushi.Matrix}

Get column indices of the maximum value for each row.
Parameters:
Name Type Attributes Description
mat Sushi.Matrix
output Sushi.Matrix <optional>
If output is given, reuse it for output.
Returns:
Type
Sushi.Matrix

(static) argminEachCol(mat, outputopt) → {Sushi.Matrix}

Get row indices of the minimum value for each column.
Parameters:
Name Type Attributes Description
mat Sushi.Matrix
output Sushi.Matrix <optional>
If output is given, reuse it for output.
Returns:
Type
Sushi.Matrix

(static) argminEachRow(mat, outputopt) → {Sushi.Matrix}

Get column indices of the minimum value for each row.
Parameters:
Name Type Attributes Description
mat Sushi.Matrix
output Sushi.Matrix <optional>
If output is given, reuse it for output.
Returns:
Type
Sushi.Matrix

(static) convolve(mat1, mat2, mode, outputopt) → {Sushi.Matrix}

Convolve mat1 and mat2 with output size determined by mode.
Parameters:
Name Type Attributes Description
mat1 Sushi.Matrix
mat2 Sushi.Matrix
mode string 'full': The output is the full discrete linear convolution of the inputs. 'valid': The output consists only of those elements that do not rely on the zero-padding. 'same': The output is the same size as mat1, centered with respect to the full output.
output Sushi.Matrix <optional>
If output is given, reuse it for output.
Returns:
Type
Sushi.Matrix

(static) diag(diag) → {Sushi.Matrix}

Construct an instance of Matrix with its diagonals being taken from diag.
Parameters:
Name Type Description
diag Sushi.Matrix | Array.<float>
Returns:
Type
Sushi.Matrix

(static) divEach(mat1, mat2, outputopt) → {Sushi.Matrix}

Divide arguments element-wise.
Parameters:
Name Type Attributes Description
mat1 Sushi.Matrix
mat2 Sushi.Matrix
output Sushi.Matrix <optional>
If output is given, reuse it for output.
Returns:
mat1 / mat2 (element-wise)
Type
Sushi.Matrix

(static) dot(mat1, mat2) → {float}

Dot product of inputs.
Parameters:
Name Type Description
mat1 Sushi.Matrix
mat2 Sushi.Matrix
Returns:
Type
float

(static) extract(mat, offset_row, offset_col, rows, cols, outputopt) → {Sushi.Matrix}

Construct an instance of Matrix with shape [rows, cols] filled with a small part of mat where offset_row and offset_col are the starting indices.
Parameters:
Name Type Attributes Description
mat Sushi.Matrix
offset_row int
offset_col int
rows int
cols int
output Sushi.Matrix <optional>
If output is given, reuse it for output.
Returns:
Type
Sushi.Matrix

(static) eye(size, outputopt) → {Sushi.Matrix}

Construct an instance of Matrix with ones on the diagonal and zeros elsewhere.
Parameters:
Name Type Attributes Description
size int The number of rows and columns
output Sushi.Matrix <optional>
If output is given, reuse it for output.
Returns:
Type
Sushi.Matrix

(static) fromArray(original_array) → {Sushi.Matrix}

Convert two-dimensional jagged array to an instance of Matrix.
Parameters:
Name Type Description
original_array Array.<Array.<float>>
Returns:
Type
Sushi.Matrix

(static) fromCSV(csv_string) → {Sushi.Matrix}

Convert csv string to an instance of Matrix.
Parameters:
Name Type Description
csv_string string
Returns:
Type
Sushi.Matrix

(static) fromJSON(data) → {Sushi.Matrix}

Construct an instance of Matrix from dumped JSON object.
Parameters:
Name Type Description
data Object
Returns:
Type
Sushi.Matrix

(static) getCol(mat, col, outputopt) → {Sushi.Matrix}

Construct an instance of Matrix with values extracted from specified col of mat.
Parameters:
Name Type Attributes Description
mat Sushi.Matrix
col int
output Sushi.Matrix <optional>
If output is given, reuse it for output.
Returns:
Type
Sushi.Matrix

(static) getEach(original, indices) → {Sushi.Matrix}

Get a value from specified index by each row or column. If indices are row-wise vector, construct row-wise vector where i-th element is set to mat[indices[i], i]. If indices are column-wise vector, construct column-wise vector where i-th element is set to mat[i, indices[i]].
Parameters:
Name Type Description
original Sushi.Matrix
indices Sushi.Matrix
Returns:
Type
Sushi.Matrix

(static) getRow(mat, row, outputopt) → {Sushi.Matrix}

Construct an instance of Matrix with values extracted from specified row of mat.
Parameters:
Name Type Attributes Description
mat Sushi.Matrix
row int
output Sushi.Matrix <optional>
If output is given, reuse it for output.
Returns:
Type
Sushi.Matrix

(static) hasNaN(mat) → {bool}

Check if the mat has at least one NaN value or not.
Parameters:
Name Type Description
mat Sushi.Matrix
Returns:
Type
bool

(static) hstack(mats, outputopt) → {Sushi.Matrix}

Stack a sequence of Matrices horizontally (column wise) to make a single Matrix.
Parameters:
Name Type Attributes Description
mats Array.<Sushi.Matrix> Array of matrices
output Sushi.Matrix <optional>
If output is given, reuse it for output.
Returns:
Type
Sushi.Matrix

(static) largeAdd(mat1, mat2, outputopt) → {Sushi.Matrix}

WebCL version of function Sushi.Matrix.add. If WebCL is not loaded, Sushi.Matrix.add is called instead.
Parameters:
Name Type Attributes Description
mat1 Sushi.Matrix
mat2 Sushi.Matrix
output Sushi.Matrix <optional>
If output is given, reuse it for output.
Returns:
Type
Sushi.Matrix

(static) largeArgmaxEachCol(mat, outputopt) → {Sushi.Matrix}

WebCL version of function Sushi.Matrix.argmaxEachCol. If WebCL is not loaded, Sushi.Matrix.argmaxEachCol is called instead.
Parameters:
Name Type Attributes Description
mat Sushi.Matrix
output Sushi.Matrix <optional>
If output is given, reuse it for output.
Returns:
Type
Sushi.Matrix

(static) largeArgmaxEachRow(mat, outputopt) → {Sushi.Matrix}

WebCL version of function Sushi.Matrix.argmaxEachRow. If WebCL is not loaded, Sushi.Matrix.argmaxEachRow is called instead.
Parameters:
Name Type Attributes Description
mat Sushi.Matrix
output Sushi.Matrix <optional>
If output is given, reuse it for output.
Returns:
Type
Sushi.Matrix

(static) largeArgminEachCol(mat, outputopt) → {Sushi.Matrix}

WebCL version of function Sushi.Matrix.argminEachCol. If WebCL is not loaded, Sushi.Matrix.argminEachCol is called instead.
Parameters:
Name Type Attributes Description
mat Sushi.Matrix
output Sushi.Matrix <optional>
If output is given, reuse it for output.
Returns:
Type
Sushi.Matrix

(static) largeArgminEachRow(mat, outputopt) → {Sushi.Matrix}

WebCL version of function Sushi.Matrix.argminEachRow. If WebCL is not loaded, Sushi.Matrix.argminEachRow is called instead.
Parameters:
Name Type Attributes Description
mat Sushi.Matrix
output Sushi.Matrix <optional>
If output is given, reuse it for output.
Returns:
Type
Sushi.Matrix

(static) largeConvolve(mat1, mat2, mode, outputopt) → {Sushi.Matrix}

WebCL version of function Sushi.Matrix.convolve. If WebCL is not loaded, Sushi.Matrix.convolve is called instead.
Parameters:
Name Type Attributes Description
mat1 Sushi.Matrix
mat2 Sushi.Matrix
mode string
output Sushi.Matrix <optional>
If output is given, reuse it for output.
Returns:
Type
Sushi.Matrix

(static) largeDivEach(mat1, mat2, outputopt) → {Sushi.Matrix}

WebCL version of function Sushi.Matrix.divEach. If WebCL is not loaded, Sushi.Matrix.divEach is called instead.
Parameters:
Name Type Attributes Description
mat1 Sushi.Matrix
mat2 Sushi.Matrix
output Sushi.Matrix <optional>
If output is given, reuse it for output.
Returns:
Type
Sushi.Matrix

(static) largeExtract(mat, offset_row, offset_col, rows, cols, outputopt) → {Sushi.Matrix}

WebCL version of function Sushi.Matrix.extract. If WebCL is not loaded, Sushi.Matrix.extract is called instead.
Parameters:
Name Type Attributes Description
mat Sushi.Matrix
offset_row int
offset_col int
rows int
cols int
output Sushi.Matrix <optional>
If output is given, reuse it for output.
Returns:
Type
Sushi.Matrix

(static) largeMaxEachCol(mat, outputopt) → {Sushi.Matrix}

WebCL version of function Sushi.Matrix.maxEachCol. If WebCL is not loaded, Sushi.Matrix.maxEachCol is called instead.
Parameters:
Name Type Attributes Description
mat Sushi.Matrix
output Sushi.Matrix <optional>
If output is given, reuse it for output.
Returns:
Type
Sushi.Matrix

(static) largeMaxEachRow(mat, outputopt) → {Sushi.Matrix}

WebCL version of function Sushi.Matrix.maxEachRow. If WebCL is not loaded, Sushi.Matrix.maxEachRow is called instead.
Parameters:
Name Type Attributes Description
mat Sushi.Matrix
output Sushi.Matrix <optional>
If output is given, reuse it for output.
Returns:
Type
Sushi.Matrix

(static) largeMul(mat1, mat2, outputopt) → {Sushi.Matrix}

WebCL version of function Sushi.Matrix.mul. If WebCL is not loaded, Sushi.Matrix.mul is called instead.
Parameters:
Name Type Attributes Description
mat1 Sushi.Matrix
mat2 Sushi.Matrix
output Sushi.Matrix <optional>
If output is given, reuse it for output.
Returns:
Type
Sushi.Matrix

(static) largeMulEach(mat1, mat2, outputopt) → {Sushi.Matrix}

WebCL version of function Sushi.Matrix.mulEach. If WebCL is not loaded, Sushi.Matrix.mulEach is called instead.
Parameters:
Name Type Attributes Description
mat1 Sushi.Matrix
mat2 Sushi.Matrix
output Sushi.Matrix <optional>
If output is given, reuse it for output.
Returns:
Type
Sushi.Matrix

(static) largeSub(mat1, mat2, outputopt) → {Sushi.Matrix}

WebCL version of function Sushi.Matrix.sub. If WebCL is not loaded, Sushi.Matrix.sub is called instead.
Parameters:
Name Type Attributes Description
mat1 Sushi.Matrix
mat2 Sushi.Matrix
output Sushi.Matrix <optional>
If output is given, reuse it for output.
Returns:
Type
Sushi.Matrix

(static) largeSum(mat) → {float}

WebCL version of function Sushi.Matrix.sum. If WebCL is not loaded, Sushi.Matrix.sum is called instead.
Parameters:
Name Type Description
mat Sushi.Matrix
Returns:
Type
float

(static) largeSumEachCol(mat, outputopt) → {Sushi.Matrix}

WebCL version of function Sushi.Matrix.sumEachCol. If WebCL is not loaded, Sushi.Matrix.sumEachCol is called instead.
Parameters:
Name Type Attributes Description
mat Sushi.Matrix
output Sushi.Matrix <optional>
If output is given, reuse it for output.
Returns:
Type
Sushi.Matrix

(static) largeSumEachRow(mat, outputopt) → {Sushi.Matrix}

WebCL version of function Sushi.Matrix.sumEachRow. If WebCL is not loaded, Sushi.Matrix.sumEachRow is called instead.
Parameters:
Name Type Attributes Description
mat Sushi.Matrix
output Sushi.Matrix <optional>
If output is given, reuse it for output.
Returns:
Type
Sushi.Matrix

(static) max(mat) → {float}

Get the element-wise maximum of mat.
Parameters:
Name Type Description
mat Sushi.Matrix
Returns:
Type
float

(static) maxEachCol(mat, outputopt) → {Sushi.Matrix}

Get the maximum values from each column.
Parameters:
Name Type Attributes Description
mat Sushi.Matrix
output Sushi.Matrix <optional>
If output is given, reuse it for output.
Returns:
Type
Sushi.Matrix

(static) maxEachRow(mat, outputopt) → {Sushi.Matrix}

Get the maximum values from each row.
Parameters:
Name Type Attributes Description
mat Sushi.Matrix
output Sushi.Matrix <optional>
If output is given, reuse it for output.
Returns:
Type
Sushi.Matrix

(static) min(mat) → {float}

Get the element-wise minimum of mat.
Parameters:
Name Type Description
mat Sushi.Matrix
Returns:
Type
float

(static) mul(mat1, mat2, outputopt) → {Sushi.Matrix}

Matrix multiplication of inputs.
Parameters:
Name Type Attributes Description
mat1 Sushi.Matrix
mat2 Sushi.Matrix
output Sushi.Matrix <optional>
If output is given, reuse it for output.
Returns:
Type
Sushi.Matrix

(static) mulEach(mat1, mat2, outputopt) → {Sushi.Matrix}

Mutiply arguments element-wise.
Parameters:
Name Type Attributes Description
mat1 Sushi.Matrix
mat2 Sushi.Matrix
output Sushi.Matrix <optional>
If output is given, reuse it for output.
Returns:
mat1 * mat2 (element-wise)
Type
Sushi.Matrix

(static) newMatOrReuseMat(rows, cols, matopt) → {Sushi.Matrix}

If mat is not given, return new (rows, cols) array. If mat is given, check the size of mat at first, then if it is consistent with given parameters, the original mat returns, otherwise raise exception.
Parameters:
Name Type Attributes Description
rows int
cols int
mat Sushi.Matrix <optional>
Returns:
Type
Sushi.Matrix

(static) qr(A) → {Sushi.Matrix.QRResult}

Compute the qr factorization of mat, where one output Q is orthonormal and the other output R is upper-triangular.
Parameters:
Name Type Description
A Sushi.Matrix
Returns:
Type
Sushi.Matrix.QRResult

(static) sub(mat1, mat2, outputopt) → {Sushi.Matrix}

Subtract arguments element-wise.
Parameters:
Name Type Attributes Description
mat1 Sushi.Matrix
mat2 Sushi.Matrix
output Sushi.Matrix <optional>
If output is given, reuse it for output.
Returns:
mat1 - mat2
Type
Sushi.Matrix

(static) sum(mat) → {float}

Sum of all elements in mat.
Parameters:
Name Type Description
mat Sushi.Matrix
Returns:
Type
float

(static) sumEachCol(mat, outputopt) → {Sushi.Matrix}

Sum of elements over each column.
Parameters:
Name Type Attributes Description
mat Sushi.Matrix
output Sushi.Matrix <optional>
If output is given, reuse it for output.
Returns:
Type
Sushi.Matrix

(static) sumEachRow(mat, outputopt) → {Sushi.Matrix}

Sum of elements over each row.
Parameters:
Name Type Attributes Description
mat Sushi.Matrix
output Sushi.Matrix <optional>
If output is given, reuse it for output.
Returns:
Type
Sushi.Matrix

(static) svd(A) → {Sushi.Matrix.SVDResult}

Compute the singular value decomposition of mat. Factors mat as U * diag(S) * V.T, where U and V are unitary and S is mat's singular values.
Parameters:
Name Type Description
A Sushi.Matrix
Returns:
Type
Sushi.Matrix.SVDResult

(static) toArray(mat) → {Array}

Convert mat to a two-dimensional jagged array.
Parameters:
Name Type Description
mat Sushi.Matrix
Returns:
Type
Array

(static) upperTriangular(mat, outputopt) → {Sushi.Matrix}

Convert matrix to upper triangle by Gaussian elimination.
Parameters:
Name Type Attributes Description
mat Sushi.Matrix
output Sushi.Matrix <optional>
If output is given, reuse it for output.
Returns:
Type
Sushi.Matrix

(static) vstack(mats, outputopt) → {Sushi.Matrix}

Stack a sequence of Matrices vetrically (row wise) to make a single Matrix.
Parameters:
Name Type Attributes Description
mats Array.<Sushi.Matrix> Array of matrices
output Sushi.Matrix <optional>
If output is given, reuse it for output.
Returns:
Type
Sushi.Matrix

add(mat) → {Sushi.Matrix}

Add mat to self. Update and return self.
Parameters:
Name Type Description
mat Sushi.Matrix
Returns:
Type
Sushi.Matrix

alias() → {Sushi.Matrix}

Create an alias of matrix which shares the member variable data.
Returns:
Type
Sushi.Matrix

clone(outputopt) → {Sushi.Matrix}

Construct a copy of self. If output is given, reuse it for output.
Parameters:
Name Type Attributes Description
output Sushi.Matrix <optional>
Returns:
Type
Sushi.Matrix

copyPropertyFrom(original)

Copy properties from the original but not its member variable data.
Parameters:
Name Type Description
original Sushi.Matrix

destruct()

If WebCL is loaded, discard WebCL buffer. Note: WebCL buffer is not garbage-collected.

det() → {float}

Determinant.
Returns:
Type
float

divEach(mat) → {Sushi.Matrix}

Divide self by mat element-wise. Update and return self.
Parameters:
Name Type Description
mat Sushi.Matrix
Returns:
Type
Sushi.Matrix

dot(mat) → {float}

Dot product with mat.
Parameters:
Name Type Description
mat Sushi.Matrix
Returns:
Type
float

equals(mat) → {bool}

Check whether all elements are completely equal to those of mat or not.
Parameters:
Name Type Description
mat Sushi.Matrix
Returns:
Type
bool

forEach(func) → {Sushi.Matrix}

Execute callback function with each row and column number. Return self.
Parameters:
Name Type Description
func Sushi.Matrix~ForEachCallback
Returns:
Type
Sushi.Matrix

gaussRandom(mu, std) → {Sushi.Matrix}

Fill all elements with random values generated from gaussian ( mean:mu, standard deviation:std ). Return self.
Parameters:
Name Type Description
mu float
std float
Returns:
Type
Sushi.Matrix

get(row, col) → {float}

Get the element of (row, col).
Parameters:
Name Type Description
row int
col int
Returns:
Type
float

getShape() → {Sushi.Matrix.Shape}

Get the number of rows and the number of columns.
Returns:
Type
Sushi.Matrix.Shape

inverse() → {Sushi.Matrix}

Inverse matrix.
Returns:
Type
Sushi.Matrix

largeAdd(mat) → {Sushi.Matrix}

WebCL version of function Sushi.Matrix#add. If WebCL is not loaded, Sushi.Matrix#add is called instead.
Parameters:
Name Type Description
mat Sushi.Matrix
Returns:
Type
Sushi.Matrix

largeClone(outputopt) → {Sushi.Matrix}

WebCL version of function Sushi.Matrix#clone. If WebCL is not loaded, Sushi.Matrix#clone is called instead.
Parameters:
Name Type Attributes Description
output Sushi.Matrix <optional>
Returns:
Type
Sushi.Matrix

largeDivEach(mat) → {Sushi.Matrix}

WebCL version of function Sushi.Matrix#divEach. If WebCL is not loaded, Sushi.Matrix#divEach is called instead.
Parameters:
Name Type Description
mat Sushi.Matrix
Returns:
Type
Sushi.Matrix

largeMul(mat, outputopt) → {Sushi.Matrix}

WebCL version of function Sushi.Matrix#mul. If WebCL is not loaded, Sushi.Matrix#mul is called instead.
Parameters:
Name Type Attributes Description
mat Sushi.Matrix
output Sushi.Matrix <optional>
Returns:
Type
Sushi.Matrix

largeMulEach(mat) → {Sushi.Matrix}

WebCL version of function Sushi.Matrix#mulEach. If WebCL is not loaded, Sushi.Matrix#mulEach is called instead.
Parameters:
Name Type Description
mat Sushi.Matrix
Returns:
Type
Sushi.Matrix

largeSub(mat) → {Sushi.Matrix}

WebCL version of function Sushi.Matrix#sub. If WebCL is not loaded, Sushi.Matrix#sub is called instead.
Parameters:
Name Type Description
mat Sushi.Matrix
Returns:
Type
Sushi.Matrix

largeTimes(times) → {Sushi.Matrix}

WebCL version of function Sushi.Matrix#times. If WebCL is not loaded, Sushi.Matrix#times is called instead.
Parameters:
Name Type Description
times float
Returns:
Type
Sushi.Matrix

largeZeros(num) → {Sushi.Matrix}

WebCL version of function Sushi.Matrix#zeros. If WebCL is not loaded, Sushi.Matrix#zeros is called instead.
Parameters:
Name Type Description
num float
Returns:
Type
Sushi.Matrix

map(func) → {Sushi.Matrix}

Set each element with a return value of callback function which takes original element as its argument. Return self.
Parameters:
Name Type Description
func Sushi.Matrix~MapCallback Callback function to calculate element value
Returns:
Type
Sushi.Matrix

mul(mat, outputopt) → {Sushi.Matrix}

Marix multiplication with mat.
Parameters:
Name Type Attributes Description
mat Sushi.Matrix
output Sushi.Matrix <optional>
If output is given, reuse it for output.
Returns:
Type
Sushi.Matrix

mulEach(mat) → {Sushi.Matrix}

Mutiply mat to self element-wise. Update and return self.
Parameters:
Name Type Description
mat Sushi.Matrix
Returns:
Type
Sushi.Matrix

nearlyEquals(mat, epsilonopt) → {bool}

Check whether all element-wise absolute differences between stored values and mat's values are within epsilon or not.
Parameters:
Name Type Attributes Default Description
mat Sushi.Matrix
epsilon float <optional>
0.01 Allowed absolute difference of each element
Returns:
Type
bool

print()

Display elements on console.

random(minopt, maxopt) → {Sushi.Matrix}

Fill all elements with random values between min and max. Return self.
Parameters:
Name Type Attributes Default Description
min float <optional>
0.0
max float <optional>
1.0
Returns:
Type
Sushi.Matrix

range() → {Sushi.Matrix}

Fill each element with its index number. Return self.
Returns:
Type
Sushi.Matrix

reshape(rows, cols)

Change shape of the matrix. An exception is thrown if the number of elements does not match current value. Return self.
Parameters:
Name Type Description
rows int
cols int

set(row, col, datum) → {Sushi.Matrix}

Set datum to the element of (row, col). Return self.
Parameters:
Name Type Description
row int
col int
datum float
Returns:
Type
Sushi.Matrix

setArray(original_array) → {Sushi.Matrix}

Set elements with given two-dimensional jagged array. Return self.
Parameters:
Name Type Description
original_array Array
Returns:
Type
Sushi.Matrix

setCol(col, mat) → {Sushi.Matrix}

Overwrite col'th column with column-wise vector mat. Return self.
Parameters:
Name Type Description
col int
mat Sushi.Matrix
Returns:
Type
Sushi.Matrix

setEach(func) → {Sushi.Matrix}

Set each element with a return value of callback function which takes the number of row and column as its argument. Return self.
Parameters:
Name Type Description
func Sushi.Matrix~SetEachCallback Callback function to calculate element value
Returns:
Type
Sushi.Matrix

setRow(row, mat) → {Sushi.Matrix}

Overwrite row'th row with row-wise vector mat. Return self.
Parameters:
Name Type Description
row int
mat Sushi.Matrix
Returns:
Type
Sushi.Matrix

sub(mat) → {Sushi.Matrix}

Subtract mat from self. Update and return self.
Parameters:
Name Type Description
mat Sushi.Matrix
Returns:
Type
Sushi.Matrix

syncData()

If the member variable data is not allocated, prepare it. If WebCL is loaded, transport data from WebCL buffer to the member variable data.

t() → {Sushi.Matrix}

Transpose matrix. Create new alias which share the member variable data and invert the member variable row_wise.
Returns:
Type
Sushi.Matrix

times(times) → {Sushi.Matrix}

Multiply num times element-wise. Change self and return self.
Parameters:
Name Type Description
times float
Returns:
Type
Sushi.Matrix

toCSV() → {string}

Dump to CSV string.
Returns:
Type
string

toJSON() → {Object}

Dump to Object
Returns:
Type
Object

toRowWise() → {Sushi.Matrix}

If the member variable row_wise is false, transpose its own elements in order to make row_wise true. Return self.
Returns:
Type
Sushi.Matrix

toString() → {string}

Create readable string of elements.
Returns:
Type
string

zeros(numopt) → {Sushi.Matrix}

Fill all elements with num. Return self.
Parameters:
Name Type Attributes Default Description
num float <optional>
0.0
Returns:
Type
Sushi.Matrix

Type Definitions

Position

Represents position in a matrix.
Type:
  • Object
Properties:
Name Type Description
row int
col int

QRResult

Resulting object of Sushi.Matrix.qr.
Type:
  • Object
Properties:
Name Type Description
Q Sushi.Matrix orthonormal
R Sushi.Matrix upper-triangular

Shape

Represents shape of a matrix.
Type:
  • Object
Properties:
Name Type Description
rows int
cols int

SVDResult

Resulting object of Sushi.Matrix.svd.
Type:
  • Object
Properties:
Name Type Description
U Sushi.Matrix
S Sushi.Matrix
V Sushi.Matrix

ForEachCallback(row, col)

Parameters:
Name Type Description
row int
col int

MapCallback(datum) → {float}

Parameters:
Name Type Description
datum float current value
Returns:
value to write
Type
float

SetEachCallback(row, col) → {float}

Parameters:
Name Type Description
row int
col int
Returns:
value to write
Type
float