Mercurial > hg > octave-nkf
diff liboctave/dMatrix.cc @ 8367:445d27d79f4e
support permutation matrix objects
author | Jaroslav Hajek <highegg@gmail.com> |
---|---|
date | Thu, 04 Dec 2008 08:31:56 +0100 |
parents | e02242c54c49 |
children | e3c9102431a9 |
line wrap: on
line diff
--- a/liboctave/dMatrix.cc +++ b/liboctave/dMatrix.cc @@ -248,6 +248,19 @@ elem (i, i) = a.elem (i, i); } +Matrix::Matrix (const PermMatrix& a) + : MArray2<double> (a.rows (), a.cols (), 0.0) +{ + const Array<octave_idx_type> ia (a); + octave_idx_type len = a.rows (); + if (a.is_col_perm ()) + for (octave_idx_type i = 0; i < len; i++) + elem (ia(i), i) = 1.0; + else + for (octave_idx_type i = 0; i < len; i++) + elem (i, ia(i)) = 1.0; +} + // FIXME -- could we use a templated mixed-type copy function // here?