Mercurial > hg > octave-nkf
annotate liboctave/numeric/SparseQR.h @ 20685:7fa1970a655d
pkg.m: drop check of nargout value, the interpreter already does that.
* scripts/pkg/pkg.m: the interpreter already checks if there was any variable
that got no value assigned, there's no need to make the code more
complicated to cover that. Also, there's no point in calling describe()
with different nargout since it doesn't check nargout.
author | Carnë Draug <carandraug@octave.org> |
---|---|
date | Thu, 03 Sep 2015 16:21:08 +0100 |
parents | 4197fc428c7d |
children |
rev | line source |
---|---|
5610 | 1 /* |
2 | |
19898
4197fc428c7d
maint: Update copyright notices for 2015.
John W. Eaton <jwe@octave.org>
parents:
17822
diff
changeset
|
3 Copyright (C) 2005-2015 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 | |
17822
ebb3ef964372
maint: Use common #define syntax "octave_filename_h" in h_files.
Rik <rik@octave.org>
parents:
17769
diff
changeset
|
23 #if !defined (octave_SparseQR_h) |
ebb3ef964372
maint: Use common #define syntax "octave_filename_h" in h_files.
Rik <rik@octave.org>
parents:
17769
diff
changeset
|
24 #define octave_SparseQR_h 1 |
5610 | 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 | |
16313
6aafe87a3144
use int64_t for idx type if --enable-64
John W. Eaton <jwe@octave.org>
parents:
15271
diff
changeset
|
34 #ifdef USE_64_BIT_IDX_T |
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 |
12153
e0e50f48df37
Explicitly disallow copying in some classes
Pascal Dupuis <Pascal.Dupuis@uclouvain.be>
parents:
12125
diff
changeset
|
76 |
e0e50f48df37
Explicitly disallow copying in some classes
Pascal Dupuis <Pascal.Dupuis@uclouvain.be>
parents:
12125
diff
changeset
|
77 private: |
e0e50f48df37
Explicitly disallow copying in some classes
Pascal Dupuis <Pascal.Dupuis@uclouvain.be>
parents:
12125
diff
changeset
|
78 |
e0e50f48df37
Explicitly disallow copying in some classes
Pascal Dupuis <Pascal.Dupuis@uclouvain.be>
parents:
12125
diff
changeset
|
79 // No copying! |
e0e50f48df37
Explicitly disallow copying in some classes
Pascal Dupuis <Pascal.Dupuis@uclouvain.be>
parents:
12125
diff
changeset
|
80 |
e0e50f48df37
Explicitly disallow copying in some classes
Pascal Dupuis <Pascal.Dupuis@uclouvain.be>
parents:
12125
diff
changeset
|
81 SparseQR_rep (const SparseQR_rep&); |
e0e50f48df37
Explicitly disallow copying in some classes
Pascal Dupuis <Pascal.Dupuis@uclouvain.be>
parents:
12125
diff
changeset
|
82 |
e0e50f48df37
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 }; |
12153
e0e50f48df37
Explicitly disallow copying in some classes
Pascal Dupuis <Pascal.Dupuis@uclouvain.be>
parents:
12125
diff
changeset
|
85 |
5610 | 86 private: |
12153
e0e50f48df37
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: |
12153
e0e50f48df37
Explicitly disallow copying in some classes
Pascal Dupuis <Pascal.Dupuis@uclouvain.be>
parents:
12125
diff
changeset
|
91 |
14846
460a3c6d8bf1
maint: Use Octave coding convention for cuddled parenthis in function calls with empty argument lists.
Rik <octave@nomad.inbox5.com>
parents:
14138
diff
changeset
|
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) | |
17769
49a5a4be04a1
maint: Use GNU style coding conventions for code in liboctave/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
100 { |
49a5a4be04a1
maint: Use GNU style coding conventions for code in liboctave/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
101 if (--rep->count == 0) |
49a5a4be04a1
maint: Use GNU style coding conventions for code in liboctave/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
102 delete rep; |
49a5a4be04a1
maint: Use GNU style coding conventions for code in liboctave/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
103 } |
5610 | 104 |
105 SparseQR& operator = (const SparseQR& a) | |
17769
49a5a4be04a1
maint: Use GNU style coding conventions for code in liboctave/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
106 { |
49a5a4be04a1
maint: Use GNU style coding conventions for code in liboctave/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
107 if (this != &a) |
49a5a4be04a1
maint: Use GNU style coding conventions for code in liboctave/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
108 { |
49a5a4be04a1
maint: Use GNU style coding conventions for code in liboctave/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
109 if (--rep->count == 0) |
49a5a4be04a1
maint: Use GNU style coding conventions for code in liboctave/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
110 delete rep; |
5610 | 111 |
17769
49a5a4be04a1
maint: Use GNU style coding conventions for code in liboctave/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
112 rep = a.rep; |
49a5a4be04a1
maint: Use GNU style coding conventions for code in liboctave/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
113 rep->count++; |
49a5a4be04a1
maint: Use GNU style coding conventions for code in liboctave/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
114 } |
49a5a4be04a1
maint: Use GNU style coding conventions for code in liboctave/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
115 return *this; |
49a5a4be04a1
maint: Use GNU style coding conventions for code in liboctave/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
116 } |
5610 | 117 |
14846
460a3c6d8bf1
maint: Use Octave coding convention for cuddled parenthis in function calls with empty argument lists.
Rik <octave@nomad.inbox5.com>
parents:
14138
diff
changeset
|
118 bool ok (void) const { return rep->ok (); } |
5610 | 119 |
14846
460a3c6d8bf1
maint: Use Octave coding convention for cuddled parenthis in function calls with empty argument lists.
Rik <octave@nomad.inbox5.com>
parents:
14138
diff
changeset
|
120 SparseMatrix V (void) const { return rep->V (); } |
5610 | 121 |
14846
460a3c6d8bf1
maint: Use Octave coding convention for cuddled parenthis in function calls with empty argument lists.
Rik <octave@nomad.inbox5.com>
parents:
14138
diff
changeset
|
122 ColumnVector Pinv (void) const { return rep->P (); } |
5610 | 123 |
14846
460a3c6d8bf1
maint: Use Octave coding convention for cuddled parenthis in function calls with empty argument lists.
Rik <octave@nomad.inbox5.com>
parents:
14138
diff
changeset
|
124 ColumnVector P (void) const { return rep->P (); } |
5610 | 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 | |
14846
460a3c6d8bf1
maint: Use Octave coding convention for cuddled parenthis in function calls with empty argument lists.
Rik <octave@nomad.inbox5.com>
parents:
14138
diff
changeset
|
130 Matrix Q (void) const { return rep->Q (); } |
7505
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, | |
17769
49a5a4be04a1
maint: Use GNU style coding conventions for code in liboctave/
Rik <rik@octave.org>
parents:
17744
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 |