7

Is there a reasonable numerical library in pure JavaScript?

I'd like array-based vectors, matrices, determinate, and matrix inversion.

This is only for small problems, not big ones. I'm aware there are choices in Python, Java, C++, or, oh, perhaps FORTRAN, not to mention R. mmm....FORTRAN......

I'd be happily surprised to get basic vector and matrix operations without having to rebuild the wheel or recode from FORTRAN for a day or two.

Paul
  • 26,170
  • 12
  • 85
  • 119

4 Answers4

5

Maybe also of interest: http://www.numericjs.com/

Simon A. Eugster
  • 4,114
  • 4
  • 36
  • 31
  • Seems not very well maintained any more (last update 2012). The link above doesn’t work. There is a github repository though: https://github.com/sloisel/numeric/ – Yushin Washio Feb 15 '21 at 20:07
4

math.js is a library which comes with matrix support. You can easily manipulate matrices and do matrix calculations.

http://mathjs.org

See the example on using matrices.

Jos de Jong
  • 6,602
  • 3
  • 38
  • 58
  • Project seems to be quite popular, but the range of matrix operations supported is rather basic… It can do multiplication and some other straightforward stuff, but no decomposition into special forms or solving linear equations supported as far as I can see – Yushin Washio Feb 15 '21 at 20:11
3

There is also, the Matlab-like javascript library: https://github.com/Etsitpab/JSM. It makes easy to deal with ND-Arrays and provides many codes for data processing.

  • 2
    The page also contains list of references to alternative libraries: "Other JavaScript libraries for numerical computation": - [mathjs](http://mathjs.org/) - [jStat](https://github.com/jstat/jstat) - [jsmat](https://github.com/ghewgill/jsmat) - [JSNum](https://github.com/kms15/jsnum) - [Numeric JavaScript](http://numericjs.com/numeric/documentation.html) - [Sylvester](http://sylvester.jcoglan.com/) - [jsfeat](http://inspirit.github.io/jsfeat/) – Roland Pihlakas Mar 05 '15 at 04:21
  • @RolandPihlakas Your comment was the best among this whole Q&A so far. My favorites are jStat, jsfeat and maybe Sylvester. jStat seems to be the only one that is actually still quite active, but they all seem to provide some nice linear algebra features. – Yushin Washio Feb 15 '21 at 20:18
3

I know of

http://code.google.com/p/webgl-mjs/

and

http://sylvester.jcoglan.com/

YXD
  • 31,741
  • 15
  • 75
  • 115
  • 1
    of these two, Sylvester has a better documented, more inviting home page. Have you used either of these? – Paul Jun 10 '11 at 12:31
  • 1
    I tested out webgl-mjs, but didn't end up using it for anything. Sylvester is supposedly quite slow, webgl-mjs is [still being maintained](http://code.google.com/p/webgl-mjs/updates/list), so beware appearances... – YXD Jun 10 '11 at 12:38
  • Looking through the source code for Sylvester, it is written in an object/prototype oriented way. There is, as you might know, a huge speed difference between native array for loops and callback oriented methods like each or map in underscore/prototype. Still a nice find though... – Paul Jun 10 '11 at 12:51