Skip to content
Calculus_is_fun edited this page Aug 28, 2024 · 18 revisions

Matrix

Constructor

Columns

the number of columns this matrix will have.

indices

The values in the matrix in reading order of LTR. 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.

Methods

add

adds argument to this element-wise

let A = new Matrix(2, [1n, 3n, 4n, new Rational(5n, 2n)]);
let B = new Matrix(2, [new Rational(1n, 2n), 1n, 4n, -1n]);
A.add(B);

A=

addRow

adds a scaled copy of one row to another

arguments

  1. source (BigInt): the row to add
  2. destination (BigInt): the row added to
  3. scale (BigInt/Rational): a row multiplier before adding (defaults to 1)
let A = new Matrix(3, [1n, 2n, 3n, 2n, 5n, 1n, 2n, 3n, 0n]);
A.addRow(0n, 1n, -2n);
A.addRow(0n, 2n, new Rational(1n, 3n));

A=

augment

appends the colums of argument to the right of this

let A = new Matrix(2, [1n, 2n, 4n, 5n, 7n, 8n]);
let B = new Matrix(1, [3n, 6n, 9n]);
A.augment(B);

A=

clone

dotProduct

gaussianElimination

hadamardProduct

inverse

isSquare

kroneckerProduct

outerProduct

product

the standard matrix product

let A = new Matrix(2, [1n, 1n, 0n, 1n]);
let B = new Matrix(1, [3n, 6n]);
A.product(B);

A=

swapRows

toLatex

returns the LaTeX code corresponding to this

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}"

transpose

flips the entries of this

Clone this wiki locally