diff liboctave/fMatrix.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/fMatrix.cc	Wed Dec 03 13:32:57 2008 +0100
+++ b/liboctave/fMatrix.cc	Thu Dec 04 08:31:56 2008 +0100
@@ -247,6 +247,19 @@
     elem (i, i) = a.elem (i, i);
 }
 
+FloatMatrix::FloatMatrix (const PermMatrix& a)
+  : MArray2<float> (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?