Comparing version
@@ -0,1 +1,11 @@ | ||
<a name="1.3.0"></a> | ||
# [1.3.0](https://github.com/mljs/matrix/compare/v1.2.1...v1.3.0) (2016-07-25) | ||
### Features | ||
* add methods scaleRows and scaleColumns ([8516f83](https://github.com/mljs/matrix/commit/8516f83)) | ||
<a name="1.2.1"></a> | ||
@@ -2,0 +12,0 @@ ## [1.2.1](https://github.com/mljs/matrix/compare/v1.2.0...v1.2.1) (2016-07-07) |
{ | ||
"name": "ml-matrix", | ||
"version": "1.2.1", | ||
"version": "1.3.0", | ||
"description": "Matrix manipulation and computation library", | ||
@@ -58,3 +58,6 @@ "main": "src/index.js", | ||
"should-approximately-deep": "^1.1.0" | ||
}, | ||
"dependencies": { | ||
"ml-array-utils": "^0.2.4" | ||
} | ||
} |
'use strict'; | ||
const arrayUtils = require('ml-array-utils'); | ||
/** | ||
@@ -1030,2 +1032,41 @@ * Real matrix | ||
/** | ||
* Returns a row-by-row scaled matrix | ||
* @param {Number} [min=0] - Minimum scaled value | ||
* @param {Number} [max=1] - Maximum scaled value | ||
* @returns {Matrix} - The scaled matrix | ||
*/ | ||
scaleRows(min, max) { | ||
min = min === undefined ? 0 : min; | ||
max = max === undefined ? 1 : max; | ||
var newMatrix = Matrix.empty(this.rows, this.columns); | ||
for(var i=0; i<this.rows; i++) { | ||
var scaled = arrayUtils.scale(this.getRow(i), {min, max}); | ||
newMatrix.setRow(i, scaled); | ||
} | ||
return newMatrix; | ||
} | ||
/** | ||
* Returns a new column-by-column scaled matrix | ||
* @param {Number} [min=0] - Minimum scaled value | ||
* @param {Number} [max=1] - Maximum scaled value | ||
* @returns {Matrix} - The new scaled matrix | ||
*/ | ||
scaleColumns(min, max) { | ||
min = min === undefined ? 0 : min; | ||
max = max === undefined ? 1 : max; | ||
var newMatrix = Matrix.empty(this.rows, this.columns); | ||
for(var i=0; i<this.columns; i++) { | ||
var scaled = arrayUtils.scale(this.getColumn(i), { | ||
min: min, | ||
max: max | ||
}); | ||
newMatrix.setColumn(i, scaled); | ||
} | ||
return newMatrix; | ||
} | ||
/** | ||
* Returns the Kronecker product (also known as tensor product) between this and other | ||
@@ -1032,0 +1073,0 @@ * See https://en.wikipedia.org/wiki/Kronecker_product |
New author
Supply chain riskA new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.
Found 1 instance in 1 package
Uses eval
Supply chain riskPackage uses dynamic code execution (e.g., eval()), which is a dangerous practice. This can prevent the code from running in certain environments and increases the risk that the code may contain exploits or malicious behavior.
Found 1 instance in 1 package
97987
1.63%2949
1.24%1
Infinity%9
Infinity%+ Added
+ Added
+ Added
+ Added