Mercurial > hg > octave-nkf
annotate liboctave/SparseCmplxQR.h @ 10396:a0b51ac0f88a
optimize accumdim with summation
author | Jaroslav Hajek <highegg@gmail.com> |
---|---|
date | Fri, 05 Mar 2010 12:31:30 +0100 |
parents | 12884915a8e4 |
children | fd0a3ac60b0e |
rev | line source |
---|---|
5610 | 1 /* |
2 | |
8920 | 3 Copyright (C) 2005, 2006, 2007, 2008 David Bateman |
5610 | 4 |
7016 | 5 This file is part of Octave. |
6 | |
5610 | 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 | |
7016 | 9 Free Software Foundation; either version 3 of the License, or (at your |
10 option) any later version. | |
5610 | 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 | |
7016 | 18 along with Octave; see the file COPYING. If not, see |
19 <http://www.gnu.org/licenses/>. | |
5610 | 20 |
21 */ | |
22 | |
23 #if !defined (sparse_cmplx_QR_h) | |
24 #define sparse_cmplx_QR_h 1 | |
25 | |
8950
d865363208d6
include <iosfwd> instead of <iostream> in header files
John W. Eaton <jwe@octave.org>
parents:
8920
diff
changeset
|
26 #include <iosfwd> |
5610 | 27 |
28 #include "dMatrix.h" | |
29 #include "CMatrix.h" | |
30 #include "dSparse.h" | |
31 #include "CSparse.h" | |
32 #include "oct-sparse.h" | |
33 | |
34 #ifdef IDX_TYPE_LONG | |
5648 | 35 #define CXSPARSE_ZNAME(name) cs_cl ## name |
5610 | 36 #else |
5648 | 37 #define CXSPARSE_ZNAME(name) cs_ci ## name |
5610 | 38 #endif |
39 | |
40 class | |
6108 | 41 OCTAVE_API |
5610 | 42 SparseComplexQR |
43 { | |
44 protected: | |
45 class SparseComplexQR_rep | |
46 { | |
47 public: | |
48 SparseComplexQR_rep (const SparseComplexMatrix& a, int order); | |
49 | |
50 ~SparseComplexQR_rep (void); | |
51 #ifdef HAVE_CXSPARSE | |
52 bool ok (void) const { return (N && S); } | |
53 #else | |
54 bool ok (void) const { return false; } | |
55 #endif | |
56 SparseComplexMatrix V (void) const; | |
57 | |
58 ColumnVector Pinv (void) const; | |
59 | |
60 ColumnVector P (void) const; | |
61 | |
62 SparseComplexMatrix R (const bool econ) const; | |
63 | |
64 ComplexMatrix C (const ComplexMatrix &b) const; | |
65 | |
7505
f5005d9510f4
Remove dispatched sparse functions and treat in the generic versions of the functions
David Bateman <dbateman@free.fr>
parents:
7017
diff
changeset
|
66 ComplexMatrix Q (void) const; |
f5005d9510f4
Remove dispatched sparse functions and treat in the generic versions of the functions
David Bateman <dbateman@free.fr>
parents:
7017
diff
changeset
|
67 |
5610 | 68 int count; |
69 | |
70 octave_idx_type nrows; | |
71 #ifdef HAVE_CXSPARSE | |
5648 | 72 CXSPARSE_ZNAME (s) *S; |
5610 | 73 |
5648 | 74 CXSPARSE_ZNAME (n) *N; |
5610 | 75 #endif |
76 }; | |
77 private: | |
78 SparseComplexQR_rep *rep; | |
79 | |
80 public: | |
81 SparseComplexQR (void) : | |
5792 | 82 rep (new SparseComplexQR_rep (SparseComplexMatrix(), 0)) { } |
5610 | 83 |
5792 | 84 SparseComplexQR (const SparseComplexMatrix& a, int order = 0) : |
5610 | 85 rep (new SparseComplexQR_rep (a, order)) { } |
86 | |
87 SparseComplexQR (const SparseComplexQR& a) : rep (a.rep) { rep->count++; } | |
88 | |
89 ~SparseComplexQR (void) | |
90 { | |
91 if (--rep->count <= 0) | |
10312
cbc402e64d83
untabify liboctave header files
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
92 delete rep; |
5610 | 93 } |
94 | |
95 SparseComplexQR& operator = (const SparseComplexQR& a) | |
96 { | |
97 if (this != &a) | |
10312
cbc402e64d83
untabify liboctave header files
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
98 { |
cbc402e64d83
untabify liboctave header files
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
99 if (--rep->count <= 0) |
cbc402e64d83
untabify liboctave header files
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
100 delete rep; |
5610 | 101 |
10312
cbc402e64d83
untabify liboctave header files
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
102 rep = a.rep; |
cbc402e64d83
untabify liboctave header files
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
103 rep->count++; |
cbc402e64d83
untabify liboctave header files
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
104 } |
5610 | 105 return *this; |
106 } | |
107 | |
108 bool ok (void) const { return rep->ok(); } | |
109 | |
110 SparseComplexMatrix V (void) const { return rep->V(); } | |
111 | |
112 ColumnVector Pinv (void) const { return rep->P(); } | |
113 | |
114 ColumnVector P (void) const { return rep->P(); } | |
115 | |
116 SparseComplexMatrix R (const bool econ = false) const | |
117 { return rep->R(econ); } | |
118 | |
119 ComplexMatrix C (const ComplexMatrix &b) const { return rep->C(b); } | |
120 | |
7505
f5005d9510f4
Remove dispatched sparse functions and treat in the generic versions of the functions
David Bateman <dbateman@free.fr>
parents:
7017
diff
changeset
|
121 ComplexMatrix Q (void) const { return rep->Q(); } |
f5005d9510f4
Remove dispatched sparse functions and treat in the generic versions of the functions
David Bateman <dbateman@free.fr>
parents:
7017
diff
changeset
|
122 |
5610 | 123 friend ComplexMatrix qrsolve (const SparseComplexMatrix &a, const Matrix &b, |
10312
cbc402e64d83
untabify liboctave header files
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
124 octave_idx_type &info); |
5610 | 125 |
126 friend SparseComplexMatrix qrsolve (const SparseComplexMatrix &a, | |
10312
cbc402e64d83
untabify liboctave header files
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
127 const SparseMatrix &b, |
cbc402e64d83
untabify liboctave header files
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
128 octave_idx_type &info); |
5610 | 129 |
130 friend ComplexMatrix qrsolve (const SparseComplexMatrix &a, | |
10312
cbc402e64d83
untabify liboctave header files
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
131 const ComplexMatrix &b, |
cbc402e64d83
untabify liboctave header files
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
132 octave_idx_type &info); |
5610 | 133 |
134 friend SparseComplexMatrix qrsolve (const SparseComplexMatrix &a, | |
10312
cbc402e64d83
untabify liboctave header files
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
135 const SparseComplexMatrix &b, |
cbc402e64d83
untabify liboctave header files
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
136 octave_idx_type &info); |
5610 | 137 |
138 protected: | |
139 #ifdef HAVE_CXSPARSE | |
5648 | 140 CXSPARSE_ZNAME (s) * S (void) { return rep->S; } |
5610 | 141 |
5648 | 142 CXSPARSE_ZNAME (n) * N (void) { return rep->N; } |
5610 | 143 #endif |
144 }; | |
145 | |
5713 | 146 |
147 // Publish externally used friend functions. | |
148 | |
149 extern ComplexMatrix qrsolve (const SparseComplexMatrix &a, const Matrix &b, | |
10312
cbc402e64d83
untabify liboctave header files
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
150 octave_idx_type &info); |
5713 | 151 |
7789
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7505
diff
changeset
|
152 extern ComplexMatrix qrsolve (const SparseComplexMatrix &a, |
10350
12884915a8e4
merge MArray classes & improve Array interface
Jaroslav Hajek <highegg@gmail.com>
parents:
10312
diff
changeset
|
153 const MArray<double> &b, |
10312
cbc402e64d83
untabify liboctave header files
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
154 octave_idx_type &info); |
7789
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7505
diff
changeset
|
155 |
5713 | 156 extern SparseComplexMatrix qrsolve (const SparseComplexMatrix &a, |
10312
cbc402e64d83
untabify liboctave header files
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
157 const SparseMatrix &b, |
cbc402e64d83
untabify liboctave header files
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
158 octave_idx_type &info); |
5713 | 159 |
160 extern ComplexMatrix qrsolve (const SparseComplexMatrix &a, | |
10312
cbc402e64d83
untabify liboctave header files
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
161 const ComplexMatrix &b, |
cbc402e64d83
untabify liboctave header files
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
162 octave_idx_type &info); |
5713 | 163 |
7789
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7505
diff
changeset
|
164 extern ComplexMatrix qrsolve (const SparseComplexMatrix &a, |
10350
12884915a8e4
merge MArray classes & improve Array interface
Jaroslav Hajek <highegg@gmail.com>
parents:
10312
diff
changeset
|
165 const MArray<Complex> &b, |
10312
cbc402e64d83
untabify liboctave header files
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
166 octave_idx_type &info); |
7789
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7505
diff
changeset
|
167 |
5713 | 168 extern SparseComplexMatrix qrsolve (const SparseComplexMatrix &a, |
10312
cbc402e64d83
untabify liboctave header files
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
169 const SparseComplexMatrix &b, |
cbc402e64d83
untabify liboctave header files
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
170 octave_idx_type &info); |
5610 | 171 #endif |