Mercurial > octave-nkf
annotate liboctave/SparseQR.h @ 12409:2848dd7c4dd7 release-3-4-x release-3-4-0
version 3.4.0 released
author | John W. Eaton <jwe@octave.org> |
---|---|
date | Tue, 08 Feb 2011 05:00:08 -0500 |
parents | 2aafbdac2ca8 |
children | 43cc49c7abd1 |
rev | line source |
---|---|
5610 | 1 /* |
2 | |
11523 | 3 Copyright (C) 2005-2011 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_QR_h) | |
24 #define sparse_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_DNAME(name) cs_dl ## name |
5610 | 36 #else |
5648 | 37 #define CXSPARSE_DNAME(name) cs_di ## name |
5610 | 38 #endif |
39 | |
40 class | |
6108 | 41 OCTAVE_API |
5610 | 42 SparseQR |
43 { | |
44 protected: | |
45 class SparseQR_rep | |
46 { | |
47 public: | |
48 SparseQR_rep (const SparseMatrix& a, int order); | |
49 | |
50 ~SparseQR_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 SparseMatrix V (void) const; | |
57 | |
58 ColumnVector Pinv (void) const; | |
59 | |
60 ColumnVector P (void) const; | |
61 | |
62 SparseMatrix R (const bool econ) const; | |
63 | |
64 Matrix C (const Matrix &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 Matrix 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 |
12125
a21a3875ca83
implement a common class for reference counts
Jaroslav Hajek <highegg@gmail.com>
parents:
11586
diff
changeset
|
68 octave_refcount<int> count; |
5610 | 69 |
70 octave_idx_type nrows; | |
71 #ifdef HAVE_CXSPARSE | |
5648 | 72 CXSPARSE_DNAME (s) *S; |
5610 | 73 |
5648 | 74 CXSPARSE_DNAME (n) *N; |
5610 | 75 #endif |
12233
2aafbdac2ca8
Explicitly disallow copying in some classes
Pascal Dupuis <Pascal.Dupuis@uclouvain.be>
parents:
12125
diff
changeset
|
76 |
2aafbdac2ca8
Explicitly disallow copying in some classes
Pascal Dupuis <Pascal.Dupuis@uclouvain.be>
parents:
12125
diff
changeset
|
77 private: |
2aafbdac2ca8
Explicitly disallow copying in some classes
Pascal Dupuis <Pascal.Dupuis@uclouvain.be>
parents:
12125
diff
changeset
|
78 |
2aafbdac2ca8
Explicitly disallow copying in some classes
Pascal Dupuis <Pascal.Dupuis@uclouvain.be>
parents:
12125
diff
changeset
|
79 // No copying! |
2aafbdac2ca8
Explicitly disallow copying in some classes
Pascal Dupuis <Pascal.Dupuis@uclouvain.be>
parents:
12125
diff
changeset
|
80 |
2aafbdac2ca8
Explicitly disallow copying in some classes
Pascal Dupuis <Pascal.Dupuis@uclouvain.be>
parents:
12125
diff
changeset
|
81 SparseQR_rep (const SparseQR_rep&); |
2aafbdac2ca8
Explicitly disallow copying in some classes
Pascal Dupuis <Pascal.Dupuis@uclouvain.be>
parents:
12125
diff
changeset
|
82 |
2aafbdac2ca8
Explicitly disallow copying in some classes
Pascal Dupuis <Pascal.Dupuis@uclouvain.be>
parents:
12125
diff
changeset
|
83 SparseQR_rep& operator = (const SparseQR_rep&); |
5610 | 84 }; |
12233
2aafbdac2ca8
Explicitly disallow copying in some classes
Pascal Dupuis <Pascal.Dupuis@uclouvain.be>
parents:
12125
diff
changeset
|
85 |
5610 | 86 private: |
12233
2aafbdac2ca8
Explicitly disallow copying in some classes
Pascal Dupuis <Pascal.Dupuis@uclouvain.be>
parents:
12125
diff
changeset
|
87 |
5610 | 88 SparseQR_rep *rep; |
89 | |
11586
12df7854fa7c
strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents:
11523
diff
changeset
|
90 public: |
12233
2aafbdac2ca8
Explicitly disallow copying in some classes
Pascal Dupuis <Pascal.Dupuis@uclouvain.be>
parents:
12125
diff
changeset
|
91 |
5792 | 92 SparseQR (void) : rep (new SparseQR_rep (SparseMatrix(), 0)) { } |
5610 | 93 |
11586
12df7854fa7c
strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents:
11523
diff
changeset
|
94 SparseQR (const SparseMatrix& a, int order = 0) : |
5610 | 95 rep (new SparseQR_rep (a, order)) { } |
96 | |
97 SparseQR (const SparseQR& a) : rep (a.rep) { rep->count++; } | |
98 | |
99 ~SparseQR (void) | |
100 { | |
101 if (--rep->count <= 0) | |
10312
cbc402e64d83
untabify liboctave header files
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
102 delete rep; |
5610 | 103 } |
104 | |
105 SparseQR& operator = (const SparseQR& a) | |
106 { | |
107 if (this != &a) | |
10312
cbc402e64d83
untabify liboctave header files
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
108 { |
cbc402e64d83
untabify liboctave header files
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
109 if (--rep->count <= 0) |
cbc402e64d83
untabify liboctave header files
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
110 delete rep; |
5610 | 111 |
10312
cbc402e64d83
untabify liboctave header files
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
112 rep = a.rep; |
cbc402e64d83
untabify liboctave header files
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
113 rep->count++; |
cbc402e64d83
untabify liboctave header files
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
114 } |
5610 | 115 return *this; |
116 } | |
117 | |
118 bool ok (void) const { return rep->ok(); } | |
119 | |
120 SparseMatrix V (void) const { return rep->V(); } | |
121 | |
122 ColumnVector Pinv (void) const { return rep->P(); } | |
123 | |
124 ColumnVector P (void) const { return rep->P(); } | |
125 | |
126 SparseMatrix R (const bool econ = false) const { return rep->R(econ); } | |
127 | |
128 Matrix C (const Matrix &b) const { return rep->C(b); } | |
129 | |
7505
f5005d9510f4
Remove dispatched sparse functions and treat in the generic versions of the functions
David Bateman <dbateman@free.fr>
parents:
7017
diff
changeset
|
130 Matrix 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
|
131 |
11586
12df7854fa7c
strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents:
11523
diff
changeset
|
132 friend Matrix qrsolve (const SparseMatrix &a, const Matrix &b, |
10312
cbc402e64d83
untabify liboctave header files
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
133 octave_idx_type &info); |
5610 | 134 |
135 friend SparseMatrix qrsolve (const SparseMatrix &a, const SparseMatrix &b, | |
10312
cbc402e64d83
untabify liboctave header files
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
136 octave_idx_type &info); |
5610 | 137 |
138 friend ComplexMatrix qrsolve (const SparseMatrix &a, const ComplexMatrix &b, | |
10312
cbc402e64d83
untabify liboctave header files
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
139 octave_idx_type &info); |
5610 | 140 |
11586
12df7854fa7c
strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents:
11523
diff
changeset
|
141 friend SparseComplexMatrix qrsolve (const SparseMatrix &a, |
10312
cbc402e64d83
untabify liboctave header files
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
142 const SparseComplexMatrix &b, |
cbc402e64d83
untabify liboctave header files
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
143 octave_idx_type &info); |
5610 | 144 |
145 protected: | |
146 #ifdef HAVE_CXSPARSE | |
5648 | 147 CXSPARSE_DNAME (s) * S (void) { return rep->S; } |
5610 | 148 |
5648 | 149 CXSPARSE_DNAME (n) * N (void) { return rep->N; } |
5610 | 150 #endif |
151 }; | |
152 | |
5713 | 153 |
154 // Publish externally used friend functions. | |
155 | |
11586
12df7854fa7c
strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents:
11523
diff
changeset
|
156 extern Matrix qrsolve (const SparseMatrix &a, const Matrix &b, |
10312
cbc402e64d83
untabify liboctave header files
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
157 octave_idx_type &info); |
5713 | 158 |
11586
12df7854fa7c
strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents:
11523
diff
changeset
|
159 extern Matrix qrsolve (const SparseMatrix &a, const MArray<double> &b, |
10312
cbc402e64d83
untabify liboctave header files
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
160 octave_idx_type &info); |
7789
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7505
diff
changeset
|
161 |
5713 | 162 extern SparseMatrix qrsolve (const SparseMatrix &a, const SparseMatrix &b, |
10312
cbc402e64d83
untabify liboctave header files
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
163 octave_idx_type &info); |
5713 | 164 |
165 extern ComplexMatrix qrsolve (const SparseMatrix &a, const ComplexMatrix &b, | |
10312
cbc402e64d83
untabify liboctave header files
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
166 octave_idx_type &info); |
5713 | 167 |
11586
12df7854fa7c
strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents:
11523
diff
changeset
|
168 extern ComplexMatrix qrsolve (const SparseMatrix &a, const MArray<Complex> &b, |
10312
cbc402e64d83
untabify liboctave header files
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
169 octave_idx_type &info); |
7789
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7505
diff
changeset
|
170 |
11586
12df7854fa7c
strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents:
11523
diff
changeset
|
171 extern SparseComplexMatrix qrsolve (const SparseMatrix &a, |
10312
cbc402e64d83
untabify liboctave header files
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
172 const SparseComplexMatrix &b, |
cbc402e64d83
untabify liboctave header files
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
173 octave_idx_type &info); |
5713 | 174 |
5610 | 175 #endif |