You're Invited:Meet the Socket Team at BlackHat and DEF CON in Las Vegas, Aug 4-6.RSVP
Socket
Book a DemoInstallSign in
Socket

ml-matrix

Package Overview
Dependencies
Maintainers
7
Versions
75
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

to
1.3.0

10

History.md

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

5

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