Mercurial > hg > octave-lyh
diff liboctave/fCmplxQRP.cc @ 8367:445d27d79f4e
support permutation matrix objects
author | Jaroslav Hajek <highegg@gmail.com> |
---|---|
date | Thu, 04 Dec 2008 08:31:56 +0100 |
parents | 39c1026191e9 |
children | c72c1c9bccdc |
line wrap: on
line diff
--- a/liboctave/fCmplxQRP.cc +++ b/liboctave/fCmplxQRP.cc @@ -86,7 +86,7 @@ Array<float> rwork (2*n); float *prwork = rwork.fortran_vec (); - Array<octave_idx_type> jpvt (n, 0); + MArray<octave_idx_type> jpvt (n, 0); octave_idx_type *pjpvt = jpvt.fortran_vec (); // Code to enforce a certain permutation could go here... @@ -97,18 +97,8 @@ // Form Permutation matrix (if economy is requested, return the // indices only!) - if (qr_type == QR::economy) - { - p.resize (1, n, 0.0); - for (octave_idx_type j = 0; j < n; j++) - p.elem (0, j) = jpvt.elem (j); - } - else - { - p.resize (n, n, 0.0); - for (octave_idx_type j = 0; j < n; j++) - p.elem (jpvt.elem (j) - 1, j) = 1.0; - } + jpvt -= 1; + p = PermMatrix (jpvt, true); octave_idx_type n2 = (qr_type == QR::economy) ? min_mn : m; @@ -131,6 +121,14 @@ q.resize (m, n2); } +FloatColumnVector +FloatComplexQRP::Pvec (void) const +{ + Array<float> pa (p); + FloatColumnVector pv (MArray<float> (pa) + 1.0f); + return pv; +} + /* ;;; Local Variables: *** ;;; mode: C++ ***