Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

ml-matrix

Package Overview
Dependencies
Maintainers
7
Versions
74
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

ml-matrix - npm Package Compare versions

Comparing version 1.1.5 to 1.2.0

README.md

10

History.md

@@ -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 @@ ==================

4

package.json
{
"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) {

SocketSocket SOC 2 Logo

Product

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

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc