Comparing version 1.1.5 to 1.2.0
@@ -0,1 +1,11 @@ | ||
<a name="1.2.0"></a> | ||
# [1.2.0](https://github.com/mljs/matrix/compare/v1.1.5...v1.2.0) (2016-07-07) | ||
### Features | ||
* add support for Math.pow ([2524b73](https://github.com/mljs/matrix/commit/2524b73)) | ||
1.1.5 / 2016-05-31 | ||
@@ -2,0 +12,0 @@ ================== |
{ | ||
"name": "ml-matrix", | ||
"version": "1.1.5", | ||
"version": "1.2.0", | ||
"description": "Matrix manipulation and computation library", | ||
@@ -56,5 +56,5 @@ "main": "src/index.js", | ||
"pretty-hrtime": "^1.0.0", | ||
"should": "^8.0.0", | ||
"should": "^9.0.2", | ||
"should-approximately-deep": "^1.1.0" | ||
} | ||
} |
@@ -5,10 +5,8 @@ 'use strict'; | ||
* Real matrix | ||
* @class Matrix | ||
* @param {number|Array|Matrix} nRows - Number of rows of the new matrix, | ||
* 2D array containing the data or Matrix instance to clone | ||
* @param {number} [nColumns] - Number of columns of the new matrix | ||
*/ | ||
class Matrix extends Array { | ||
/** | ||
* @constructor | ||
* @param {number|Array|Matrix} nRows - Number of rows of the new matrix, | ||
* 2D array containing the data or Matrix instance to clone | ||
* @param {number} [nColumns] - Number of columns of the new matrix | ||
*/ | ||
constructor(nRows, nColumns) { | ||
@@ -1343,2 +1341,20 @@ if (Matrix.isMatrix(nRows)) { | ||
var inplaceMethodWithArgs = ` | ||
(function %name%(...args) { | ||
for (var i = 0; i < this.rows; i++) { | ||
for (var j = 0; j < this.columns; j++) { | ||
this[i][j] = %method%(this[i][j], ...args); | ||
} | ||
} | ||
return this; | ||
}) | ||
`; | ||
var staticMethodWithArgs = ` | ||
(function %name%(matrix, ...args) { | ||
var newMatrix = new Matrix(matrix); | ||
return newMatrix.%name%(...args); | ||
}) | ||
`; | ||
var operators = [ | ||
@@ -1361,8 +1377,11 @@ // Arithmetic operators | ||
for (var operator of operators) { | ||
var inplaceOp = eval(fillTemplateFunction(inplaceOperator, {name: operator[1], op: operator[0]})); | ||
var inplaceOpS = eval(fillTemplateFunction(inplaceOperatorScalar, {name: operator[1] + 'S', op: operator[0]})); | ||
var inplaceOpM = eval(fillTemplateFunction(inplaceOperatorMatrix, {name: operator[1] + 'M', op: operator[0]})); | ||
var staticOp = eval(fillTemplateFunction(staticOperator, {name: operator[1]})); | ||
for (var i = 1; i < operator.length; i++) { | ||
Matrix.prototype[operator[i]] = eval(fillTemplateFunction(inplaceOperator, {name: operator[i], op: operator[0]})); | ||
Matrix.prototype[operator[i] + 'S'] = eval(fillTemplateFunction(inplaceOperatorScalar, {name: operator[i] + 'S', op: operator[0]})); | ||
Matrix.prototype[operator[i] + 'M'] = eval(fillTemplateFunction(inplaceOperatorMatrix, {name: operator[i] + 'M', op: operator[0]})); | ||
Matrix[operator[i]] = eval(fillTemplateFunction(staticOperator, {name: operator[i]})); | ||
Matrix.prototype[operator[i]] = inplaceOp; | ||
Matrix.prototype[operator[i] + 'S'] = inplaceOpS; | ||
Matrix.prototype[operator[i] + 'M'] = inplaceOpM; | ||
Matrix[operator[i]] = staticOp; | ||
} | ||
@@ -1384,8 +1403,23 @@ } | ||
for (var method of methods) { | ||
var inplaceMeth = eval(fillTemplateFunction(inplaceMethod, {name: method[1], method: method[0]})); | ||
var staticMeth = eval(fillTemplateFunction(staticMethod, {name: method[1]})); | ||
for (var i = 1; i < method.length; i++) { | ||
Matrix.prototype[method[i]] = eval(fillTemplateFunction(inplaceMethod, {name: method[i], method: method[0]})); | ||
Matrix[method[i]] = eval(fillTemplateFunction(staticMethod, {name: method[i]})); | ||
Matrix.prototype[method[i]] = inplaceMeth; | ||
Matrix[method[i]] = staticMeth; | ||
} | ||
} | ||
var methodsWithArgs = [ | ||
['Math.pow', 'pow'] | ||
]; | ||
for (var methodWithArg of methodsWithArgs) { | ||
var inplaceMethWithArgs = eval(fillTemplateFunction(inplaceMethodWithArgs, {name: methodWithArg[1], method: methodWithArg[0]})); | ||
var staticMethWithArgs = eval(fillTemplateFunction(staticMethodWithArgs, {name: methodWithArg[1]})); | ||
for (var i = 1; i < methodWithArg.length; i++) { | ||
Matrix.prototype[methodWithArg[i]] = inplaceMethWithArgs; | ||
Matrix[methodWithArg[i]] = staticMethWithArgs; | ||
} | ||
} | ||
function fillTemplateFunction(template, values) { | ||
@@ -1392,0 +1426,0 @@ for (var i in values) { |
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
No README
QualityPackage does not have a README. This may indicate a failed publish or a low quality package.
Found 1 instance in 1 package
96078
13
2909
0
28