Mercurial > hg > octave-nkf
diff liboctave/CSparse.cc @ 8366:8b1a2555c4e2
implement diagonal matrix objects
* * *
author | Jaroslav Hajek <highegg@gmail.com> |
---|---|
date | Wed, 03 Dec 2008 13:32:57 +0100 |
parents | 64cf956a109c |
children | 25bc2d31e1bf |
line wrap: on
line diff
--- a/liboctave/CSparse.cc +++ b/liboctave/CSparse.cc @@ -144,6 +144,22 @@ } } +SparseComplexMatrix::SparseComplexMatrix (const ComplexDiagMatrix& a) + : MSparse<Complex> (a.rows (), a.cols (), a.nnz ()) +{ + octave_idx_type nz = a.nnz (), l = a.length (); + for (octave_idx_type i = 0, j = 0; i < l; i++) + { + if (a(i, i) != Complex (0.0, 0.0)) + { + data (j) = a(i, i); + ridx (j) = i; + cidx (j) = j; + j++; + } + } + cidx (nz) = nz; +} bool SparseComplexMatrix::operator == (const SparseComplexMatrix& a) const {