comparison liboctave/numeric/schur.h @ 21266:e69eaee28737

make better use of templates for Schur decomposition * liboctave/numeric/schur.h, liboctave/numeric/schur.cc: New files generated from SCHUR.h, SCHUR.cc, CmplxSCHUR.h, CmplxSCHUR.cc, dbleSCHUR.h, dbleSCHUR.cc, fCmplxSCHUR.h, fCmplxSCHUR.cc, floatSCHUR.h, and floatSCHUR.cc and making them templates. * liboctave/numeric/module.mk: Update. * libinterp/corefcn/schur.cc, sqrtm.cc, CMatrix.cc, dMatrix.cc, fCMatrix.cc, fMatrix.cc, mx-defs.h, mx-ext.h: Use new template classes and header file.
author John W. Eaton <jwe@octave.org>
date Mon, 15 Feb 2016 20:06:12 -0500
parents liboctave/numeric/dbleSCHUR.h@1473547f50f5
children bc536eff5eab
comparison
equal deleted inserted replaced
21265:f780d057a3ec 21266:e69eaee28737
1 /*
2
3 Copyright (C) 1994-2015 John W. Eaton
4
5 This file is part of Octave.
6
7 Octave is free software; you can redistribute it and/or modify it
8 under the terms of the GNU General Public License as published by the
9 Free Software Foundation; either version 3 of the License, or (at your
10 option) any later version.
11
12 Octave is distributed in the hope that it will be useful, but WITHOUT
13 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
14 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
15 for more details.
16
17 You should have received a copy of the GNU General Public License
18 along with Octave; see the file COPYING. If not, see
19 <http://www.gnu.org/licenses/>.
20
21 */
22
23 #if ! defined (octave_schur_h)
24 #define octave_schur_h 1
25
26 #include "octave-config.h"
27
28 #include <iosfwd>
29 #include <string>
30
31 #include "dMatrix.h"
32 #include "CMatrix.h"
33 #include "fMatrix.h"
34 #include "fCMatrix.h"
35
36 template <typename T> class schur;
37
38 template <typename T>
39 class
40 schur
41 {
42 public:
43
44 schur (void) : schur_mat (), unitary_mat () { }
45
46 schur (const T& a, const std::string& ord, bool calc_unitary = true)
47 : schur_mat (), unitary_mat ()
48 {
49 init (a, ord, calc_unitary);
50 }
51
52 schur (const T& a, const std::string& ord, octave_idx_type& info,
53 bool calc_unitary = true)
54 : schur_mat (), unitary_mat ()
55 {
56 info = init (a, ord, calc_unitary);
57 }
58
59 // This one should really be protected or private but we need it in
60 // rsf2csf and I don't see how to make that function a friend of
61 // this class.
62 schur (const T& s, const T& u) : schur_mat (s), unitary_mat (u) { }
63
64 schur (const schur& a)
65
66 : schur_mat (a.schur_mat), unitary_mat (a.unitary_mat)
67 { }
68
69 schur& operator = (const schur& a)
70 {
71 if (this != &a)
72 {
73 schur_mat = a.schur_mat;
74 unitary_mat = a.unitary_mat;
75 }
76
77 return *this;
78 }
79
80 ~schur (void) { }
81
82 T schur_matrix (void) const { return schur_mat; }
83
84 T unitary_matrix (void) const { return unitary_mat; }
85
86 protected:
87
88 private:
89
90 T schur_mat;
91 T unitary_mat;
92
93 octave_idx_type
94 init (const T& a, const std::string& ord, bool calc_unitary);
95 };
96
97 template <typename RT, typename AT>
98 extern schur<RT>
99 rsf2csf (const AT& s, const AT& u);
100
101 template <typename T>
102 extern std::ostream&
103 operator << (std::ostream& os, const schur<T>& a);
104
105 #endif