1 USING: math.matrices math.vectors tools.test math kernel ;
2 IN: math.matrices.tests
23 { 1 2 3 } diagonal-matrix
32 { 1 2 3 5 } 3 vandermonde-matrix
102 } [ 3 4 hilbert-matrix ] unit-test
109 } [ 4 toeplitz-matrix ] unit-test
116 } [ 4 hankel-matrix ] unit-test
181 { { 3 } } { { 2 } } m.
187 { { 1 3 } } { { 5 } { 2 } } m.
202 { { 0 0 1 } } [ { 1 0 0 } { 0 1 0 } cross ] unit-test
203 { { 1 0 0 } } [ { 0 1 0 } { 0 0 1 } cross ] unit-test
204 { { 0 1 0 } } [ { 0 0 1 } { 1 0 0 } cross ] unit-test
205 { { 0.0 -0.707 0.707 } } [ { 1.0 0.0 0.0 } { 0.0 0.707 0.707 } cross ] unit-test
206 { { 0 -2 2 } } [ { -1 -1 -1 } { 1 -1 -1 } cross ] unit-test
207 { { 1 0 0 } } [ { 1 1 0 } { 1 0 0 } proj ] unit-test
209 { { { 4181 6765 } { 6765 10946 } } }
210 [ { { 0 1 } { 1 1 } } 20 m^n ] unit-test
211 [ { { 0 1 } { 1 1 } } -20 m^n ] [ negative-power-matrix? ] must-fail-with
214 { { 0 5 0 10 } { 6 7 12 14 } { 0 15 0 20 } { 18 21 24 28 } }
216 [ { { 1 2 } { 3 4 } } { { 0 5 } { 6 7 } } kron ] unit-test
225 } [ { { 1 1 } { 1 -1 } } dup kron ] unit-test
230 { 1 -1 1 -1 1 -1 1 -1 }
231 { 1 1 -1 -1 1 1 -1 -1 }
232 { 1 -1 -1 1 1 -1 -1 1 }
233 { 1 1 1 1 -1 -1 -1 -1 }
234 { 1 -1 1 -1 -1 1 -1 1 }
235 { 1 1 -1 -1 -1 -1 1 1 }
236 { 1 -1 -1 1 -1 1 1 -1 }
238 } [ { { 1 1 } { 1 -1 } } dup dup kron kron ] unit-test
243 { 1 -1 1 -1 1 -1 1 -1 }
244 { 1 1 -1 -1 1 1 -1 -1 }
245 { 1 -1 -1 1 1 -1 -1 1 }
246 { 1 1 1 1 -1 -1 -1 -1 }
247 { 1 -1 1 -1 -1 1 -1 1 }
248 { 1 1 -1 -1 -1 -1 1 1 }
249 { 1 -1 -1 1 -1 1 1 -1 }
251 } [ { { 1 1 } { 1 -1 } } dup dup kron swap kron ] unit-test
254 ! kron is not generally commutative, make sure we have the right order
257 { 1 2 3 4 5 1 2 3 4 5 }
258 { 6 7 8 9 10 6 7 8 9 10 }
259 { 1 2 3 4 5 -1 -2 -3 -4 -5 }
260 { 6 7 8 9 10 -6 -7 -8 -9 -10 }
265 { { 1 2 3 4 5 } { 6 7 8 9 10 } } kron
270 { 1 1 2 2 3 3 4 4 5 5 }
271 { 1 -1 2 -2 3 -3 4 -4 5 -5 }
272 { 6 6 7 7 8 8 9 9 10 10 }
273 { 6 -6 7 -7 8 -8 9 -9 10 -10 }
278 { { 1 2 3 4 5 } { 6 7 8 9 10 } } swap kron
285 } [ { 5 6 7 } { 1 2 3 } outer ] unit-test
288 CONSTANT: test-points {
289 { 80 27 89 } { 80 27 88 } { 75 25 90 }
290 { 62 24 87 } { 62 22 87 } { 62 23 87 }
291 { 62 24 93 } { 62 24 93 } { 58 23 87 }
292 { 58 18 80 } { 58 18 89 } { 58 17 88 }
293 { 58 18 82 } { 58 19 93 } { 50 18 89 }
294 { 50 18 86 } { 50 19 72 } { 50 19 79 }
295 { 50 20 80 } { 56 20 82 } { 70 20 91 }
300 { 84+2/35 22+23/35 24+4/7 }
301 { 22+23/35 9+104/105 6+87/140 }
302 { 24+4/7 6+87/140 28+5/7 }
305 test-points sample-cov-matrix
310 { 80+8/147 21+85/147 23+59/147 }
311 { 21+85/147 9+227/441 6+15/49 }
312 { 23+59/147 6+15/49 27+17/49 }
315 test-points population-cov-matrix
333 2 2 [ 5 ] make-matrix
342 2 3 [ + ] make-matrix-with-indices
381 { t } [ { } square-matrix? ] unit-test
382 { t } [ { { 1 } } square-matrix? ] unit-test
383 { t } [ { { 1 2 } { 3 4 } } square-matrix? ] unit-test
384 { f } [ { { 1 } { 2 3 } } square-matrix? ] unit-test
385 { f } [ { { 1 2 } } square-matrix? ] unit-test
388 [ { { 2 -2 1 } { 1 3 -1 } { 2 -4 2 } } m-1norm ] unit-test
391 [ { { 2 -2 1 } { 1 3 -1 } { 2 -4 2 } } m-infinity-norm ] unit-test
394 [ { { 1 1 } { 1 1 } } frobenius-norm ] unit-test