UNPKG

3.3 kBJavaScriptView Raw
1var assert = require('assert');
2var approx = require('../../../../tools/approx');
3var market = require('../../../../tools/matrixmarket');
4var math = require('../../../../index');
5math.import(require('../../../../lib/function/algebra/sparse/cs_amd'));
6
7var cs_amd = math.sparse.cs_amd;
8
9describe('cs_amd', function () {
10
11 it('should approximate minimum degree ordering, 48 x 48, natural ordering (order=0), matrix market', function (done) {
12 // import matrix
13 market.import('tools/matrices/bcsstk01.tar.gz', ['bcsstk01/bcsstk01.mtx'])
14 .then(function (matrices) {
15 // matrix
16 var m = matrices[0];
17
18 // symbolic ordering and analysis, order = 0
19 var q = cs_amd(0, m);
20
21 // verify
22 assert(q === null);
23
24 // indicate test has completed
25 done();
26 })
27 .fail(function (error) {
28 // indicate test has completed
29 done(error);
30 });
31 });
32
33 it('should approximate minimum degree ordering, 48 x 48, amd(A+A\') (order=1), matrix market', function (done) {
34 // import matrix
35 market.import('tools/matrices/bcsstk01.tar.gz', ['bcsstk01/bcsstk01.mtx'])
36 .then(function (matrices) {
37 // matrix
38 var m = matrices[0];
39
40 // symbolic ordering and analysis, order = 1
41 var q = cs_amd(1, m);
42
43 // verify
44 approx.deepEqual(q, [10, 28, 29, 24, 0, 11, 30, 6, 23, 22, 40, 46, 42, 18, 4, 16, 34, 5, 9, 39, 21, 44, 45, 43, 15, 25, 26, 27, 3, 33, 41, 19, 20, 2, 38, 32, 1, 14, 8, 13, 37, 31, 12, 36, 17, 47, 35, 7]);
45
46 // indicate test has completed
47 done();
48 })
49 .fail(function (error) {
50 // indicate test has completed
51 done(error);
52 });
53 });
54
55 it('should approximate minimum degree ordering, 48 x 48, amd(A\'*A) (order=2), matrix market', function (done) {
56 // import matrix
57 market.import('tools/matrices/bcsstk01.tar.gz', ['bcsstk01/bcsstk01.mtx'])
58 .then(function (matrices) {
59 // matrix
60 var m = matrices[0];
61
62 // symbolic ordering and analysis, order = 2
63 var q = cs_amd(2, m, false);
64
65 // verify
66 approx.deepEqual(q, [26, 27, 25, 44, 9, 15, 21, 33, 39, 43, 45, 3, 29, 24, 28, 47, 6, 18, 36, 0, 1, 4, 20, 2, 10, 11, 12, 8, 14, 16, 7, 13, 17, 23, 30, 34, 38, 32, 31, 41, 35, 22, 19, 37, 40, 42, 46, 5]);
67
68 // indicate test has completed
69 done();
70 })
71 .fail(function (error) {
72 // indicate test has completed
73 done(error);
74 });
75 });
76
77 it('should approximate minimum degree ordering, 48 x 48, amd(A\'*A) (order=3), matrix market', function (done) {
78 // import matrix
79 market.import('tools/matrices/bcsstk01.tar.gz', ['bcsstk01/bcsstk01.mtx'])
80 .then(function (matrices) {
81 // matrix
82 var m = matrices[0];
83
84 // symbolic ordering and analysis, order = 3
85 var q = cs_amd(3, m, false);
86
87 // verify
88 approx.deepEqual(q, [26, 27, 25, 44, 9, 15, 21, 33, 39, 43, 45, 3, 29, 24, 28, 47, 6, 18, 36, 0, 1, 4, 20, 2, 10, 11, 12, 8, 14, 16, 7, 13, 17, 23, 30, 34, 38, 32, 31, 41, 35, 22, 19, 37, 40, 42, 46, 5]);
89
90 // indicate test has completed
91 done();
92 })
93 .fail(function (error) {
94 // indicate test has completed
95 done(error);
96 });
97 });
98});
\No newline at end of file