fredrick / gauss

JavaScript statistics, analytics, and data library - Node.js and web browser ready
https://npmjs.org/package/gauss
Other
433 stars 29 forks source link

Easy way to element-wise add/multiply/divide two vectors #15

Closed pablojim closed 11 years ago

pablojim commented 11 years ago

Maybe I'm missing it but is there an easy way to element-wise add/multiply/divide two vectors.

If not, is this something you consider adding/accepting pull requests for?

fredrick commented 11 years ago

This functionality currently does not exist, can you give an example of what you were thinking? Absolutely, I would welcome the contribution.

pablojim commented 11 years ago

So I was thinking methods like these:

var a = new gauss.Vector(1, 2), b = new gauss.Vector(3, 4); var c= a.add(b); assert.equal(new gauss.Vector(4,6), c);

Probably will just throw an error if non-matching length vectors are passed in.

Maybe allow for scalar operations also:

assert.equal(new gauss.Vector(11,12), a.add(10));

Similar for multiply/divide/subtract.

fredrick commented 11 years ago

I like it, if you do submit a pull request, I'd be more than happy to look at it.