matrix-determinant
TypeScript icon, indicating that this package has built-in type declarations

1.0.5 • Public • Published

Matrix (2d array) Determinant

codecov

This package is allowing you to calculate matrix determinant.

Example

import { determinant } from "matrix-determinant";

const m1 = [[1]];
console.log(determinant(m1)); // 1

const m2 = [[1, 3],
            [2, 5]];
console.log(determinant(m2)); // -1

const m3 = [[2, 5, 3],
            [1, -2, -1],
            [1, 3, 4]];
console.log(determinant(m3)); // -20

const m4 = [[1, 2, 3, 4],
            [5, 0, 2, 8],
            [3, 5, 6, 7],
            [2, 5, 3, 1]];
console.log(determinant(m4)); // 24


const mInvalid = [[1, 2, 3, 4],
                  [5, 0, 2, 8],
                  [3, 7],
                  [2, 5, 3, 1]];
console.log(determinant(mInvalid)); // Error("Invalid Matrix")

Package Sidebar

Install

npm i matrix-determinant

Weekly Downloads

1

Version

1.0.5

License

ISC

Unpacked Size

3.51 kB

Total Files

4

Last publish

Collaborators

  • antonsacred