TypeError if data are not symmetric
Readonly
columnsNumber of columns of the matrix.
Readonly
diagonalalias for rows
or columns
(square matrix so equals)
Readonly
rowsNumber of rows of the matrix.
Readonly
sizeTotal number of elements in the matrix.
Adds the values of a vector to each column.
Array or vector.
Symmetric add row / column
Adds the values of a vector to each row.
Array or vector.
Applies a callback for each element of the matrix. The function is called in the matrix (this) context.
Function that will be called for each element in the matrix.
remove sides (rows / columns) with falsy value from mask.
const matrix = new SymmetricMatrix([
[0,1,2,3],
[1,0,4,5],
[2,4,0,6],
[3,5,6,0],
]);
matrix.applyMask([1,0,0,1]);
assert.deepEqual(matrix.toCompact(), new SymmetricMatrix([
[0,3],
[3,0],
]).toCompact());
RangeError if mask length is different of matrix sideSize
Center the matrix in-place. By default, the mean value of the matrix is subtracted from every value.
Optional
options: ICenterOptionsCenter the matrix in-place. By default, the mean values in the give dimension are subtracted from the values.
center by 'row' or 'column'.
Optional
options: ICenterByOptionsCreates an exact and independent copy of the matrix.
Computes the cumulative sum of the matrix elements (in place, row by row).
Alias for AbstractMatrix.diag.
Divides the values of each column by those of a vector.
Array or vector.
Divides the values of each row by those of a vector.
Array or vector.
Computes the dot (scalar) product between the matrix and another.
Fills the matrix with a given value. All elements will be set to this value.
New value.
Multiplies the values of a column with a scalar.
Column index.
Multiplies the values of a vector with each column.
Array or vector.
Multiplies the values of a row with a scalar.
Row index.
Multiplies the values of a vector with each row.
Array or vector.
Negates the matrix. All elements will be multiplied by -1
.
Alias for AbstractMatrix.neg.
Symmetric remove row / column
Creates a new matrix that is a repetition of the current matrix. New matrix has rows times the number of rows of the original matrix, and columns times the number of columns of the original matrix.
Optional
options: IRepeatOptionsvar matrix = new Matrix([[1, 2]]);
matrix.repeat({ rows: 2 }); // [[1, 2], [1, 2]]
Scale the matrix in-place. By default, values are divided by their standard deviation.
Optional
options: IScaleOptionsScale the matrix in-place. By default, values are divided by the standard deviation in the given dimension.
scale by 'row' or 'column'.
Optional
options: IScaleByOptionsReturns a new column-by-column scaled matrix.
Optional
options: IScaleOptionsvar matrix = new Matrix([[1, 2], [-1, 0]]);
var scaledMatrix = matrix.scaleColumns(); // [[1, 1], [0, 0]]
Returns a new row-by-row scaled matrix.
Optional
options: IScaleOptionsReturn a new matrix based on a selection of rows and columns. Order of the indices matters and the same index can be used more than once.
The row indices to select.
The column indices to select.
Sets a given element of the matrix.
Index of the element's row.
Index of the element's column.
The new value for the element.
Sets a column at the given index.
Column index.
Array or vector to set.
Sets a row at the given index.
Row index.
Array or vector to set.
Set a part of the matrix to the given sub-matrix.
The source matrix from which to extract values.
The index of the first row to set.
The index of the first column to set.
Sorts the columns in-place.
Optional
compareFunction: ((a, b) => number)Sorts the rows in-place.
Optional
compareFunction: ((a, b) => number)Returns the standard deviation of all elements of the matrix.
Optional
options: IVarianceOptionsReturns the standard deviation by the given dimension.
standard deviation by 'row' or 'column'.
Optional
options: IVarianceByOptionsSubtracts the values of a vector from each column.
Array or vector.
Returns a subset of the matrix based on an array of column indices.
Array containing the column indices.
Optional
startRow: numberFirst row index. Default: 0
.
Optional
endRow: numberLast row index. Default: this.rows - 1
.
Returns a subset of the matrix based on an array of row indices.
Array containing the row indices.
Optional
startColumn: numberFirst column index. Default: 0
.
Optional
endColumn: numberLast column index. Default: this.columns - 1
.
Subtracts the values of a vector from each row.
Array or vector.
Swap two columns.
First column index.
Second column index.
Swap two rows.
First row index.
Second row index.
Alias for AbstractMatrix.kroneckerProduct.
Compact format upper-right corner of matrix iterate from left to right, from top to bottom.
full view | usefull data
A B C D | A B C D
A 1 2 3 4 | A 1 2 3 4
B 2 5 6 7 | B · 5 6 7
C 3 6 8 9 | C · · 8 9
D 4 7 9 10 | D · · · 10
will return compact 1D array [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]
length is S(i=0, n=sideSize) => 10 for a 4 sideSized matrix
Optional
options: IToStringOptionsReturns the variance of all elements of the matrix.
Optional
options: IVarianceOptionsReturns the variance by the given dimension.
variance by 'row' or 'column'.
Optional
options: IVarianceByOptionsStatic
absStatic
acosStatic
acoshStatic
addStatic
andStatic
asinStatic
asinhStatic
atanStatic
atanhStatic
cbrtStatic
ceilStatic
checkStatic
clz32Static
columnStatic
copyStatic
cosStatic
coshStatic
diagCreates a diagonal matrix based on the given array.
Array containing the data for the diagonal.
Optional
rows: numberNumber of rows. Default: data.length
.
Optional
columns: numberNumber of columns. Default: rows
.
Static
diagonalAlias for AbstractMatrix.diag.
Optional
rows: numberOptional
columns: numberStatic
divStatic
divideStatic
expStatic
expm1Static
eyeCreates an identity matrix with the given dimension. Values of the diagonal will be 1 and others will be 0.
Number of rows.
Optional
columns: numberNumber of columns. Default: rows
.
Optional
value: numberValue to fill the diagonal with. Default: 1
.
Static
floorStatic
from1DArrayStatic
fromTypeError if compact
is not the compact form of a Symmetric Matrix
(Math.sqrt(8 * compactLength + 1) - 1) / 2
must be an integer
Static
froundStatic
identityAlias for AbstractMatrix.eye.
Optional
columns: numberOptional
value: numberStatic
isReturns whether value
is a Matrix.
The value to check.
Static
isStatic
leftStatic
logStatic
log10Static
log1pStatic
log2Static
maxStatic
minStatic
modStatic
modulusStatic
mulStatic
multiplyStatic
notStatic
onesCreates a symmetric matrix with the given dimensions. Values will be set to one.
is private, do not override it.
Number of rows or columns (square).
The new symmetric matrix.
Static
orStatic
powStatic
randCreates a matrix with the given dimensions. Values will be randomly set.
Number of rows.
Number of columns.
Optional
options: IRandomOptionsOptions object.
The new matrix.
Static
randCreates a matrix with the given dimensions. Values will be random integers.
Number of rows.
Number of columns.
Optional
options: IRandomIntOptionsStatic
randomOptional
options: IRandomOptionsStatic
rightStatic
roundStatic
rowStatic
signStatic
signStatic
sinStatic
sinhStatic
sqrtStatic
subStatic
subtractStatic
tanStatic
tanhStatic
truncStatic
xorStatic
zeroStatic
zerosCreates a symmetric matrix with the given dimensions. Values will be set to zero. This is equivalent to calling the Matrix constructor.
is private, do not override it.
Number of rows or columns (square).
The new symmetric matrix.
Throws
TypeError if otherMatrix is not symmetric