comparison yetilab/matrix/test/test_matrix.yeti @ 259:fae62dca8048

Make concat also return sparse when all its inputs are sparse
author Chris Cannam
date Wed, 22 May 2013 09:22:10 +0100
parents f3b7b5d20f88
children de770971a628
comparison
equal deleted inserted replaced
258:f3b7b5d20f88 259:fae62dca8048
380 [(newMatrix (ColumnMajor ()) [[1,4],[0,5]]), 380 [(newMatrix (ColumnMajor ()) [[1,4],[0,5]]),
381 (newMatrix (RowMajor ()) [[3],[6]])]) 381 (newMatrix (RowMajor ()) [[3],[6]])])
382 (newMatrix (ColumnMajor ()) [[1,4],[0,5],[3,6]]) 382 (newMatrix (ColumnMajor ()) [[1,4],[0,5],[3,6]])
383 ), 383 ),
384 384
385 "sparseConcat-horiz-\(name)": \(
386 s = mat.concat (Horizontal ())
387 [mat.toSparse (newMatrix (ColumnMajor ()) [[1,4],[0,5]]),
388 mat.toSparse (newMatrix (RowMajor ()) [[3],[6]])];
389 compareMatrices s (newMatrix (ColumnMajor ()) [[1,4],[0,5],[3,6]]) and
390 compare (mat.isSparse? s) true and
391 compare (mat.density s) (5/6)
392 ),
393
385 "concatFail-horiz-\(name)": \( 394 "concatFail-horiz-\(name)": \(
386 try 395 try
387 \() (mat.concat (Horizontal ()) 396 \() (mat.concat (Horizontal ())
388 [(newMatrix (ColumnMajor ()) [[1,4],[0,5]]), 397 [(newMatrix (ColumnMajor ()) [[1,4],[0,5]]),
389 (newMatrix (ColumnMajor ()) [[3],[6]])]); 398 (newMatrix (ColumnMajor ()) [[3],[6]])]);
397 compareMatrices 406 compareMatrices
398 (mat.concat (Vertical ()) 407 (mat.concat (Vertical ())
399 [(newMatrix (ColumnMajor ()) [[1,4],[0,5]]), 408 [(newMatrix (ColumnMajor ()) [[1,4],[0,5]]),
400 (newMatrix (RowMajor ()) [[3,6]])]) 409 (newMatrix (RowMajor ()) [[3,6]])])
401 (newMatrix (ColumnMajor ()) [[1,4,3],[0,5,6]]) 410 (newMatrix (ColumnMajor ()) [[1,4,3],[0,5,6]])
411 ),
412
413 "sparseConcat-vert-\(name)": \(
414 s = mat.concat (Vertical ())
415 [mat.toSparse (newMatrix (ColumnMajor ()) [[1,4],[0,5]]),
416 mat.toSparse (newMatrix (RowMajor ()) [[3,6]])];
417 compareMatrices s (newMatrix (ColumnMajor ()) [[1,4,3],[0,5,6]]) and
418 compare (mat.isSparse? s) true and
419 compare (mat.density s) (5/6)
402 ), 420 ),
403 421
404 "concatFail-vert-\(name)": \( 422 "concatFail-vert-\(name)": \(
405 try 423 try
406 \() (mat.concat (Vertical ()) 424 \() (mat.concat (Vertical ())