UNPKG

1.51 kBMarkdownView Raw
1# algebra
2
3> Vectors, Matrices, Tensors for Node.js
4
5[![NPM version](https://badge.fury.io/js/algebra.png)](http://badge.fury.io/js/algebra) [![Build Status](https://travis-ci.org/fibo/algebra.png?branch=master)](https://travis-ci.org/fibo/algebra?branch=master) [![Dependency Status](https://gemnasium.com/fibo/algebra.png)](https://gemnasium.com/fibo/algebra)
6
7For more information point your browser to [algebra Homepage](//g14n.info/algebra).
8
9## Status
10
11*algebra* is under development. Api can change until version **1.0** but not without a good reason.
12
13## Synopsis
14
15```
16var algebra = require('algebra');
17
18var R = algebra.Real;
19
20// Static addition operator
21console.log(R.add(1, 2, 3)); // 1 + 2 + 3 = 6
22
23// Create two real numbers: x = 2, y = -1
24var x = new R(2),
25 y = new R(-1);
26
27// Operators on objects are mutators. Here x value is modified, multipling it by y value.
28x.mul(y);
29console.log(x.data); // 2 * (-1) = -2
30
31// Number coercion and chained operators.
32// Resulting x value will be 0.25: x -> x + 5 -> x * 2 -> x ^-1
33x.add(5).mul(2).inv();
34console.log(x.data); // ((-3 + 5) * 2)^(-1) = 0.25
35
36// Vectors, Matrices, Tensors
37var R2 = algebra.VectorSpace(R)(2);
38
39var v1 = new R2([0, 1]);
40var v2 = new R2([1, -4]);
41```
42
43##See also
44
45* [algebra quick start](//g14n.info/algebra/examples/quick-start)
46: A 60 seconds tutorial to get your hands dirty with algebra.
47
48## Installation
49
50With [npm](https://npmjs.org/) do
51
52```bash
53$ npm install algebra
54```
55
56## License
57
58[MIT](//g14n.info/mit-licence)
59