Mercurial > hg > octave-nkf
diff liboctave/fCmplxQR.cc @ 9713:7918eb15040c
refactor the QR classes onto a templated base
author | Jaroslav Hajek <highegg@gmail.com> |
---|---|
date | Mon, 12 Oct 2009 10:42:49 +0200 |
parents | b03953732530 |
children | 4c0cdbe0acca |
line wrap: on
line diff
--- a/liboctave/fCmplxQR.cc +++ b/liboctave/fCmplxQR.cc @@ -34,6 +34,10 @@ #include "idx-vector.h" #include "oct-locbuf.h" +#include "base-qr.cc" + +template class base_qr<FloatComplexMatrix>; + extern "C" { F77_RET_T @@ -82,14 +86,13 @@ #endif } -FloatComplexQR::FloatComplexQR (const FloatComplexMatrix& a, QR::type qr_type) - : q (), r () +FloatComplexQR::FloatComplexQR (const FloatComplexMatrix& a, qr_type_t qr_type) { init (a, qr_type); } void -FloatComplexQR::init (const FloatComplexMatrix& a, QR::type qr_type) +FloatComplexQR::init (const FloatComplexMatrix& a, qr_type_t qr_type) { octave_idx_type m = a.rows (); octave_idx_type n = a.cols (); @@ -100,7 +103,7 @@ octave_idx_type info = 0; FloatComplexMatrix afact = a; - if (m > n && qr_type == QR::std) + if (m > n && qr_type == qr_type_std) afact.resize (m, m); if (m > 0) @@ -120,12 +123,12 @@ } void FloatComplexQR::form (octave_idx_type n, FloatComplexMatrix& afact, - FloatComplex *tau, QR::type qr_type) + FloatComplex *tau, qr_type_t qr_type) { octave_idx_type m = afact.rows (), min_mn = std::min (m, n); octave_idx_type info; - if (qr_type == QR::raw) + if (qr_type == qr_type_raw) { for (octave_idx_type j = 0; j < min_mn; j++) { @@ -143,7 +146,7 @@ { // afact will become q. q = afact; - octave_idx_type k = qr_type == QR::economy ? n : m; + octave_idx_type k = qr_type == qr_type_economy ? n : m; r = FloatComplexMatrix (k, n); for (octave_idx_type j = 0; j < n; j++) { @@ -187,32 +190,6 @@ } } -FloatComplexQR::FloatComplexQR (const FloatComplexMatrix& q_arg, const FloatComplexMatrix& r_arg) -{ - octave_idx_type qr = q_arg.rows (), qc = q_arg.columns (); - octave_idx_type rr = r_arg.rows (), rc = r_arg.columns (); - if (qc == rr && (qr == qc || (qr > qc && rr == rc))) - { - q = q_arg; - r = r_arg; - } - else - (*current_liboctave_error_handler) ("QR dimensions mismatch"); -} - -QR::type -FloatComplexQR::get_type (void) const -{ - QR::type retval; - if (!q.is_empty () && q.is_square ()) - retval = QR::std; - else if (q.rows () > q.columns () && r.is_square ()) - retval = QR::economy; - else - retval = QR::raw; - return retval; -} - #ifdef HAVE_QRUPDATE void