1 | // load math.js (using node.js)
|
2 | var math = require('../index');
|
3 |
|
4 | // create a sparse matrix
|
5 | console.log('creating a 1000x1000 sparse matrix...');
|
6 | var a = math.eye(1000, 1000, 'sparse');
|
7 |
|
8 | // do operations with a sparse matrix
|
9 | console.log('doing some operations on the sparse matrix...');
|
10 | var b = math.multiply(a, a);
|
11 | var c = math.multiply(b, math.complex(2, 2));
|
12 | var d = math.transpose(c);
|
13 | var e = math.multiply(d, a);
|
14 |
|
15 | // we will not print the output, but doing the same operations
|
16 | // with a dense matrix are very slow, try it for yourself.
|
17 | console.log('already done');
|
18 | console.log('now try this with a dense matrix :)');
|