-
-
Constructs new Matrix from given 2D array
Parameters:
Name |
Type |
Description |
arry |
Array.<Array.<number>>
|
(default=[[]]) array containing elements of new matrix |
- Source:
-
/var/www/html/software/jsmatrix/jsmatrix.src.js, line 4336
Returns:
new Matrix object
-
Type
-
JSMatrix.Matrix
Example
m = JSMatrix.Matrix.create([[1,2,3],[4,5,6],[7,8,9]]) // m = Matrix([[1,2,3],[4,5,6],[7,8,9]])
-
-
Constructs new diagonal matrix from given 1D array
Parameters:
Name |
Type |
Description |
arry |
Array.<number>
|
JSMatrix.Vector
|
array or vector containing elements of new matrix |
- Source:
-
/var/www/html/software/jsmatrix/jsmatrix.src.js, line 4360
Returns:
new Matrix object
-
Type
-
JSMatrix.Matrix
Example
m1 = JSMatrix.Matrix.Diagonal([1,2,3]); // m1 = Matrix([[1,0,0],[0,2,0],[0,0,3]])
m2 = JSMatrix.Matrix.Diagonal(JSMatrix.vec([1,2,3])); // m2 = Matrix([[1,0,0],[0,2,0],[0,0,3]])
-
<static> Householder(vec=0, precompI) → {JSMatrix.Matrix}
-
Creates a Householder matrix from given vector (ret = I - 2*v*v^T/(v^T*v). Householder matrix is symmetric, orthogonal and involutary
Parameters:
Name |
Type |
Argument |
Description |
vec=0 |
JSMatrix.Vector
|
|
Householder vector to form Householder matrix |
precompI |
JSMatrix.Matrix
|
<optional>
|
=undefined] precomputed identity matrix to save some time of creation |
- Source:
-
/var/www/html/software/jsmatrix/jsmatrix.src.js, line 4437
Returns:
Householder matrix
-
Type
-
JSMatrix.Matrix
Example
m1 = JSMatrix.Matrix.Householder(JSMatrix.vec([0,1,0]))
// m1 = Matrix([[1,0,0],[0,-1,0],[0,0,1]])
b1 = m1.isSymmetric() // b1 = true
b2 = m1.isOrthogonal() // b2 = true
b3 = m1.isInvolutary() // b3 = true
-
<static> I()
-
Alias for JSMatrix.Matrix.Identity(), see {@JSMatrix.Matrix#Identity}
- Source:
-
/var/www/html/software/jsmatrix/jsmatrix.src.js, line 4386
-
-
Constructs new identity matrix of given size
Parameters:
Name |
Type |
Description |
size |
number
|
size of returned matrix |
- Source:
-
/var/www/html/software/jsmatrix/jsmatrix.src.js, line 4375
Returns:
identity matri
-
Type
-
JSMatrix.Matrix
Example
m = JSMatrix.Matrix.Identity(4) // m = Matrix([[1,0,0,0],[0,1,0,0],[0,0,1,0],[0,0,0,1]])
-
<static> Ones(nRows, nCols) → {JSMatrix.Matrix}
-
Creates a matrix of given size full of ones
Parameters:
Name |
Type |
Argument |
Description |
nRows |
number
|
<optional>
|
=0] number of rows |
nCols |
number
|
<optional>
|
=0] number of columns |
- Source:
-
/var/www/html/software/jsmatrix/jsmatrix.src.js, line 4411
Returns:
new vector full of zero
-
Type
-
JSMatrix.Matrix
Example
m = JSMatrix.Matrix.Ones(2,3); // m = Matrix([[1,1,1],[1,1,1]])
-
<static> UnitMatrix()
-
Alias for Matrix.Identity(), see {@JSMatrix.Matrix#Identity}
- Source:
-
/var/www/html/software/jsmatrix/jsmatrix.src.js, line 4391
-
<static> Zeros(nRows, nCols) → {JSMatrix.Matrix}
-
Creates a matrix of given size full of zeros
Parameters:
Name |
Type |
Argument |
Description |
nRows |
number
|
<optional>
|
=0] number of rows |
nCols |
number
|
<optional>
|
=0] number of columns |
- Source:
-
/var/www/html/software/jsmatrix/jsmatrix.src.js, line 4400
Returns:
new matrix full of zero
-
Type
-
JSMatrix.Matrix
Example
m = JSMatrix.Matrix.Zeros(2,3); // m = Matrix([[0,0,0],[0,0,0]])
-
-
Returns receiver's elementwse absolute value
- Source:
-
/var/www/html/software/jsmatrix/jsmatrix.src.js, line 2834
Returns:
receiver's elementwise absolute value
-
Type
-
JSMatrix.Matrix
Example
a = JSMatrix.mat([[1,-2,3],[-4,5,-6],[-7,8,-9]]);
b = a.abs(); // b = Matrix([[1,2,3],[4,5,6],[7,8,9]])
-
-
Returns sum of receiver and matrix ( ret = this + mat )
Parameters:
- Source:
-
/var/www/html/software/jsmatrix/jsmatrix.src.js, line 1527
Returns:
sum of receiver and matrix
-
Type
-
JSMatrix.Matrix
Example
m1 = JSMatrix.mat([[1,2],[3,4]]);
m2 = JSMatrix.mat([[2,5],[3,2]]);
m3 = m1.add(m2); // m3 = Matrix([[3,7],[6,6]])
-
antiSymmetrize()
-
Anti-symmetrize receiver ( this = this - .5*(this+this^T) ). Receiver must be square
- Source:
-
/var/www/html/software/jsmatrix/jsmatrix.src.js, line 2294
Example
m = JSMatrix.mat([[1,2,3],[0,-1,5],[-1,1,7]])
m.antiSymmetrize(); // m = Matrix([[0,1,2],[-1,0,2],[-2,-2,0]])
b = m.isAntiSymmetric(); // b = true
-
antiSymmetrized()
-
Returns anti-symetric part of receiver ( ret = this - .5*(this+this^T) ). Receiver must be square
- Source:
-
/var/www/html/software/jsmatrix/jsmatrix.src.js, line 2313
Example
m1 = JSMatrix.mat([[1,2,3],[0,-1,5],[-1,1,7]])
m2 = m1.antiSymmetrized(); // m2 = Matrix([[0,1,2],[-1,0,3],[-2,0,0]])
b = m2.isAntiSymmetric(); // b = true
-
appendCols(cols)
-
Appends vector(s)/matrix(s) as column(s) to receiver
Parameters:
- Source:
-
/var/www/html/software/jsmatrix/jsmatrix.src.js, line 2774
Example
m = JSMatrix.mat([[1,2],[3,4]]);
m.appendCols(JSMatrix.vec([7,6]));
// m = Matrix([[1,2,7],[3,4,6]])
m.appendCols(JSMatrix.mat([[1,3],[2,4]]));
// m = Matrix([[1,2,7,1,3],[3,4,6,2,4]])
m = JSMatrix.mat([[1,2],[3,4]]);
m.appendCols([JSMatrix.vec([2,1]),JSMatrix.vec([33,44])]);
// m = Matrix([[1,2,2,33],[3,4,1,44]])
m = JSMatrix.mat([[1,2],[3,4]]);
m.appendCols([JSMatrix.mat([[11,12],[21,22]]),JSMatrix.mat([[9,8],[7,6]])]);
// m = Matrix([[1,2,11,12,9,8],[3,4,21,22,7,6]])
-
appendRows(rows)
-
Appends vector(s)/matrix(s) as row(s) to receiver
Parameters:
- Source:
-
/var/www/html/software/jsmatrix/jsmatrix.src.js, line 2735
Example
m = JSMatrix.mat([[1,2],[3,4]]);
m.appendRows(JSMatrix.vec([7,6]));
// m = Matrix([[1,2],[3,4],[7,6]])
m.appendRows(JSMatrix.mat([[1,3],[2,4]]));
// m = Matrix([[1,2],[3,4],[7,6],[1,3],[2,4]])
m = JSMatrix.mat([[1,2],[3,4]]);
m.appendRows([JSMatrix.vec([2,1]),JSMatrix.vec([33,44])]);
// m = Matrix([[1,2],[3,4],[2,1],[33,44]])
m = JSMatrix.mat([[1,2],[3,4]]);
m.appendRows([JSMatrix.mat([[11,12],[21,22]]),JSMatrix.mat([[5,6],[7,8]])]);
// m = Matrix([[1,2],[3,4],[11,12],[21,22],[5,6],[7,8]])
-
assemble(mat, rows, cols)
-
assemble receiver to given matrix ( mat[rows][cols] += this )
Parameters:
- Source:
-
/var/www/html/software/jsmatrix/jsmatrix.src.js, line 2517
Example
m1 = JSMatrix.mat([[11,12,13,14],[21,22,23,24],[31,32,33,34],[41,42,43,44]]);
m2 = JSMatrix.mat([[66,77],[88,99]]);
m2.assemble(m1,[1,2],[0,2]);
// m1 = Matrix([11,12,13,14],[87,22,100,24],[119,32,132,34],[41,42,43,44]])
-
backwardSubstitution(vec, saveOrig) → {JSMatrix.Vector}
-
Returns vector x as a solution of this*ret = vec, receiver is assumed to be upper triangular matrix
Parameters:
Name |
Type |
Argument |
Description |
vec |
JSMatrix.Vector
|
|
right hand side |
saveOrig |
boolean
|
<optional>
|
=true] if true, returns vec will be unchanged and new vector will be returned. If false, solution will be saved to vec and vec will be returned |
- Source:
-
/var/www/html/software/jsmatrix/jsmatrix.src.js, line 3252
Returns:
solution of this*ret = vec
-
Type
-
JSMatrix.Vector
Example
a = JSMatrix.mat([[1,2,3,4],[0,5,6,7],[0,0,8,9],[0,0,0,10]]);
y = JSMatrix.vec([20,34,25,10]);
x = a.backwardSubstitution(y);
// x = Vector([4,3,2,1])
// y = Vector([20,34,25,10])
check = a.mul(x); // check = Vector([20,34,25,10])
yy = y.copy();
// yy = Vector([20,34,25,10])
a.backwardSubstitution(yy,false);
// yy = Vector([4,3,2,1])
-
beAntiSymmetricPartOf(mat)
-
Modifies receiver to become anti-symmetric part of given matrix (this = mat - .5*(mat+mat^T) ). mat has to be square
Parameters:
- Source:
-
/var/www/html/software/jsmatrix/jsmatrix.src.js, line 2344
Example
m1 = JSMatrix.mat([[1],[3]]);
m2 = JSMatrix.mat([[1,2,3],[0,-1,5],[-1,1,7]])
m1.beAntiSymmetricPartOf(m2); // m1 = Matrix([[0,1,2],[-1,0,3],[-2,0,0]])
b = m1.isAntiSymmetric(); // b = true
-
beCopyOf(mat)
-
Modifies receiver to become copy of given matrix (this = mat). Receiver's size is adjusted
Parameters:
- Source:
-
/var/www/html/software/jsmatrix/jsmatrix.src.js, line 2567
Example
m1 = JSMatrix.mat([[4],[5]]);
m2 = JSMatrix.mat([[1,2,3],[4,5,6]]);
m1.beCopyOf(m2); // m1 = Matrix([[1,2,3],[4,5,6]])
-
beDifferenceOf(mat1, mat2)
-
Modifies receiver to become difference of two matrices ( this = mat1 - mat2 ). Receiver's size is adjusted
Parameters:
- Source:
-
/var/www/html/software/jsmatrix/jsmatrix.src.js, line 1618
Example
m = JSMatrix.mat([[5],[9]]);
m1 = JSMatrix.mat([[1,2],[3,4]]);
m2 = JSMatrix.mat([[2,5],[3,2]]);
m.beDifferenceOf(m1,m2); // m = Matrix([[-1,-3],[0,2]])
-
beDyadicProductOf(vec1, vec2)
-
Modifies receiver to become dyadic product of two vectors (this = vec1*vec2^T ). Receiver's size is adjusted
Parameters:
- Source:
-
/var/www/html/software/jsmatrix/jsmatrix.src.js, line 2021
Example
m = JSMatrix.mat([[4],[5]]);
v1 = JSMatrix.vec([1,2,3]);
v2 = JSMatrix.vec([4,5,6]);
m.beDyadicProductOf(v1,v2); // m = Matrix([[4,5,6],[8,10,12],[12,15,18]])
-
beFullOfOnes()
-
Sets all elements of receiver to 1.0
- Source:
-
/var/www/html/software/jsmatrix/jsmatrix.src.js, line 1331
Example
m = JSMatrix.mat([[2,3,4],[5,6,7]]);
m.beFullOfOnes(); // m = Matrix([[1,1,1],[1,1,1]])
-
beInverseOf(mat, method, precompDecomps)
-
Sets receiver as an inversion of given matrix
Parameters:
Name |
Type |
Argument |
Description |
mat |
JSMatrix.Matrix
|
|
given matrix |
method |
string
|
<optional>
|
="default"] see {@JSMatrix.Matrix#inversed} for details} |
precompDecomps |
Array.<JSMatrix.Matrix>
|
<optional>
|
=undefined] precomputed matrix decompositions if we want to use some |
- Source:
-
/var/www/html/software/jsmatrix/jsmatrix.src.js, line 4266
Example
m1 = JSMatrix.mat([[1],[2]]);
m2 = JSMatrix.mat([[1,2,2],[1,0,1],[1,2,1]]);
m1.beInverseOf(m2); // m1 = Matrix([[2.3,-1.4,-0.8],[-1.4,1.2,0.4],[-0.8,0.4,0.8]])
-
beNegativeOf(mat)
-
Modifies receiver to become negative of given matrix (this = -vec). Receiver's size is adjusted
Parameters:
- Source:
-
/var/www/html/software/jsmatrix/jsmatrix.src.js, line 1669
Example
m1 = JSMatrix.mat([[2],[3]]);
m2 = JSMatrix.mat([[1,2,3],[4,5,6]]);
m1.beNegativeOf(m2); // m1 = Matrix([[-1,-2,-3],[-4,-5,-6]])
-
beProductOf(mat1, mat2)
-
Modifies receiver to become product of two matrices (this = mat1*mat2 ). Receiver's size is adjusted
Parameters:
- Source:
-
/var/www/html/software/jsmatrix/jsmatrix.src.js, line 2042
Example
m1 = JSMatrix.mat([[1],[2]]);
m2 = JSMatrix.mat([[11,12],[21,22]]);
m3 = JSMatrix.mat([[1,2],[3,4]]);
m1.beProductOf(m2,m3); // m1 = Matrix([[47,70],[87,130]])
-
beProductTOf(mat1, mat2)
-
Modifies receiver to become product of two matrices (this = mat1*mat2^T )
Parameters:
- Source:
-
/var/www/html/software/jsmatrix/jsmatrix.src.js, line 2094
Example
m1 = JSMatrix.mat([[1],[2]]);
m2 = JSMatrix.mat([[11,12],[21,22]]);
m3 = JSMatrix.mat([[1,3],[2,4]]);
m1.beProductTOf(m2,m3); // m1 = Matrix([[47,70],[87,130]])
-
beSubMatrixOf(mat, rows, cols)
-
Sets receiver to be submatrix of given matrix ( this = mat[rows][cols] )
Parameters:
- Source:
-
/var/www/html/software/jsmatrix/jsmatrix.src.js, line 2406
Example
m1 = JSMatrix.mat([[11,12,13,14],[21,22,23,24],[31,32,33,34],[41,42,43,44]]);
m2 = JSMatrix.mat([[1],[2]]);
m2.beSubMatrixOf(m1,[1,2],[0,2]); // m2 = Matrix([[21,23],[31,33]])
-
beSumOf(mat1, mat2)
-
Modifies receiver to become sum of two matrices ( this = mat1 + mat2 ). Receiver's size is adjusted
Parameters:
- Source:
-
/var/www/html/software/jsmatrix/jsmatrix.src.js, line 1562
Example
m = JSMatrix.mat([[5],[9]]);
m1 = JSMatrix.mat([[1,2],[3,4]]);
m2 = JSMatrix.mat([[2,5],[3,2]]);
m.beSumOf(m1,m2); // m = Matrix([[3,7],[6,6]])
-
beSymmetricPartOf(mat)
-
Modifies receiver to become symmetric part of given matrix (this = .5*(mat+mat^T) ). mat has to be square
Parameters:
Name |
Type |
Description |
mat |
JSMatrix.Matrix
|
given matrix. Receiver's size is adjusted |
- Source:
-
/var/www/html/software/jsmatrix/jsmatrix.src.js, line 2268
Example
m1 = JSMatrix.mat([[1],[3]]);
m2 = JSMatrix.mat([[1,2,3],[0,-1,5],[-1,1,7]])
m1.beSymmetricPartOf(m2); // m1 = Matrix([[1,1,1],[1,-1,3],[1,3,7]])
b = m1.isSymmetric(); // b = true
-
beTProductOf(mat1, mat2)
-
Modifies receiver to become product of two matrices (this = mat1^T*mat2 )
Parameters:
- Source:
-
/var/www/html/software/jsmatrix/jsmatrix.src.js, line 2068
Example
m1 = JSMatrix.mat([[1],[2]]);
m2 = JSMatrix.mat([[11,21],[12,22]]);
m3 = JSMatrix.mat([[1,2],[3,4]]);
m1.beTProductOf(m2,m3); // m1 = Matrix([[47,70],[87,130]])
-
beTProductTOf(mat1, mat2)
-
Modifies receiver to become product of two matrices (this = mat1^T*mat2^T )
Parameters:
- Source:
-
/var/www/html/software/jsmatrix/jsmatrix.src.js, line 2120
Example
m1 = JSMatrix.mat([[1],[2]]);
m2 = JSMatrix.mat([[11,21],[12,22]]);
m3 = JSMatrix.mat([[1,3],[2,4]]);
m1.beTProductTOf(m2,m3); // m1 = Matrix([[47,70],[87,130]])
-
beTranspositionOf(mat)
-
Modifies receiver to become transposition of given matrix (this = mat^T ). Receiver's size is adjusted
Parameters:
- Source:
-
/var/www/html/software/jsmatrix/jsmatrix.src.js, line 2201
Example
m1 = JSMatrix.mat([[4],[5]]);
m2 = JSMatrix.mat([[1,2,3],[4,5,6]]);
m1.beTranspositionOf(m2) // m1 = mat([[1,4],[2,5],[3,6]])
-
beUnitMatrix(newSize)
-
Modifies receiver to be unit matrix
Parameters:
Name |
Type |
Argument |
Description |
newSize |
number
|
<optional>
|
(default=0) new size or receiver. If omitted or 0, current size is considered (then required square matrix), else resized to newSize |
- Source:
-
/var/www/html/software/jsmatrix/jsmatrix.src.js, line 1352
Example
m = JSMatrix.mat([[1],[2]]);
m.beUnitMatrix(); // m = Matrix([[1],[2]])
/// nothing happened, m is not square
m.beUnitMatrix(2); // m = Matrix([[1,0],[0,1]])
m = JSMatrix.mat([[2,3],[4,5]]);
m.beUnitMatrix(); // m = Matrix([[1,0],[0,1]])
-
canMultiplyMat(mat) → {boolean}
-
Testing if receiver can multiply given matrix ( this * mat )
Parameters:
- Source:
-
/var/www/html/software/jsmatrix/jsmatrix.src.js, line 2888
Returns:
true if the multiplication is possible, false otherwise
-
Type
-
boolean
Example
m1 = JSMatrix.mat([[1,2,3],[4,5,6]]);
m2 = JSMatrix.mat([[7,8,9],[10,11,12]]);
m3 = JSMatrix.mat([[11,12],[21,22],[31,32]]);
t1 = m1.canMultiplyMat(m2); // t1 = false
t2 = m1.canMultiplyMat(m3); // t2 = true
-
canMultiplyVec(vec) → {boolean}
-
Testing if receiver can multiply given vector ( this * vec )
Parameters:
- Source:
-
/var/www/html/software/jsmatrix/jsmatrix.src.js, line 2902
Returns:
true if the multiplication is possible, false otherwise
-
Type
-
boolean
Example
m = JSMatrix.mat([[1,2,3],[4,5,6]]);
v1 = JSMatrix.vec([1,2,3]);
v2 = JSMatrix.vec([4,5]);
t1 = m.canMultiplyVec(v1); // t1 = true
t2 = m.canMultiplyVec(v2); // t2 = false
-
chol()
-
Alias for Cholesky decomposition, see {@JSMatrix.Matrix#choleskyDecomposition}
- Source:
-
/var/www/html/software/jsmatrix/jsmatrix.src.js, line 3486
-
choleskyDecomposition(saveOrig, checkSymm) → {JSMatrix.Matrix}
-
Returns lower triangular matrix of Cholesky decomposition of receiver. Receiver must be square, symmetric and positive definite. ( ret * ret^T = this )
Parameters:
Name |
Type |
Argument |
Description |
saveOrig |
boolean
|
<optional>
|
=true] if true, receiver is not changed. If false, solution will be saved to receiver |
checkSymm |
boolean
|
<optional>
|
=false] if true, test of receiver symmetricity is performed, otherwise not |
- Source:
-
/var/www/html/software/jsmatrix/jsmatrix.src.js, line 3440
Returns:
lower triangular Cholesky matrix
-
Type
-
JSMatrix.Matrix
Example
a = JSMatrix.mat([[1,2,4],[2,13,23],[4,23,77]]);
l = a.choleskyDecomposition(); // l = Matrix([[1,0,0],[2,3,0],[4,5,6]])
check = l.x(l.T()); // check = Matrix([[1,2,4],[2,13,23],[4,23,77]]);
-
containsOnlyOnes()
-
Alias for isOne(), see {@JSMatrix.Matrix#isOne}
- Source:
-
/var/www/html/software/jsmatrix/jsmatrix.src.js, line 3093
-
containsOnlyZeros()
-
Alias for isZero(), see {@JSMatrix.Matrix#isZero}
- Source:
-
/var/www/html/software/jsmatrix/jsmatrix.src.js, line 3071
-
-
Returns copy of receiver
- Source:
-
/var/www/html/software/jsmatrix/jsmatrix.src.js, line 2542
Returns:
copy of receiver
-
Type
-
JSMatrix.Matrix
Example
m1 = JSMatrix.mat([[11,12],[21,22]]);
m2 = m1;
m3 = m1.copied();
m1.set(1,0,6);
// m1 = Matrix([[11,12],[6,22]])
// m2 = Matrix([[11,12],[6,22]])
// m3 = Matrix([[11,12],[21,22]])
-
copy()
-
Alias for copied(), see {@JSMatrix.Matrix#copied}
- Source:
-
/var/www/html/software/jsmatrix/jsmatrix.src.js, line 2558
-
decrCol(c, vec)
-
Decerements one column of receiver
Parameters:
Name |
Type |
Description |
c |
number
|
index of column to set |
vec |
JSMatrix.Vector
|
vector to be decremented from c-th column |
- Source:
-
/var/www/html/software/jsmatrix/jsmatrix.src.js, line 1786
Example
m = JSMatrix.mat([[1,2,3],[4,5,6],[7,8,9]]);
m.decrCol(1,JSMatrix.vec([11,12,13])); // m = Matrix([[1,-9,3],[4,-7,6],[7,-5,9]])
-
decrRow(r, vec)
-
Decerements one row of receiver
Parameters:
Name |
Type |
Description |
r |
number
|
index of row to set |
vec |
JSMatrix.Vector
|
vector to be decremented from r-th row |
- Source:
-
/var/www/html/software/jsmatrix/jsmatrix.src.js, line 1772
Example
m = JSMatrix.mat([[1,2,3],[4,5,6],[7,8,9]]);
m.decrRow(1,JSMatrix.vec([11,12,13])); // m = Matrix([[1,2,3],[-7,-7,-7],[7,8,9]])
-
decrsm()
-
Alias for decrSubMatrix, see {@JSMatrix.Matrix#decrSubMatrix}
- Source:
-
/var/www/html/software/jsmatrix/jsmatrix.src.js, line 2505
-
decrSubMatrix(rows, cols, mat)
-
Decrement submatrix at defined positions of receiver ( this[rows][cols] -= mat )
Parameters:
- Source:
-
/var/www/html/software/jsmatrix/jsmatrix.src.js, line 2488
Example
m = JSMatrix.mat([[11,12,13,14],[21,22,23,24],[31,32,33,34],[41,42,43,44]]);
m.decrSubMatrix([1,2],[0,2],JSMatrix.mat([[66,77],[88,99]]));
// m = Matrix([11,12,13,14],[-45,22,-54,24],[-57,32,-66,34],[41,42,43,44]])
-
det()
-
Alias for determinant, see {@JSMatrix.Matrix#determinant}
- Source:
-
/var/www/html/software/jsmatrix/jsmatrix.src.js, line 4323
-
determinant(method, precompDecomps) → {number|null}
-
Returns determinant of receiver.
Parameters:
Name |
Type |
Argument |
Description |
method |
string
|
<optional>
|
="default"] used method. Options are "default" and "lu" for using LU decomposition, "schurForm" or "schur" for using schur form, "schurDecomposition" for using schur decomposition, "eigen" or "eigenDecomposition" for using eigendecomposition |
precompDecomps |
Object
|
<optional>
|
precomputed decomposition (consistent with method parameter) |
- Source:
-
/var/www/html/software/jsmatrix/jsmatrix.src.js, line 4293
Returns:
determinant of receiver
-
Type
-
number
|
null
Example
a = JSMatrix.mat([[4,2,1],[2,5,3],[1,3,6]]);
d = a.determinant(); // d = 67
d = a.determinant('lu'); // d = 67
d = a.determinant('schur'); // d = 67
d = a.determinant('schurdecomposition'); // d = 67
d = a.determinant('eigen'); // d = 67
-
diag()
-
Alias for diagonalToVector(), see {@JSMatrix.Matrix#diagonalToVector}
- Source:
-
/var/www/html/software/jsmatrix/jsmatrix.src.js, line 2596
-
-
Returns vector containing receiver's diagonal elements
- Source:
-
/var/www/html/software/jsmatrix/jsmatrix.src.js, line 2585
Returns:
vector containing receiver's diagonal elements
-
Type
-
JSMatrix.Vector
Example
m = JSMatrix.mat([[1,2,3],[4,5,6],[7,8,9]]);
v = m.diag(); // v = Vector([1,5,9])
-
diagProduct() → {number|null}
-
Returns product of diagonal elements of the receiver
- Source:
-
/var/www/html/software/jsmatrix/jsmatrix.src.js, line 1403
Returns:
product of diagonal elements of the receiver
-
Type
-
number
|
null
Example
m = JSMatrix.mat([[1,2,3],[4,5,6],[7,8,9]]);
p = m.diagProduct(); // p = 45
-
diagSum()
-
Alias for trace, see {@JSMatrix.Matrix#trace}
- Source:
-
/var/www/html/software/jsmatrix/jsmatrix.src.js, line 1395
-
dprod()
-
Alias for diagProduct, see {@JSMatrix.Matrix#diagProduct}
- Source:
-
/var/www/html/software/jsmatrix/jsmatrix.src.js, line 1416
-
eigenDecomposition(method, precompSchurDecomp) → {Object|null}
-
Returns orthogonal matrix P and diagonal matrix L of eigendecomposition of the receiver such that this=P*L*P^-1 (obtained from eigenvalue equation this*P = P*L). If receiver is symmetric, P is orthogonal. Columns of P are eigenvectors of this and diagonal elements of L are corresponding eigenvalues
Parameters:
Name |
Type |
Argument |
Description |
method |
string
|
<optional>
|
(default="default") method of eigenvalues solution ["defaul","symm"] |
precompSchurDecomp |
Object
|
<optional>
|
precomputed Schur decomposition |
- Source:
-
/var/www/html/software/jsmatrix/jsmatrix.src.js, line 4104
Returns:
{p,l} matrix P and diagonal matrix L of eigendecomposition of receiver
-
Type
-
Object
|
null
Example
m1 = JSMatrix.mat([[4,2,3,1],[3,6,5,7],[5,3,8,1],[2,3,4,5]]);
pl = m1.eigenDecomposition()
p = pl.p
l = pl.l
// p = Matrix([[0.287,-0.05676,-0.7041, 0.4897],[0.6779,0.7997,-1.367,-0.9794],[0.5142,-0.6248,1.294,0],[0.4398,0.2640,0.1196,0.4897]])
// l = Matrix([[15.61,0,0,0],[0,4.192,0,0],[0,0,2.201,0],[0,0,0,1]])
c = p.mulm(l).mulm(p.inv())
// c =
-
eigSymmetric(params) → {Object|null}
-
Returns eigenvalues (L) and eigenvectors (P) of symmetric receiver ( (this-lambda*mat)*phi = 0 ). Eigenvectors are normalized with respect to mat
Parameters:
Name |
Type |
Argument |
Description |
params |
Object
|
<optional>
|
Properties
Name |
Type |
Argument |
Description |
mat |
JSMatrix.Matrix
|
<optional>
|
=JSMatrix.Matrix.Identity] mat in (this-lambda*mat)*phi = 0 ). If mat==Matrix.Identity (default), then the "classical" eigenvalue problem is solved ( (this-lambda*I)*phi = 0 -> this*phi=lambda*phi) |
nEigModes |
number
|
string
|
|
='all'] number of first eigenvalues and eigenvectors to be returned. if "all" is, then all eigenvalues are returned |
method |
string
|
<optional>
|
="default"] method of the solution. "default" and "invit" stands for Stodola's inverse iterations methods with Gramm-Schmidt orthogonalization, "subspace" for subspace iterations |
highest |
boolean
|
<optional>
|
=true] find params.nEigModes highest eigenvalues if true, params.nEigModes lowest eigenvalues otherwise |
maxiter |
number
|
<optional>
|
=1000] maximum number of iterations |
|
- Source:
-
/var/www/html/software/jsmatrix/jsmatrix.src.js, line 3977
Returns:
[lambda1 ,lambda2,...,lambdaN],[phi1,phi2,...,phiN]], lambdai is i-th eigenvalue, phii is i-th eigenvector. N = nEigModes
//
-
Type
-
Object
|
null
Example
k = JSMatrix.mat([[9,3,0,0],[3,8,2,0],[0,2,7,2],[0,0,2,8]]);
m = JSMatrix.Matrix.Diagonal([3,2,4,3]);
e = k.eigSymmetric({mat:m,nEigModes:2,highest:false});
ls = e.eigVals;
ps = e.eigVecs;
l1 = ls[0]; // l1 = 1.2504038497315775
l2 = ls[1]; // l2 = 2.279120228657416
p1 = ps[0]; // p1 = Vector([ 0.1288306767139194, -0.22540165581364102, 0.4265175098731745, -0.20077135620035116 ])
p2 = ps[1]; // p2 = Vector([ 0.4514687335612619, -0.32545467450354726, -0.11713473474653795, 0.2014979513549984 ])
///
e = k.eigSymmetric({mat:m,nEigModes:2,highest:true,method:'subspace'});
ls = e.eigVals;
ps = e.eigVecs;
l3 = ls[1]; // l3 = 2.948867853467429
l4 = ls[0]; // l4 = 4.938274734810245
p3 = ps[1]; // p3 = Vector([ 0.14681878659487543, -0.007507144503266177, -0.21233717286242818, -0.5016212772448967 ])
p4 = ps[0]; // p4 = Vector([ 0.3022519091588433, 0.585847242190032, 0.09630780190740544, 0.028264211960396433 ])
///
c1 = k.x(p1).sub(m.x(p1).x(l1)); // c1 = Vector([0,0,0,0])
c2 = k.x(p2).sub(m.x(p2).x(l2)); // c2 = Vector([0,0,0,0])
c3 = k.x(p3).sub(m.x(p3) .x(l3)); // c3 = Vector([0,0,0,0])
c4 = k.x(p4).sub(m.x(p4).x(l4)); // c4 = Vector([0,0,0,0])
-
eigVals(method) → {Array.<number>}
-
Returns eigenvalues of receiver (this*x = ret*x)
Parameters:
Name |
Type |
Argument |
Description |
method |
string
|
<optional>
|
="default"] method of solution. "default" and "schur" stand for similar transformation of receiver into schur form |
- Source:
-
/var/www/html/software/jsmatrix/jsmatrix.src.js, line 4081
Returns:
eigenvalues of receiver
-
Type
-
Array.<number>
Example
m1 = JSMatrix.mat([[4,2,3,1],[3,6,5,7],[5,3,8,1],[2,3,4,5]]);
v1 = m1.schurForm().diag().toArray();
// v1 = [15.6072, 4.1916, 2.2012, 1 ]
v2 = m1.eigVals();
// v2 = [15.6072, 4.1916, 2.2012, 1 ]
-
empty()
-
Empties receiver (resizes it to size 0)
- Source:
-
/var/www/html/software/jsmatrix/jsmatrix.src.js, line 1299
Example
m = JSMatrix.mat([[1,2],[3,4]]);
m.empty(); // m = Matrix([[]])
-
forwardSubstitution(vec, saveOrig) → {JSMatrix.Vector}
-
Returns vector x as a solution of this*ret = vec, receiver is assumed to be lower triangular matrix
Parameters:
Name |
Type |
Argument |
Description |
vec |
JSMatrix.Vector
|
|
right hand side |
saveOrig |
boolean
|
<optional>
|
=true] if true, returns vec will be unchanged and new vector will be returned. If false, solution will be saved to vec and vec will be returned |
- Source:
-
/var/www/html/software/jsmatrix/jsmatrix.src.js, line 3206
Returns:
solution of this*ret = vec
-
Type
-
JSMatrix.Vector
Example
a = JSMatrix.mat([[1,0,0,0],[2,3,0,0],[4,5,6,0],[7,8,9,10]]);
y = JSMatrix.vec([4,17,43,80]);
x = a.forwardSubstitution(y);
// x = Vector([4,3,2,1])
// y = Vector([4,17,43,80])
check = a.mul(x); // check = Vector([4,17,43,80])
yy = y.copy();
// yy = Vector([4,17,43,80])
a.forwardSubstitution(yy,false);
// yy = Vector([4,3,2,1])
-
fromArray(arry)
-
Sets elements of receiver form given Array object
Parameters:
Name |
Type |
Description |
arry |
Array.<Array.<number>>
|
2D array containing new receiver elements |
- Source:
-
/var/www/html/software/jsmatrix/jsmatrix.src.js, line 1488
Example
m = JSMatrix.mat([[3,2],[1,1]])
m.fromArray([[1,2,3],[4,5,6],[7,8,9]]); // m = Matrix([[1,2,3],[4,5,6],[7,8,9]])
-
gaussianElimination(rhs, pivoting, saveOrig) → {JSMatrix.Vector}
-
Returns vector as a solution of system of linear equations using gaussian elimination method (this * ret = rhs --> ret )
Parameters:
Name |
Type |
Argument |
Description |
rhs |
JSMatrix.Vector
|
|
vector of right hand sides |
pivoting |
string
|
<optional>
|
="default"] what type of pivoting to use. "default" and "nopivot" stands for no pivoting, "partpivot" for implicit partial pivoting (only row interchanges) |
saveOrig |
boolean
|
<optional>
|
=true] if true, returns vec will be unchanged and new vector will be returned. If false, solution will be saved to vec and vec will be returned |
- Source:
-
/var/www/html/software/jsmatrix/jsmatrix.src.js, line 3297
Returns:
vector of solution
-
Type
-
JSMatrix.Vector
Example
a = JSMatrix.mat([[1,2,9],[8,3,2],[3,7,3]]);
b = JSMatrix.vec([32,20,26]);
x = a.gaussianElimination(b); // x = Vector([1,2,3])
x = a.gaussianElimination(b,'partpivot'); // x = Vector([1,2,3])
a.gaussianElimination(b,'nopivot',false);
// a = Matrix([[1,2,9],[8,-13,-70],[3,1,-29.384615384615387]])
// b = Vector([1,2,3])
-
-
Returns matrix, whose columns are solutions of system of equations this*ret = rhs
Parameters:
Name |
Type |
Argument |
Description |
rhs |
JSMatrix.Matrix
|
Array.<JSMatrix.Vector>
|
JSMatrix.Vector
|
|
matrix/vector/array of vectors representing right hand sides |
pivoting |
string
|
<optional>
|
="default"] what type of pivoting to use. "default" and "nopivot" stands for no pivoting, "partpivot" for implicit partial pivoting (only row interchanges) |
saveOrig |
boolean
|
<optional>
|
=true] if true, receiver is not changed. If false, solution will be saved to rhs and rhs will be returned |
- Source:
-
/var/www/html/software/jsmatrix/jsmatrix.src.js, line 3356
Returns:
matrix, whose columns are solution for particular right hand sides
-
Type
-
JSMatrix.Vector
|
Array.<JSMatrix.Vector>
|
JSMatrix.Matrix
Example
a = JSMatrix.mat([[1,2,9],[8,3,2],[3,7,3]]);
b1 = JSMatrix.vec([32,20,26]);
b2 = JSMatrix.vec([16,32,26]);
b3 = [b1.copy(),b2.copy()];
b4 = JSMatrix.mat([b1.toArray(),b2.toArray()]).T();
x1 = a.gaussJordanElimination(b1);
// x1 = Vector([ 1, 2, 3 ])
x2 = a.gaussJordanElimination(b2);
// x2 = Vector([ 3, 2, 1 ])
x3 = a.gaussJordanElimination(b3);
// x3 = [Vector([ 1, 2, 3 ]) ,Vector([ 3, 2, 1 ])]
x4 = a.gaussJordanElimination(b4);
// x4 = Matrix([[ 1, 3 ], [ 2, 2 ], [ 3, 1 ]])
x5 = a.gaussJordanElimination(b1,'nopivot');;
// x5 = Vector([ 1, 2, 3 ])
x6 = a.gaussJordanElimination(b2,'nopivot');
// x6 = Vector([ 3, 2, 1 ])
x7 = a.gaussJordanElimination(b3,'nopivot');
// x7 = Vector([ 1, 2, 3 ]) ,Vector([ 3, 2, 1 ])
x8 = a.gaussJordanElimination(b4,'nopivot');
// x8 = Matrix([[ 1, 3 ], [ 2, 2 ], [ 3, 1 ]])
a.gaussJordanElimination(b4,'nopivot',false);
// b4 = Matrix([[ 1, 3 ], [ 2, 2 ], [ 3, 1 ]])
-
get(r, c) → {number|null}
-
Coefficient access function, returns one element of receiver ( ret = this[r][c] ). Matrix.get(r,c) is much safer than direct Matrix[r][c] access method
Parameters:
Name |
Type |
Description |
r |
number
|
index of row of element to be returned |
c |
number
|
index of column of element to be returned |
- Source:
-
/var/www/html/software/jsmatrix/jsmatrix.src.js, line 1433
Returns:
value of the element at r-th row and c-th column
-
Type
-
number
|
null
Example
m = JSMatrix.mat([[11,12,13],[21,22,23],[31,32,33]]);
g = m.get(1,2); // g = 23
g = m[1][2]; // g = 23
/// c out of bounds
g = m.get(1,5); // g = null
g = m[1][5]; // g = undefined
/// r out of bounds
g = m.get(6,5) // g = null
/// g = m[6][5]; would be error (m[6] is not defined)
-
-
Returns one column of receiver
Parameters:
Name |
Type |
Description |
c |
number
|
index of column to return |
- Source:
-
/var/www/html/software/jsmatrix/jsmatrix.src.js, line 1702
Returns:
c-th column of receiver as vector
-
Type
-
JSMatrix.Vector
Example
m = JSMatrix.mat([[1,2,3],[4,5,6],[7,8,9]]);
v = m.getCol(1); // v = Vector([2,5,8])
-
-
Returns one row of receiver
Parameters:
Name |
Type |
Description |
r |
number
|
index of row to return |
- Source:
-
/var/www/html/software/jsmatrix/jsmatrix.src.js, line 1688
Returns:
r-th row of receiver as vector
-
Type
-
JSMatrix.Vector
Example
m = JSMatrix.mat([[1,2,3],[4,5,6],[7,8,9]]);
v = m.getRow(1); // v = Vector([4,5,6])
-
getsm()
-
Alias for getSubMatrix, see {@JSMatrix.Matrix#getSubMatrix}
- Source:
-
/var/www/html/software/jsmatrix/jsmatrix.src.js, line 2395
-
-
Returns submatrix of receiver ( ret = this[rows][cols] )
Parameters:
Name |
Type |
Description |
rows |
Array.<number>
|
JSMatrix.Vector
|
array containing rows coefficients of desired submatrix |
cols |
Array.<number>
|
JSMatrix.Vector
|
array containing columns coefficients of desired submatrix |
- Source:
-
/var/www/html/software/jsmatrix/jsmatrix.src.js, line 2372
Returns:
desired submatrix
-
Type
-
JSMatrix.Matrix
Example
m1 = JSMatrix.mat([[11,12,13,14],[21,22,23,24],[31,32,33,34],[41,42,43,44]]);
m2 = m1.getSubMatrix([1,2],[0,2]); // m2 = Matrix([[21,23],[31,33]])
-
giveAntiSymmetricPart()
-
Alias for symetrized(), see {@JSMatrix.Matrix#antiSymmetrized}
- Source:
-
/var/www/html/software/jsmatrix/jsmatrix.src.js, line 2334
-
giveDeterminant()
-
Alias for determinant, see {@JSMatrix.Matrix#determinant}
- Source:
-
/var/www/html/software/jsmatrix/jsmatrix.src.js, line 4328
-
giveSymmetricPart()
-
Alias for symmetrized(), see {@JSMatrix.Matrix#symmetrized}
- Source:
-
/var/www/html/software/jsmatrix/jsmatrix.src.js, line 2258
-
iadd(mat)
-
Add given matrix to receiver ( this += mat )
Parameters:
- Source:
-
/var/www/html/software/jsmatrix/jsmatrix.src.js, line 1546
Example
m1 = JSMatrix.mat([[1,2],[3,4]]);
m2 = JSMatrix.mat([[2,5],[3,2]]);
m1.iadd(m2); // m1 = Matrix([[3,7],[6,6]])
-
implicitPartialPivotPermutation(saveOrig) → {Object|null}
-
Returns row permutation matrix using implicit partial pivoting (for each column find row with relatively highest element at that column and place that line to the position such that the highest element is on diagonal. Lines that are placed in this way are not considered for further steps)
Parameters:
Name |
Type |
Argument |
Description |
saveOrig |
boolean
|
<optional>
|
=true] if true, returns permutated copy of receiver. If false, permutate receiver and return this |
- Source:
-
/var/www/html/software/jsmatrix/jsmatrix.src.js, line 3155
Returns:
{mat:JSMatrix.Matrix,coeffs:Array.} permutated matrix and array containing coefficients of original matrix according to position in the permutated one ( such that this.rowPermutation(coeffs) = ret )
-
Type
-
Object
|
null
Example
m1 = JSMatrix.mat([[1,2,4,9],[1,8,1,1],[9,4,5,3],[1,2,6,2]]);
m2 = m1.implicitPartialPivotPermutation();
// m2.mat = Matrix([[9,4,5,3],[1,8,1,1],[1,2,6,2],[1,2,4,9]])
// m2.coeffs = [2,1,3,0]
// m1 = Matrix([[1,2,4,9],[1,8,1,1],[9,4,5,3],[1,2,6,2]])
m3 = m1.rowPermutation(m2.coeffs); // m3 = Matrix([[9,4,5,3],[1,8,1,1],[1,2,6,2],[1,2,4,9]])
b = m3.isEqualTo(m2.mat); // b = true
m4 = m2.mat.rowPermutation(m2.coeffs,true); // m4 = Matrix([[1,2,4,9],[1,8,1,1],[9,4,5,3],[1,2,6,2]])
b = m4.isEqualTo(m1); // b = true
m1.implicitPartialPivotPermutation(false);
// m1 = Matrix([[9,4,5,3],[1,8,1,1],[1,2,6,2],[1,2,4,9]])
-
imulf(f)
-
Multiply receiver by float f ( this *= f )
Parameters:
Name |
Type |
Description |
f |
number
|
float multiplier |
- Source:
-
/var/www/html/software/jsmatrix/jsmatrix.src.js, line 1928
Example
m = JSMatrix.mat([[1,2,3],[4,5,6]]);
m.imulf(3); // m = Matrix([[3,6,9],[12,15,18]])
-
incr(r, c, val)
-
Coefficient access function, increment one element of receiver ( this[r][c] += val ). Matrix.incr(r,c,val) is much safer than direct Matrix[r][c]+=val access method
Parameters:
Name |
Type |
Description |
r |
number
|
index of row of element to be incremented |
c |
number
|
index of column of element to be incremented |
val |
number
|
value to be add |
- Source:
-
/var/www/html/software/jsmatrix/jsmatrix.src.js, line 1476
Example
m = JSMatrix.mat([[11,12,13],[21,22,23],[31,32,33]]);
m.incr(1,2,3.45); // m = Matrix([[11,12,13],[21,22,26.45],[31,32,33]])
m[1][2] += 3.45; // m = Matrix([[11,12,13],[21,22,29.9],[31,32,33]])
/// c out of bounds
m.incr(1,5,3.45); // m = Matrix([[11,12,13],[21,22,29.9],[31,32,33]])
/// m[1][5] += 3.45); would be error (m[1][5] is not defined)
/// r out of bounds
m.incr(6,5,3.45); // m = Matrix([[11,12,13],[21,22,29.9],[31,32,33]])
/// m[6][5] += 3.45; would be error (m[6] is not defined)
-
incrCol(c, vec)
-
Incerements one column of receiver
Parameters:
Name |
Type |
Description |
c |
number
|
index of column to set |
vec |
JSMatrix.Vector
|
vector to be incremented to c-th column |
- Source:
-
/var/www/html/software/jsmatrix/jsmatrix.src.js, line 1758
Example
m = JSMatrix.mat([[1,2,3],[4,5,6],[7,8,9]]);
m.incrCol(1,JSMatrix.vec([11,12,13])); // m = Matrix([[1,13,3],[4,17,6],[7,21,9]])
-
incrRow(r, vec)
-
Incerements one row of receiver
Parameters:
Name |
Type |
Description |
r |
number
|
index of row to set |
vec |
JSMatrix.Vector
|
vector to be incremented to r-th row |
- Source:
-
/var/www/html/software/jsmatrix/jsmatrix.src.js, line 1744
Example
m = JSMatrix.mat([[1,2,3],[4,5,6],[7,8,9]]);
m.incrRow(1,JSMatrix.vec([11,12,13])); // m = Matrix([[1,2,3],[15,17,19],[7,8,9]])
-
incrsm()
-
Alias for incrSubMatrix, see {@JSMatrix.Matrix#incrSubMatrix}
- Source:
-
/var/www/html/software/jsmatrix/jsmatrix.src.js, line 2477
-
incrSubMatrix(rows, cols, mat)
-
Increment submatrix at defined positions of receiver ( this[rows][cols] += mat )
Parameters:
- Source:
-
/var/www/html/software/jsmatrix/jsmatrix.src.js, line 2460
Example
m = JSMatrix.mat([[11,12,13,14],[21,22,23,24],[31,32,33,34],[41,42,43,44]]);
m.incrSubMatrix([1,2],[0,2],JSMatrix.mat([[66,77],[88,99]]));
// m = Matrix([11,12,13,14],[87,22,100,24],[119,32,132,34],[41,42,43,44]])
-
ineg()
-
Alias for neagete(), see {@JSMatrix.Matrix#negate}
- Source:
-
/var/www/html/software/jsmatrix/jsmatrix.src.js, line 1660
-
inv()
-
Alias for inversion, see {@JSMatrix.Matrix#inversed}
- Source:
-
/var/www/html/software/jsmatrix/jsmatrix.src.js, line 4255
-
inversed(method, precompDecomps) → {JSMatrix.Matrix}
-
Returns inversion of receiver
Parameters:
Name |
Type |
Argument |
Description |
method |
string
|
<optional>
|
="default"] method used for solution. Options are "default" and "gaussjordan" for Gauss-Jordan method, "lu" for solution with LU decomposition, "eigen" with eigen decomposition, "symmeigen" with eigen decomposition when receiver is symmetric, "svd" for SVD decomposition |
precompDecomps |
Array.<JSMatrix.Matrix>
|
<optional>
|
=undefined] precomputed matrix decompositions if we want to use some |
- Source:
-
/var/www/html/software/jsmatrix/jsmatrix.src.js, line 4189
Returns:
inversion of receiver
-
Type
-
JSMatrix.Matrix
Example
a = JSMatrix.mat([[1,2,2],[1,0,1],[1,2,1]]);
i1 = a.inversed(); // i1 =
c = a.mulm(i1) // c = Matrix([[1,0,0],[0,1,0],[0,0,1]])
i2 = a.inversed('lu') // i2 = Matrix([[-1,1,1],[0,-0.5,0.5],[1,0,-1]])
i3 = a.inversed('eigen') // i3 = Matrix([[-1,1,1],[0,-0.5,0.5],[1,0,-1]])
i4 = a.inversed('svd') // i4 = Matrix([[-1,1,1],[0,-0.5,0.5],[1,0,-1]])
check = a.x(i1); // check = Matrix([[1,0,0],[0,1,0],[0,0,1]])
-
isAntiSymmetric() → {boolean}
-
Testing if receiver is anti-symmetric
- Source:
-
/var/www/html/software/jsmatrix/jsmatrix.src.js, line 2944
Returns:
true if receiver is anti-symmetric, false otherwise
-
Type
-
boolean
Example
m1 = JSMatrix.mat([[11,12,13],[21,22,23],[31,32,33]]);
m2 = JSMatrix.mat([[0,12,13],[-12,0,23],[-13,-23,0]]);
t1 = m1.isAntiSymmetric(); // t1 = false
t2 = m2.isAntiSymmetric(); // t2 = true
-
isEmpty()
-
Tests if receiver is empty (has size 0,0)
- Source:
-
/var/www/html/software/jsmatrix/jsmatrix.src.js, line 1311
Returns:
true if receiver is empty, false otherwise
Example
v1 = new JSMatrix.Matrix(2,3);
v2 = new JSMatrix.Matrix();
b1 = v1.isEmpty(); // b1 = false
b2 = v2.isEmpty(); // b2 = true
-
isEqualTo(mat) → {boolean}
-
Testing matrix equality
Parameters:
Name |
Type |
Description |
mat |
JSMatrix.Matrix
|
matrix to be compared with receiver |
- Source:
-
/var/www/html/software/jsmatrix/jsmatrix.src.js, line 2854
Returns:
true if this==mat, false otherwise
-
Type
-
boolean
Example
a = JSMatrix.mat([[1,2,3],[4,5,6],[7,8,9]]);
b = JSMatrix.mat([[1,2,2.999999999],[4.0000000000002,5,6],[7,8,8.9999999999]]);
c = JSMatrix.mat([[1,2,3],[4,5,6],[7,8,9],[10,11,12]]);
t1 = a.isEqualTo(b); // t1 = true
t2 = a.isEqualTo(c); // t2 = false
-
isIdentity() → {boolean}
-
Test if receiver is identity matrix
- Source:
-
/var/www/html/software/jsmatrix/jsmatrix.src.js, line 3031
Returns:
true if receiver is identity, false otherwise
-
Type
-
boolean
Example
m1 = JSMatrix.mat([[1,0,0],[0,1,0],[0,0,-1]]);
m2 = JSMatrix.mat([[1,0,0],[0,1,0],[0,0,1]]);
i1 = m1.isIdentity() // i1 = false
i2 = m2.isIdentity() // i2 = true
-
isInvolutary() → {boolean}
-
Tests receiver's involutariness (if this*this=I -> this^-1=this)
- Source:
-
/var/www/html/software/jsmatrix/jsmatrix.src.js, line 3133
Returns:
true if receiver is involutary, false otherwise
-
Type
-
boolean
Example
m = JSMatrix.mat([[1,0,0],[0,-1,0],[0,0,-1]])
t = m.isInvolutary() // t = true
-
isLowerTriangular() → {boolean}
-
Testing if receiver is lower triangular matrix
- Source:
-
/var/www/html/software/jsmatrix/jsmatrix.src.js, line 2983
Returns:
true if receiver is lower triangular, false otherwise
-
Type
-
boolean
Example
m1 = JSMatrix.mat([[1,2,3],[4,5,6],[7,8,9]]);
m2 = JSMatrix.mat([[1,0,0],[4,5,0],[7,8,9]]);
t1 = m1.isLowerTriangular(); // t1 = false
t2 = m2.isLowerTriangular(); // t2 = true
-
isOne() → {boolean}
-
Test if receiver is matrix full of ones
- Source:
-
/var/www/html/software/jsmatrix/jsmatrix.src.js, line 3081
Returns:
true if receiver is full of ones, false otherwise
-
Type
-
boolean
Example
m1 = JSMatrix.mat([[1,1,1],[1,.999999999999,1],[1,1,1]]);
m2 = JSMatrix.mat([[1,0,0],[0,1,0],[0,0,1]]);
i1 = m1.isOne() // i1 = true
i2 = m2.isOne() // i2 = false
-
isOrthogonal() → {boolean}
-
Tests receiver's orthogonality (i.e. this*this^T = I => this^-1 = this^T)
- Source:
-
/var/www/html/software/jsmatrix/jsmatrix.src.js, line 3108
Returns:
true if receiver is orthogonal, false otherwise
-
Type
-
boolean
Example
m1 = JSMatrix.Matrix.Householder(JSMatrix.vec([0,1,0]))
// m1 = Matrix([[1,0,0],[0,-1,0],[0,0,1]]);
m2 = JSMatrix.mat([[0,0,1],[1,0,0],[0,1,0]])
m3 = JSMatrix.mat([[1,2,3],[4,5,6],[7,8,9]])
m4 = JSMatrix.mat([[0.8,0,0.6],[0,1,0],[-0.8,0,0.6]]);
b1 = m1.isOrthogonal() // b1 = true
b2 = m2.isOrthogonal() // b2 = true
b3 = m3.isOrthogonal() // b3 = false
b4 = m4.isOrthogonal() // b4 = true
-
isPositiveDefinite() → {boolean}
-
Tests receiver's positive definitness
- Source:
-
/var/www/html/software/jsmatrix/jsmatrix.src.js, line 3122
Returns:
true if receiver is positive definite (if Cholesky decomposition can be performed), false otherwise
-
Type
-
boolean
Example
m1 = JSMatrix.mat([[9,2,1],[2,8,3],[1,3,7]])
m2 = JSMatrix.mat([[-9,2,1],[2,8,3],[1,3,7]])
b1 = m1.isPositiveDefinite() // b1 = true
b2 = m2.isPositiveDefinite() // b2 = false
-
isSameSizeAs(mat) → {boolean}
-
Testing matrix size equality
Parameters:
- Source:
-
/var/www/html/software/jsmatrix/jsmatrix.src.js, line 2874
Returns:
true if mat and receiver has same size, false otherwise
-
Type
-
boolean
Example
a = JSMatrix.mat([[1,2,3],[4,5,6]]);
b = JSMatrix.mat([[5,6,7],[8,9,10],[11,12,13]]);
c = JSMatrix.mat([[14,15,16],[17,18,19]]);
t1 = a.isSameSizeAs(b); // t1 = false
t2 = a.isSameSizeAs(c); // t2 = true
-
isSingular() → {boolean}
-
Test receiver's singularity
- Source:
-
/var/www/html/software/jsmatrix/jsmatrix.src.js, line 3017
Returns:
true if receiver is singular (if abs(this.det()) < JSMatrix.TOL), false otherwise
-
Type
-
boolean
Example
a = JSMatrix.mat([[1,2,3],[2,4,6],[4,5,6]]);
b = JSMatrix.mat([[4,2,1],[2,5,3],[1,3,6]]);
s1 = a.isSingular(); // s1 = true
s2 = b.isSingular(); // s2 = false
-
isSquare() → {boolean}
-
Testing if receiver is square
- Source:
-
/var/www/html/software/jsmatrix/jsmatrix.src.js, line 2914
Returns:
true if receiver is square matrix, false otherwise
-
Type
-
boolean
Example
m1 = JSMatrix.mat([[1,2,3],[4,5,6]]);
m2 = JSMatrix.mat([[1,2,3],[4,5,6],[7,8,9]]);
t1 = m1.isSquare(); // t1 = false
t2 = m2.isSquare(); // t2 = true
-
isSymmetric() → {boolean}
-
Testing if receiver is symmetric
- Source:
-
/var/www/html/software/jsmatrix/jsmatrix.src.js, line 2926
Returns:
true if receiver is symmetric, false otherwise
-
Type
-
boolean
Example
m1 = JSMatrix.mat([[11,12,13],[21,22,23],[31,32,33]]);
m2 = JSMatrix.mat([[11,12,13],[12,22,23],[13,23,33]]);
t1 = m1.isSymmetric(); // t1 = false
t2 = m2.isSymmetric(); // t2 = true
-
isTranspositionOf(mat) → {boolean}
-
Testing if receiver is transposition of given matrix
Parameters:
- Source:
-
/var/www/html/software/jsmatrix/jsmatrix.src.js, line 2964
Returns:
true if this==mat^T, false otherwise
-
Type
-
boolean
Example
m1 = JSMatrix.mat([[1,2,3],[4,5,6]]);
m2 = JSMatrix.mat([[1,4],[2,5],[3,6]]);
m3 = JSMatrix.mat([[1,2],[4,5]]);
b1 = m1.isTranspositionOf(m2); // b1 = true
b2 = m1.isTranspositionOf(m3); // b2 = false
-
isub(mat)
-
Subtract given matrix to receiver ( this -= mat )
Parameters:
- Source:
-
/var/www/html/software/jsmatrix/jsmatrix.src.js, line 1602
Example
m1 = JSMatrix.mat([[1,2],[3,4]]);
m2 = JSMatrix.mat([[2,5],[3,2]]);
m1.isub(m2); // m1 = Matrix([[-1,-3],[0,2]])
-
isUnitMatrix()
-
Alias for isIdentity, see {@JSMatrix.Matrix#isIdentity}
- Source:
-
/var/www/html/software/jsmatrix/jsmatrix.src.js, line 3049
-
isUpperTriangular() → {boolean}
-
Testing if receiver is upper triangular matrix
- Source:
-
/var/www/html/software/jsmatrix/jsmatrix.src.js, line 3000
Returns:
true if receiver is upper triangular, false otherwise
-
Type
-
boolean
Example
m1 = JSMatrix.mat([[1,2,3],[4,5,6],[7,8,9]]);
m2 = JSMatrix.mat([[1,2,3],[0,5,6],[0,0,9]]);
t1 = m1.isUpperTriangular(); // t1 = false
t2 = m2.isUpperTriangular(); // t2 = true
-
isZero() → {boolean}
-
Test if receiver is zero matrix (full of zeroes)
- Source:
-
/var/www/html/software/jsmatrix/jsmatrix.src.js, line 3059
Returns:
true if receiver is zero, false otherwise
-
Type
-
boolean
Example
m1 = JSMatrix.mat([[0,0,0],[0,1e-16,0],[0,0,0]]);
m2 = JSMatrix.mat([[1,0,0],[0,1,0],[0,0,1]]);
i1 = m1.isZero() // i1 = true
i2 = m2.isZero() // i2 = false
-
lduDecomposition(pivoting) → {Object|null}
-
Returns lower triangular (L), diagonal (D) and upper triangular (U) matrix of the receiver such that L*D*U=this. Diagonal elements of both L and U are all 1. Receiver must be square.
Parameters:
Name |
Type |
Argument |
Description |
pivoting |
string
|
<optional>
|
="default"] what type of pivoting to use. "default" and "nopivot" stands for no pivoting, "partpivot" for implicit partial pivoting (only row interchanges) |
- Source:
-
/var/www/html/software/jsmatrix/jsmatrix.src.js, line 3574
Returns:
{l,d,u}, lower, diagonal and upper triangular matrices
-
Type
-
Object
|
null
Example
a = JSMatrix.mat([[2,10,8],[4,23,22],[6,42,52]]);
ldu = a.lduDecomposition();
l = ldu.l; // l = Matrix([[1,0,0],[2,1,0],[3,4,1]])
d = ldu.d; // d = Vector([2,3,4])
u = ldu.u; // u = Matrix([[1,5,4],[0,1,2],[0,0,1]])
check = l.x(d.diag()).x(u) // check = Matrix([[2,10,8],[4,23,22],[6,42,52]]);
-
-
Returns vector/array of vectors/matrix as a solution of system of linear equations (this*ret=rhs --> ret). Receiver must be square. TODO: solution with LU decomposition with permutation
Parameters:
Name |
Type |
Argument |
Description |
rhs |
JSMatrix.Vector
|
Array.<JSMatrix.Vector>
|
JSMatrix.Matrix
|
|
vector of right hand sides. Array of vectors or Matrix as rhs is supported only with "gaussjordan" method |
method |
string
|
<optional>
|
="default"] method of the solution. Implemented methods are "default" and "gauss" for gaussian elimination, "gaussjordan" for Gauss-Jordan elimination (supporting more than one right hand sides in form of array of vectors or matrix with columns as rhs), "lu" for using LU decomposition, "ldu" for using LDU decomposition, "cholesky" for using Cholesky decomposition, "qr" for using QR decomposition |
saveOrig |
boolean
|
<optional>
|
=true] if true, receiver and rhs is not changed. If false, solution will be saved to rhs and rhs will be returned and receiver will be changed |
precompDecomps |
Array.<JSMatrix.Matrix>
|
<optional>
|
=undefined] array of Matrices objects, used for solution using matrix decomposition as precomputed values (the decomposition is performed within linSolve function if args parameter is not specified) |
- Source:
-
/var/www/html/software/jsmatrix/jsmatrix.src.js, line 3702
Returns:
vector/array of vectors/matrix of solution
-
Type
-
JSMatrix.Vector
|
Array.<JSMatrix.Vector>
|
JSMatrix.Matrix
Example
a = JSMatrix.mat([[1,2,9],[8,3,2],[3,7,3]]);
b = JSMatrix.vec([32,20,26]);
x1 = a.linSolve(b); // x1 = Vector([1,2,3])
x2 = a.linSolve(b,'gauss'); // x2 = Vector([1,2,3])
x3 = a.linSolve(b,'gaussjordan'); // x3 = Vector([1,2,3])
x4 = a.linSolve(b,'lu'); // x4 = Vector([1,2,3])
x5 = a.linSolve(b,'ldu'); // x5 = Vector([1,2,3])
x7 = a.linSolve(b,'qr'); // x7 = Vector([1,2,3])
a2 = JSMatrix.mat([[1,2,4],[2,13,23],[4,23,77]]);
b2 = JSMatrix.vec([17,97,281]);
x6 = a2.linSolve(b2,'cholesky'); // x6 = Vector([1,2,3])
-
lltDecomposition()
-
Alias for Cholesky decomposition, see {@JSMatrix.Matrix#choleskyDecomposition}
- Source:
-
/var/www/html/software/jsmatrix/jsmatrix.src.js, line 3491
-
luDecomposition(pivoting) → {Object|null}
-
Returns lower (L) and upper (U) triangular matrix of the receiver such that L*U=this. Diagonal elements of L are all 1. Receiver must be square.
Parameters:
Name |
Type |
Argument |
Description |
pivoting |
string
|
<optional>
|
="default"] what type of pivoting to use. "default" and "nopivot" stands for no pivoting, "partpivot" for implicit partial pivoting (only row interchanges) |
- Source:
-
/var/www/html/software/jsmatrix/jsmatrix.src.js, line 3503
Returns:
{l,u}, lower and upper triangular matrices
-
Type
-
Object
|
null
Example
a = JSMatrix.mat([[6,5,4],[12,13,10],[18,27,21]]);
lu = a.luDecomposition();
l = lu.l; // l = Matrix([[1,0,0],[2,1,0],[3,4,1]])
u = lu.u; // u = Matrix([[6,5,4],[0,3,2],[0,0,1]])
check = l.x(u); // check = Matrix([[6,5,4],[12,13,10],[18,27,21]])
-
max() → {number}
-
Returns receiver's maximal element
- Source:
-
/var/www/html/software/jsmatrix/jsmatrix.src.js, line 2802
Returns:
receiver's maximal element
-
Type
-
number
Example
a = JSMatrix.mat([[1,-2,3],[-4,5,-6],[-7,8,-9]]);
b = a.max(); // b = 8
-
min() → {number}
-
Returns receiver's minimal element
- Source:
-
/var/www/html/software/jsmatrix/jsmatrix.src.js, line 2818
Returns:
receiver's minimal element
-
Type
-
number
Example
a = JSMatrix.mat([[1,-2,3],[-4,5,-6],[-7,8,-9]]);
b = a.min(); // b = -9
-
-
Returns product of receiver and given multiplier (Matrix, Vector or float)
Parameters:
- Source:
-
/var/www/html/software/jsmatrix/jsmatrix.src.js, line 1999
Returns:
copy of receiver multiplied by what
-
Type
-
JSMatrix.Matrix
|
JSMatrix.Vector
Example
m1 = JSMatrix.mat([[1,2,3],[4,5,6]]);
m2 = m1.mul(3); // m2 = Matrix([[3,6,9],[12,15,18]])
//
m3 = JSMatrix.mat([[11,12,13],[21,22,23],[31,32,33]]);
v1 = JSMatrix.vec([1,2,3]);
v2 = m3.mul(v1) // v2 = Vector([74,134,194]);
//
m4 = JSMatrix.mat([[11,12],[21,22]]);
m5 = JSMatrix.mat([[1,2],[3,4]]);
m6 = m4.mul(m5); // m6 = Matrix([[47,70],[87,130]])
-
-
Returns receiver multiplied by float f ( ret = this * f )
Parameters:
Name |
Type |
Description |
f |
number
|
float multiplier |
- Source:
-
/var/www/html/software/jsmatrix/jsmatrix.src.js, line 1909
Returns:
copy of receiver multiplied by f
-
Type
-
JSMatrix.Matrix
Example
m1 = JSMatrix.mat([[1,2,3],[4,5,6]]);
m2 = m1.mulf(3); // m2 = Matrix([[3,6,9],[12,15,18]])
-
-
Returns product of receiver and given matrix ( ret = this * mat )
Parameters:
- Source:
-
/var/www/html/software/jsmatrix/jsmatrix.src.js, line 1965
Returns:
copy of receiver multiplied by mat
-
Type
-
JSMatrix.Matrix
Example
m1 = JSMatrix.mat([[11,12],[21,22]]);
m2 = JSMatrix.mat([[1,2],[3,4]]);
m3 = m1.mulm(m2); // m3 = Matrix([[47,70],[87,130]])
-
-
Returns product of receiver and given vector ( ret = this * vec )
Parameters:
- Source:
-
/var/www/html/software/jsmatrix/jsmatrix.src.js, line 1942
Returns:
copy of receiver multiplied by vec
-
Type
-
JSMatrix.Vector
Example
m = JSMatrix.mat([[11,12,13],[21,22,23],[31,32,33]]);
v1 = JSMatrix.vec([1,2,3]);
v2 = m.mulv(v1); // v2 = Vector([74,134,194])
-
neg()
-
Alias for neageted(), see {@JSMatrix.Matrix#negated}
- Source:
-
/var/www/html/software/jsmatrix/jsmatrix.src.js, line 1644
-
negate()
-
Negate receiver ( ret *= -1., ret = -ret )
- Source:
-
/var/www/html/software/jsmatrix/jsmatrix.src.js, line 1651
Example
m1 = JSMatrix.mat([[1,2,3],[4,5,6]]);
m1.negate(); // m1 = Matrix([[-1,-2,-3],[-4,-5,-6]])
-
-
Returns negative of receiver ( ret = -this )
- Source:
-
/var/www/html/software/jsmatrix/jsmatrix.src.js, line 1637
Returns:
negative of receiver
-
Type
-
JSMatrix.Matrix
Example
m1 = JSMatrix.mat([[1,2,3],[4,5,6]]);
m2 = m1.negated(); // m2 = Matrix([[-1,-2,-3],[-4,-5,-6]])
-
one()
-
Alias for beFullOfOnes(), see {@JSMatrix.Matrix#beFullOfOnes}
- Source:
-
/var/www/html/software/jsmatrix/jsmatrix.src.js, line 1340
-
permuteRows(coeffs, backward)
-
Permute rows of receiver according to given coefficients
Parameters:
Name |
Type |
Argument |
Description |
coeffs |
Array.<number>
|
JSMatrix.Vector
|
|
coefficients of row permutation |
backward |
boolean
|
<optional>
|
=false] if false, receiver's rows is permutated to given coefficients (forward). If true, from given coefficients (backward) |
- Source:
-
/var/www/html/software/jsmatrix/jsmatrix.src.js, line 1834
Example
m = JSMatrix.mat([[11,12,13],[21,22,23],[31,32,33]]);
m.permuteRows([1,2,0]); // m = Matrix([[21,22,23],[31,32,33],[11,12,13]])
m.permuteRows([1,2,0],true); // m = mat([[11,12,13],[21,22,23],[31,32,33]])
-
polarDecomposition(precompSvd) → {Object|null}
-
Returns orthogonal matrix R and symmetric matrix U of polar decomposition of the receiver such that this=R*U. The decomposition is computed from SVD decomposition (this = U*S*V^T -> R = U*V^T, U = V*S*V^T
Parameters:
Name |
Type |
Argument |
Description |
precompSvd |
Object
|
<optional>
|
=undefined] precomputed SVD decomposition |
- Source:
-
/var/www/html/software/jsmatrix/jsmatrix.src.js, line 3930
Returns:
{r,u} orthogonal matrix R and symmetric matrix U of polar decomposition of receiver
-
Type
-
Object
|
null
Example
m = JSMatrix.mat([[1.6,.6,0],[-1.2,0.8,0],[0,0,3]])
ru = m.polarDecomposition();
r = ru.r; // r = Matrix([[0.8,0.6,0],[-0.6,0.8,0],[0,0,1]])
u = ru.u; // u = Matrix([[2,0,0],[0,1,0],[0,0,3]])
b1 = r.isOrthogonal(); // b1 = true
b2 = u.isSymmetric(); // b2 = true
c = r.mulm(u); // c = Matrix([[1.6,.6,0],[-1.2,0.8,0],[0,0,3]])
-
resize(nRows, nCols)
-
Resize receiver according to given size (delete extra elements or add zero elements)
Parameters:
Name |
Type |
Description |
nRows |
number
|
new number of rows |
nCols |
number
|
new number of columns |
- Source:
-
/var/www/html/software/jsmatrix/jsmatrix.src.js, line 2642
Example
m1 = JSMatrix.mat([[11,12,13,14],[21,22,23,24],[31,32,33,34],[41,42,43,44]]);
m2 = JSMatrix.mat([[11,12],[21,22]]);
m1.resize(3,3); // m1 = Matrix([[11,12,13],[21,22,23],[31,32,33]])
m2.resize(3,3); // m2 = Matrix([[11,12,0],[21,22,0],[0,0,0]])
-
-
Returns resized copy of receiver according to given size (delete extra elements or add zero elements)
Parameters:
Name |
Type |
Description |
nRows |
number
|
new number of rows |
nCols |
number
|
new number of columns |
- Source:
-
/var/www/html/software/jsmatrix/jsmatrix.src.js, line 2683
Returns:
resized copy of receiver
-
Type
-
JSMatrix.Matrix
Example
m1 = JSMatrix.mat([[11,12,13],[21,22,23],[31,32,33]]);
m2 = m1.resized(2,4); // m2 = Matrix([[11,12,13,0],[21,22,23,0]])
m3 = m1.resized(4,2); // m3 = Matrix([[11,12],[21,22],[31,32],[0,0]])
-
rowPermutation(coeffs, backward) → {JSMatrix.Matrix}
-
Returns copy of receiver with rows permutated according to given coefficients
Parameters:
Name |
Type |
Argument |
Description |
coeffs |
Array.<number>
|
JSMatrix.Vector
|
|
coefficients of permutation. |
backward |
boolean
|
<optional>
|
=false] if false, receiver is permutated to given coefficients (forward). If true, from given coefficients (backward) |
- Source:
-
/var/www/html/software/jsmatrix/jsmatrix.src.js, line 1877
Returns:
copy of receiver with permutated rows
-
Type
-
JSMatrix.Matrix
Example
m1 = JSMatrix.mat([[11,12,13],[21,22,23],[31,32,33]]);
m2 = m1.rowPermutation([1,2,0]); // m2 = Matrix([[21,22,23],[31,32,33],[11,12,13]])
m3 = m1.rowPermutation([1,2,0],true); // m3 = mat([[31,32,33],[11,12,13],[21,22,23]])
-
schurDecomposition(saveOrig, maxiter) → {Object|null}
-
returns orthogonal matrix Q and upper triangular matrix S as Schur decomposition of receiver such that this=Q*S*Q^-1. Columns of Q are eigenvectors of receiver and diagonal elements of S are eigenvalues of receiver
Parameters:
Name |
Type |
Argument |
Description |
saveOrig |
boolean
|
<optional>
|
=true] if true, returns new matrices, if false, S is formed into original matrix |
maxiter |
number
|
<optional>
|
=1000] maximum number of iterations |
- Source:
-
/var/www/html/software/jsmatrix/jsmatrix.src.js, line 3812
Returns:
{q,s} - Scur decomposition of receiver
-
Type
-
Object
|
null
Example
m1 = JSMatrix.mat([[4,2,3,1],[3,6,5,7],[5,3,8,1],[2,3,4,5]]);
qs = m1.schurDecomposition();
q = qs.q; s = qs.s;
// s = Matrix([[ 15.6072, -3.6605, -0.7006, 2.3149 ], [ 0, 4.1916, 3.3807, 2.0775 ], [ 0, 0, 2.2012, 0.0769 ], [ 0, 0, 0, 1 ]])
qr = s.qrDecomposition();
q1 = qr.q; r = qr.r;
// q1 = Matrix([[ 1, 0, 0, 0 ], [ 0, 1, 0, 0 ], [ 0, 0, 1, 0 ], [ 0, 0, 0, 1 ]])
// r = Matrix([[ 15.6072, -3.6605, -0.7006, 2.3149 ], [ 0, 4.1916, 3.3807, 2.0775 ], [ 0, 0, 2.2012, 0.0769 ], [ 0, 0, 0, 1 ]])
b1 = q.isOrthogonal() // b1 = true
b2 = s.isUpperTriangular() // b2 = true
c = q.mulm(s).mulm(q.inv()); // c = Matrix([[4,2,3,1],[3,6,5,7],[5,3,8,1],[2,3,4,5]])
-
-
returns Schur form of receiver (upper triangular matrix with eigenvalues of the receiver on the diagonal). QR algorithm is used for calculation
Parameters:
Name |
Type |
Argument |
Description |
saveOrig |
boolean
|
<optional>
|
=true] if true, returns new matrix, if false the Schur form is formed on original matrix |
maxiter |
number
|
<optional>
|
=1000] maximum number of iterations |
- Source:
-
/var/www/html/software/jsmatrix/jsmatrix.src.js, line 3765
Returns:
Schur form of receiver (upper triangular matrix with eigenvalues on diagonal)
-
Type
-
JSMatrix.Matrix
Example
m1 = JSMatrix.mat([[4,2,3,1],[3,6,5,7],[5,3,8,1],[2,3,4,5]]);
m2 = m1.schurForm(); // m2 = Matrix([[ 15.6072, -3.6605, -0.7006, 2.3149 ], [ 0, 4.1916, 3.3807, 2.0775 ], [ 0, 0, 2.2012, 0.0769 ], [ 0, 0, 0, 1 ]])
b = m2.isUpperTriangular(); // b = true
-
set(r, c, val)
-
Coefficient access function, sets one element of receiver ( this[r][c] = val ). Matrix.set(r,c,val) is much safer than direct Matrix[r][c]=val access method
Parameters:
Name |
Type |
Description |
r |
number
|
index of row of element to be set |
c |
number
|
index of column of element to be set |
val |
number
|
value to be set |
- Source:
-
/var/www/html/software/jsmatrix/jsmatrix.src.js, line 1455
Example
m = JSMatrix.mat([[11,12,13],[21,22,23],[31,32,33]]);
m.set(1,2,3.45); // m = Matrix([[11,12,13],[21,22,3.45],[31,32,33]])
m[1][2] = 3.45; // m = Matrix([[11,12,13],[21,22,3.45],[31,32,33]])
m = JSMatrix.mat([[11,12,13],[21,22,23],[31,32,33]]);
/// c out of bounds (nothing is done by both appraches)
m.set(1,5,8.45); // m = Matrix([[11,12,13],[21,22,3.45],[31,32,33]])
m[1][5] = 8.45; // m = Matrix([[11,12,13],[21,22,3.45],[31,32,33]])
/// r out of bounds
m.set(6,5,8.45); // m = Matrix([[11,12,13],[21,22,3.45],[31,32,33]])
/// m[6][5] = 8.45; would be error (m[6] is not defined)
-
setCol(c, vec)
-
Sets one column of receiver
Parameters:
Name |
Type |
Description |
c |
number
|
index of column to set |
vec |
JSMatrix.Vector
|
vector to be set as new c-th column |
- Source:
-
/var/www/html/software/jsmatrix/jsmatrix.src.js, line 1730
Example
m = JSMatrix.mat([[1,2,3],[4,5,6],[7,8,9]]);
m.setCol(1,JSMatrix.vec([11,12,13])); // m = Matrix([[1,11,3],[4,12,6],[7,13,9]])
-
setRow(r, vec)
-
Sets one row of receiver
Parameters:
Name |
Type |
Description |
r |
number
|
index of row to set |
vec |
JSMatrix.Vector
|
vector to be set as new r-th row |
- Source:
-
/var/www/html/software/jsmatrix/jsmatrix.src.js, line 1716
Example
m = JSMatrix.mat([[1,2,3],[4,5,6],[7,8,9]]);
m.setRow(1,JSMatrix.vec([11,12,13])); // m = Matrix([[1,2,3],[11,12,13],[7,8,9]])
-
setsm()
-
Alias for setSubMatrix, see {@JSMatrix.Matrix#setSubMatrix}
- Source:
-
/var/www/html/software/jsmatrix/jsmatrix.src.js, line 2449
-
setSubMatrix(rows, cols, mat)
-
Sets submatrix at defined positions of receiver ( this[rows][cols] = mat )
Parameters:
- Source:
-
/var/www/html/software/jsmatrix/jsmatrix.src.js, line 2432
Example
m = JSMatrix.mat([[11,12,13,14],[21,22,23,24],[31,32,33,34],[41,42,43,44]]);
m.setSubMatrix([1,2],[0,2],JSMatrix.mat([[66,77],[88,99]]));
// m = Matrix([[11,12,13,14],[66,22,77,24],[88,32,99,34],[41,42,43,44]])
-
singularValueDecomposition() → {Object|null}
-
Returns orthogonal matrix U, diagonal matrix S and orthogonal matrix V of singular value decomposition (SVD) of receiver such that this = U*S*V^T. U is computed as orthonormalized iegenvectors of this^T*this, V as orhonormalized eigenvectors of this*this^T and diagonal components of S as square roots of eigenvalues of this^T*this (TODO faster algorithm). this*V = U*S, A^T*U = V*S. Current implementation allows only square matrices (TODO gegeral-shaped matrices)
- Source:
-
/var/www/html/software/jsmatrix/jsmatrix.src.js, line 3859
Returns:
{u,s,v} orthogonal matrix U, diagonal of matrix S and orthogonal matrix V of svd decomposition of receiver
-
Type
-
Object
|
null
Example
m1 = JSMatrix.mat([[1.6,0.6,0.],[-1.2,0.8,0.],[0.,0.,3.]])
svd = m1.singularValueDecomposition();
u = svd.u; // u = Matrix([[0.6,0.8,0],[0.8,-0.6,0],[0,0,1]])
s = svd.s; // s = Vector([1,2,3])
v = svd.v; // v = Matrix([[0,1,0],[1,0,0],[0,0,1]])
b1 = u.isOrthogonal() // b1 = true
b2 = v.isOrthogonal() // b2 = true
c = u.mulm(s.diag()).mulm(v.transposed());
// c = JSMatrix.mat([[1.6,0.6,0.],[-1.2,0.8,0.],[0.,0.,3.]])
-
size() → {Object}
-
Returns size of receiver as [nRows,nCols]
- Source:
-
/var/www/html/software/jsmatrix/jsmatrix.src.js, line 1373
Returns:
{nRows:number,nCols:number} size of receiver
-
Type
-
Object
Example
m = JSMatrix.mat([[1,2,3],[4,5,6]]);
s = m.size(); // s = {nRows:2,nCols:3}
nRows = s.nRows; // nRows = 2
nCols = s.nCols; // nCols = 3
-
spectralDecomposition()
-
Returns spectral decomposition of receiver, identical to {@JSMatrix.Matrix#eigenDecomposition}
- Source:
-
/var/www/html/software/jsmatrix/jsmatrix.src.js, line 4153
-
-
Returns difference of receiver and matrix ( ret = this - mat )
Parameters:
- Source:
-
/var/www/html/software/jsmatrix/jsmatrix.src.js, line 1583
Returns:
sum of receiver and matrix
-
Type
-
JSMatrix.Matrix
Example
m1 = JSMatrix.mat([[1,2],[3,4]]);
m2 = JSMatrix.mat([[2,5],[3,2]]);
m3 = m1.sub(m2); // m3 = Matrix([[-1,-3],[0,2]])
-
svd()
-
Alias for singular value decomposition, see JSMatrix.Matrix.singularValueDecomposition
- Source:
-
/var/www/html/software/jsmatrix/jsmatrix.src.js, line 3879
-
swapCols(c1, c2)
-
Swaps two columns of receiver
Parameters:
Name |
Type |
Description |
c1 |
number
|
index of first row to swap |
c2 |
number
|
index of second row to swap |
- Source:
-
/var/www/html/software/jsmatrix/jsmatrix.src.js, line 1815
Example
m = JSMatrix.mat([[11,12,13],[21,22,23],[31,32,33]]);
m.swapCols(0,2); // m = Matrix([[13,12,11],[23,22,21],[33,32,31]])
-
swapRows(r1, r2)
-
Swaps two rows of receiver
Parameters:
Name |
Type |
Description |
r1 |
number
|
index of first row to swap |
r2 |
number
|
index of second row to swap |
- Source:
-
/var/www/html/software/jsmatrix/jsmatrix.src.js, line 1800
Example
m = JSMatrix.mat([[11,12,13],[21,22,23],[31,32,33]]);
m.swapRows(0,2); // m = Matrix([[31,32,33],[21,22,23],[11,12,13]])
-
symmetrize()
-
Symmetrize receiver ( this = .5*(this+this^T) ). Receiver must be square
- Source:
-
/var/www/html/software/jsmatrix/jsmatrix.src.js, line 2219
Example
m = JSMatrix.mat([[1,2,3],[0,-1,5],[-1,1,7]])
m.symmetrize(); // m = Matrix([[1,1,1],[1,-1,3],[1,3,7]])
b = m.isSymmetric(); // b = true
-
symmetrized()
-
Returns symmetric part of receiver ( ret = .5*(this+this^T) ). Receiver must be square
- Source:
-
/var/www/html/software/jsmatrix/jsmatrix.src.js, line 2237
Example
m1 = JSMatrix.mat([[1,2,3],[0,-1,5],[-1,1,7]])
m2 = m1.symmetrized(); // m2 = Matrix([[1,1,1],[1,-1,3],[1,3,7]])
b = m2.isSymmetric(); // b = true
-
T()
-
Alias for transposed(), see {@JSMatrix.Matrix#transposed}
- Source:
-
/var/www/html/software/jsmatrix/jsmatrix.src.js, line 2157
-
toArray() → {Array.<Array.<number>>}
-
Returns elements of receiver as an Array object
- Source:
-
/var/www/html/software/jsmatrix/jsmatrix.src.js, line 1508
Returns:
2D array containing receiver's elements
-
Type
-
Array.<Array.<number>>
Example
m =JSMatrix.mat([[11,12],[21,22]]);
a = m.toArray(); // a = [[11,12],[21,22]]
-
toString() → {string}
-
Returns string representation of receiver
- Source:
-
/var/www/html/software/jsmatrix/jsmatrix.src.js, line 2604
Returns:
string representation of receiver
-
Type
-
string
Example
m = JSMatrix.mat([[1,2,3],[4,5,6],[7,8,9]]);
s = m.toString(); // s = 'Matrix([[1,2,3],[4,5,6],[7,8,9]])'
-
trace() → {number|null}
-
Returns trace (sum of diagonal elements) of the receiver
- Source:
-
/var/www/html/software/jsmatrix/jsmatrix.src.js, line 1383
Returns:
trace of the receiver
-
Type
-
number
|
null
Example
m = JSMatrix.mat([[1,2,3],[4,5,6],[7,8,9]])
tr = m.trace() // tr = 15
-
transpose()
-
Modifies receiver to become transposition of itself ( this = this^T )
- Source:
-
/var/www/html/software/jsmatrix/jsmatrix.src.js, line 2165
Example
m = JSMatrix.mat([[1,2,3],[4,5,6]]);
m.transpose(); // m = Matrix([[1,4],[2,5],[3,6]])
m.transpose(); // m = Matrix([[1,2,3],[4,5,6]])
-
-
Returns transposition of receiver ( ret = this^T )
- Source:
-
/var/www/html/software/jsmatrix/jsmatrix.src.js, line 2143
Returns:
transposed copy of receiver
-
Type
-
JSMatrix.Matrix
Example
m1 = JSMatrix.mat([[1,2,3],[4,5,6]]);
m2 = m1.transposed(); // m2 = Matrix([[1,4],[2,5],[3,6]])
-
x()
-
Alias for mul(), see {@JSMatrix.Matrix#mul}
- Source:
-
/var/www/html/software/jsmatrix/jsmatrix.src.js, line 2010
-
zero()
-
Zeroes all elements of receiver
- Source:
-
/var/www/html/software/jsmatrix/jsmatrix.src.js, line 1320
Example
m = JSMatrix.mat([[1,2,3],[4,5,6],[7,8,9]]);
m.zero(); // m = Matrix([[0,0,0],[0,0,0],[0,0,0]])