Mercurial > hg > octave-lyh
annotate liboctave/dSparse.h @ 10785:c2041adcf234
remove unnecessary sparse indexing overloads
author | Jaroslav Hajek <highegg@gmail.com> |
---|---|
date | Tue, 13 Jul 2010 12:08:08 +0200 |
parents | b4d2080b6df7 |
children | 4b51c0a20a98 |
rev | line source |
---|---|
5164 | 1 /* |
2 | |
8920 | 3 Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009 David Bateman |
7016 | 4 Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003, 2004 Andy Adler |
5 | |
6 This file is part of Octave. | |
5164 | 7 |
8 Octave is free software; you can redistribute it and/or modify it | |
9 under the terms of the GNU General Public License as published by the | |
7016 | 10 Free Software Foundation; either version 3 of the License, or (at your |
11 option) any later version. | |
5164 | 12 |
13 Octave is distributed in the hope that it will be useful, but WITHOUT | |
14 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or | |
15 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License | |
16 for more details. | |
17 | |
18 You should have received a copy of the GNU General Public License | |
7016 | 19 along with Octave; see the file COPYING. If not, see |
20 <http://www.gnu.org/licenses/>. | |
5164 | 21 |
22 */ | |
23 | |
24 #if !defined (octave_dSparse_h) | |
25 #define octave_dSparse_h 1 | |
26 | |
27 #include "dMatrix.h" | |
28 #include "dNDArray.h" | |
29 #include "CMatrix.h" | |
30 #include "dColVector.h" | |
31 #include "CColVector.h" | |
32 | |
8335 | 33 #include "DET.h" |
5164 | 34 #include "MSparse.h" |
35 #include "MSparse-defs.h" | |
36 #include "Sparse-op-defs.h" | |
5785 | 37 #include "MatrixType.h" |
5164 | 38 |
8968
91d53dc37f79
Add perm * sparse, perm \ sparse, sparse * perm, and sparse / perm operations.
Jason Riedy <jason@acm.org>
parents:
8966
diff
changeset
|
39 class PermMatrix; |
8964
f4f4d65faaa0
Implement sparse * diagonal and diagonal * sparse operations, double-prec only.
Jason Riedy <jason@acm.org>
parents:
8920
diff
changeset
|
40 class DiagMatrix; |
5164 | 41 class SparseComplexMatrix; |
42 class SparseBoolMatrix; | |
43 | |
44 class | |
6108 | 45 OCTAVE_API |
5164 | 46 SparseMatrix : public MSparse<double> |
47 { | |
48 public: | |
49 | |
50 typedef void (*solve_singularity_handler) (double rcond); | |
51 | |
52 SparseMatrix (void) : MSparse<double> () { } | |
53 | |
5275 | 54 SparseMatrix (octave_idx_type r, octave_idx_type c) : MSparse<double> (r, c) { } |
5164 | 55 |
6823 | 56 SparseMatrix (const dim_vector& dv, octave_idx_type nz = 0) : |
57 MSparse<double> (dv, nz) { } | |
58 | |
5275 | 59 explicit SparseMatrix (octave_idx_type r, octave_idx_type c, double val) |
5164 | 60 : MSparse<double> (r, c, val) { } |
61 | |
62 SparseMatrix (const SparseMatrix& a) : MSparse<double> (a) { } | |
63 | |
64 SparseMatrix (const SparseMatrix& a, const dim_vector& dv) | |
65 : MSparse<double> (a, dv) { } | |
66 | |
67 SparseMatrix (const MSparse<double>& a) : MSparse<double> (a) { } | |
68 | |
69 explicit SparseMatrix (const SparseBoolMatrix& a); | |
70 | |
71 explicit SparseMatrix (const Matrix& a) : MSparse<double> (a) { } | |
72 | |
73 explicit SparseMatrix (const NDArray& a) : MSparse<double> (a) { } | |
74 | |
10479
ded9beac7582
optimize sparse matrix assembly
Jaroslav Hajek <highegg@gmail.com>
parents:
10421
diff
changeset
|
75 SparseMatrix (const Array<double>& a, const idx_vector& r, |
ded9beac7582
optimize sparse matrix assembly
Jaroslav Hajek <highegg@gmail.com>
parents:
10421
diff
changeset
|
76 const idx_vector& c, octave_idx_type nr = -1, |
10527
b4d2080b6df7
Replace nzmax by nnz as needed
David Bateman <dbateman@free.fr>
parents:
10480
diff
changeset
|
77 octave_idx_type nc = -1, bool sum_terms = true, |
b4d2080b6df7
Replace nzmax by nnz as needed
David Bateman <dbateman@free.fr>
parents:
10480
diff
changeset
|
78 octave_idx_type nzm = -1) |
b4d2080b6df7
Replace nzmax by nnz as needed
David Bateman <dbateman@free.fr>
parents:
10480
diff
changeset
|
79 : MSparse<double> (a, r, c, nr, nc, sum_terms, nzm) { } |
10479
ded9beac7582
optimize sparse matrix assembly
Jaroslav Hajek <highegg@gmail.com>
parents:
10421
diff
changeset
|
80 |
8366
8b1a2555c4e2
implement diagonal matrix objects
Jaroslav Hajek <highegg@gmail.com>
parents:
8335
diff
changeset
|
81 explicit SparseMatrix (const DiagMatrix& a); |
8b1a2555c4e2
implement diagonal matrix objects
Jaroslav Hajek <highegg@gmail.com>
parents:
8335
diff
changeset
|
82 |
8910
6e9f26506804
optimize diag -> sparse and perm -> sparse conversions
Jaroslav Hajek <highegg@gmail.com>
parents:
8366
diff
changeset
|
83 explicit SparseMatrix (const PermMatrix& a); |
6e9f26506804
optimize diag -> sparse and perm -> sparse conversions
Jaroslav Hajek <highegg@gmail.com>
parents:
8366
diff
changeset
|
84 |
5275 | 85 SparseMatrix (octave_idx_type r, octave_idx_type c, octave_idx_type num_nz) : MSparse<double> (r, c, num_nz) { } |
5164 | 86 |
87 SparseMatrix& operator = (const SparseMatrix& a) | |
88 { | |
89 MSparse<double>::operator = (a); | |
90 return *this; | |
91 } | |
92 | |
93 bool operator == (const SparseMatrix& a) const; | |
94 bool operator != (const SparseMatrix& a) const; | |
95 | |
96 bool is_symmetric (void) const; | |
97 | |
9790
a5035bc7fbfb
rewrite dispatch part & slightly improve min,max,cummin,cummax
Jaroslav Hajek <highegg@gmail.com>
parents:
8968
diff
changeset
|
98 SparseMatrix max (int dim = -1) const; |
a5035bc7fbfb
rewrite dispatch part & slightly improve min,max,cummin,cummax
Jaroslav Hajek <highegg@gmail.com>
parents:
8968
diff
changeset
|
99 SparseMatrix max (Array<octave_idx_type>& index, int dim = -1) const; |
a5035bc7fbfb
rewrite dispatch part & slightly improve min,max,cummin,cummax
Jaroslav Hajek <highegg@gmail.com>
parents:
8968
diff
changeset
|
100 SparseMatrix min (int dim = -1) const; |
a5035bc7fbfb
rewrite dispatch part & slightly improve min,max,cummin,cummax
Jaroslav Hajek <highegg@gmail.com>
parents:
8968
diff
changeset
|
101 SparseMatrix min (Array<octave_idx_type>& index, int dim = -1) const; |
5164 | 102 |
103 // destructive insert/delete/reorder operations | |
104 | |
5275 | 105 SparseMatrix& insert (const SparseMatrix& a, octave_idx_type r, octave_idx_type c); |
5164 | 106 |
6823 | 107 SparseMatrix& insert (const SparseMatrix& a, const Array<octave_idx_type>& indx); |
108 | |
5275 | 109 SparseMatrix concat (const SparseMatrix& rb, const Array<octave_idx_type>& ra_idx); |
5164 | 110 SparseComplexMatrix concat (const SparseComplexMatrix& rb, |
10312
cbc402e64d83
untabify liboctave header files
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
111 const Array<octave_idx_type>& ra_idx); |
5164 | 112 |
6108 | 113 friend OCTAVE_API SparseMatrix real (const SparseComplexMatrix& a); |
114 friend OCTAVE_API SparseMatrix imag (const SparseComplexMatrix& a); | |
5164 | 115 |
6108 | 116 friend OCTAVE_API SparseMatrix atan2 (const double& x, const SparseMatrix& y); |
117 friend OCTAVE_API SparseMatrix atan2 (const SparseMatrix& x, const double& y); | |
118 friend OCTAVE_API SparseMatrix atan2 (const SparseMatrix& x, const SparseMatrix& y); | |
5164 | 119 |
120 SparseMatrix transpose (void) const | |
121 { | |
122 return MSparse<double>::transpose (); | |
123 } | |
5506 | 124 SparseMatrix hermitian (void) const { return transpose (); } |
5164 | 125 |
8303
b11c31849b44
improve norm computation capabilities
Jaroslav Hajek <highegg@gmail.com>
parents:
7922
diff
changeset
|
126 // extract row or column i. |
b11c31849b44
improve norm computation capabilities
Jaroslav Hajek <highegg@gmail.com>
parents:
7922
diff
changeset
|
127 |
b11c31849b44
improve norm computation capabilities
Jaroslav Hajek <highegg@gmail.com>
parents:
7922
diff
changeset
|
128 RowVector row (octave_idx_type i) const; |
b11c31849b44
improve norm computation capabilities
Jaroslav Hajek <highegg@gmail.com>
parents:
7922
diff
changeset
|
129 |
b11c31849b44
improve norm computation capabilities
Jaroslav Hajek <highegg@gmail.com>
parents:
7922
diff
changeset
|
130 ColumnVector column (octave_idx_type i) const; |
b11c31849b44
improve norm computation capabilities
Jaroslav Hajek <highegg@gmail.com>
parents:
7922
diff
changeset
|
131 |
5506 | 132 private: |
5785 | 133 SparseMatrix dinverse (MatrixType &mattyp, octave_idx_type& info, |
10312
cbc402e64d83
untabify liboctave header files
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
134 double& rcond, const bool force = false, |
cbc402e64d83
untabify liboctave header files
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
135 const bool calccond = true) const; |
5506 | 136 |
5785 | 137 SparseMatrix tinverse (MatrixType &mattyp, octave_idx_type& info, |
10312
cbc402e64d83
untabify liboctave header files
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
138 double& rcond, const bool force = false, |
cbc402e64d83
untabify liboctave header files
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
139 const bool calccond = true) const; |
5506 | 140 |
141 public: | |
5164 | 142 SparseMatrix inverse (void) const; |
5785 | 143 SparseMatrix inverse (MatrixType& mattype) const; |
144 SparseMatrix inverse (MatrixType& mattype, octave_idx_type& info) const; | |
145 SparseMatrix inverse (MatrixType& mattype, octave_idx_type& info, | |
10312
cbc402e64d83
untabify liboctave header files
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
146 double& rcond, int force = 0, int calc_cond = 1) const; |
5164 | 147 |
148 DET determinant (void) const; | |
5275 | 149 DET determinant (octave_idx_type& info) const; |
150 DET determinant (octave_idx_type& info, double& rcond, int calc_cond = 1) const; | |
5164 | 151 |
152 private: | |
153 // Diagonal matrix solvers | |
5785 | 154 Matrix dsolve (MatrixType &typ, const Matrix& b, octave_idx_type& info, |
10312
cbc402e64d83
untabify liboctave header files
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
155 double& rcond, solve_singularity_handler sing_handler, |
cbc402e64d83
untabify liboctave header files
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
156 bool calc_cond = false) const; |
5164 | 157 |
5785 | 158 ComplexMatrix dsolve (MatrixType &typ, const ComplexMatrix& b, |
10312
cbc402e64d83
untabify liboctave header files
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
159 octave_idx_type& info, double& rcond, |
cbc402e64d83
untabify liboctave header files
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
160 solve_singularity_handler sing_handler, |
cbc402e64d83
untabify liboctave header files
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
161 bool calc_cond = false) const; |
5164 | 162 |
5785 | 163 SparseMatrix dsolve (MatrixType &typ, const SparseMatrix& b, |
10312
cbc402e64d83
untabify liboctave header files
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
164 octave_idx_type& info, double& rcond, |
cbc402e64d83
untabify liboctave header files
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
165 solve_singularity_handler sing_handler, |
cbc402e64d83
untabify liboctave header files
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
166 bool calc_cond = false) const; |
5164 | 167 |
5785 | 168 SparseComplexMatrix dsolve (MatrixType &typ, const SparseComplexMatrix& b, |
10312
cbc402e64d83
untabify liboctave header files
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
169 octave_idx_type& info, double& rcond, |
cbc402e64d83
untabify liboctave header files
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
170 solve_singularity_handler sing_handler, |
cbc402e64d83
untabify liboctave header files
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
171 bool calc_cond = false) const; |
5164 | 172 |
173 // Upper triangular matrix solvers | |
5785 | 174 Matrix utsolve (MatrixType &typ, const Matrix& b, octave_idx_type& info, |
10312
cbc402e64d83
untabify liboctave header files
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
175 double& rcond, solve_singularity_handler sing_handler, |
cbc402e64d83
untabify liboctave header files
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
176 bool calc_cond = false) const; |
5164 | 177 |
5785 | 178 ComplexMatrix utsolve (MatrixType &typ, const ComplexMatrix& b, |
10312
cbc402e64d83
untabify liboctave header files
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
179 octave_idx_type& info, double& rcond, |
cbc402e64d83
untabify liboctave header files
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
180 solve_singularity_handler sing_handler, |
cbc402e64d83
untabify liboctave header files
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
181 bool calc_cond = false) const; |
5164 | 182 |
5785 | 183 SparseMatrix utsolve (MatrixType &typ, const SparseMatrix& b, |
10312
cbc402e64d83
untabify liboctave header files
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
184 octave_idx_type& info, double& rcond, |
cbc402e64d83
untabify liboctave header files
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
185 solve_singularity_handler sing_handler, |
cbc402e64d83
untabify liboctave header files
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
186 bool calc_cond = false) const; |
5164 | 187 |
5785 | 188 SparseComplexMatrix utsolve (MatrixType &typ, const SparseComplexMatrix& b, |
10312
cbc402e64d83
untabify liboctave header files
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
189 octave_idx_type& info, double& rcond, |
cbc402e64d83
untabify liboctave header files
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
190 solve_singularity_handler sing_handler, |
cbc402e64d83
untabify liboctave header files
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
191 bool calc_cond = false) const; |
5164 | 192 |
193 // Lower triangular matrix solvers | |
5785 | 194 Matrix ltsolve (MatrixType &typ, const Matrix& b, octave_idx_type& info, |
10312
cbc402e64d83
untabify liboctave header files
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
195 double& rcond, solve_singularity_handler sing_handler, |
cbc402e64d83
untabify liboctave header files
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
196 bool calc_cond = false) const; |
5164 | 197 |
5785 | 198 ComplexMatrix ltsolve (MatrixType &typ, const ComplexMatrix& b, |
10312
cbc402e64d83
untabify liboctave header files
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
199 octave_idx_type& info, double& rcond, |
cbc402e64d83
untabify liboctave header files
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
200 solve_singularity_handler sing_handler, |
cbc402e64d83
untabify liboctave header files
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
201 bool calc_cond = false) const; |
5164 | 202 |
5785 | 203 SparseMatrix ltsolve (MatrixType &typ, const SparseMatrix& b, |
10312
cbc402e64d83
untabify liboctave header files
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
204 octave_idx_type& info, double& rcond, |
cbc402e64d83
untabify liboctave header files
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
205 solve_singularity_handler sing_handler, |
cbc402e64d83
untabify liboctave header files
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
206 bool calc_cond = false) const; |
5164 | 207 |
5785 | 208 SparseComplexMatrix ltsolve (MatrixType &typ, const SparseComplexMatrix& b, |
10312
cbc402e64d83
untabify liboctave header files
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
209 octave_idx_type& info, double& rcond, |
cbc402e64d83
untabify liboctave header files
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
210 solve_singularity_handler sing_handler, |
cbc402e64d83
untabify liboctave header files
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
211 bool calc_cond = false) const; |
5164 | 212 |
213 // Tridiagonal matrix solvers | |
5785 | 214 Matrix trisolve (MatrixType &typ, const Matrix& b, octave_idx_type& info, |
10312
cbc402e64d83
untabify liboctave header files
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
215 double& rcond, solve_singularity_handler sing_handler, |
cbc402e64d83
untabify liboctave header files
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
216 bool calc_cond = false) const; |
5164 | 217 |
5785 | 218 ComplexMatrix trisolve (MatrixType &typ, const ComplexMatrix& b, |
10312
cbc402e64d83
untabify liboctave header files
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
219 octave_idx_type& info, double& rcond, |
cbc402e64d83
untabify liboctave header files
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
220 solve_singularity_handler sing_handler, |
cbc402e64d83
untabify liboctave header files
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
221 bool calc_cond = false) const; |
5164 | 222 |
5785 | 223 SparseMatrix trisolve (MatrixType &typ, const SparseMatrix& b, |
10312
cbc402e64d83
untabify liboctave header files
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
224 octave_idx_type& info, double& rcond, |
cbc402e64d83
untabify liboctave header files
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
225 solve_singularity_handler sing_handler, |
cbc402e64d83
untabify liboctave header files
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
226 bool calc_cond = false) const; |
5164 | 227 |
5785 | 228 SparseComplexMatrix trisolve (MatrixType &typ, const SparseComplexMatrix& b, |
10312
cbc402e64d83
untabify liboctave header files
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
229 octave_idx_type& info, double& rcond, |
cbc402e64d83
untabify liboctave header files
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
230 solve_singularity_handler sing_handler, |
cbc402e64d83
untabify liboctave header files
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
231 bool calc_cond = false) const; |
5164 | 232 |
233 // Banded matrix solvers (umfpack/cholesky) | |
5785 | 234 Matrix bsolve (MatrixType &typ, const Matrix& b, octave_idx_type& info, |
10312
cbc402e64d83
untabify liboctave header files
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
235 double& rcond, solve_singularity_handler sing_handler, |
cbc402e64d83
untabify liboctave header files
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
236 bool calc_cond = false) const; |
5164 | 237 |
5785 | 238 ComplexMatrix bsolve (MatrixType &typ, const ComplexMatrix& b, |
10312
cbc402e64d83
untabify liboctave header files
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
239 octave_idx_type& info, double& rcond, |
cbc402e64d83
untabify liboctave header files
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
240 solve_singularity_handler sing_handler, |
cbc402e64d83
untabify liboctave header files
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
241 bool calc_cond = false) const; |
5164 | 242 |
5785 | 243 SparseMatrix bsolve (MatrixType &typ, const SparseMatrix& b, |
10312
cbc402e64d83
untabify liboctave header files
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
244 octave_idx_type& info, double& rcond, |
cbc402e64d83
untabify liboctave header files
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
245 solve_singularity_handler sing_handler, |
cbc402e64d83
untabify liboctave header files
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
246 bool calc_cond = false) const; |
5164 | 247 |
5785 | 248 SparseComplexMatrix bsolve (MatrixType &typ, const SparseComplexMatrix& b, |
10312
cbc402e64d83
untabify liboctave header files
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
249 octave_idx_type& info, double& rcond, |
cbc402e64d83
untabify liboctave header files
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
250 solve_singularity_handler sing_handler, |
cbc402e64d83
untabify liboctave header files
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
251 bool calc_cond = false) const; |
5164 | 252 |
253 // Full matrix solvers (umfpack/cholesky) | |
5681 | 254 void * factorize (octave_idx_type& err, double &rcond, Matrix &Control, |
10312
cbc402e64d83
untabify liboctave header files
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
255 Matrix &Info, solve_singularity_handler sing_handler, |
cbc402e64d83
untabify liboctave header files
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
256 bool calc_cond = false) const; |
5164 | 257 |
5785 | 258 Matrix fsolve (MatrixType &typ, const Matrix& b, octave_idx_type& info, |
10312
cbc402e64d83
untabify liboctave header files
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
259 double& rcond, solve_singularity_handler sing_handler, |
cbc402e64d83
untabify liboctave header files
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
260 bool calc_cond = false) const; |
5164 | 261 |
5785 | 262 ComplexMatrix fsolve (MatrixType &typ, const ComplexMatrix& b, |
10312
cbc402e64d83
untabify liboctave header files
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
263 octave_idx_type& info, double& rcond, |
cbc402e64d83
untabify liboctave header files
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
264 solve_singularity_handler sing_handler, |
cbc402e64d83
untabify liboctave header files
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
265 bool calc_cond = false) const; |
5164 | 266 |
5785 | 267 SparseMatrix fsolve (MatrixType &typ, const SparseMatrix& b, |
10312
cbc402e64d83
untabify liboctave header files
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
268 octave_idx_type& info, double& rcond, |
cbc402e64d83
untabify liboctave header files
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
269 solve_singularity_handler sing_handler, |
cbc402e64d83
untabify liboctave header files
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
270 bool calc_cond = false) const; |
5164 | 271 |
5785 | 272 SparseComplexMatrix fsolve (MatrixType &typ, const SparseComplexMatrix& b, |
10312
cbc402e64d83
untabify liboctave header files
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
273 octave_idx_type& info, double& rcond, |
cbc402e64d83
untabify liboctave header files
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
274 solve_singularity_handler sing_handler, |
cbc402e64d83
untabify liboctave header files
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
275 bool calc_cond = false) const; |
5164 | 276 |
277 public: | |
278 // Generic interface to solver with no probing of type | |
5785 | 279 Matrix solve (MatrixType &typ, const Matrix& b) const; |
280 Matrix solve (MatrixType &typ, const Matrix& b, octave_idx_type& info) const; | |
281 Matrix solve (MatrixType &typ, const Matrix& b, octave_idx_type& info, | |
10312
cbc402e64d83
untabify liboctave header files
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
282 double& rcond) const; |
5785 | 283 Matrix solve (MatrixType &typ, const Matrix& b, octave_idx_type& info, |
10312
cbc402e64d83
untabify liboctave header files
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
284 double& rcond, solve_singularity_handler sing_handler, |
cbc402e64d83
untabify liboctave header files
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
285 bool singular_fallback = true) const; |
5164 | 286 |
5785 | 287 ComplexMatrix solve (MatrixType &typ, const ComplexMatrix& b) const; |
288 ComplexMatrix solve (MatrixType &typ, const ComplexMatrix& b, | |
10312
cbc402e64d83
untabify liboctave header files
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
289 octave_idx_type& info) const; |
5785 | 290 ComplexMatrix solve (MatrixType &typ, const ComplexMatrix& b, |
10312
cbc402e64d83
untabify liboctave header files
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
291 octave_idx_type& info, double& rcond) const; |
5785 | 292 ComplexMatrix solve (MatrixType &typ, const ComplexMatrix& b, |
10312
cbc402e64d83
untabify liboctave header files
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
293 octave_idx_type& info, double& rcond, |
cbc402e64d83
untabify liboctave header files
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
294 solve_singularity_handler sing_handler, |
cbc402e64d83
untabify liboctave header files
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
295 bool singular_fallback = true) const; |
5164 | 296 |
5785 | 297 SparseMatrix solve (MatrixType &typ, const SparseMatrix& b) const; |
298 SparseMatrix solve (MatrixType &typ, const SparseMatrix& b, | |
10312
cbc402e64d83
untabify liboctave header files
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
299 octave_idx_type& info) const; |
5785 | 300 SparseMatrix solve (MatrixType &typ, const SparseMatrix& b, |
10312
cbc402e64d83
untabify liboctave header files
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
301 octave_idx_type& info, double& rcond) const; |
5785 | 302 SparseMatrix solve (MatrixType &typ, const SparseMatrix& b, |
10312
cbc402e64d83
untabify liboctave header files
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
303 octave_idx_type& info, double& rcond, |
cbc402e64d83
untabify liboctave header files
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
304 solve_singularity_handler sing_handler, |
cbc402e64d83
untabify liboctave header files
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
305 bool singular_fallback = true) const; |
5164 | 306 |
5785 | 307 SparseComplexMatrix solve (MatrixType &typ, |
10312
cbc402e64d83
untabify liboctave header files
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
308 const SparseComplexMatrix& b) const; |
5785 | 309 SparseComplexMatrix solve (MatrixType &typ, const SparseComplexMatrix& b, |
10312
cbc402e64d83
untabify liboctave header files
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
310 octave_idx_type& info) const; |
5785 | 311 SparseComplexMatrix solve (MatrixType &typ, const SparseComplexMatrix& b, |
10312
cbc402e64d83
untabify liboctave header files
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
312 octave_idx_type& info, double& rcond) const; |
5785 | 313 SparseComplexMatrix solve (MatrixType &typ, const SparseComplexMatrix& b, |
10312
cbc402e64d83
untabify liboctave header files
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
314 octave_idx_type& info, double& rcond, |
cbc402e64d83
untabify liboctave header files
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
315 solve_singularity_handler sing_handler, |
cbc402e64d83
untabify liboctave header files
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
316 bool singular_fallabck = true) const; |
5164 | 317 |
5785 | 318 ColumnVector solve (MatrixType &typ, const ColumnVector& b) const; |
319 ColumnVector solve (MatrixType &typ, const ColumnVector& b, | |
10312
cbc402e64d83
untabify liboctave header files
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
320 octave_idx_type& info) const; |
5785 | 321 ColumnVector solve (MatrixType &typ, const ColumnVector& b, |
10312
cbc402e64d83
untabify liboctave header files
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
322 octave_idx_type& info, double& rcond) const; |
5785 | 323 ColumnVector solve (MatrixType &typ, const ColumnVector& b, |
10312
cbc402e64d83
untabify liboctave header files
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
324 octave_idx_type& info, double& rcond, |
cbc402e64d83
untabify liboctave header files
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
325 solve_singularity_handler sing_handler) const; |
5164 | 326 |
5785 | 327 ComplexColumnVector solve (MatrixType &typ, |
10312
cbc402e64d83
untabify liboctave header files
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
328 const ComplexColumnVector& b) const; |
5785 | 329 ComplexColumnVector solve (MatrixType &typ, const ComplexColumnVector& b, |
10312
cbc402e64d83
untabify liboctave header files
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
330 octave_idx_type& info) const; |
5785 | 331 ComplexColumnVector solve (MatrixType &typ, const ComplexColumnVector& b, |
10312
cbc402e64d83
untabify liboctave header files
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
332 octave_idx_type& info, double& rcond) const; |
5785 | 333 ComplexColumnVector solve (MatrixType &typ, const ComplexColumnVector& b, |
10312
cbc402e64d83
untabify liboctave header files
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
334 octave_idx_type& info, double& rcond, |
cbc402e64d83
untabify liboctave header files
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
335 solve_singularity_handler sing_handler) const; |
5164 | 336 |
337 // Generic interface to solver with probing of type | |
338 Matrix solve (const Matrix& b) const; | |
5275 | 339 Matrix solve (const Matrix& b, octave_idx_type& info) const; |
340 Matrix solve (const Matrix& b, octave_idx_type& info, double& rcond) const; | |
341 Matrix solve (const Matrix& b, octave_idx_type& info, double& rcond, | |
10312
cbc402e64d83
untabify liboctave header files
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
342 solve_singularity_handler sing_handler) const; |
5164 | 343 |
344 ComplexMatrix solve (const ComplexMatrix& b) const; | |
5275 | 345 ComplexMatrix solve (const ComplexMatrix& b, octave_idx_type& info) const; |
346 ComplexMatrix solve (const ComplexMatrix& b, octave_idx_type& info, | |
10312
cbc402e64d83
untabify liboctave header files
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
347 double& rcond) const; |
5275 | 348 ComplexMatrix solve (const ComplexMatrix& b, octave_idx_type& info, double& rcond, |
10312
cbc402e64d83
untabify liboctave header files
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
349 solve_singularity_handler sing_handler) const; |
5164 | 350 |
351 SparseMatrix solve (const SparseMatrix& b) const; | |
5275 | 352 SparseMatrix solve (const SparseMatrix& b, octave_idx_type& info) const; |
353 SparseMatrix solve (const SparseMatrix& b, octave_idx_type& info, | |
10312
cbc402e64d83
untabify liboctave header files
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
354 double& rcond) const; |
5275 | 355 SparseMatrix solve (const SparseMatrix& b, octave_idx_type& info, double& rcond, |
10312
cbc402e64d83
untabify liboctave header files
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
356 solve_singularity_handler sing_handler) const; |
5164 | 357 |
358 SparseComplexMatrix solve (const SparseComplexMatrix& b) const; | |
5275 | 359 SparseComplexMatrix solve (const SparseComplexMatrix& b, octave_idx_type& info) const; |
360 SparseComplexMatrix solve (const SparseComplexMatrix& b, octave_idx_type& info, | |
10312
cbc402e64d83
untabify liboctave header files
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
361 double& rcond) const; |
5275 | 362 SparseComplexMatrix solve (const SparseComplexMatrix& b, octave_idx_type& info, |
10312
cbc402e64d83
untabify liboctave header files
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
363 double& rcond, |
cbc402e64d83
untabify liboctave header files
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
364 solve_singularity_handler sing_handler) const; |
5164 | 365 |
366 ColumnVector solve (const ColumnVector& b) const; | |
5275 | 367 ColumnVector solve (const ColumnVector& b, octave_idx_type& info) const; |
368 ColumnVector solve (const ColumnVector& b, octave_idx_type& info, double& rcond) const; | |
369 ColumnVector solve (const ColumnVector& b, octave_idx_type& info, double& rcond, | |
10312
cbc402e64d83
untabify liboctave header files
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
370 solve_singularity_handler sing_handler) const; |
5164 | 371 |
372 ComplexColumnVector solve (const ComplexColumnVector& b) const; | |
5275 | 373 ComplexColumnVector solve (const ComplexColumnVector& b, octave_idx_type& info) const; |
374 ComplexColumnVector solve (const ComplexColumnVector& b, octave_idx_type& info, | |
10312
cbc402e64d83
untabify liboctave header files
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
375 double& rcond) const; |
5275 | 376 ComplexColumnVector solve (const ComplexColumnVector& b, octave_idx_type& info, |
10312
cbc402e64d83
untabify liboctave header files
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
377 double& rcond, |
cbc402e64d83
untabify liboctave header files
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
378 solve_singularity_handler sing_handler) const; |
5164 | 379 |
380 // other operations | |
381 | |
382 bool any_element_is_negative (bool = false) const; | |
7922
935be827eaf8
error for NaN values in & and | expressions
John W. Eaton <jwe@octave.org>
parents:
7802
diff
changeset
|
383 bool any_element_is_nan (void) const; |
5164 | 384 bool any_element_is_inf_or_nan (void) const; |
9852
aabf7a8c2e57
implement sparse logical conversion
Jaroslav Hajek <highegg@gmail.com>
parents:
9812
diff
changeset
|
385 bool any_element_not_one_or_zero (void) const; |
6989 | 386 bool all_elements_are_zero (void) const; |
5164 | 387 bool all_elements_are_int_or_inf_or_nan (void) const; |
388 bool all_integers (double& max_val, double& min_val) const; | |
389 bool too_large_for_float (void) const; | |
390 | |
391 SparseBoolMatrix operator ! (void) const; | |
392 | |
393 SparseBoolMatrix all (int dim = -1) const; | |
394 SparseBoolMatrix any (int dim = -1) const; | |
395 | |
396 SparseMatrix cumprod (int dim = -1) const; | |
397 SparseMatrix cumsum (int dim = -1) const; | |
398 SparseMatrix prod (int dim = -1) const; | |
399 SparseMatrix sum (int dim = -1) const; | |
400 SparseMatrix sumsq (int dim = -1) const; | |
401 SparseMatrix abs (void) const; | |
402 | |
5275 | 403 SparseMatrix diag (octave_idx_type k = 0) const; |
5164 | 404 |
405 Matrix matrix_value (void) const; | |
406 | |
407 SparseMatrix squeeze (void) const; | |
408 | |
409 SparseMatrix reshape (const dim_vector& new_dims) const; | |
410 | |
5275 | 411 SparseMatrix permute (const Array<octave_idx_type>& vec, bool inv = false) const; |
5164 | 412 |
5275 | 413 SparseMatrix ipermute (const Array<octave_idx_type>& vec) const; |
5164 | 414 |
415 // i/o | |
416 | |
6108 | 417 friend OCTAVE_API std::ostream& operator << (std::ostream& os, const SparseMatrix& a); |
418 friend OCTAVE_API std::istream& operator >> (std::istream& is, SparseMatrix& a); | |
7503
8c32f95c2639
convert mapper functions to new format
David Bateman <dbateman@free.fr>
parents:
7017
diff
changeset
|
419 |
5164 | 420 }; |
421 | |
5509 | 422 // Publish externally used friend functions. |
423 | |
6108 | 424 extern OCTAVE_API SparseMatrix real (const SparseComplexMatrix& a); |
425 extern OCTAVE_API SparseMatrix imag (const SparseComplexMatrix& a); | |
5509 | 426 |
427 // Other operators. | |
428 | |
6108 | 429 extern OCTAVE_API SparseMatrix operator * (const SparseMatrix& a, |
10312
cbc402e64d83
untabify liboctave header files
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
430 const SparseMatrix& b); |
6108 | 431 extern OCTAVE_API Matrix operator * (const Matrix& a, |
10312
cbc402e64d83
untabify liboctave header files
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
432 const SparseMatrix& b); |
7802
1a446f28ce68
implement optimized sparse-dense transposed multiplication
Jaroslav Hajek <highegg@gmail.com>
parents:
7503
diff
changeset
|
433 extern OCTAVE_API Matrix mul_trans (const Matrix& a, |
10312
cbc402e64d83
untabify liboctave header files
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
434 const SparseMatrix& b); |
6108 | 435 extern OCTAVE_API Matrix operator * (const SparseMatrix& a, |
10312
cbc402e64d83
untabify liboctave header files
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
436 const Matrix& b); |
7802
1a446f28ce68
implement optimized sparse-dense transposed multiplication
Jaroslav Hajek <highegg@gmail.com>
parents:
7503
diff
changeset
|
437 extern OCTAVE_API Matrix trans_mul (const SparseMatrix& a, |
10312
cbc402e64d83
untabify liboctave header files
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
438 const Matrix& b); |
5164 | 439 |
8964
f4f4d65faaa0
Implement sparse * diagonal and diagonal * sparse operations, double-prec only.
Jason Riedy <jason@acm.org>
parents:
8920
diff
changeset
|
440 extern OCTAVE_API SparseMatrix operator * (const DiagMatrix&, const SparseMatrix&); |
f4f4d65faaa0
Implement sparse * diagonal and diagonal * sparse operations, double-prec only.
Jason Riedy <jason@acm.org>
parents:
8920
diff
changeset
|
441 extern OCTAVE_API SparseMatrix operator * (const SparseMatrix&, const DiagMatrix&); |
f4f4d65faaa0
Implement sparse * diagonal and diagonal * sparse operations, double-prec only.
Jason Riedy <jason@acm.org>
parents:
8920
diff
changeset
|
442 |
8966
1bba53c0a38d
Implement diag + sparse, diag - sparse, sparse + diag, sparse - diag.
Jason Riedy <jason@acm.org>
parents:
8964
diff
changeset
|
443 extern OCTAVE_API SparseMatrix operator + (const DiagMatrix&, const SparseMatrix&); |
1bba53c0a38d
Implement diag + sparse, diag - sparse, sparse + diag, sparse - diag.
Jason Riedy <jason@acm.org>
parents:
8964
diff
changeset
|
444 extern OCTAVE_API SparseMatrix operator + (const SparseMatrix&, const DiagMatrix&); |
1bba53c0a38d
Implement diag + sparse, diag - sparse, sparse + diag, sparse - diag.
Jason Riedy <jason@acm.org>
parents:
8964
diff
changeset
|
445 extern OCTAVE_API SparseMatrix operator - (const DiagMatrix&, const SparseMatrix&); |
1bba53c0a38d
Implement diag + sparse, diag - sparse, sparse + diag, sparse - diag.
Jason Riedy <jason@acm.org>
parents:
8964
diff
changeset
|
446 extern OCTAVE_API SparseMatrix operator - (const SparseMatrix&, const DiagMatrix&); |
1bba53c0a38d
Implement diag + sparse, diag - sparse, sparse + diag, sparse - diag.
Jason Riedy <jason@acm.org>
parents:
8964
diff
changeset
|
447 |
8968
91d53dc37f79
Add perm * sparse, perm \ sparse, sparse * perm, and sparse / perm operations.
Jason Riedy <jason@acm.org>
parents:
8966
diff
changeset
|
448 extern OCTAVE_API SparseMatrix operator * (const PermMatrix&, const SparseMatrix&); |
91d53dc37f79
Add perm * sparse, perm \ sparse, sparse * perm, and sparse / perm operations.
Jason Riedy <jason@acm.org>
parents:
8966
diff
changeset
|
449 extern OCTAVE_API SparseMatrix operator * (const SparseMatrix&, const PermMatrix&); |
91d53dc37f79
Add perm * sparse, perm \ sparse, sparse * perm, and sparse / perm operations.
Jason Riedy <jason@acm.org>
parents:
8966
diff
changeset
|
450 |
6108 | 451 extern OCTAVE_API SparseMatrix min (double d, const SparseMatrix& m); |
452 extern OCTAVE_API SparseMatrix min (const SparseMatrix& m, double d); | |
453 extern OCTAVE_API SparseMatrix min (const SparseMatrix& a, const SparseMatrix& b); | |
5164 | 454 |
6108 | 455 extern OCTAVE_API SparseMatrix max (double d, const SparseMatrix& m); |
456 extern OCTAVE_API SparseMatrix max (const SparseMatrix& m, double d); | |
457 extern OCTAVE_API SparseMatrix max (const SparseMatrix& a, const SparseMatrix& b); | |
5164 | 458 |
6708 | 459 SPARSE_SMS_CMP_OP_DECLS (SparseMatrix, double, OCTAVE_API) |
460 SPARSE_SMS_BOOL_OP_DECLS (SparseMatrix, double, OCTAVE_API) | |
5164 | 461 |
6708 | 462 SPARSE_SSM_CMP_OP_DECLS (double, SparseMatrix, OCTAVE_API) |
463 SPARSE_SSM_BOOL_OP_DECLS (double, SparseMatrix, OCTAVE_API) | |
5164 | 464 |
6708 | 465 SPARSE_SMSM_CMP_OP_DECLS (SparseMatrix, SparseMatrix, OCTAVE_API) |
466 SPARSE_SMSM_BOOL_OP_DECLS (SparseMatrix, SparseMatrix, OCTAVE_API) | |
5164 | 467 |
468 SPARSE_FORWARD_DEFS (MSparse, SparseMatrix, Matrix, double) | |
469 | |
5351 | 470 #ifdef IDX_TYPE_LONG |
5322 | 471 #define UMFPACK_DNAME(name) umfpack_dl_ ## name |
472 #else | |
473 #define UMFPACK_DNAME(name) umfpack_di_ ## name | |
474 #endif | |
475 | |
5164 | 476 #endif |