scalanlp/breeze — pull request #272 by gabeos (2014-07-03 21:36:59+00:00)
Title: Added missing CSCMatrix functionality towards parity with DenseMatrix

Added some functionality to CSCMatrix that seemed like it was missing based on DenseMatrix operations --
** Note: Comments on style integration with breeze codebase would be great. I've gotten in the habit of doing things in a scala-esque way, foldLefts, etc. but I'm not entirely confident that these are the best way to implement some of the native functionality in CSCMatrix, and think it could likely be done better with operations on inner data structures.

Main Additions:

* CSCMatrix[V].flatten(): SparseVector[V]
Flattens CSCMatrix into SparseVector of size = rows * cols

* diag(CSCMatrix[V]): SparseVector[V]
Produces SparseVector[V] of size = rows, values = diagonal of matrix

* diag(SparseVector[V]): CSCMatrix[V]
Produces CSCMatrix[V] of size = length x length, with diagonal as expected

* [CSCMatrix[V],CSCMatrix[V]] InPlaceImpl2 UpdateOps
Adds functionality for standard set of UpdateOps on CSCMatrix with CSCMatrix using expand macro.

Test Additions:
* diag Test: Tests that diag(Matrix) === SV and diag(SV) === Matrix for Sparse and Dense cases.
* CSCMatrix InPlaceOps Test: Limited, tests only in-place multiplication and division.

I'm planning to add the rest of the implicits for CSCMatrix X Scalar, CSCMatrix X SparseVector, etc. but wanted to get some reviews on this implementation before continuing, so this is basically a partial, but (I believe) fully functional PR.