comparison liboctave/numeric/qr.h @ 21279:eb1524b07fe3

better use of templates for qr classes * liboctave/numeric/qr.h, liboctave/numeric/qr.cc: New files for qr classes generated from CmplxQR.cc, CmplxQR.h, base-qr.cc, base-qr.h, dbleQR.cc, dbleQR.h, fCmplxQR.cc, fCmplxQR.h, floatQR.cc, and floatQR.h with classes converted to templates. * liboctave/numeric/module.mk: Update. * qz.cc, qr.cc, CmplxQRP.cc, CmplxQRP.h, dbleQRP.cc, dbleQRP.h, fCmplxQRP.cc fCmplxQRP.h, floatQRP.cc, floatQRP.h, mx-defs.h, mx-ext.h: Use new classes.
author John W. Eaton <jwe@octave.org>
date Wed, 17 Feb 2016 02:57:21 -0500
parents liboctave/numeric/base-qr.h@1473547f50f5
children 6ca3acf5fad8
comparison
equal deleted inserted replaced
21278:48d82f74243e 21279:eb1524b07fe3
1 /*
2
3 Copyright (C) 1994-2015 John W. Eaton
4 Copyright (C) 2008-2009 Jaroslav Hajek
5 Copyright (C) 2009 VZLU Prague
6
7 This file is part of Octave.
8
9 Octave is free software; you can redistribute it and/or modify it
10 under the terms of the GNU General Public License as published by the
11 Free Software Foundation; either version 3 of the License, or (at your
12 option) any later version.
13
14 Octave is distributed in the hope that it will be useful, but WITHOUT
15 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
16 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
17 for more details.
18
19 You should have received a copy of the GNU General Public License
20 along with Octave; see the file COPYING. If not, see
21 <http://www.gnu.org/licenses/>.
22
23 */
24
25 #if ! defined (octave_qr_h)
26 #define octave_qr_h 1
27
28 #include "octave-config.h"
29
30 #include "Array.h"
31
32 template <typename T>
33 class
34 qr
35 {
36 public:
37
38 typedef typename T::element_type ELT_T;
39 typedef typename T::row_vector_type RV_T;
40 typedef typename T::column_vector_type CV_T;
41
42 enum type
43 {
44 std,
45 raw,
46 economy
47 };
48
49 qr (void) : q (), r () { }
50
51 qr (const T& a, type qr_type = qr::std)
52 : q (), r ()
53 {
54 init (a, qr_type);
55 }
56
57 qr (const T& q, const T& r);
58
59 qr (const qr& a) : q (a.q), r (a.r) { }
60
61 qr& operator = (const qr& a)
62 {
63 if (this != &a)
64 {
65 q = a.q;
66 r = a.r;
67 }
68
69 return *this;
70 }
71
72 virtual ~qr (void) { }
73
74 T Q (void) const { return q; }
75
76 T R (void) const { return r; }
77
78 type get_type (void) const;
79
80 bool regular (void) const;
81
82 void init (const T& a, type qr_type);
83
84 void update (const CV_T& u, const CV_T& v);
85
86 void update (const T& u, const T& v);
87
88 void insert_col (const CV_T& u, octave_idx_type j);
89
90 void insert_col (const T& u, const Array<octave_idx_type>& j);
91
92 void delete_col (octave_idx_type j);
93
94 void delete_col (const Array<octave_idx_type>& j);
95
96 void insert_row (const RV_T& u, octave_idx_type j);
97
98 void delete_row (octave_idx_type j);
99
100 void shift_cols (octave_idx_type i, octave_idx_type j);
101
102 protected:
103
104 T q;
105 T r;
106
107 void form (octave_idx_type n, T& afact, ELT_T *tau, type qr_type);
108 };
109
110 extern void warn_qrupdate_once (void);
111
112 #endif