eigenjs
v0.0.89
Published
The goal of this project is to port Eigen library into JavaScript for linear algebra.
Downloads
153
Maintainers
Readme
EigenJS
The goal of this project is to port Eigen library into JavaScript for linear algebar.
Installation
- OS X (XCode & Command Line Tools)
- Linux (GCC >= 4.8):
$ npm install eigenjs
- Windows7/8 (Visual Studio 2012):
$ npm install eigenjs --msvs_version=2012
API
- Complex
- Complex Class Methods
- Complex(real, [imag])
- Complex.polar(scalar, scalar)
- Complex.cos(scalar)
- Complex.cos(comp)
- Complex.cosh(scalar)
- Complex.cosh(comp)
- Complex.exp(scalar)
- Complex.exp(comp)
- Complex.log(scalar)
- Complex.log(comp)
- Complex.log10(scalar)
- Complex.log10(comp)
- Complex.pow(scalar, scalar)
- Complex.pow(scalar, comp)
- Complex.pow(comp, scalar)
- Complex.pow(comp, comp)
- Complex.sin(scalar)
- Complex.sin(comp)
- Complex.sinh(scalar)
- Complex.sinh(comp)
- Complex.sqrt(scalar)
- Complex.sqrt(comp)
- Complex.tan(scalar)
- Complex.tan(comp)
- Complex.tanh(scalar)
- Complex.tanh(comp)
- Complex.acos(scalar)
- Complex.acos(comp)
- Complex.acosh(scalar)
- Complex.acosh(comp)
- Complex.asin(scalar)
- Complex.asin(comp)
- Complex.asinh(scalar)
- Complex.asinh(comp)
- Complex.atan(scalar)
- Complex.atan(comp)
- Complex.atanh(scalar)
- Complex.atanh(comp)
- Complex Instance Methods
- comp.abs()
- comp.arg()
- comp.norm()
- comp.conj()
- comp.proj(scalar)
- comp.proj(comp)
- comp.add(scalar)
- comp.add(comp)
- comp.adda(scalar)
- comp.adda(comp)
- comp.sub(scalar)
- comp.sub(comp)
- comp.suba(scalar)
- comp.suba(comp)
- comp.mul(scalar)
- comp.mul(comp)
- comp.mul(mat)
- comp.mul(vec)
- comp.mul(rvec)
- comp.mul(mblock)
- comp.mul(vblock)
- comp.mul(rvblock)
- comp.mul(cmat)
- comp.mul(cvec)
- comp.mul(crvec)
- comp.mul(cmblock)
- comp.mul(cvblock)
- comp.mul(crvblock)
- comp.mula(scalar)
- comp.mula(comp)
- comp.div(scalar)
- comp.div(comp)
- comp.diva(scalar)
- comp.diva(comp)
- comp.equals(scalar)
- comp.equals(comp)
- comp.isApprox(comp, [prec = 1e-12])
- comp.toString()
- Complex Properties
- Complex Class Methods
- Matrix
- Matrix Class Methods
- Matrix(mat)
- Matrix(vec)
- Matrix(rvec)
- Matrix(mblock)
- Matrix(vblock)
- Matrix(rvblock)
- Matrix(rows, cols)
- Matrix.Zero(n)
- Matrix.Zero(rows, cols)
- Matrix.Ones(n)
- Matrix.Ones(rows, cols)
- Matrix.Constant(rows, cols, scalar)
- Matrix.Constant(rows, cols, comp)
- Matrix.Random(n)
- Matrix.Random(rows, cols)
- Matrix.Identity(n)
- Matrix.Identity(rows, cols)
- Matrix Instance Methods
- mat.rows()
- mat.cols()
- mat.set(row, col, scalar)
- mat.set(scalar_array)
- mat.get(row, col)
- mat.assign(mat)
- mat.assign(vec)
- mat.assign(rvec)
- mat.assign(mblock)
- mat.assign(vblock)
- mat.assign(rvblock)
- mat.value()
- mat.setZero()
- mat.setOnes()
- mat.setConstant(scalar)
- mat.setRandom()
- mat.setIdentity()
- mat.setDiagonal(index, vec)
- mat.setDiagonal(index, rvec)
- mat.block(startRow, startCol, blockRows, blockCols)
- mat.row(n)
- mat.col(n)
- mat.topRows(n)
- mat.bottomRows(n)
- mat.middleRows(startRow, n)
- mat.leftCols(n)
- mat.rightCols(n)
- mat.middleCols(startCol, n)
- mat.topLeftCorner(cRows, cCols)
- mat.topRightCorner(cRows, cCols)
- mat.bottomLeftCorner(cRows, cCols)
- mat.bottomRightCorner(cRows, cCols)
- mat.replicate(rowFactor, colFactor)
- mat.add(mat)
- mat.add(vec)
- mat.add(rvec)
- mat.add(mblock)
- mat.add(vblock)
- mat.add(rvblock)
- mat.add(cmat)
- mat.add(cvec)
- mat.add(crvec)
- mat.add(cmblock)
- mat.add(cvblock)
- mat.add(crvblock)
- mat.adda(mat)
- mat.adda(vec)
- mat.adda(rvec)
- mat.adda(mblock)
- mat.adda(vblock)
- mat.adda(rvblock)
- mat.sub(mat)
- mat.sub(vec)
- mat.sub(rvec)
- mat.sub(mblock)
- mat.sub(vblock)
- mat.sub(rvblock)
- mat.sub(cmat)
- mat.sub(cvec)
- mat.sub(crvec)
- mat.sub(cmblock)
- mat.sub(cvblock)
- mat.sub(crvblock)
- mat.suba(mat)
- mat.suba(vec)
- mat.suba(rvec)
- mat.suba(mblock)
- mat.suba(vblock)
- mat.suba(rvblock)
- mat.mul(scalar)
- mat.mul(comp)
- mat.mul(mat)
- mat.mul(vec)
- mat.mul(rvec)
- mat.mul(mblock)
- mat.mul(vblock)
- mat.mul(rvblock)
- mat.mul(cmat)
- mat.mul(cvec)
- mat.mul(crvec)
- mat.mul(cmblock)
- mat.mul(cvblock)
- mat.mul(crvblock)
- mat.mula(scalar)
- mat.mula(mat)
- mat.mula(vec)
- mat.mula(rvec)
- mat.mula(mblock)
- mat.mula(vblock)
- mat.mula(rvblock)
- mat.div(scalar)
- mat.div(comp)
- mat.diva(scalar)
- mat.transpose()
- mat.conjugate()
- mat.adjoint()
- mat.determinant()
- mat.inverse()
- mat.trace()
- mat.diagonal([index = 0])
- mat.norm()
- mat.redux(func)
- mat.sum()
- mat.prod()
- mat.mean()
- mat.visit(func)
- mat.maxCoeff()
- mat.maxCoeff(obj)
- mat.maxCoeff(func)
- mat.minCoeff()
- mat.minCoeff(obj)
- mat.minCoeff(func)
- mat.equals(mat)
- mat.equals(vec)
- mat.equals(rvec)
- mat.equals(mblock)
- mat.equals(vblock)
- mat.equals(rvblock)
- mat.isApprox(mat, [prec = 1e-12])
- mat.isApprox(vec, [prec = 1e-12])
- mat.isApprox(rvec, [prec = 1e-12])
- mat.isApprox(mblock, [prec = 1e-12])
- mat.isApprox(vblock, [prec = 1e-12])
- mat.isApprox(rvblock, [prec = 1e-12])
- mat.isSquare()
- mat.isZero([prec = 1e-12])
- mat.isOnes([prec = 1e-12])
- mat.isIdentity([prec = 1e-12])
- mat.isDiagonal([prec = 1e-12])
- mat.all()
- mat.any()
- mat.count()
- mat.allFinite()
- mat.hasNaN()
- mat.partialPivLu()
- mat.fullPivLu()
- mat.toString([options])
- Matrix Class Methods
- Complex Matrix
- Complex Matrix Class Methods
- CMatrix(mat)
- CMatrix(vec)
- CMatrix(rvec)
- CMatrix(mblock)
- CMatrix(vblock)
- CMatrix(rvblock)
- CMatrix(cmat)
- CMatrix(cvec)
- CMatrix(crvec)
- CMatrix(cmblock)
- CMatrix(cvblock)
- CMatrix(crvblock)
- CMatrix(rows, cols)
- CMatrix.Zero(n)
- CMatrix.Zero(rows, cols)
- CMatrix.Ones(n)
- CMatrix.Ones(rows, cols)
- CMatrix.Constant(rows, cols, scalar)
- CMatrix.Constant(rows, cols, comp)
- CMatrix.Random(n)
- CMatrix.Random(rows, cols)
- CMatrix.Identity(n)
- CMatrix.Identity(rows, cols)
- Complex Matrix Instance Methods
- cmat.rows()
- cmat.cols()
- cmat.set(row, col, comp)
- cmat.set(comp_array)
- cmat.get(row, col)
- cmat.assign(mat)
- cmat.assign(vec)
- cmat.assign(rvec)
- cmat.assign(mblock)
- cmat.assign(vblock)
- cmat.assign(rvblock)
- cmat.assign(cmat)
- cmat.assign(cvec)
- cmat.assign(crvec)
- cmat.assign(cmblock)
- cmat.assign(cvblock)
- cmat.assign(crvblock)
- cmat.value()
- cmat.setZero()
- cmat.setOnes()
- cmat.setConstant(scalar)
- cmat.setConstant(comp)
- cmat.setRandom()
- cmat.setIdentity()
- cmat.setDiagonal(index, vec)
- cmat.setDiagonal(index, rvec)
- cmat.setDiagonal(index, cvec)
- cmat.setDiagonal(index, crvec)
- cmat.block(startRow, startCol, blockRows, blockCols)
- cmat.row(n)
- cmat.col(n)
- cmat.topRows(n)
- cmat.bottomRows(n)
- cmat.middleRows(startRow, n)
- cmat.leftCols(n)
- cmat.rightCols(n)
- cmat.middleCols(startCol, n)
- cmat.topLeftCorner(cRows, cCols)
- cmat.topRightCorner(cRows, cCols)
- cmat.bottomLeftCorner(cRows, cCols)
- cmat.bottomRightCorner(cRows, cCols)
- cmat.replicate(rowFactor, colFactor)
- cmat.add(mat)
- cmat.add(vec)
- cmat.add(rvec)
- cmat.add(mblock)
- cmat.add(vblock)
- cmat.add(rvblock)
- cmat.add(cmat)
- cmat.add(cvec)
- cmat.add(crvec)
- cmat.add(cmblock)
- cmat.add(cvblock)
- cmat.add(crvblock)
- cmat.adda(mat)
- cmat.adda(vec)
- cmat.adda(rvec)
- cmat.adda(mblock)
- cmat.adda(vblock)
- cmat.adda(rvblock)
- cmat.adda(cmat)
- cmat.adda(cvec)
- cmat.adda(crvec)
- cmat.adda(cmblock)
- cmat.adda(cvblock)
- cmat.adda(crvblock)
- cmat.sub(mat)
- cmat.sub(vec)
- cmat.sub(rvec)
- cmat.sub(mblock)
- cmat.sub(vblock)
- cmat.sub(rvblock)
- cmat.sub(cmat)
- cmat.sub(cvec)
- cmat.sub(crvec)
- cmat.sub(cmblock)
- cmat.sub(cvblock)
- cmat.sub(crvblock)
- cmat.suba(mat)
- cmat.suba(vec)
- cmat.suba(rvec)
- cmat.suba(mblock)
- cmat.suba(vblock)
- cmat.suba(rvblock)
- cmat.suba(cmat)
- cmat.suba(cvec)
- cmat.suba(crvec)
- cmat.suba(cmblock)
- cmat.suba(cvblock)
- cmat.suba(crvblock)
- cmat.mul(scalar)
- cmat.mul(comp)
- cmat.mul(mat)
- cmat.mul(vec)
- cmat.mul(rvec)
- cmat.mul(mblock)
- cmat.mul(vblock)
- cmat.mul(rvblock)
- cmat.mul(cmat)
- cmat.mul(cvec)
- cmat.mul(crvec)
- cmat.mul(cmblock)
- cmat.mul(cvblock)
- cmat.mul(crvblock)
- cmat.mula(scalar)
- cmat.mula(comp)
- cmat.mula(mat)
- cmat.mula(vec)
- cmat.mula(rvec)
- cmat.mula(mblock)
- cmat.mula(vblock)
- cmat.mula(rvblock)
- cmat.mula(cmat)
- cmat.mula(cvec)
- cmat.mula(crvec)
- cmat.mula(cmblock)
- cmat.mula(cvblock)
- cmat.mula(crvblock)
- cmat.div(scalar)
- cmat.div(comp)
- cmat.diva(scalar)
- cmat.diva(comp)
- cmat.transpose()
- cmat.conjugate()
- cmat.adjoint()
- cmat.determinant()
- cmat.inverse()
- cmat.trace()
- cmat.diagonal([index = 0])
- cmat.norm()
- cmat.redux(func)
- cmat.sum()
- cmat.prod()
- cmat.mean()
- cmat.visit(func)
- cmat.equals(cmat)
- cmat.equals(cvec)
- cmat.equals(crvec)
- cmat.equals(cmblock)
- cmat.equals(cvblock)
- cmat.equals(crvblock)
- cmat.isApprox(cmat, [prec = 1e-12])
- cmat.isApprox(cvec, [prec = 1e-12])
- cmat.isApprox(crvec, [prec = 1e-12])
- cmat.isApprox(cmblock, [prec = 1e-12])
- cmat.isApprox(cvblock, [prec = 1e-12])
- cmat.isApprox(crvblock, [prec = 1e-12])
- cmat.isSquare()
- cmat.isZero([prec = 1e-12])
- cmat.isOnes([prec = 1e-12])
- cmat.isIdentity([prec = 1e-12])
- cmat.isDiagonal([prec = 1e-12])
- cmat.allFinite()
- cmat.hasNaN()
- cmat.partialPivLu()
- cmat.fullPivLu()
- cmat.toString([options])
- Complex Matrix Class Methods
- Vector inherits from Matrix
- Vector Class Methods
- Vector Instance Methods
- vec.set(row, scalar)
- vec.set(scalar_array)
- vec.get(row)
- vec.setLinSpaced(low, high)
- vec.setLinSpaced(size, low, high)
- vec.block(startRow, blockRows)
- vec.head(n)
- vec.tail(n)
- vec.dot(mat)
- vec.dot(vec)
- vec.dot(rvec)
- vec.dot(mblock)
- vec.dot(vblock)
- vec.dot(rvblock)
- vec.dot(cmat)
- vec.dot(cvec)
- vec.dot(crvec)
- vec.dot(cmblock)
- vec.dot(cvblock)
- vec.dot(crvblock)
- vec.asDiagonal()
- vec.normalize()
- vec.maxCoeff()
- vec.maxCoeff(obj)
- vec.maxCoeff(func)
- vec.minCoeff()
- vec.minCoeff(obj)
- vec.minCoeff(func)
- Complex Vector inherits from CMatrix
- Complex Vector Class Methods
- Complex Vector Instance Methods
- cvec.set(row, comp)
- cvec.set(comp_array)
- cvec.get(row)
- cvec.block(startRow, blockRows)
- cvec.head(n)
- cvec.tail(n)
- cvec.dot(mat)
- cvec.dot(vec)
- cvec.dot(rvec)
- cvec.dot(mblock)
- cvec.dot(vblock)
- cvec.dot(rvblock)
- cvec.dot(cmat)
- cvec.dot(cvec)
- cvec.dot(crvec)
- cvec.dot(cmblock)
- cvec.dot(cvblock)
- cvec.dot(crvblock)
- cvec.asDiagonal()
- cvec.normalize()
- Row Vector inherits from Matrix
- Row Vector Class Methods
- Row Vector Instance Methods
- rvec.set(col, scalar)
- rvec.set(scalar_array)
- rvec.get(col)
- rvec.setLinSpaced(low, high)
- rvec.setLinSpaced(size, low, high)
- rvec.block(startCol, blockCols)
- rvec.head(n)
- rvec.tail(n)
- rvec.dot(mat)
- rvec.dot(vec)
- rvec.dot(rvec)
- rvec.dot(mblock)
- rvec.dot(vblock)
- rvec.dot(rvblock)
- rvec.dot(cmat)
- rvec.dot(cvec)
- rvec.dot(crvec)
- rvec.dot(cmblock)
- rvec.dot(cvblock)
- rvec.dot(crvblock)
- rvec.asDiagonal()
- rvec.normalize()
- rvec.maxCoeff()
- rvec.maxCoeff(obj)
- rvec.maxCoeff(func)
- rvec.minCoeff()
- rvec.minCoeff(obj)
- rvec.minCoeff(func)
- Complex Row Vector inherits from CMatrix
- Complex Row Vector Class Methods
- CRowVector(mat)
- CRowVector(vec)
- CRowVector(rvec)
- CRowVector(mblock)
- CRowVector(vblock)
- CRowVector(rvblock)
- CRowVector(cmat)
- CRowVector(cvec)
- CRowVector(crvec)
- CRowVector(cmblock)
- CRowVector(cvblock)
- CRowVector(crvblock)
- CRowVector(cols)
- CRowVector(comp_array)
- CRowVector.Constant(cols, scalar)
- CRowVector.Constant(cols, comp)
- Complex Row Vector Instance Methods
- crvec.set(col, comp)
- crvec.set(comp_array)
- crvec.get(col)
- crvec.block(startCol, blockCols)
- crvec.head(n)
- crvec.tail(n)
- crvec.dot(mat)
- crvec.dot(vec)
- crvec.dot(rvec)
- crvec.dot(mblock)
- crvec.dot(vblock)
- crvec.dot(rvblock)
- crvec.dot(cmat)
- crvec.dot(cvec)
- crvec.dot(crvec)
- crvec.dot(cmblock)
- crvec.dot(cvblock)
- crvec.dot(crvblock)
- crvec.asDiagonal()
- crvec.normalize()
- Complex Row Vector Class Methods
- Matrix Block inherits from Matrix
- Complex Matrix Block inherits from CMatrix
- Vector Block inherits from Vector and MatrixBlock
- Complex Vector Block inherits from CVector and CMatrixBlock
- Row Vector Block inherits from RowVector and MatrixBlock
- Complex Row Vector Block inherits from CRowVector and CMatrixBlock
- Partial Pivoting LU
- Complex Partial Pivoting LU
- Full Pivoting LU
- Complex Full Pivoting LU
Complex
Complex Class Methods
Complex(real, [imag])
var C = require('eigenjs').Complex
, c = new C(3, -4);
console.log('c = %s', c);
c = (3,-4)
Complex.polar(scalar, scalar)
var C = require('eigenjs').Complex
, rho = 5
, theta = -0.9272952180016122
, c = C.polar(rho, theta);
console.log(c.conj().toString());
console.log(c.real * Math.cos(c.imag));
console.log(c.real * Math.sin(c.imag));
(5,0.927295)
3.0000000000000004
-3.9999999999999996
Complex.cos(scalar)
Complex.cos(comp)
var C = require('eigenjs').Complex
, c1 = new C(Math.PI/4, 0)
, c2 = C.cos(c1);
console.log(c2.toString());
(0.707107,-0)
Complex.cosh(scalar)
Complex.cosh(comp)
var C = require('eigenjs').Complex
, c1 = new C(0, 0)
, c2 = C.cosh(c1);
console.log(c2.toString());
(1,0)
Complex.exp(scalar)
Complex.exp(comp)
var C = require('eigenjs').Complex
, c1 = new C(1, 0)
, c2 = C.exp(c1);
console.log(c2.toString());
(2.71828,0)
Complex.log(scalar)
Complex.log(comp)
var C = require('eigenjs').Complex
, c1 = new C(Math.E, 0)
, c2 = C.log(c1);
console.log(c2.toString());
(1,0)
Complex.log10(scalar)
Complex.log10(comp)
var C = require('eigenjs').Complex
, c1 = new C(1000, 0)
, c2 = C.log10(c1);
console.log(c2.toString());
(3,0)
Complex.pow(scalar, scalar)
Complex.pow(scalar, comp)
Complex.pow(comp, scalar)
Complex.pow(comp, comp)
var C = require('eigenjs').Complex
, c = C.pow(2, 3)
console.log(c.toString());
(8,0)
Complex.sin(scalar)
Complex.sin(comp)
var C = require('eigenjs').Complex
, c1 = new C(Math.PI/4, 0)
, c2 = C.sin(c1);
console.log(c2.toString());
(0.707107,0)
Complex.sinh(scalar)
Complex.sinh(comp)
var C = require('eigenjs').Complex
, c1 = new C(0, 0)
, c2 = C.sinh(c1);
console.log(c2.toString());
(0,0)
Complex.sqrt(scalar)
Complex.sqrt(comp)
var C = require('eigenjs').Complex
, c1 = new C(9, 0)
, c2 = C.sqrt(c1);
console.log(c2.toString());
(3,0)
Complex.tan(scalar)
Complex.tan(comp)
var C = require('eigenjs').Complex
, c1 = new C(Math.PI/4, 0)
, c2 = C.tan(c1);
console.log(c2.toString());
(1,0)
Complex.tanh(scalar)
Complex.tanh(comp)
var C = require('eigenjs').Complex
, c1 = new C(Infinity, 0)
, c2 = C.tanh(c1);
console.log(c2.toString());
(1,0)
Complex.acos(scalar)
Complex.acos(comp)
var C = require('eigenjs').Complex
, c1 = new C(1, 0)
, c2 = C.acos(c1);
console.log(c2.toString());
(0,0)
Complex.acosh(scalar)
Complex.acosh(comp)
var C = require('eigenjs').Complex
, c1 = new C(1.54308, 0)
, c2 = C.acosh(c1);
console.log(c2.toString());
(0.999999,0)
Complex.asin(scalar)
Complex.asin(comp)
var C = require('eigenjs').Complex
, c1 = new C(1, 0)
, c2 = C.asin(c1);
console.log(c2.toString());
(1.5708,7.82511e-09)
Complex.asinh(scalar)
Complex.asinh(comp)
var C = require('eigenjs').Complex
, c1 = new C(1, 0)
, c2 = C.asinh(c1);
console.log(c2.toString());
(0.881374,0)
Complex.atan(scalar)
Complex.atan(comp)
var C = require('eigenjs').Complex
, c1 = new C(Infinity, 0)
, c2 = C.atan(c1);
console.log(c2.toString());
(1.5708,0)
Complex.atanh(scalar)
Complex.atanh(comp)
var C = require('eigenjs').Complex
, c1 = new C(1, 0)
, c2 = C.atanh(c1);
console.log(c2.toString());
(inf,0)
Complex Instance Methods
comp.abs()
var C = require('eigenjs').Complex
, c = new C(3, -4);
console.log(c.abs());
5
comp.arg()
var C = require('eigenjs').Complex
, c = new C(3, -4);
console.log(c.arg());
console.log('(%d,%d)', c.abs() * Math.cos(c.arg()), c.abs() * Math.sin(c.arg()));
-0.9272952180016122
(3.0000000000000004,-3.9999999999999996)
comp.norm()
var C = require('eigenjs').Complex
, c = new C(3, -4);
console.log(c.norm());
25
comp.conj()
var C = require('eigenjs').Complex
, c = new C(3, -4);
console.log(c.conj().toString());
(3,4)
comp.proj(scalar)
comp.proj(comp)
var C = require('eigenjs').Complex
, c1 = new C(0, -Infinity)
, c2 = C.proj(c1);
console.log(c2.toString());
(inf, -0)
comp.add(scalar)
comp.add(comp)
var C = require('eigenjs').Complex
, c1 = new C(3, 0)
, c2 = new C(0, 4)
, c3 = c1.add(c2);
console.log(c3.toString());
(3,4)
comp.adda(scalar)
comp.adda(comp)
var C = require('eigenjs').Complex
, c1 = new C(3, 0)
, c2 = new C(0, 4);
c1.adda(c2);
console.log(c1.toString());
(3,4)
comp.sub(scalar)
comp.sub(comp)
var C = require('eigenjs').Complex
, c1 = new C(3, 4)
, c2 = new C(2, -3)
, c3 = c1.sub(c2);
console.log(c3.toString());
(1,7)
comp.suba(scalar)
comp.suba(comp)
var C = require('eigenjs').Complex
, c1 = new C(5, 8)
, c2 = new C(-3, 4);
c1.suba(c2);
console.log(c1.toString());
(8,4)
comp.mul(scalar)
comp.mul(comp)
comp.mul(mat)
comp.mul(vec)
comp.mul(rvec)
comp.mul(mblock)
comp.mul(vblock)
comp.mul(rvblock)
comp.mul(cmat)
comp.mul(cvec)
comp.mul(crvec)
comp.mul(cmblock)
comp.mul(cvblock)
comp.mul(crvblock)
var C = require('eigenjs').Complex
, c1 = new C(1, 8)
, c2 = new C(6, 4)
, c3 = c1.mul(c2);
console.log(c3.toString());
(-26,52)
comp.mula(scalar)
comp.mula(comp)
var C = require('eigenjs').Complex
, c1 = new C(3, 1)
, c2 = new C(2, 4)
c1.mula(c2);
console.log(c1.toString());
(2,14)
comp.div(scalar)
comp.div(comp)
var C = require('eigenjs').Complex
, c1 = new C(4, 8)
, c2 = new C(2, 0)
, c3 = c1.div(c2);
console.log(c3.toString());
(2,4)
comp.diva(scalar)
comp.diva(comp)
var C = require('eigenjs').Complex
, c1 = new C(3, 9)
, c2 = new C(9, 0)
c1.diva(c2);
console.log(c2.toString());
(0.333333,1)
comp.equals(scalar)
comp.equals(comp)
var C = require('eigenjs').Complex
, c1 = new C(1, 0)
, c2 = c1.conj();
console.log(c1.equals(c2));
true
comp.isApprox(comp, [prec = 1e-12])
var C = require('eigenjs').Complex
, c1 = new C(1/3, 0)
, c2 = new C(0.3333, 0);
console.log(c1.isApprox(c2, 1e-3));
true
comp.toString()
var C = require('eigenjs').Complex
, c = new C(3, -4);
console.log(c.toString());
(3,-4)
Complex Properties
comp.real
comp.imag
var C = require('eigenjs').Complex
, c = new C(3, -4);
c.real = 6;
c.imag = 8;
console.log('(%d,%d)', c.real, c.imag);
(6,8)
Matrix
Matrix Class Methods
Matrix(mat)
Matrix(vec)
Matrix(rvec)
Matrix(mblock)
Matrix(vblock)
Matrix(rvblock)
var M = require('eigenjs').Matrix
, mat = new M.Random(2, 3)
, mat2 = new M(mat);
console.log('mat =\n%s\n', mat);
console.log('mat2 =\n%s', mat2);
mat =
0.381981 -0.373117 -0.866239
-0.0467884 -0.981309 -0.885573
mat2 =
0.381981 -0.373117 -0.866239
-0.0467884 -0.981309 -0.885573
Matrix(rows, cols)
var M = require('eigenjs').Matrix
, mat = new M(2, 3);
console.log('mat =\n%s', mat);
mat =
0 0 0
0 0 0
Matrix.Zero(n)
Matrix.Zero(rows, cols)
var M = require('eigenjs').Matrix
, mat = M.Zero(2, 3);
console.log('mat = \n%s', mat);
mat =
0 0 0
0 0 0
Matrix.Ones(n)
Matrix.Ones(rows, cols)
var M = require('eigenjs').Matrix
, mat = M.Ones(2, 3);
console.log('mat = \n%s', mat);
mat =
1 1 1
1 1 1
Matrix.Constant(rows, cols, scalar)
Matrix.Constant(rows, cols, comp)
var M = require('eigenjs').Matrix
, mat = M.Constant(4, 4, 0.6);
console.log('mat = \n%s', mat);
mat =
0.6 0.6 0.6 0.6
0.6 0.6 0.6 0.6
0.6 0.6 0.6 0.6
0.6 0.6 0.6 0.6
Matrix.Random(n)
Matrix.Random(rows, cols)
var M = require('eigenjs').Matrix
, mat = M.Random(2, 3);
console.log('mat = \n%s', mat);
mat =
-0.421952 -0.671276 0.547419
0.260209 -0.13622 0.464891
Matrix.Identity(n)
Matrix.Identity(rows, cols)
var M = require('eigenjs').Matrix
, mat1 = M.Identity(2)
, mat2 = M.Identity(2, 3);
console.log('mat1 = \n%s', mat1);
console.log('mat2 = \n%s', mat2);
mat1 =
1 0
0 1
mat2 =
1 0 0
0 1 0
Matrix Instance Methods
mat.rows()
mat.cols()
var M = require('eigenjs').Matrix
, mat = new M(2, 3);
console.log(mat.rows());
console.log(mat.cols());
2
3
mat.set(row, col, scalar)
var M = require('eigenjs').Matrix
, mat = new M(2, 2);
mat.set(0, 0, 1)
.set(0, 1, 2)
.set(1, 0, 3)
.set(1, 1, 4);
console.log('mat = \n%s', mat);
mat =
1 2
3 4
mat.set(scalar_array)
var M = require('eigenjs').Matrix
, mat = new M(3, 3);
mat.set([
1, 2, 3,
4, 5, 6,
7, 8, 9
]);
console.log('mat = \n%s', mat);
mat =
1 2 3
4 5 6
7 8 9
mat.get(row, col)
var M = require('eigenjs').Matrix
, mat = new M(2, 2);
mat.set([
1, 2,
3, 4
]);
console.log(mat.get(0, 0) + ' ' + mat.get(0, 1));
console.log(mat.get(1, 0) + ' ' + mat.get(1, 1));
1 2
3 4
mat.assign(mat)
mat.assign(vec)
mat.assign(rvec)
mat.assign(mblock)
mat.assign(vblock)
mat.assign(rvblock)
var M = require('eigenjs').Matrix
, mat = M.Random(4, 4);
mat.assign(M.Zero(4, 4));
console.log('mat = \n%s', mat);
mat =
0 0 0 0
0 0 0 0
0 0 0 0
0 0 0 0
mat.value()
Returns the unique coefficient of a 1x1 expression
var M = require('eigenjs').Matrix
, mat = M.Random(1, 1);
console.log('%d', mat.value());
-0.7131525574778916
mat.setZero()
var M = require('eigenjs').Matrix
, mat = new M.Random(3, 3);
console.log('mat =\n%s\n', mat);
console.log('mat =\n%s', mat.setZero());
mat =
0.244911 -0.752925 -0.562905
0.215088 -0.406688 -0.750836
0.983236 0.800109 0.695126
mat =
0 0 0
0 0 0
0 0 0
mat.setOnes()
var M = require('eigenjs').Matrix
, mat = new M.Zero(3, 3);
console.log('mat =\n%s\n', mat);
console.log('mat =\n%s', mat.setOnes());
mat =
0 0 0
0 0 0
0 0 0
mat =
1 1 1
1 1 1
1 1 1
mat.setConstant(scalar)
var M = require('eigenjs').Matrix
, mat = new M.Zero(3, 3);
console.log('mat =\n%s\n', mat);
console.log('mat =\n%s', mat.setConstant(0.6));
mat =
0 0 0
0 0 0
0 0 0
mat =
0.6 0.6 0.6
0.6 0.6 0.6
0.6 0.6 0.6
mat.setRandom()
var M = require('eigenjs').Matrix
, mat = new M.Zero(3, 3);
console.log('mat =\n%s\n', mat);
console.log('mat =\n%s', mat.setRandom());
mat =
0 0 0
0 0 0
0 0 0
mat =
-0.292434 -0.0673437 0.283946
-0.938224 0.154289 0.283845
-0.725773 -0.862362 0.583097
mat.setIdentity()
var M = require('eigenjs').Matrix
, mat = new M.Zero(3, 3);
console.log('mat =\n%s\n', mat);
console.log('mat =\n%s', mat.setIdentity());
mat =
0 0 0
0 0 0
0 0 0
mat =
1 0 0
0 1 0
0 0 1
mat.setDiagonal(index, vec)
mat.setDiagonal(index, rvec)
var M = require('eigenjs').Matrix
, mat = new M.Zero(3, 3)
, dia = mat.diagonal(1);
console.log('mat =\n%s\n', mat);
dia.setRandom();
console.log('mat =\n%s', mat.setDiagonal(1, dia));
mat =
0 0 0
0 0 0
0 0 0
mat =
0 -0.294006 0
0 0 0.634569
0 0 0
mat.block(startRow, startCol, blockRows, blockCols)
var M = require('eigenjs').Matrix
, mat = new M.Identity(4, 4)
, mblock = mat.block(1, 1, 2, 2);
mblock.assign(M.Random(2, 2));
console.log('mat =\n%s', mat);
mat =
1 0 0 0
0 -0.822352 0.533723 0
0 0.721993 0.287646 0
0 0 0 1
mat.row(n)
var Eigen = require('eigenjs')
, M = Eigen.Matrix
, RV = Eigen.RowVector
, mat = new M.Zero(3, 3)
, mblock = mat.row(1);
mblock.assign(RV.Random(3));
console.log('mat =\n%s', mat);
mat =
0 0 0
-0.843392 -0.891355 0.991578
0 0 0
mat.col(n)
var Eigen = require('eigenjs')
, M = Eigen.Matrix
, V = Eigen.Vector
, mat = new M.Zero(3, 3)
, mblock = mat.col(1);
mblock.assign(V.Random(3));
console.log('mat =\n%s', mat);
mat =
0 0.674939 0
0 -0.303923 0
0 -0.0302965 0
mat.topRows(n)
Returns a block consisting of the top rows of *this.
var M = require('eigenjs').Matrix
, mat = new M(4, 4).set([
7, 9, -5, 3,
-2, -6, 1, 0,
6, -3, 0, 9,
6, 6, 3, 9
]);
console.log('%s', mat.topRows(2));
7 9 -5 3
-2 -6 1 0
mat.bottomRows(n)
Returns a block consisting of the bottom rows of *this.
var M = require('eigenjs').Matrix
, mat = new M(4, 4).set([
7, 9, -5, 3,
-2, -6, 1, 0,
6, -3, 0, 9,
6, 6, 3, 9
]);
console.log('%s', mat.bottomRows(2));
6 -3 0 9
6 6 3 9
mat.middleRows(startRow, n)
Returns a block consisting of a range of rows of *this.
var M = require('eigenjs').Matrix
, mat = new M(4, 4).set([
7, 9, -5, 3,
-2, -6, 1, 0,
6, -3, 0, 9,
6, 6, 3, 9
]);
console.log('%s', mat.middleRows(1, 2));
-2 -6 1 0
6 -3 0 9
mat.leftCols(n)
Returns a block consisting of the left columns of *this.
var M = require('eigenjs').Matrix
, mat = new M(4, 4).set([
7, 9, -5, 3,
-2, -6, 1, 0,
6, -3, 0, 9,
6, 6, 3, 9
]);
console.log('%s', mat.leftCols(2));
7 9
-2 -6
6 -3
6 6
mat.rightCols(n)
Returns a block consisting of the right columns of *this.
var M = require('eigenjs').Matrix
, mat = new M(4, 4).set([
7, 9, -5, 3,
-2, -6, 1, 0,
6, -3, 0, 9,
6, 6, 3, 9
]);
console.log('%s', mat.rightCols(2));
-5 3
1 0
0 9
3 9
mat.middleCols(startCol, n)
Returns a block consisting of a range of columns of *this.
var M = require('eigenjs').Matrix
, mat = new M(4, 4).set([
7, 9, -5, 3,
-2, -6, 1, 0,
6, -3, 0, 9,
6, 6, 3, 9
]);
console.log('%s', mat.middleCols(1, 2));
9 -5
-6 1
-3 0
6 3
mat.topLeftCorner(cRows, cCols)
Returns a block consisting of a top-left corner of *this.
var M = require('eigenjs').Matrix
, mat = new M(4, 4).set([
7, 9, -5, 3,
-2, -6, 1, 0,
6, -3, 0, 9,
6, 6, 3, 9
]);
console.log('%s', mat.topLeftCorner(2, 2));
7 9
-2 -6
mat.topRightCorner(cRows, cCols)
Returns a block consisting of a top-right corner of *this.
var M = require('eigenjs').Matrix
, mat = new M(4, 4).set([
7, 9, -5, 3,
-2, -6, 1, 0,
6, -3, 0, 9,
6, 6, 3, 9
]);
console.log('%s', mat.topRightCorner(2, 2));
-5 3
1 0
mat.bottomLeftCorner(cRows, cCols)
Returns a block consisting of a bottom-left corner of *this.
var M = require('eigenjs').Matrix
, mat = new M(4, 4).set([
7, 9, -5, 3,
-2, -6, 1, 0,
6, -3, 0, 9,
6, 6, 3, 9
]);
console.log('%s', mat.bottomLeftCorner(2, 2));
6 -3
6 6
mat.bottomRightCorner(cRows, cCols)
Returns a block consisting of a bottom-right corner of *this.
var M = require('eigenjs').Matrix
, mat = new M(4, 4).set([
7, 9, -5, 3,
-2, -6, 1, 0,
6, -3, 0, 9,
6, 6, 3, 9
]);
console.log('%s', mat.bottomRightCorner(2, 2));
0 9
3 9
mat.replicate(rowFactor, colFactor)
var M = require('eigenjs').Matrix
, mat = new M(3, 1).set([
7,
-2,
6
]);
console.log('%s', mat.replicate(2, 5));
7 7 7 7 7
-2 -2 -2 -2 -2
6 6 6 6 6
7 7 7 7 7
-2 -2 -2 -2 -2
6 6 6 6 6
mat.add(mat)
mat.add(vec)
mat.add(rvec)
mat.add(mblock)
mat.add(vblock)
mat.add(rvblock)
mat.add(cmat)
mat.add(cvec)
mat.add(crvec)
mat.add(cmblock)
mat.add(cvblock)
mat.add(crvblock)
var M = require('eigenjs').Matrix
, mat1 = new M(2, 2)
, mat2 = new M(2, 2)
, mat3;
mat1.set([
1, 3,
2, 4
]);
mat2.set([
5, 6,
7, 8
]);
mat3 = mat1.add(mat2);
console.log('mat3 = \n%s', mat3);
mat3 =
6 9
9 12
mat.adda(mat)
mat.adda(vec)
mat.adda(rvec)
mat.adda(mblock)
mat.adda(vblock)
mat.adda(rvblock)
var M = require('eigenjs').Matrix
, mat1 = new M(2, 2)
, mat2 = new M(2, 2);
mat1.set([
1, 3,
2, 4
]);
mat2.set([
5, 6,
7, 8
]);
mat1.adda(mat2);
console.log('mat1 = \n%s', mat1);
mat1 =
6 9
9 12
mat.sub(mat)
mat.sub(vec)
mat.sub(rvec)
mat.sub(mblock)
mat.sub(vblock)
mat.sub(rvblock)
mat.sub(cmat)
mat.sub(cvet)
mat.sub(crvet)
mat.sub(cmblock)
mat.sub(cvblock)
mat.sub(crvblock)
var M = require('eigenjs').Matrix
, mat1 = new M(2, 2)
, mat2 = new M(2, 2)
, mat3;
mat1.set([
1, 3,
2, 4
]);
mat2.set([
5, 6,
7, 8
]);
mat3 = mat1.sub(mat2);
console.log('mat3 = \n%s', mat3);
mat3 =
-4 -3
-5 -4
mat.suba(mat)
mat.suba(vec)
mat.suba(rvec)
mat.suba(mblock)
mat.suba(vblock)
mat.suba(rvblock)
var M = require('eigenjs').Matrix
, mat1 = new M(2, 2)
, mat2 = new M(2, 2);
mat1.set([
1, 3,
2, 4
]);
mat2.set([
5, 6,
7, 8
]);
mat1.suba(mat2);
console.log('mat1 = \n%s', mat1);
mat1 =
-4 -3
-5 -4
mat.mul(scalar)
mat.mul(comp)
mat.mul(mat)
mat.mul(vec)
mat.mul(rvec)
mat.mul(mblock)
mat.mul(vblock)
mat.mul(rvblock)
mat.mul(cmat)
mat.mul(cvec)
mat.mul(crvec)
mat.mul(cvblock)
mat.mul(crvblock)
var M = require('eigenjs').Matrix
, mat1 = new M(2, 3)
, vec = new M(3, 1)
, mat2;
mat1.set([
1, 2, 3,
4, 5, 6
]);
vec.set([
1,
6,
8
]);
mat2 = mat1.mul(vec);
console.log('mat2 = \n%s', mat2);
mat2 =
37
82
mat.mula(scalar)
mat.mula(mat)
mat.mula(vec)
mat.mula(rvec)
mat.mula(mblock)
mat.mula(vblock)
mat.mula(rvblock)
var M = require('eigenjs').Matrix
, mat = new M(2, 3)
, vec = new M(3, 1);
mat.set([
1, 2, 3,
4, 5, 6
]);
vec.set([
1,
6,
8
]);
mat.mula(vec);
console.log('mat = \n%s', mat);
mat =
37
82
mat.div(scalar)
mat.div(comp)
var M = require('eigenjs').Matrix
, mat1 = new M(2, 2)
, mat2;
mat1.set([
1, 2,
3, 4
]);
mat2 = mat1.div(2);
console.log('mat2 = \n%s', mat2);
mat2 =
0.5 1
1.5 2
mat.diva(scalar)
var M = require('eigenjs').Matrix
, mat = new M(2, 2);
mat.set([
1, 2,
3, 4
]);
mat.diva(2);
console.log('mat = \n%s', mat);
mat =
0.5 1
1.5 2
mat.transpose()
var M = require('eigenjs').Matrix
, mat1 = new M.Random(3, 2)
, mat2 = mat1.transpose();
console.log('mat1 = \n%s', mat1);
console.log('mat2 = \n%s', mat2);
mat1 =
-0.112813 -0.325566
-0.0500345 0.213005
-0.930346 -0.022705
mat2 =
-0.112813 -0.0500345 -0.930346
-0.325566 0.213005 -0.022705
mat.conjugate()
var M = require('eigenjs').Matrix
, mat1 = new M.Random(2, 2)
, mat2 = mat1.conjugate();
console.log(mat1.equals(mat2));
true
mat.adjoint()
var M = require('eigenjs').Matrix
, mat1 = new M.Random(3, 2)
, mat2 = mat1.adjoint();
console.log('mat1 = \n%s', mat1);
console.log('mat2 = \n%s', mat2);
mat1 =
0.997487 0.0670765
0.770148 -0.645138
-0.12185 -0.835853
mat2 =
0.997487 0.770148 -0.12185
0.0670765 -0.645138 -0.835853
mat.determinant()
Returns the determinant of this matrix. This method uses class PartialPivLU.
var M = require('eigenjs').Matrix
, mat = new M.Random(2, 2);
console.log('mat = \n%s\n', mat);
console.log('det = %d', mat.determinant());
mat =
0.132371 -0.813862
0.758326 -0.58171
det = 0.540171350604003
mat.inverse()
Returns the matrix inverse of this matrix. This method uses class PartialPivLU.
var M = require('eigenjs').Matrix
, mat = new M(3, 3).set([
1, 2, 3,
0, 1, 4,
5, 6, 0
])
, inv = mat.inverse();
console.log('inv = \n%s', inv);
inv =
-24 18 5
20 -15 -4
-5 4 1
mat.trace()
var M = require('eigenjs').Matrix
, mat = new M(2, 3).set([
1, 2, 3,
4, 5, 6
])
, tr = mat.trace();
console.log('mat = \n%s\n', mat);
console.log('tr = ', tr);
mat =
1 2 3
4 5 6
tr = 6
mat.diagonal([index = 0])
var M = require('eigenjs').Matrix
, mat = new M(4, 4).set([
7, 9, -5, -3,
-2, -6, 1, 0,
6, -3, 0, 9,
6, 6, 3, 9
]);
console.log('%s', mat.diagonal(1).transpose());
console.log('%s', mat.diagonal(-2).transpose());
9 1 9
6 6
mat.norm()
Returns the Frobenius norm.
var M = require('eigenjs').Matrix
, mat = new M(3, 3).set([
1, 2, 3,
4, 5, 6,
7, 8, 9
]);
console.log('%d', mat.norm());
16.881943016134134
mat.redux(func)
- func
Function
The result of a full redux operation on the whoie matrix or vector usingfunc
.
var M = require('eigenjs').Matrix
, mat = new M(3, 3).set([
1, 2, 3,
4, 5, 6,
7, 8, 9
])
, func = function(a, b) { return a + b; };
console.log('%d', mat.redux(func));
45
mat.sum()
var M = require('eigenjs').Matrix
, mat = new M(3, 3).set([
1, 2, 3,
4, 5, 6,
7, 8, 9
]);
console.log('%d', mat.sum());
45
mat.prod()
var M = require('eigenjs').Matrix
, mat = new M(3, 3).set([
1, 2, 3,
4, 5, 6,
7, 8, 9
]);
console.log('%d', mat.prod());
362880
mat.mean()
var M = require('eigenjs').Matrix
, mat = new M(3, 3).set([
1, 2, 3,
4, 5, 6,
7, 8, 9
]);
console.log('%d', mat.mean());
5
mat.visit(func)
- func
Function
Applies thefunc
to the whole coefficients of the matrix or vector.
var M = require('eigenjs').Matrix
, mat = new M(3, 3).set([
1, 2, 3,
4, 5, 6,
7, 8, 9
]);
mat.visit(function(value, row, col) {
console.log('mat(%d, %d) = %d', row, col, value);
});
mat(0, 0) = 1
mat(1, 0) = 4
mat(2, 0) = 7
mat(0, 1) = 2
mat(1, 1) = 5
mat(2, 1) = 8
mat(0, 2) = 3
mat(1, 2) = 6
mat(2, 2) = 9
mat.maxCoeff()
var M = require('eigenjs').Matrix
, mat = new M.Random(3, 3);
console.log('mat = \n%s\n', mat);
console.log('max = %d', mat.maxCoeff());
mat =
0.175793 -0.547068 -0.959701
0.561311 -0.579446 0.297471
-0.0382309 -0.743676 -0.411312
max = 0.5613114636211243
mat.maxCoeff(obj)
- obj
Object
var M = require('eigenjs').Matrix
, mat = new M.Random(3, 3)
, obj = {};
console.log('mat = \n%s\n', mat);
console.log('max = %s', mat.maxCoeff(obj));
console.log('obj = %s', JSON.stringify(obj));
mat =
-0.68294 0.690895 -0.698356
-0.174138 -0.119934 0.733219
-0.743578 0.262349 -0.795382
max = 0.7332185766348702
obj = {"maxCoeff":0.7332185766348702,"rowId":1,"colId":2}
mat.maxCoeff(func)
- func
Function
var M = require('eigenjs').Matrix
, mat = new M.Random(3, 3)
, func = function(rowId, colId) {
console.log('rowId = %d, colId = %d', rowId, colId);
};
console.log('mat = \n%s\n', mat);
console.log('max = %d', mat.maxCoeff(func));
mat =
-0.552622 -0.355055 0.141004
0.0814275 0.58272 -0.13819
0.552011 -0.217758 -0.551142
rowId = 1, colId = 1
max = 0.5827204285109044
mat.minCoeff()
var M = require('eigenjs').Matrix
, mat = new M.Random(3, 3);
console.log('mat = \n%s\n', mat);
console.log('min = %d', mat.minCoeff());
mat =
-0.725041 0.511321 0.29833
0.233345 -0.22101 0.0355704
-0.167162 -0.514649 -0.168438
min = -0.7250411527813604
mat.minCoeff(obj)
- obj
Object
var M = require('eigenjs').Matrix
, mat = new M.Random(3, 3)
, obj = {};
console.log('mat = \n%s\n', mat);
console.log('min = %d', mat.minCoeff(obj));
console.log('obj = %s', JSON.stringify(obj));
mat =
0.74568 0.870563 -0.82341
0.636928 -0.455949 0.944912
0.855648 0.872564 -0.87055
min = -0.8705498761825962
obj = {"minCoeff":-0.8705498761825962,"rowId":2,"colId":2}
mat.minCoeff(func)
- func
Function
var M = require('eigenjs').Matrix
, mat = new M.Random(3, 3)
, func = function(rowId, colId) {
console.log('rowId = %d, colId = %d', rowId, colId);
};
console.log('mat = \n%s\n', mat);
console.log('min = %d', mat.minCoeff(func));
0.371743 0.261372 0.144462
-0.111958 0.884582 -0.02937
0.314765 -0.823458 0.378298
rowId = 2, colId = 1
min = -0.8234578174648144
mat.equals(mat)
mat.equals(vec)
mat.equals(rvec)
mat.equals(mblock)
mat.equals(vblock)
mat.equals(rvblock)
var M = require('eigenjs').Matrix
, mat1 = new M(2, 2)
, mat2 = new M(2, 2)
, mat3 = new M(2, 2);
mat1.set([
1, 2,
3, 4
]);
mat2.set([
1, 0,
0, 1
]);
mat3.set([
0, 2,
3, 3
]);
console.log(mat1.equals(mat2.add(mat3)));
true
mat.isApprox(mat, [prec = 1e-12])
mat.isApprox(vec, [prec = 1e-12])
mat.isApprox(rvec, [prec = 1e-12])
mat.isApprox(mblock, [prec = 1e-12])
mat.isApprox(vblock, [prec = 1e-12])
mat.isApprox(rvblock, [prec = 1e-12])
var M = require('eigenjs').Matrix
, mat1 = new M(2, 2)
, mat2 = new M(2, 2);
mat1.set([
1, 3,
5, 7
]).diva(11);
mat2.set([
0.091, 0.273,
0.455, 0.636
]);
console.log(mat1.isApprox(mat2, 1e-3));
true
mat.isSquare()
var M = require('eigenjs').Matrix
, mat1 = new M(4, 4)
, mat2 = new M(3, 2);
console.log(mat1.isSquare());
console.log(mat2.isSquare());
true
false
mat.isZero([prec = 1e-12])
var M = require('eigenjs').Matrix
, mat = new M(2, 3).set([
0, 0, 0.0001,
0, 0, 0
]);
console.log(mat.isZero());
console.log(mat.isZero(1e-3));
false
true
mat.isOnes([prec = 1e-12])
var M = require('eigenjs').Matrix
, mat = new M(2, 3).set([
1, 1, 1.0001,
1, 0.9997, 1
]);
console.log(mat.isOnes());
console.log(mat.isOnes(1e-3));
false
true
mat.isIdentity([prec = 1e-12])
var M = require('eigenjs').Matrix
, mat = new M(3, 3).set([
1, 0, 0.0001,
0, 0.9997, 0,
0, 0, 1
]);
console.log(mat.isIdentity());
console.log(mat.isIdentity(1e-3));
false
true
mat.isDiagonal([prec = 1e-12])
var M = require('eigenjs').Matrix
, mat = new M(3, 3).set([
1e+04, 0, 1,
0, 1e+04, 0,
0, 0, 1e+04
]);
console.log(mat.isDiagonal());
console.log(mat.isDiagonal(1e-3));
false
true
mat.all()
Returns true if all coefficients are true.
var M = require('eigenjs').Matrix
, mat = new M.Constant(3, 3, 1);
console.log('mat = \n%s\n%s\n', mat, mat.all());
mat.set(0, 0, 0);
console.log('mat = \n%s\n%s', mat, mat.all());
mat =
1 1 1
1 1 1
1 1 1
true
mat =
0 1 1
1 1 1
1 1 1
false
mat.any()
Returns true if at least one coefficient is true.
var M = require('eigenjs').Matrix
, mat = new M.Zero(3, 3);
console.log('mat = \n%s\n%s\n', mat, mat.any());
mat.set(0, 0, 1);
console.log('mat = \n%s\n%s', mat, mat.any());
mat =
0 0 0
0 0 0
0 0 0
false
mat =
1 0 0
0 0 0
0 0 0
true
mat.count()
Returns the number of coefficients which evaluate to true.
var M = require('eigenjs').Matrix
, mat = new M.Zero(3, 3);
mat.block(0, 1, 3, 2).setOnes();
console.log('mat = \n%s\n', mat);
console.log('%d', mat.count());
mat =
0 1 1
0 1 1
0 1 1
6
mat.allFinite()
Returns true if *this contains only finite numbers, i.e., no NaN and no +/-INF values.
var M = require('eigenjs').Matrix
, mat = new M.Random(3, 3);
console.log('mat = \n%s\n%s\n', mat, mat.allFinite());
mat.set(0, 0, Infinity);
console.log('mat = \n%s\n%s', mat, mat.allFinite());
mat =
0.202332 0.271506 -0.887678
0.592388 -0.806422 0.799406
0.26443 0.461303 -0.389755
true
mat =
inf 0.271506 -0.887678
0.592388 -0.806422 0.799406
0.26443 0.461303 -0.389755
false
mat.hasNaN()
Returns true if *this contains at least one Not A Number (NaN).
var M = require('eigenjs').Matrix
, mat = new M.Zero(3, 3);
console.log('mat = \n%s\n%s\n', mat, mat.hasNaN());
mat.set(1, 1, NaN);
console.log('mat = \n%s\n%s', mat, mat.hasNaN());
mat =
0 0 0
0 0 0
0 0 0
false
mat =
0 0 0
0 nan 0
0 0 0
true
mat.partialPivLu()
Returns the partial-pivoting LU decomposition of *this.
var M = require('eigenjs').Matrix
, mat = new M(3, 3).set([
1, 4, 5,
4, 2, 6,
5, 6, 3
])
, pplu = mat.partialPivLu();
console.log('P = \n%s\n', pplu.permutationP());
console.log('L = \n%s\n', pplu.matrixL());
console.log('U = \n%s', pplu.matrixU());
P =
0 0 1
0 1 0
1 0 0
L =
1 0 0
0.8 1 0
0.2 -1 1
U =
5 6 3
0 -2.8 3.6
0 0 8
mat.fullPivLu()
Returns the full-pivoting LU decomposition of *this.
var M = require('eigenjs').Matrix
, mat = new M(2, 4).set([
1, 1, 1, 3,
1, 2, -1, 4
])
, fplu = mat.fullPivLu();
console.log('P = \n%s\n', fplu.permutationP());
console.log('L = \n%s\n', fplu.matrixL());
console.log('U = \n%s\n', fplu.matrixU());
console.log('Q = \n%s', fplu.permutationQ());
P =
0 1
1 0
L =
1 0
0.75 1
U =
4 -1 2 1
0 1.75 -0.5 0.25
Q =
0 0 0 1
0 0 1 0
0 1 0 0
1 0 0 0
mat.toString([options])
- options
Object
- precision
Number
Default=6
. The number of digits for floating point values. - fullPrecision
Booleam
Default=false
. If set to true, then the number of digits will be computed to match the full precision of each floating-point type. - dontAlignCols
Booleam
Default=false
. If set to true, it allows to disable the alignment of columnt, resulting in faster code. - coeffSeparator
String
Default=' '
. The string printed between two coefficients of the same row. - rowSepara
- precision