-
Notifications
You must be signed in to change notification settings - Fork 0
Matrix
the number of columns this matrix will have.
The values in the matrix in reading order. can be Numbers, BigInts, or Rationals. They all get converted to Rationals.
let A = new Matrix(2,1,2,3,4);
If indices is the string "identity", creates an identity matrix of given size.
Returns a latex string representing the Matrix.
let A = new Matrix(2,1, 2, new Rational(2n,3n), 10);
console.log(A.toLatex()); // "\begin{bmatrix}1 & 2 // \frac{2}{3} & 10 \end{bmatrix}"
A =
The latex of a Matrix is not easy to follow, so I'll use codecogs Latex renderer to show matrices after the code runs. Unfortunately the renderer doesn't allow me to color the background, so you might want to change to light mode as black on grey isn't the easiest to read.
returns a copy of the matrix so you can manipulate it without affecting the original.
let A = new Matrix(2,1,2,3,4);
let copy = A.clone();
copy.gaussianElimination();
A =
copy =
swaps 2 rows of a matrix, where the top row is row 0.
A = new matrix(2,1,2,3,4,5,6);
A.swapRows(0,2);
A =
Adds a multiple of one row to another.
let A = new Matrix(3,1,2,3,4,5,6);
let B = A.clone();
A.addRow(0,1,new Rational(-1n));
B.addRow(0,1);
A =
B =
Multiplies a row by a Rational.
let A = new Matrix(2,1,2,3,4);
A.scaleRow(0,new Rational(3n));
A =
Multiplies all the indices by a Rational.
let A = new Matrix(2,1,2,3,4);
A.scale(new Rational(3n));
A =
Returns a transposed copy of this.
let A = new Matrix(1,1,2,3,4);
let transposedA = A.transpose();
A =
transposedA =
Returns true if this is a square matrix.
let square = new Matrix(3,1,2,3,4,5,6,7,8,9);
let nonsquare = new Marix(2,1,2,3,4,5,6);
console.log(square.isSquare()); // true
console.log(nonsquare.isSquare()); // false
Does gaussian elimination on this, row reducing the matrix.
returns the determinate of this