Socket
Socket
Sign inDemoInstall

matrix-inverse

Package Overview
Dependencies
0
Maintainers
2
Versions
4
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 1.0.1 to 2.0.0

4

CHANGELOG.md
# Changelog
## 2.0.0
- Given an uninvertible matrix, return null instead of throwing an exception.
## 1.0.1

@@ -4,0 +8,0 @@

31

matrix-inverse.js
var Sylvester = {}
Sylvester.Matrix = function() {}
Sylvester.Matrix = function () {}
Sylvester.Matrix.create = function(elements) {
Sylvester.Matrix.create = function (elements) {
var M = new Sylvester.Matrix()

@@ -10,3 +10,3 @@ return M.setElements(elements)

Sylvester.Matrix.I = function(n) {
Sylvester.Matrix.I = function (n) {
var els = [],

@@ -26,7 +26,7 @@ i = n,

Sylvester.Matrix.prototype = {
dup: function() {
dup: function () {
return Sylvester.Matrix.create(this.elements)
},
isSquare: function() {
isSquare: function () {
var cols = this.elements.length === 0 ? 0 : this.elements[0].length

@@ -36,3 +36,3 @@ return this.elements.length === cols

toRightTriangular: function() {
toRightTriangular: function () {
if (this.elements.length === 0) return Sylvester.Matrix.create([])

@@ -79,3 +79,3 @@ var M = this.dup(),

determinant: function() {
determinant: function () {
if (this.elements.length === 0) {

@@ -96,7 +96,7 @@ return 1

isSingular: function() {
isSingular: function () {
return this.isSquare() && this.determinant() === 0
},
augment: function(matrix) {
augment: function (matrix) {
if (this.elements.length === 0) {

@@ -126,3 +126,3 @@ return this.dup()

inverse: function() {
inverse: function () {
if (this.elements.length === 0) {

@@ -175,3 +175,3 @@ return null

setElements: function(els) {
setElements: function (els) {
var i,

@@ -201,4 +201,9 @@ j,

module.exports = function(elements) {
return Sylvester.Matrix.create(elements).inverse().elements
module.exports = function (elements) {
const mat = Sylvester.Matrix.create(elements).inverse()
if (mat !== null) {
return mat.elements
} else {
return null
}
}
{
"name": "matrix-inverse",
"version": "1.0.1",
"version": "2.0.0",
"description": "Matrix inverse (code from sylvester)",

@@ -10,3 +10,3 @@ "main": "matrix-inverse.js",

"prettier:check": "prettier --check \"**/*.@(yml|json|js|md)\"",
"test": "npm run test && npm run prettier:check"
"test": "npm run test:js && npm run prettier:check"
},

@@ -25,3 +25,3 @@ "keywords": [

"chai-stats": "~0.3.0",
"prettier": "^1.18.2"
"prettier": "^2.0.5"
},

@@ -28,0 +28,0 @@ "files": [

@@ -28,3 +28,6 @@ # matrix-inverse

const M = [[3, 3.2], [3.5, 3.6]]
const M = [
[3, 3.2],
[3.5, 3.6],
]

@@ -31,0 +34,0 @@ const M_inv = matrixInverse(M)

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc