🚀 Big News: Socket Acquires Coana to Bring Reachability Analysis to Every Appsec Team.Learn more
Socket
DemoInstallSign in
Socket

linear-algebra

Package Overview
Dependencies
Maintainers
1
Versions
12
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

linear-algebra - npm Package Compare versions

Comparing version

to
2.3.0

2

bower.json
{
"name": "linear-algebra",
"main": "dist/linear-algebra.js",
"version": "2.2.0",
"version": "2.3.0",
"authors": [

@@ -6,0 +6,0 @@ "Ramesh Nair <ram@hiddentao.com>"

@@ -497,2 +497,57 @@ (function (root, factory) {

/**
* Add each value from given array to each column in this matrix.
*
* @param {Vector} vector Array with same length as matrix columns.
*
* @return {Matrix} New instance.
*/
Matrix.prototype.plusCols = function(vector) {
if (this.cols !== vector.size) {
_throwError('Vector length must equal no. of columns');
}
var a = new Array(this.rows);
for (var i=0; i<this.rows; ++i) {
a[i] = new Array(this.cols);
for (var j=0; j<this.cols; ++j) {
a[i][j] = this.data[i][j] + vector.data[j];
}
}
return new Matrix(a);
};
/**
* Add each value from given array to each column in this matrix.
*
* @param {Vector} vector Array with same length as matrix columns.
*
* @return {this}
*/
Matrix.prototype.plusColsP = function(vector) {
if (this.cols !== vector.size) {
_throwError('Vector length must equal no. of columns');
}
for (var i=0; i<this.rows; ++i) {
for (var j=0; j<this.cols; ++j) {
this.data[i][j] += vector.data[j];
}
}
return this;
};
return LinAlg;

@@ -499,0 +554,0 @@ };

@@ -1,1 +0,1 @@

!function(t,r){"use strict";"function"==typeof define&&define.amd?define([],r):"object"==typeof exports?module.exports=r():t.linearAlgebra=r()}(this,function(){"use strict";var t=function(t){throw new Error("linear-algebra: "+t)};return function(r){r=r||{},r.add&&console.warn("linear-algebra: adder (options.add) will not be used in non-precision version");var s={},e=s.Vector=function(t){this.data=t,this.size=t.length};Object.defineProperty(e.prototype,"isVector",{value:!0}),e.prototype.scale=function(t){for(var r=new Array(this.size),s=0;s<this.size;++s)r[s]=this.data[s]*t;return new e(r)},e.prototype.scaleP=function(t){for(var r=0;r<this.size;++r)this.data[r]*=t;return this},e.zero=function(t){for(var r=new Array(t),s=0;t>s;++s)r[s]=0;return new e(r)};var i=s.Matrix=function(t){this.data=t,this.rows=t.length,this.cols=t[0].length,this.size=[this.rows,this.cols]};return Object.defineProperty(i.prototype,"isMatrix",{value:!0}),i.prototype.scale=function(t){for(var r=new Array(this.rows),s=0;s<this.rows;++s){r[s]=new Array(this.cols);for(var e=0;e<this.cols;++e)r[s][e]=this.data[s][e]*t}return new i(r)},i.prototype.scale=function(t){for(var r=new Array(this.rows),s=0;s<this.rows;++s){r[s]=new Array(this.cols);for(var e=0;e<this.cols;++e)r[s][e]=this.data[s][e]*t}return new i(r)},i.prototype.scaleP=function(t){for(var r=0;r<this.rows;++r)for(var s=0;s<this.cols;++s)this.data[r][s]*=t;return this},i.prototype.transpose=function(){var t,r,s=new Array(this.cols);for(r=0;r<this.cols;++r)for(s[r]=new Array(this.rows),t=0;t<this.rows;++t)s[r][t]=this.data[t][r];return new i(s)},i.identity=function(t){return i.scalar(t,1)},i.scalar=function(t,r){var s,e,o=new Array(t);for(s=0;t>s;++s){for(o[s]=new Array(t),e=0;t>e;++e)o[s][e]=0;o[s][s]=r}return new i(o)},e.prototype.dot=function(r){this.size!==r.size&&t("Vector dot product requires vectors to have same size");for(var s=0,e=0;e<this.size;++e)s+=this.data[e]*r.data[e];return s},e.prototype.minus=function(r){this.size!==r.size&&t("Vector subtraction requires vectors to have same size");for(var s=new Array(this.size),i=0;i<this.size;++i)s[i]=this.data[i]-r.data[i];return new e(s)},e.prototype.minusP=function(r){this.size!==r.size&&t("Vector subtraction requires vectors to have same size");for(var s=0;s<this.size;++s)this.data[s]=this.data[s]-r.data[s];return this},e.prototype.plus=function(r){this.size!==r.size&&t("Vector addition requires vectors to have same size");for(var s=new Array(this.size),i=0;i<this.size;++i)s[i]=this.data[i]+r.data[i];return new e(s)},e.prototype.plusP=function(r){this.size!==r.size&&t("Vector addition requires vectors to have same size");for(var s=0;s<this.size;++s)this.data[s]=this.data[s]+r.data[s];return this},e.prototype.sum=function(){for(var t=0,r=0;r<this.size;++r)t+=this.data[r];return t},i.prototype.dot=function(r,s){this.cols!==s.size&&t("Vector dot product requires this.columns = vector.size");for(var e=0,i=0;i<this.cols;++i)e+=this.data[r][i]*s.data[i];return e},i.prototype.mul=function(r){var s,o,a,n;if(r.isMatrix){for(this.cols!==r.rows&&t("Multiplying by matrix requires this.columns = matrix.rows"),s=new Array(this.rows),o=0;o<this.rows;++o)for(s[o]=new Array(r.cols),n=0;n<r.cols;++n)for(s[o][n]=0,a=0;a<this.cols;++a)s[o][n]+=this.data[o][a]*r.data[a][n];return new i(s)}if(r.isVector){for(this.cols!==r.size&&t("Multiplying by vector requires this.columns = vector.size"),s=new Array(this.rows),o=0;o<this.rows;++o)for(s[o]=0,a=0;a<this.cols;++a)s[o]+=this.data[o][a]*r.data[a];return new e(s)}},s}});
!function(t,r){"use strict";"function"==typeof define&&define.amd?define([],r):"object"==typeof exports?module.exports=r():t.linearAlgebra=r()}(this,function(){"use strict";var t=function(t){throw new Error("linear-algebra: "+t)};return function(r){r=r||{},r.add&&console.warn("linear-algebra: adder (options.add) will not be used in non-precision version");var s={},e=s.Vector=function(t){this.data=t,this.size=t.length};Object.defineProperty(e.prototype,"isVector",{value:!0}),e.prototype.scale=function(t){for(var r=new Array(this.size),s=0;s<this.size;++s)r[s]=this.data[s]*t;return new e(r)},e.prototype.scaleP=function(t){for(var r=0;r<this.size;++r)this.data[r]*=t;return this},e.zero=function(t){for(var r=new Array(t),s=0;t>s;++s)r[s]=0;return new e(r)};var o=s.Matrix=function(t){this.data=t,this.rows=t.length,this.cols=t[0].length,this.size=[this.rows,this.cols]};return Object.defineProperty(o.prototype,"isMatrix",{value:!0}),o.prototype.scale=function(t){for(var r=new Array(this.rows),s=0;s<this.rows;++s){r[s]=new Array(this.cols);for(var e=0;e<this.cols;++e)r[s][e]=this.data[s][e]*t}return new o(r)},o.prototype.scale=function(t){for(var r=new Array(this.rows),s=0;s<this.rows;++s){r[s]=new Array(this.cols);for(var e=0;e<this.cols;++e)r[s][e]=this.data[s][e]*t}return new o(r)},o.prototype.scaleP=function(t){for(var r=0;r<this.rows;++r)for(var s=0;s<this.cols;++s)this.data[r][s]*=t;return this},o.prototype.transpose=function(){var t,r,s=new Array(this.cols);for(r=0;r<this.cols;++r)for(s[r]=new Array(this.rows),t=0;t<this.rows;++t)s[r][t]=this.data[t][r];return new o(s)},o.identity=function(t){return o.scalar(t,1)},o.scalar=function(t,r){var s,e,i=new Array(t);for(s=0;t>s;++s){for(i[s]=new Array(t),e=0;t>e;++e)i[s][e]=0;i[s][s]=r}return new o(i)},e.prototype.dot=function(r){this.size!==r.size&&t("Vector dot product requires vectors to have same size");for(var s=0,e=0;e<this.size;++e)s+=this.data[e]*r.data[e];return s},e.prototype.minus=function(r){this.size!==r.size&&t("Vector subtraction requires vectors to have same size");for(var s=new Array(this.size),o=0;o<this.size;++o)s[o]=this.data[o]-r.data[o];return new e(s)},e.prototype.minusP=function(r){this.size!==r.size&&t("Vector subtraction requires vectors to have same size");for(var s=0;s<this.size;++s)this.data[s]=this.data[s]-r.data[s];return this},e.prototype.plus=function(r){this.size!==r.size&&t("Vector addition requires vectors to have same size");for(var s=new Array(this.size),o=0;o<this.size;++o)s[o]=this.data[o]+r.data[o];return new e(s)},e.prototype.plusP=function(r){this.size!==r.size&&t("Vector addition requires vectors to have same size");for(var s=0;s<this.size;++s)this.data[s]=this.data[s]+r.data[s];return this},e.prototype.sum=function(){for(var t=0,r=0;r<this.size;++r)t+=this.data[r];return t},o.prototype.dot=function(r,s){this.cols!==s.size&&t("Vector dot product requires this.columns = vector.size");for(var e=0,o=0;o<this.cols;++o)e+=this.data[r][o]*s.data[o];return e},o.prototype.mul=function(r){var s,i,a,n;if(r.isMatrix){for(this.cols!==r.rows&&t("Multiplying by matrix requires this.columns = matrix.rows"),s=new Array(this.rows),i=0;i<this.rows;++i)for(s[i]=new Array(r.cols),n=0;n<r.cols;++n)for(s[i][n]=0,a=0;a<this.cols;++a)s[i][n]+=this.data[i][a]*r.data[a][n];return new o(s)}if(r.isVector){for(this.cols!==r.size&&t("Multiplying by vector requires this.columns = vector.size"),s=new Array(this.rows),i=0;i<this.rows;++i)for(s[i]=0,a=0;a<this.cols;++a)s[i]+=this.data[i][a]*r.data[a];return new e(s)}},o.prototype.plusCols=function(r){this.cols!==r.size&&t("Vector length must equal no. of columns");for(var s=new Array(this.rows),e=0;e<this.rows;++e){s[e]=new Array(this.cols);for(var i=0;i<this.cols;++i)s[e][i]=this.data[e][i]+r.data[i]}return new o(s)},o.prototype.plusColsP=function(r){this.cols!==r.size&&t("Vector length must equal no. of columns");for(var s=0;s<this.rows;++s)for(var e=0;e<this.cols;++e)this.data[s][e]+=r.data[e];return this},s}});

@@ -496,2 +496,54 @@ (function (root, factory) {

/**
* Add each value from given array to each column in this matrix.
*
* @param {Vector} vector Array with same length as matrix columns.
*
* @return {Matrix} New instance.
*/
Matrix.prototype.plusCols = function(vector) {
if (this.cols !== vector.size) {
_throwError('Vector length must equal no. of columns');
}
var a = new Array(this.rows);
for (var i=0; i<this.rows; ++i) {
a[i] = new Array(this.cols);
for (var j=0; j<this.cols; ++j) {
a[i][j] = adder([ this.data[i][j], vector.data[j] ]);
}
}
return new Matrix(a);
};
/**
* Add each value from given array to each column in this matrix.
*
* @param {Vector} vector Array with same length as matrix columns.
*
* @return {this}
*/
Matrix.prototype.plusColsP = function(vector) {
if (this.cols !== vector.size) {
_throwError('Vector length must equal no. of columns');
}
for (var i=0; i<this.rows; ++i) {
for (var j=0; j<this.cols; ++j) {
this.data[i][j] = adder([ this.data[i][j], vector.data[j] ]);
}
}
return this;
};
return LinAlg;

@@ -498,0 +550,0 @@ };

@@ -1,1 +0,1 @@

!function(t,r){"use strict";"function"==typeof define&&define.amd?define([],r):"object"==typeof exports?module.exports=r():t.linearAlgebra=r()}(this,function(){"use strict";var t=function(t){throw new Error("linear-algebra: "+t)};return function(r){r=r||{};var s=r.add;s||t("options.add must be set for precision calculation");var e={},i=e.Vector=function(t){this.data=t,this.size=t.length};Object.defineProperty(i.prototype,"isVector",{value:!0}),i.prototype.scale=function(t){for(var r=new Array(this.size),s=0;s<this.size;++s)r[s]=this.data[s]*t;return new i(r)},i.prototype.scaleP=function(t){for(var r=0;r<this.size;++r)this.data[r]*=t;return this},i.zero=function(t){for(var r=new Array(t),s=0;t>s;++s)r[s]=0;return new i(r)};var o=e.Matrix=function(t){this.data=t,this.rows=t.length,this.cols=t[0].length,this.size=[this.rows,this.cols]};return Object.defineProperty(o.prototype,"isMatrix",{value:!0}),o.prototype.scale=function(t){for(var r=new Array(this.rows),s=0;s<this.rows;++s){r[s]=new Array(this.cols);for(var e=0;e<this.cols;++e)r[s][e]=this.data[s][e]*t}return new o(r)},o.prototype.scale=function(t){for(var r=new Array(this.rows),s=0;s<this.rows;++s){r[s]=new Array(this.cols);for(var e=0;e<this.cols;++e)r[s][e]=this.data[s][e]*t}return new o(r)},o.prototype.scaleP=function(t){for(var r=0;r<this.rows;++r)for(var s=0;s<this.cols;++s)this.data[r][s]*=t;return this},o.prototype.transpose=function(){var t,r,s=new Array(this.cols);for(r=0;r<this.cols;++r)for(s[r]=new Array(this.rows),t=0;t<this.rows;++t)s[r][t]=this.data[t][r];return new o(s)},o.identity=function(t){return o.scalar(t,1)},o.scalar=function(t,r){var s,e,i=new Array(t);for(s=0;t>s;++s){for(i[s]=new Array(t),e=0;t>e;++e)i[s][e]=0;i[s][s]=r}return new o(i)},i.prototype.dot=function(r){this.size!==r.size&&t("Vector dot product requires vectors to have same size");for(var e=new Array(this.size),i=0;i<this.size;++i)e[i]=this.data[i]*r.data[i];return s(e)},i.prototype.minus=function(r){this.size!==r.size&&t("Vector subtraction requires vectors to have same size");for(var e=new Array(this.size),o=0;o<this.size;++o)e[o]=s([this.data[o],-r.data[o]]);return new i(e)},i.prototype.minusP=function(r){this.size!==r.size&&t("Vector subtraction requires vectors to have same size");for(var e=0;e<this.size;++e)this.data[e]=s([this.data[e],-r.data[e]]);return this},i.prototype.plus=function(r){this.size!==r.size&&t("Vector addition requires vectors to have same size");for(var e=new Array(this.size),o=0;o<this.size;++o)e[o]=s([this.data[o],r.data[o]]);return new i(e)},i.prototype.plusP=function(r){this.size!==r.size&&t("Vector addition requires vectors to have same size");for(var e=0;e<this.size;++e)this.data[e]=s([this.data[e],r.data[e]]);return this},i.prototype.sum=function(){return s(this.data)},o.prototype.dot=function(r,e){this.cols!==e.size&&t("Vector dot product requires this.columns = vector.size");for(var i=new Array(this.cols),o=0;o<this.cols;++o)i[o]=this.data[r][o]*e.data[o];return s(i)},o.prototype.mul=function(r){var e,a,n,h,c;if(r.isMatrix){for(this.cols!==r.rows&&t("Multiplying by matrix requires this.columns = matrix.rows"),e=new Array(this.rows),a=new Array(this.cols),n=0;n<this.rows;++n)for(e[n]=new Array(r.cols),c=0;c<r.cols;++c){for(h=0;h<this.cols;++h)a[h]=this.data[n][h]*r.data[h][c];e[n][c]=s(a)}return new o(e)}if(r.isVector){for(this.cols!==r.size&&t("Multiplying by vector requires this.columns = vector.size"),e=new Array(this.rows),a=new Array(r.size),n=0;n<this.rows;++n){for(h=0;h<this.cols;++h)a[h]=this.data[n][h]*r.data[h];e[n]=s(a)}return new i(e)}},e}});
!function(t,r){"use strict";"function"==typeof define&&define.amd?define([],r):"object"==typeof exports?module.exports=r():t.linearAlgebra=r()}(this,function(){"use strict";var t=function(t){throw new Error("linear-algebra: "+t)};return function(r){r=r||{};var s=r.add;s||t("options.add must be set for precision calculation");var e={},i=e.Vector=function(t){this.data=t,this.size=t.length};Object.defineProperty(i.prototype,"isVector",{value:!0}),i.prototype.scale=function(t){for(var r=new Array(this.size),s=0;s<this.size;++s)r[s]=this.data[s]*t;return new i(r)},i.prototype.scaleP=function(t){for(var r=0;r<this.size;++r)this.data[r]*=t;return this},i.zero=function(t){for(var r=new Array(t),s=0;t>s;++s)r[s]=0;return new i(r)};var o=e.Matrix=function(t){this.data=t,this.rows=t.length,this.cols=t[0].length,this.size=[this.rows,this.cols]};return Object.defineProperty(o.prototype,"isMatrix",{value:!0}),o.prototype.scale=function(t){for(var r=new Array(this.rows),s=0;s<this.rows;++s){r[s]=new Array(this.cols);for(var e=0;e<this.cols;++e)r[s][e]=this.data[s][e]*t}return new o(r)},o.prototype.scale=function(t){for(var r=new Array(this.rows),s=0;s<this.rows;++s){r[s]=new Array(this.cols);for(var e=0;e<this.cols;++e)r[s][e]=this.data[s][e]*t}return new o(r)},o.prototype.scaleP=function(t){for(var r=0;r<this.rows;++r)for(var s=0;s<this.cols;++s)this.data[r][s]*=t;return this},o.prototype.transpose=function(){var t,r,s=new Array(this.cols);for(r=0;r<this.cols;++r)for(s[r]=new Array(this.rows),t=0;t<this.rows;++t)s[r][t]=this.data[t][r];return new o(s)},o.identity=function(t){return o.scalar(t,1)},o.scalar=function(t,r){var s,e,i=new Array(t);for(s=0;t>s;++s){for(i[s]=new Array(t),e=0;t>e;++e)i[s][e]=0;i[s][s]=r}return new o(i)},i.prototype.dot=function(r){this.size!==r.size&&t("Vector dot product requires vectors to have same size");for(var e=new Array(this.size),i=0;i<this.size;++i)e[i]=this.data[i]*r.data[i];return s(e)},i.prototype.minus=function(r){this.size!==r.size&&t("Vector subtraction requires vectors to have same size");for(var e=new Array(this.size),o=0;o<this.size;++o)e[o]=s([this.data[o],-r.data[o]]);return new i(e)},i.prototype.minusP=function(r){this.size!==r.size&&t("Vector subtraction requires vectors to have same size");for(var e=0;e<this.size;++e)this.data[e]=s([this.data[e],-r.data[e]]);return this},i.prototype.plus=function(r){this.size!==r.size&&t("Vector addition requires vectors to have same size");for(var e=new Array(this.size),o=0;o<this.size;++o)e[o]=s([this.data[o],r.data[o]]);return new i(e)},i.prototype.plusP=function(r){this.size!==r.size&&t("Vector addition requires vectors to have same size");for(var e=0;e<this.size;++e)this.data[e]=s([this.data[e],r.data[e]]);return this},i.prototype.sum=function(){return s(this.data)},o.prototype.dot=function(r,e){this.cols!==e.size&&t("Vector dot product requires this.columns = vector.size");for(var i=new Array(this.cols),o=0;o<this.cols;++o)i[o]=this.data[r][o]*e.data[o];return s(i)},o.prototype.mul=function(r){var e,a,n,h,c;if(r.isMatrix){for(this.cols!==r.rows&&t("Multiplying by matrix requires this.columns = matrix.rows"),e=new Array(this.rows),a=new Array(this.cols),n=0;n<this.rows;++n)for(e[n]=new Array(r.cols),c=0;c<r.cols;++c){for(h=0;h<this.cols;++h)a[h]=this.data[n][h]*r.data[h][c];e[n][c]=s(a)}return new o(e)}if(r.isVector){for(this.cols!==r.size&&t("Multiplying by vector requires this.columns = vector.size"),e=new Array(this.rows),a=new Array(r.size),n=0;n<this.rows;++n){for(h=0;h<this.cols;++h)a[h]=this.data[n][h]*r.data[h];e[n]=s(a)}return new i(e)}},o.prototype.plusCols=function(r){this.cols!==r.size&&t("Vector length must equal no. of columns");for(var e=new Array(this.rows),i=0;i<this.rows;++i){e[i]=new Array(this.cols);for(var a=0;a<this.cols;++a)e[i][a]=s([this.data[i][a],r.data[a]])}return new o(e)},o.prototype.plusColsP=function(r){this.cols!==r.size&&t("Vector length must equal no. of columns");for(var e=0;e<this.rows;++e)for(var i=0;i<this.cols;++i)this.data[e][i]=s([this.data[e][i],r.data[i]]);return this},e}});
{
"name": "linear-algebra",
"version": "2.2.0",
"version": "2.3.0",
"description": "Efficient, high-performance linear algebra library",

@@ -5,0 +5,0 @@ "main": "index.js",

@@ -149,2 +149,14 @@ # linear-algebra

console.log( prod ); // -38
// Add a vector to all columns
m = new Matrix( [ [1, 2, 3], [4, 5, 6] ] );
v = new Vector( [ -1, -2, -4] );
m2 = m.plusCols(v);
console.log( m2.data ); // [ [0, 0, -1], [3, 3, 2] ]
// Add a vector to all columns in-place
m = new Matrix( [ [1, 2, 3], [4, 5, 6] ] );
v = new Vector( [ -1, -2, -4] );
m.plusColsP(v);
console.log( m.data ); // [ [0, 0, -1], [3, 3, 2] ]
```

@@ -151,0 +163,0 @@

@@ -85,1 +85,56 @@ /**

};
/**
* Add each value from given array to each column in this matrix.
*
* @param {Vector} vector Array with same length as matrix columns.
*
* @return {Matrix} New instance.
*/
Matrix.prototype.plusCols = function(vector) {
if (this.cols !== vector.size) {
_throwError('Vector length must equal no. of columns');
}
var a = new Array(this.rows);
for (var i=0; i<this.rows; ++i) {
a[i] = new Array(this.cols);
for (var j=0; j<this.cols; ++j) {
a[i][j] = this.data[i][j] + vector.data[j];
}
}
return new Matrix(a);
};
/**
* Add each value from given array to each column in this matrix.
*
* @param {Vector} vector Array with same length as matrix columns.
*
* @return {this}
*/
Matrix.prototype.plusColsP = function(vector) {
if (this.cols !== vector.size) {
_throwError('Vector length must equal no. of columns');
}
for (var i=0; i<this.rows; ++i) {
for (var j=0; j<this.cols; ++j) {
this.data[i][j] += vector.data[j];
}
}
return this;
};

@@ -89,1 +89,53 @@ /**

};
/**
* Add each value from given array to each column in this matrix.
*
* @param {Vector} vector Array with same length as matrix columns.
*
* @return {Matrix} New instance.
*/
Matrix.prototype.plusCols = function(vector) {
if (this.cols !== vector.size) {
_throwError('Vector length must equal no. of columns');
}
var a = new Array(this.rows);
for (var i=0; i<this.rows; ++i) {
a[i] = new Array(this.cols);
for (var j=0; j<this.cols; ++j) {
a[i][j] = adder([ this.data[i][j], vector.data[j] ]);
}
}
return new Matrix(a);
};
/**
* Add each value from given array to each column in this matrix.
*
* @param {Vector} vector Array with same length as matrix columns.
*
* @return {this}
*/
Matrix.prototype.plusColsP = function(vector) {
if (this.cols !== vector.size) {
_throwError('Vector length must equal no. of columns');
}
for (var i=0; i<this.rows; ++i) {
for (var j=0; j<this.cols; ++j) {
this.data[i][j] = adder([ this.data[i][j], vector.data[j] ]);
}
}
return this;
};

@@ -266,2 +266,46 @@ var chai = require('chai'),

},
'plus columns': {
'wrong size': function() {
var a = [ [1,2], [3,4], [5,6] ];
var m = new this.Matrix(a);
var v = new this.Vector([1,2, 3]);
expect(function() {
m.plusCols(v);
}).to.throw('Vector length must equal no. of columns');
},
'right size': function() {
var a = [ [1,2], [3,4], [5,6] ];
var m = new this.Matrix(a);
var v = new this.Vector([2, 3.1]);
var m2 = m.plusCols(v);
m2.should.not.eql(m);
m2.data.should.eql([ [3,5.1], [5,7.1], [7,9.1] ]);
}
},
'plus columns in-place': {
'wrong size': function() {
var a = [ [1,2], [3,4], [5,6] ];
var m = new this.Matrix(a);
var v = new this.Vector([1,2, 3]);
expect(function() {
m.plusColsP(v);
}).to.throw('Vector length must equal no. of columns');
},
'right size': function() {
var a = [ [1,2], [3,4], [5,6] ];
var m = new this.Matrix(a);
var v = new this.Vector([2, 3.1]);
var m2 = m.plusColsP(v);
m2.should.eql(m);
m.data.should.eql([ [3,5.1], [5,7.1], [7,9.1] ]);
}
},
'scalar': function() {

@@ -268,0 +312,0 @@ var m1 = this.Matrix.scalar(3, 1.2);