Comparing version 1.0.1 to 1.0.2
@@ -0,1 +1,6 @@ | ||
1.0.2 / 2015-10-05 | ||
================== | ||
* remove const and let for Safari support | ||
1.0.0 / 2015-09-10 | ||
@@ -2,0 +7,0 @@ ================== |
{ | ||
"name": "ml-matrix", | ||
"version": "1.0.1", | ||
"version": "1.0.2", | ||
"description": "Matrix manipulation and computation library", | ||
@@ -5,0 +5,0 @@ "main": "src/index.js", |
@@ -13,3 +13,4 @@ # ml-matrix | ||
:warning: This library uses ES2015 classes and extends Array. It is not compatible with versions of Node.js/io.js <2.0.0 | ||
:warning: This library uses ES2015 classes and extends Array. It is not compatible with versions of Node.js/io.js <2.0.0 | ||
Supported browsers are: Google Chrome, Safari and Microsoft Edge. | ||
@@ -16,0 +17,0 @@ ## [Documentation](./Documentation.md) |
'use strict'; | ||
const Matrix = require('../matrix'); | ||
var Matrix = require('../matrix'); | ||
@@ -5,0 +5,0 @@ // https://github.com/lutzroeder/Mapack/blob/master/Source/CholeskyDecomposition.cs |
'use strict'; | ||
const Matrix = require('../matrix'); | ||
const util = require('./util'); | ||
const hypotenuse = util.hypotenuse; | ||
const getFilled2DArray = util.getFilled2DArray; | ||
var Matrix = require('../matrix'); | ||
var util = require('./util'); | ||
var hypotenuse = util.hypotenuse; | ||
var getFilled2DArray = util.getFilled2DArray; | ||
@@ -8,0 +8,0 @@ // https://github.com/lutzroeder/Mapack/blob/master/Source/EigenvalueDecomposition.cs |
'use strict'; | ||
const Matrix = require('../matrix'); | ||
var Matrix = require('../matrix'); | ||
@@ -5,0 +5,0 @@ // https://github.com/lutzroeder/Mapack/blob/master/Source/LuDecomposition.cs |
'use strict'; | ||
const Matrix = require('../matrix'); | ||
const hypotenuse = require('./util').hypotenuse; | ||
var Matrix = require('../matrix'); | ||
var hypotenuse = require('./util').hypotenuse; | ||
@@ -6,0 +6,0 @@ //https://github.com/lutzroeder/Mapack/blob/master/Source/QrDecomposition.cs |
'use strict'; | ||
const Matrix = require('../matrix'); | ||
const util = require('./util'); | ||
const hypotenuse = util.hypotenuse; | ||
const getFilled2DArray = util.getFilled2DArray; | ||
var Matrix = require('../matrix'); | ||
var util = require('./util'); | ||
var hypotenuse = util.hypotenuse; | ||
var getFilled2DArray = util.getFilled2DArray; | ||
@@ -8,0 +8,0 @@ // https://github.com/lutzroeder/Mapack/blob/master/Source/SingularValueDecomposition.cs |
@@ -5,7 +5,7 @@ 'use strict'; | ||
if (Math.abs(a) > Math.abs(b)) { | ||
let r = b / a; | ||
var r = b / a; | ||
return Math.abs(a) * Math.sqrt(1 + r * r); | ||
} | ||
if (b !== 0) { | ||
let r = a / b; | ||
var r = a / b; | ||
return Math.abs(b) * Math.sqrt(1 + r * r); | ||
@@ -12,0 +12,0 @@ } |
'use strict'; | ||
const Matrix = require('./matrix'); | ||
var Matrix = require('./matrix'); | ||
const SingularValueDecomposition = require('./dc/svd'); | ||
const EigenvalueDecomposition = require('./dc/evd'); | ||
const LuDecomposition = require('./dc/lu'); | ||
const QrDecomposition = require('./dc/qr'); | ||
const CholeskyDecomposition = require('./dc/cholesky'); | ||
var SingularValueDecomposition = require('./dc/svd'); | ||
var EigenvalueDecomposition = require('./dc/evd'); | ||
var LuDecomposition = require('./dc/lu'); | ||
var QrDecomposition = require('./dc/qr'); | ||
var CholeskyDecomposition = require('./dc/cholesky'); | ||
@@ -11,0 +11,0 @@ function inverse(matrix) { |
@@ -54,7 +54,7 @@ 'use strict'; | ||
static from1DArray(newRows, newColumns, newData) { | ||
let length = newRows * newColumns; | ||
var length = newRows * newColumns; | ||
if (length !== newData.length) { | ||
throw new RangeError('Data length does not match given dimensions'); | ||
} | ||
let newMatrix = new Matrix(newRows, newColumns); | ||
var newMatrix = new Matrix(newRows, newColumns); | ||
for (var row = 0; row < newRows; row++) { | ||
@@ -74,3 +74,3 @@ for (var column = 0; column < newColumns; column++) { | ||
static rowVector(newData) { | ||
let vector = new Matrix(1, newData.length); | ||
var vector = new Matrix(1, newData.length); | ||
for (var i = 0; i < newData.length; i++) { | ||
@@ -88,3 +88,3 @@ vector[0][i] = newData[i]; | ||
static columnVector(newData) { | ||
let vector = new Matrix(newData.length, 1); | ||
var vector = new Matrix(newData.length, 1); | ||
for (var i = 0; i < newData.length; i++) { | ||
@@ -135,3 +135,3 @@ vector[i][0] = newData[i]; | ||
if (rng === undefined) rng = Math.random; | ||
let matrix = Matrix.empty(rows, columns); | ||
var matrix = Matrix.empty(rows, columns); | ||
for (var i = 0; i < rows; i++) { | ||
@@ -153,4 +153,4 @@ for (var j = 0; j < rows; j++) { | ||
if (columns === undefined) columns = rows; | ||
const min = Math.min(rows, columns); | ||
let matrix = Matrix.zeros(rows, columns); | ||
var min = Math.min(rows, columns); | ||
var matrix = Matrix.zeros(rows, columns); | ||
for (var i = 0; i < min; i++) { | ||
@@ -170,7 +170,7 @@ matrix[i][i] = 1; | ||
static diag(data, rows, columns) { | ||
const l = data.length; | ||
var l = data.length; | ||
if (rows === undefined) rows = l; | ||
if (columns === undefined) columns = rows; | ||
const min = Math.min(l, rows, columns); | ||
let matrix = Matrix.zeros(rows, columns); | ||
var min = Math.min(l, rows, columns); | ||
var matrix = Matrix.zeros(rows, columns); | ||
for (var i = 0; i < min; i++) { | ||
@@ -189,5 +189,5 @@ matrix[i][i] = data[i]; | ||
static min(matrix1, matrix2) { | ||
const rows = matrix1.length; | ||
const columns = matrix1[0].length; | ||
let result = new Matrix(rows, columns); | ||
var rows = matrix1.length; | ||
var columns = matrix1[0].length; | ||
var result = new Matrix(rows, columns); | ||
for (var i = 0; i < rows; i++) { | ||
@@ -208,5 +208,5 @@ for(var j = 0; j < columns; j++) { | ||
static max(matrix1, matrix2) { | ||
const rows = matrix1.length; | ||
const columns = matrix1[0].length; | ||
let result = new Matrix(rows, columns); | ||
var rows = matrix1.length; | ||
var columns = matrix1[0].length; | ||
var result = new Matrix(rows, columns); | ||
for (var i = 0; i < rows; i++) { | ||
@@ -254,4 +254,4 @@ for(var j = 0; j < columns; j++) { | ||
} | ||
let ii = this.rows; | ||
let jj = this.columns; | ||
var ii = this.rows; | ||
var jj = this.columns; | ||
for (var i = 0; i < ii; i++) { | ||
@@ -270,3 +270,3 @@ for (var j = 0; j < jj; j++) { | ||
clone() { | ||
let newMatrix = new Matrix(this.rows, this.columns); | ||
var newMatrix = new Matrix(this.rows, this.columns); | ||
for (var row = 0; row < this.rows; row++) { | ||
@@ -285,3 +285,3 @@ for (var column = 0; column < this.columns; column++) { | ||
to1DArray() { | ||
let array = new Array(this.size); | ||
var array = new Array(this.size); | ||
for (var i = 0; i < this.rows; i++) { | ||
@@ -300,3 +300,3 @@ for (var j = 0; j < this.columns; j++) { | ||
to2DArray() { | ||
let copy = new Array(this.rows); | ||
var copy = new Array(this.rows); | ||
for (var i = 0; i < this.rows; i++) { | ||
@@ -483,3 +483,3 @@ copy[i] = [].concat(this[i]); | ||
checkColumnIndex(this, index); | ||
let column = new Array(this.rows); | ||
var column = new Array(this.rows); | ||
for (var i = 0; i < this.rows; i++) { | ||
@@ -560,3 +560,3 @@ column[i] = this[i][index]; | ||
checkColumnIndex(this, column2); | ||
let temp, row; | ||
var temp, row; | ||
for (var i = 0; i < this.rows; i++) { | ||
@@ -723,3 +723,3 @@ row = this[i]; | ||
max() { | ||
let v = this[0][0]; | ||
var v = this[0][0]; | ||
for (var i = 0; i < this.rows; i++) { | ||
@@ -740,4 +740,4 @@ for (var j = 0; j < this.columns; j++) { | ||
maxIndex() { | ||
let v = this[0][0]; | ||
let idx = [0, 0]; | ||
var v = this[0][0]; | ||
var idx = [0, 0]; | ||
for (var i = 0; i < this.rows; i++) { | ||
@@ -760,3 +760,3 @@ for (var j = 0; j < this.columns; j++) { | ||
min() { | ||
let v = this[0][0]; | ||
var v = this[0][0]; | ||
for (var i = 0; i < this.rows; i++) { | ||
@@ -777,4 +777,4 @@ for (var j = 0; j < this.columns; j++) { | ||
minIndex() { | ||
let v = this[0][0]; | ||
let idx = [0, 0]; | ||
var v = this[0][0]; | ||
var idx = [0, 0]; | ||
for (var i = 0; i < this.rows; i++) { | ||
@@ -799,3 +799,3 @@ for (var j = 0; j < this.columns; j++) { | ||
checkRowIndex(this, row); | ||
let v = this[row][0]; | ||
var v = this[row][0]; | ||
for (var i = 1; i < this.columns; i++) { | ||
@@ -816,4 +816,4 @@ if (this[row][i] > v) { | ||
checkRowIndex(this, row); | ||
let v = this[row][0]; | ||
let idx = [row, 0]; | ||
var v = this[row][0]; | ||
var idx = [row, 0]; | ||
for (var i = 1; i < this.columns; i++) { | ||
@@ -835,3 +835,3 @@ if (this[row][i] > v) { | ||
checkRowIndex(this, row); | ||
let v = this[row][0]; | ||
var v = this[row][0]; | ||
for (var i = 1; i < this.columns; i++) { | ||
@@ -852,4 +852,4 @@ if (this[row][i] < v) { | ||
checkRowIndex(this, row); | ||
let v = this[row][0]; | ||
let idx = [row, 0]; | ||
var v = this[row][0]; | ||
var idx = [row, 0]; | ||
for (var i = 1; i < this.columns; i++) { | ||
@@ -871,3 +871,3 @@ if (this[row][i] < v) { | ||
checkColumnIndex(this, column); | ||
let v = this[0][column]; | ||
var v = this[0][column]; | ||
for (var i = 1; i < this.rows; i++) { | ||
@@ -888,4 +888,4 @@ if (this[i][column] > v) { | ||
checkColumnIndex(this, column); | ||
let v = this[0][column]; | ||
let idx = [0, column]; | ||
var v = this[0][column]; | ||
var idx = [0, column]; | ||
for (var i = 1; i < this.rows; i++) { | ||
@@ -907,3 +907,3 @@ if (this[i][column] > v) { | ||
checkColumnIndex(this, column); | ||
let v = this[0][column]; | ||
var v = this[0][column]; | ||
for (var i = 1; i < this.rows; i++) { | ||
@@ -924,4 +924,4 @@ if (this[i][column] < v) { | ||
checkColumnIndex(this, column); | ||
let v = this[0][column]; | ||
let idx = [0, column]; | ||
var v = this[0][column]; | ||
var idx = [0, column]; | ||
for (var i = 1; i < this.rows; i++) { | ||
@@ -941,4 +941,4 @@ if (this[i][column] < v) { | ||
diag() { | ||
const min = Math.min(this.rows, this.columns); | ||
let diag = new Array(min); | ||
var min = Math.min(this.rows, this.columns); | ||
var diag = new Array(min); | ||
for (var i = 0; i < min; i++) { | ||
@@ -955,3 +955,3 @@ diag[i] = this[i][i]; | ||
sum() { | ||
let v = 0; | ||
var v = 0; | ||
for (var i = 0; i < this.rows; i++) { | ||
@@ -978,3 +978,3 @@ for (var j = 0; j < this.columns; j++) { | ||
prod() { | ||
let prod = 1; | ||
var prod = 1; | ||
for (var i = 0; i < this.rows; i++) { | ||
@@ -993,3 +993,3 @@ for (var j = 0; j < this.columns; j++) { | ||
cumulativeSum() { | ||
let sum = 0; | ||
var sum = 0; | ||
for (var i = 0; i < this.rows; i++) { | ||
@@ -1011,3 +1011,3 @@ for (var j = 0; j < this.columns; j++) { | ||
if (Matrix.isMatrix(vector2)) vector2 = vector2.to1DArray(); | ||
let vector1 = this.to1DArray(); | ||
var vector1 = this.to1DArray(); | ||
if (vector1.length !== vector2.length) { | ||
@@ -1032,9 +1032,9 @@ throw new RangeError('vectors do not have the same size'); | ||
const m = this.rows; | ||
const n = this.columns; | ||
const p = other.columns; | ||
var m = this.rows; | ||
var n = this.columns; | ||
var p = other.columns; | ||
let result = new Matrix(m, p); | ||
var result = new Matrix(m, p); | ||
let Bcolj = new Array(n); | ||
var Bcolj = new Array(n); | ||
for (var j = 0; j < p; j++) { | ||
@@ -1062,3 +1062,3 @@ for (var k = 0; k < n; k++) | ||
transpose() { | ||
let result = new Matrix(this.columns, this.rows); | ||
var result = new Matrix(this.columns, this.rows); | ||
for (var i = 0; i < this.rows; i++) { | ||
@@ -1110,3 +1110,3 @@ for (var j = 0; j < this.columns; j++) { | ||
} | ||
let newMatrix = new Matrix(endRow - startRow + 1, endColumn - startColumn + 1); | ||
var newMatrix = new Matrix(endRow - startRow + 1, endColumn - startColumn + 1); | ||
for (var i = startRow; i <= endRow; i++) { | ||
@@ -1134,3 +1134,3 @@ for (var j = startColumn; j <= endColumn; j++) { | ||
let newMatrix = new Matrix(indices.length, endColumn - startColumn + 1); | ||
var newMatrix = new Matrix(indices.length, endColumn - startColumn + 1); | ||
for (var i = 0; i < indices.length; i++) { | ||
@@ -1161,3 +1161,3 @@ for (var j = startColumn; j <= endColumn; j++) { | ||
let newMatrix = new Matrix(endRow - startRow + 1, indices.length); | ||
var newMatrix = new Matrix(endRow - startRow + 1, indices.length); | ||
for (var i = 0; i < indices.length; i++) { | ||
@@ -1179,4 +1179,4 @@ for (var j = startRow; j <= endRow; j++) { | ||
trace() { | ||
const min = Math.min(this.rows, this.columns); | ||
let trace = 0; | ||
var min = Math.min(this.rows, this.columns); | ||
var trace = 0; | ||
for (var i = 0; i < min; i++) { | ||
@@ -1201,3 +1201,3 @@ trace += this[i][i]; | ||
function checkRowIndex(matrix, index, outer) { | ||
const max = outer ? matrix.rows : matrix.rows - 1; | ||
var max = outer ? matrix.rows : matrix.rows - 1; | ||
if (index < 0 || index > max) | ||
@@ -1255,3 +1255,3 @@ throw new RangeError('Row index out of range'); | ||
function checkColumnIndex(matrix, index, outer) { | ||
const max = outer ? matrix.columns : matrix.columns - 1; | ||
var max = outer ? matrix.columns : matrix.columns - 1; | ||
if (index < 0 || index > max) | ||
@@ -1292,3 +1292,3 @@ throw new RangeError('Column index out of range'); | ||
const inplaceOperator = ` | ||
var inplaceOperator = ` | ||
(function %name%(value) { | ||
@@ -1300,3 +1300,3 @@ if (typeof value === 'number') return this.%name%S(value); | ||
const inplaceOperatorScalar = ` | ||
var inplaceOperatorScalar = ` | ||
(function %name%S(value) { | ||
@@ -1312,3 +1312,3 @@ for (var i = 0; i < this.rows; i++) { | ||
const inplaceOperatorMatrix = ` | ||
var inplaceOperatorMatrix = ` | ||
(function %name%M(matrix) { | ||
@@ -1325,5 +1325,5 @@ checkDimensions(this, matrix); | ||
const staticOperator = ` | ||
var staticOperator = ` | ||
(function %name%(matrix, value) { | ||
const newMatrix = new Matrix(matrix); | ||
var newMatrix = new Matrix(matrix); | ||
return newMatrix.%name%(value); | ||
@@ -1333,3 +1333,3 @@ }) | ||
const inplaceMethod = ` | ||
var inplaceMethod = ` | ||
(function %name%() { | ||
@@ -1345,5 +1345,5 @@ for (var i = 0; i < this.rows; i++) { | ||
const staticMethod = ` | ||
var staticMethod = ` | ||
(function %name%(matrix) { | ||
const newMatrix = new Matrix(matrix); | ||
var newMatrix = new Matrix(matrix); | ||
return newMatrix.%name%(); | ||
@@ -1353,3 +1353,3 @@ }) | ||
const operators = [ | ||
var operators = [ | ||
// Arithmetic operators | ||
@@ -1370,4 +1370,4 @@ ['+', 'add'], | ||
for (let operator of operators) { | ||
for (let i = 1; i < operator.length; i++) { | ||
for (var operator of operators) { | ||
for (var i = 1; i < operator.length; i++) { | ||
Matrix.prototype[operator[i]] = eval(fillTemplateFunction(inplaceOperator, {name: operator[i], op: operator[0]})); | ||
@@ -1381,3 +1381,3 @@ Matrix.prototype[operator[i] + 'S'] = eval(fillTemplateFunction(inplaceOperatorScalar, {name: operator[i] + 'S', op: operator[0]})); | ||
const methods = [ | ||
var methods = [ | ||
['~', 'not'] | ||
@@ -1394,4 +1394,4 @@ ]; | ||
for (let method of methods) { | ||
for (let i = 1; i < method.length; i++) { | ||
for (var method of methods) { | ||
for (var i = 1; i < method.length; i++) { | ||
Matrix.prototype[method[i]] = eval(fillTemplateFunction(inplaceMethod, {name: method[i], method: method[0]})); | ||
@@ -1398,0 +1398,0 @@ Matrix[method[i]] = eval(fillTemplateFunction(staticMethod, {name: method[i]})); |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
3034584
28