@@ -62,8 +62,49 @@ describe('config', function () {
6262 assert . deepStrictEqual ( math2 . subset ( A , index ( 1 , [ 1 , 2 ] ) ) . toArray ( ) , [ [ 5 , 6 ] ] )
6363 assert . deepStrictEqual ( math2 . subset ( A , index ( [ 0 , 1 ] , 1 ) ) . toArray ( ) , [ [ 2 ] , [ 5 ] ] )
6464
65- // Test without legacy syntax
65+ // test sylvester
66+ assert . ok ( math2 . norm ( math2 . subtract ( math2 . sylvester ( [
67+ [ - 5.3 , - 1.4 , - 0.2 , 0.7 ] ,
68+ [ - 0.4 , - 1.0 , - 0.1 , - 1.2 ] ,
69+ [ 0.3 , 0.7 , - 2.5 , 0.7 ] ,
70+ [ 3.6 , - 0.1 , 1.4 , - 2.4 ]
71+ ] , [
72+ [ 1.1 , - 0.3 , - 0.9 , 0.8 , - 2.5 ] ,
73+ [ - 0.6 , 2.6 , 0.2 , 0.4 , 1.3 ] ,
74+ [ 0.4 , - 0.5 , - 0.2 , 0.2 , - 0.1 ] ,
75+ [ - 0.4 , - 1.9 , - 0.2 , 0.5 , 1.4 ] ,
76+ [ 0.4 , - 1.0 , - 0.1 , - 0.8 , - 1.3 ]
77+ ] , [
78+ [ 1.4 , 1.1 , - 1.9 , 0.1 , 1.2 ] ,
79+ [ - 1.7 , 0.1 , - 0.4 , 2.1 , 0.5 ] ,
80+ [ 1.9 , 2.3 , - 0.8 , - 0.7 , 1.0 ] ,
81+ [ - 1.1 , 2.8 , - 0.8 , - 0.3 , 0.9 ]
82+ ] ) , [
83+ [ - 0.19393862606643053 , - 0.17101629636521865 , 2.709348263225366 , - 0.0963000767188319 , 0.5244718194343121 ] ,
84+ [ 0.38421326955977486 , - 0.21159588555260944 , - 6.544262021555474 , - 0.15113424769761136 , - 2.312533293658291 ] ,
85+ [ - 2.2708235174374747 , 4.498279916441834 , 1.4553799673144823 , - 0.9300926971755248 , 2.5508111398452353 ] ,
86+ [ - 1.0935231387905004 , 4.113817086842746 , 5.747671819196675 , - 0.9408309030864932 , 2.967655969930743 ]
87+ ] ) , 'fro' ) < 1e-3 )
88+
89+ const a = [
90+ [ 0 , 2 , 0 , 0 , 0 ] ,
91+ [ 0 , 1 , 0 , 2 , 4 ] ,
92+ [ 0 , 0 , 0 , 0 , 0 ] ,
93+ [ 8 , 4 , 0 , 3 , 0 ] ,
94+ [ 0 , 0 , 0 , 6 , 0 ]
95+ ]
96+ // test column
97+ assert . deepStrictEqual (
98+ math2 . column ( a , 4 ) . valueOf ( ) , [ [ 0 ] , [ 4 ] , [ 0 ] , [ 0 ] , [ 0 ] ]
99+ )
100+
101+ // test row
102+ assert . deepStrictEqual (
103+ math2 . row ( a , 3 ) . valueOf ( ) , [ [ 8 , 4 , 0 , 3 , 0 ] ]
104+ )
105+
66106 math2 . config ( { legacySubset : false } )
107+ // Test without legacy syntax
67108 assert . deepStrictEqual ( math2 . subset ( A , index ( 1 , 2 ) ) , 6 )
68109 assert . deepStrictEqual ( math2 . subset ( A , index ( [ 1 ] , 2 ) ) . toArray ( ) , [ 6 ] )
69110 assert . deepStrictEqual ( math2 . subset ( A , index ( 1 , [ 2 ] ) ) . toArray ( ) , [ 6 ] )
@@ -73,6 +114,40 @@ describe('config', function () {
73114 assert . deepStrictEqual ( math2 . subset ( A , index ( [ 0 , 1 ] , 1 ) ) . toArray ( ) , [ 2 , 5 ] )
74115 assert . deepStrictEqual ( math2 . subset ( A , index ( [ 0 , 1 ] , [ 1 ] ) ) . toArray ( ) , [ [ 2 ] , [ 5 ] ] )
75116
117+ // test with conifgLegacy removed
118+ assert . ok ( math2 . norm ( math2 . subtract ( math2 . sylvester ( [
119+ [ - 5.3 , - 1.4 , - 0.2 , 0.7 ] ,
120+ [ - 0.4 , - 1.0 , - 0.1 , - 1.2 ] ,
121+ [ 0.3 , 0.7 , - 2.5 , 0.7 ] ,
122+ [ 3.6 , - 0.1 , 1.4 , - 2.4 ]
123+ ] , [
124+ [ 1.1 , - 0.3 , - 0.9 , 0.8 , - 2.5 ] ,
125+ [ - 0.6 , 2.6 , 0.2 , 0.4 , 1.3 ] ,
126+ [ 0.4 , - 0.5 , - 0.2 , 0.2 , - 0.1 ] ,
127+ [ - 0.4 , - 1.9 , - 0.2 , 0.5 , 1.4 ] ,
128+ [ 0.4 , - 1.0 , - 0.1 , - 0.8 , - 1.3 ]
129+ ] , [
130+ [ 1.4 , 1.1 , - 1.9 , 0.1 , 1.2 ] ,
131+ [ - 1.7 , 0.1 , - 0.4 , 2.1 , 0.5 ] ,
132+ [ 1.9 , 2.3 , - 0.8 , - 0.7 , 1.0 ] ,
133+ [ - 1.1 , 2.8 , - 0.8 , - 0.3 , 0.9 ]
134+ ] ) , [
135+ [ - 0.19393862606643053 , - 0.17101629636521865 , 2.709348263225366 , - 0.0963000767188319 , 0.5244718194343121 ] ,
136+ [ 0.38421326955977486 , - 0.21159588555260944 , - 6.544262021555474 , - 0.15113424769761136 , - 2.312533293658291 ] ,
137+ [ - 2.2708235174374747 , 4.498279916441834 , 1.4553799673144823 , - 0.9300926971755248 , 2.5508111398452353 ] ,
138+ [ - 1.0935231387905004 , 4.113817086842746 , 5.747671819196675 , - 0.9408309030864932 , 2.967655969930743 ]
139+ ] ) , 'fro' ) < 1e-3 )
140+
141+ // test column with conifgLegacy removed
142+ assert . deepStrictEqual (
143+ math2 . column ( a , 4 ) . valueOf ( ) , [ [ 0 ] , [ 4 ] , [ 0 ] , [ 0 ] , [ 0 ] ]
144+ )
145+
146+ // test row with conifgLegacy removed
147+ assert . deepStrictEqual (
148+ math2 . row ( a , 3 ) . valueOf ( ) , [ [ 8 , 4 , 0 , 3 , 0 ] ]
149+ )
150+
76151 // Restore console.warn
77152 warnStub . restore ( )
78153 } )
0 commit comments