Mercurial > hg > octave-nkf
diff liboctave/floatQR.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/floatQR.cc +++ b/liboctave/floatQR.cc @@ -34,6 +34,10 @@ #include "idx-vector.h" #include "oct-locbuf.h" +#include "base-qr.cc" + +template class base_qr<FloatMatrix>; + extern "C" { F77_RET_T @@ -80,14 +84,13 @@ #endif } -FloatQR::FloatQR (const FloatMatrix& a, QR::type qr_type) - : q (), r () +FloatQR::FloatQR (const FloatMatrix& a, qr_type_t qr_type) { init (a, qr_type); } void -FloatQR::init (const FloatMatrix& a, QR::type qr_type) +FloatQR::init (const FloatMatrix& a, qr_type_t qr_type) { octave_idx_type m = a.rows (); octave_idx_type n = a.cols (); @@ -98,7 +101,7 @@ octave_idx_type info = 0; FloatMatrix afact = a; - if (m > n && qr_type == QR::std) + if (m > n && qr_type == qr_type_std) afact.resize (m, m); if (m > 0) @@ -118,12 +121,12 @@ } void FloatQR::form (octave_idx_type n, FloatMatrix& afact, - float *tau, QR::type qr_type) + float *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++) { @@ -141,7 +144,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 = FloatMatrix (k, n); for (octave_idx_type j = 0; j < n; j++) { @@ -185,32 +188,6 @@ } } -FloatQR::FloatQR (const FloatMatrix& q_arg, const FloatMatrix& 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 -FloatQR::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