1 | var assert = require('assert');
|
2 | var approx = require('../../../../tools/approx');
|
3 | var market = require('../../../../tools/matrixmarket');
|
4 | var math = require('../../../../index');
|
5 | math.import(require('../../../../lib/function/algebra/sparse/cs_amd'));
|
6 |
|
7 | var cs_amd = math.sparse.cs_amd;
|
8 |
|
9 | describe('cs_amd', function () {
|
10 |
|
11 | it('should approximate minimum degree ordering, 48 x 48, natural ordering (order=0), matrix market', function (done) {
|
12 |
|
13 | market.import('tools/matrices/bcsstk01.tar.gz', ['bcsstk01/bcsstk01.mtx'])
|
14 | .then(function (matrices) {
|
15 |
|
16 | var m = matrices[0];
|
17 |
|
18 |
|
19 | var q = cs_amd(0, m);
|
20 |
|
21 |
|
22 | assert(q === null);
|
23 |
|
24 |
|
25 | done();
|
26 | })
|
27 | .fail(function (error) {
|
28 |
|
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 |
|
35 | market.import('tools/matrices/bcsstk01.tar.gz', ['bcsstk01/bcsstk01.mtx'])
|
36 | .then(function (matrices) {
|
37 |
|
38 | var m = matrices[0];
|
39 |
|
40 |
|
41 | var q = cs_amd(1, m);
|
42 |
|
43 |
|
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 |
|
47 | done();
|
48 | })
|
49 | .fail(function (error) {
|
50 |
|
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 |
|
57 | market.import('tools/matrices/bcsstk01.tar.gz', ['bcsstk01/bcsstk01.mtx'])
|
58 | .then(function (matrices) {
|
59 |
|
60 | var m = matrices[0];
|
61 |
|
62 |
|
63 | var q = cs_amd(2, m, false);
|
64 |
|
65 |
|
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 |
|
69 | done();
|
70 | })
|
71 | .fail(function (error) {
|
72 |
|
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 |
|
79 | market.import('tools/matrices/bcsstk01.tar.gz', ['bcsstk01/bcsstk01.mtx'])
|
80 | .then(function (matrices) {
|
81 |
|
82 | var m = matrices[0];
|
83 |
|
84 |
|
85 | var q = cs_amd(3, m, false);
|
86 |
|
87 |
|
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 |
|
91 | done();
|
92 | })
|
93 | .fail(function (error) {
|
94 |
|
95 | done(error);
|
96 | });
|
97 | });
|
98 | }); |
\ | No newline at end of file |