Mercurial > hg > octave-nkf
annotate liboctave/dSparse.h @ 10509:ddbd812d09aa
properly compress sparse matrices after assembly
author | Jaroslav Hajek <highegg@gmail.com> |
---|---|
date | Mon, 12 Apr 2010 12:57:44 +0200 |
parents | 19e1e4470e01 |
children | b4d2080b6df7 |
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, |
ded9beac7582
optimize sparse matrix assembly
Jaroslav Hajek <highegg@gmail.com>
parents:
10421
diff
changeset
|
77 octave_idx_type nc = -1, bool sum_terms = true) |
ded9beac7582
optimize sparse matrix assembly
Jaroslav Hajek <highegg@gmail.com>
parents:
10421
diff
changeset
|
78 : MSparse<double> (a, r, c, nr, nc, sum_terms) { } |
ded9beac7582
optimize sparse matrix assembly
Jaroslav Hajek <highegg@gmail.com>
parents:
10421
diff
changeset
|
79 |
8366
8b1a2555c4e2
implement diagonal matrix objects
Jaroslav Hajek <highegg@gmail.com>
parents:
8335
diff
changeset
|
80 explicit SparseMatrix (const DiagMatrix& a); |
8b1a2555c4e2
implement diagonal matrix objects
Jaroslav Hajek <highegg@gmail.com>
parents:
8335
diff
changeset
|
81 |
8910
6e9f26506804
optimize diag -> sparse and perm -> sparse conversions
Jaroslav Hajek <highegg@gmail.com>
parents:
8366
diff
changeset
|
82 explicit SparseMatrix (const PermMatrix& a); |
6e9f26506804
optimize diag -> sparse and perm -> sparse conversions
Jaroslav Hajek <highegg@gmail.com>
parents:
8366
diff
changeset
|
83 |
5275 | 84 SparseMatrix (octave_idx_type r, octave_idx_type c, octave_idx_type num_nz) : MSparse<double> (r, c, num_nz) { } |
5164 | 85 |
86 SparseMatrix& operator = (const SparseMatrix& a) | |
87 { | |
88 MSparse<double>::operator = (a); | |
89 return *this; | |
90 } | |
91 | |
92 bool operator == (const SparseMatrix& a) const; | |
93 bool operator != (const SparseMatrix& a) const; | |
94 | |
95 bool is_symmetric (void) const; | |
96 | |
9790
a5035bc7fbfb
rewrite dispatch part & slightly improve min,max,cummin,cummax
Jaroslav Hajek <highegg@gmail.com>
parents:
8968
diff
changeset
|
97 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
|
98 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
|
99 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
|
100 SparseMatrix min (Array<octave_idx_type>& index, int dim = -1) const; |
5164 | 101 |
102 // destructive insert/delete/reorder operations | |
103 | |
5275 | 104 SparseMatrix& insert (const SparseMatrix& a, octave_idx_type r, octave_idx_type c); |
5164 | 105 |
6823 | 106 SparseMatrix& insert (const SparseMatrix& a, const Array<octave_idx_type>& indx); |
107 | |
5275 | 108 SparseMatrix concat (const SparseMatrix& rb, const Array<octave_idx_type>& ra_idx); |
5164 | 109 SparseComplexMatrix concat (const SparseComplexMatrix& rb, |
10312
cbc402e64d83
untabify liboctave header files
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
110 const Array<octave_idx_type>& ra_idx); |
5164 | 111 |
6108 | 112 friend OCTAVE_API SparseMatrix real (const SparseComplexMatrix& a); |
113 friend OCTAVE_API SparseMatrix imag (const SparseComplexMatrix& a); | |
5164 | 114 |
6108 | 115 friend OCTAVE_API SparseMatrix atan2 (const double& x, const SparseMatrix& y); |
116 friend OCTAVE_API SparseMatrix atan2 (const SparseMatrix& x, const double& y); | |
117 friend OCTAVE_API SparseMatrix atan2 (const SparseMatrix& x, const SparseMatrix& y); | |
5164 | 118 |
119 SparseMatrix transpose (void) const | |
120 { | |
121 return MSparse<double>::transpose (); | |
122 } | |
5506 | 123 SparseMatrix hermitian (void) const { return transpose (); } |
5164 | 124 |
8303
b11c31849b44
improve norm computation capabilities
Jaroslav Hajek <highegg@gmail.com>
parents:
7922
diff
changeset
|
125 // extract row or column i. |
b11c31849b44
improve norm computation capabilities
Jaroslav Hajek <highegg@gmail.com>
parents:
7922
diff
changeset
|
126 |
b11c31849b44
improve norm computation capabilities
Jaroslav Hajek <highegg@gmail.com>
parents:
7922
diff
changeset
|
127 RowVector row (octave_idx_type i) const; |
b11c31849b44
improve norm computation capabilities
Jaroslav Hajek <highegg@gmail.com>
parents:
7922
diff
changeset
|
128 |
b11c31849b44
improve norm computation capabilities
Jaroslav Hajek <highegg@gmail.com>
parents:
7922
diff
changeset
|
129 ColumnVector column (octave_idx_type i) const; |
b11c31849b44
improve norm computation capabilities
Jaroslav Hajek <highegg@gmail.com>
parents:
7922
diff
changeset
|
130 |
5506 | 131 private: |
5785 | 132 SparseMatrix dinverse (MatrixType &mattyp, octave_idx_type& info, |
10312
cbc402e64d83
untabify liboctave header files
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
133 double& rcond, const bool force = false, |
cbc402e64d83
untabify liboctave header files
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
134 const bool calccond = true) const; |
5506 | 135 |
5785 | 136 SparseMatrix tinverse (MatrixType &mattyp, octave_idx_type& info, |
10312
cbc402e64d83
untabify liboctave header files
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
137 double& rcond, const bool force = false, |
cbc402e64d83
untabify liboctave header files
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
138 const bool calccond = true) const; |
5506 | 139 |
140 public: | |
5164 | 141 SparseMatrix inverse (void) const; |
5785 | 142 SparseMatrix inverse (MatrixType& mattype) const; |
143 SparseMatrix inverse (MatrixType& mattype, octave_idx_type& info) const; | |
144 SparseMatrix inverse (MatrixType& mattype, octave_idx_type& info, | |
10312
cbc402e64d83
untabify liboctave header files
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
145 double& rcond, int force = 0, int calc_cond = 1) const; |
5164 | 146 |
147 DET determinant (void) const; | |
5275 | 148 DET determinant (octave_idx_type& info) const; |
149 DET determinant (octave_idx_type& info, double& rcond, int calc_cond = 1) const; | |
5164 | 150 |
151 private: | |
152 // Diagonal matrix solvers | |
5785 | 153 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
|
154 double& rcond, solve_singularity_handler sing_handler, |
cbc402e64d83
untabify liboctave header files
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
155 bool calc_cond = false) const; |
5164 | 156 |
5785 | 157 ComplexMatrix dsolve (MatrixType &typ, const ComplexMatrix& b, |
10312
cbc402e64d83
untabify liboctave header files
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
158 octave_idx_type& info, double& rcond, |
cbc402e64d83
untabify liboctave header files
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
159 solve_singularity_handler sing_handler, |
cbc402e64d83
untabify liboctave header files
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
160 bool calc_cond = false) const; |
5164 | 161 |
5785 | 162 SparseMatrix dsolve (MatrixType &typ, const SparseMatrix& b, |
10312
cbc402e64d83
untabify liboctave header files
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
163 octave_idx_type& info, double& rcond, |
cbc402e64d83
untabify liboctave header files
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
164 solve_singularity_handler sing_handler, |
cbc402e64d83
untabify liboctave header files
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
165 bool calc_cond = false) const; |
5164 | 166 |
5785 | 167 SparseComplexMatrix dsolve (MatrixType &typ, const SparseComplexMatrix& b, |
10312
cbc402e64d83
untabify liboctave header files
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
168 octave_idx_type& info, double& rcond, |
cbc402e64d83
untabify liboctave header files
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
169 solve_singularity_handler sing_handler, |
cbc402e64d83
untabify liboctave header files
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
170 bool calc_cond = false) const; |
5164 | 171 |
172 // Upper triangular matrix solvers | |
5785 | 173 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
|
174 double& rcond, solve_singularity_handler sing_handler, |
cbc402e64d83
untabify liboctave header files
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
175 bool calc_cond = false) const; |
5164 | 176 |
5785 | 177 ComplexMatrix utsolve (MatrixType &typ, const ComplexMatrix& b, |
10312
cbc402e64d83
untabify liboctave header files
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
178 octave_idx_type& info, double& rcond, |
cbc402e64d83
untabify liboctave header files
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
179 solve_singularity_handler sing_handler, |
cbc402e64d83
untabify liboctave header files
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
180 bool calc_cond = false) const; |
5164 | 181 |
5785 | 182 SparseMatrix utsolve (MatrixType &typ, const SparseMatrix& b, |
10312
cbc402e64d83
untabify liboctave header files
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
183 octave_idx_type& info, double& rcond, |
cbc402e64d83
untabify liboctave header files
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
184 solve_singularity_handler sing_handler, |
cbc402e64d83
untabify liboctave header files
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
185 bool calc_cond = false) const; |
5164 | 186 |
5785 | 187 SparseComplexMatrix utsolve (MatrixType &typ, const SparseComplexMatrix& b, |
10312
cbc402e64d83
untabify liboctave header files
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
188 octave_idx_type& info, double& rcond, |
cbc402e64d83
untabify liboctave header files
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
189 solve_singularity_handler sing_handler, |
cbc402e64d83
untabify liboctave header files
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
190 bool calc_cond = false) const; |
5164 | 191 |
192 // Lower triangular matrix solvers | |
5785 | 193 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
|
194 double& rcond, solve_singularity_handler sing_handler, |
cbc402e64d83
untabify liboctave header files
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
195 bool calc_cond = false) const; |
5164 | 196 |
5785 | 197 ComplexMatrix ltsolve (MatrixType &typ, const ComplexMatrix& b, |
10312
cbc402e64d83
untabify liboctave header files
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
198 octave_idx_type& info, double& rcond, |
cbc402e64d83
untabify liboctave header files
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
199 solve_singularity_handler sing_handler, |
cbc402e64d83
untabify liboctave header files
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
200 bool calc_cond = false) const; |
5164 | 201 |
5785 | 202 SparseMatrix ltsolve (MatrixType &typ, const SparseMatrix& b, |
10312
cbc402e64d83
untabify liboctave header files
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
203 octave_idx_type& info, double& rcond, |
cbc402e64d83
untabify liboctave header files
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
204 solve_singularity_handler sing_handler, |
cbc402e64d83
untabify liboctave header files
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
205 bool calc_cond = false) const; |
5164 | 206 |
5785 | 207 SparseComplexMatrix ltsolve (MatrixType &typ, const SparseComplexMatrix& b, |
10312
cbc402e64d83
untabify liboctave header files
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
208 octave_idx_type& info, double& rcond, |
cbc402e64d83
untabify liboctave header files
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
209 solve_singularity_handler sing_handler, |
cbc402e64d83
untabify liboctave header files
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
210 bool calc_cond = false) const; |
5164 | 211 |
212 // Tridiagonal matrix solvers | |
5785 | 213 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
|
214 double& rcond, solve_singularity_handler sing_handler, |
cbc402e64d83
untabify liboctave header files
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
215 bool calc_cond = false) const; |
5164 | 216 |
5785 | 217 ComplexMatrix trisolve (MatrixType &typ, const ComplexMatrix& b, |
10312
cbc402e64d83
untabify liboctave header files
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
218 octave_idx_type& info, double& rcond, |
cbc402e64d83
untabify liboctave header files
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
219 solve_singularity_handler sing_handler, |
cbc402e64d83
untabify liboctave header files
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
220 bool calc_cond = false) const; |
5164 | 221 |
5785 | 222 SparseMatrix trisolve (MatrixType &typ, const SparseMatrix& b, |
10312
cbc402e64d83
untabify liboctave header files
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
223 octave_idx_type& info, double& rcond, |
cbc402e64d83
untabify liboctave header files
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
224 solve_singularity_handler sing_handler, |
cbc402e64d83
untabify liboctave header files
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
225 bool calc_cond = false) const; |
5164 | 226 |
5785 | 227 SparseComplexMatrix trisolve (MatrixType &typ, const SparseComplexMatrix& b, |
10312
cbc402e64d83
untabify liboctave header files
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
228 octave_idx_type& info, double& rcond, |
cbc402e64d83
untabify liboctave header files
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
229 solve_singularity_handler sing_handler, |
cbc402e64d83
untabify liboctave header files
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
230 bool calc_cond = false) const; |
5164 | 231 |
232 // Banded matrix solvers (umfpack/cholesky) | |
5785 | 233 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
|
234 double& rcond, solve_singularity_handler sing_handler, |
cbc402e64d83
untabify liboctave header files
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
235 bool calc_cond = false) const; |
5164 | 236 |
5785 | 237 ComplexMatrix bsolve (MatrixType &typ, const ComplexMatrix& b, |
10312
cbc402e64d83
untabify liboctave header files
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
238 octave_idx_type& info, double& rcond, |
cbc402e64d83
untabify liboctave header files
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
239 solve_singularity_handler sing_handler, |
cbc402e64d83
untabify liboctave header files
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
240 bool calc_cond = false) const; |
5164 | 241 |
5785 | 242 SparseMatrix bsolve (MatrixType &typ, const SparseMatrix& b, |
10312
cbc402e64d83
untabify liboctave header files
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
243 octave_idx_type& info, double& rcond, |
cbc402e64d83
untabify liboctave header files
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
244 solve_singularity_handler sing_handler, |
cbc402e64d83
untabify liboctave header files
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
245 bool calc_cond = false) const; |
5164 | 246 |
5785 | 247 SparseComplexMatrix bsolve (MatrixType &typ, const SparseComplexMatrix& b, |
10312
cbc402e64d83
untabify liboctave header files
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
248 octave_idx_type& info, double& rcond, |
cbc402e64d83
untabify liboctave header files
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
249 solve_singularity_handler sing_handler, |
cbc402e64d83
untabify liboctave header files
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
250 bool calc_cond = false) const; |
5164 | 251 |
252 // Full matrix solvers (umfpack/cholesky) | |
5681 | 253 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
|
254 Matrix &Info, solve_singularity_handler sing_handler, |
cbc402e64d83
untabify liboctave header files
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
255 bool calc_cond = false) const; |
5164 | 256 |
5785 | 257 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
|
258 double& rcond, solve_singularity_handler sing_handler, |
cbc402e64d83
untabify liboctave header files
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
259 bool calc_cond = false) const; |
5164 | 260 |
5785 | 261 ComplexMatrix fsolve (MatrixType &typ, const ComplexMatrix& b, |
10312
cbc402e64d83
untabify liboctave header files
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
262 octave_idx_type& info, double& rcond, |
cbc402e64d83
untabify liboctave header files
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
263 solve_singularity_handler sing_handler, |
cbc402e64d83
untabify liboctave header files
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
264 bool calc_cond = false) const; |
5164 | 265 |
5785 | 266 SparseMatrix fsolve (MatrixType &typ, const SparseMatrix& b, |
10312
cbc402e64d83
untabify liboctave header files
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
267 octave_idx_type& info, double& rcond, |
cbc402e64d83
untabify liboctave header files
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
268 solve_singularity_handler sing_handler, |
cbc402e64d83
untabify liboctave header files
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
269 bool calc_cond = false) const; |
5164 | 270 |
5785 | 271 SparseComplexMatrix fsolve (MatrixType &typ, const SparseComplexMatrix& b, |
10312
cbc402e64d83
untabify liboctave header files
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
272 octave_idx_type& info, double& rcond, |
cbc402e64d83
untabify liboctave header files
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
273 solve_singularity_handler sing_handler, |
cbc402e64d83
untabify liboctave header files
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
274 bool calc_cond = false) const; |
5164 | 275 |
276 public: | |
277 // Generic interface to solver with no probing of type | |
5785 | 278 Matrix solve (MatrixType &typ, const Matrix& b) const; |
279 Matrix solve (MatrixType &typ, const Matrix& b, octave_idx_type& info) const; | |
280 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
|
281 double& rcond) const; |
5785 | 282 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
|
283 double& rcond, solve_singularity_handler sing_handler, |
cbc402e64d83
untabify liboctave header files
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
284 bool singular_fallback = true) const; |
5164 | 285 |
5785 | 286 ComplexMatrix solve (MatrixType &typ, const ComplexMatrix& b) const; |
287 ComplexMatrix solve (MatrixType &typ, const ComplexMatrix& b, | |
10312
cbc402e64d83
untabify liboctave header files
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
288 octave_idx_type& info) const; |
5785 | 289 ComplexMatrix solve (MatrixType &typ, const ComplexMatrix& b, |
10312
cbc402e64d83
untabify liboctave header files
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
290 octave_idx_type& info, double& rcond) const; |
5785 | 291 ComplexMatrix solve (MatrixType &typ, const ComplexMatrix& b, |
10312
cbc402e64d83
untabify liboctave header files
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
292 octave_idx_type& info, double& rcond, |
cbc402e64d83
untabify liboctave header files
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
293 solve_singularity_handler sing_handler, |
cbc402e64d83
untabify liboctave header files
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
294 bool singular_fallback = true) const; |
5164 | 295 |
5785 | 296 SparseMatrix solve (MatrixType &typ, const SparseMatrix& b) const; |
297 SparseMatrix solve (MatrixType &typ, const SparseMatrix& b, | |
10312
cbc402e64d83
untabify liboctave header files
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
298 octave_idx_type& info) const; |
5785 | 299 SparseMatrix solve (MatrixType &typ, const SparseMatrix& b, |
10312
cbc402e64d83
untabify liboctave header files
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
300 octave_idx_type& info, double& rcond) const; |
5785 | 301 SparseMatrix solve (MatrixType &typ, const SparseMatrix& b, |
10312
cbc402e64d83
untabify liboctave header files
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
302 octave_idx_type& info, double& rcond, |
cbc402e64d83
untabify liboctave header files
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
303 solve_singularity_handler sing_handler, |
cbc402e64d83
untabify liboctave header files
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
304 bool singular_fallback = true) const; |
5164 | 305 |
5785 | 306 SparseComplexMatrix solve (MatrixType &typ, |
10312
cbc402e64d83
untabify liboctave header files
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
307 const SparseComplexMatrix& b) const; |
5785 | 308 SparseComplexMatrix solve (MatrixType &typ, const SparseComplexMatrix& b, |
10312
cbc402e64d83
untabify liboctave header files
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
309 octave_idx_type& info) const; |
5785 | 310 SparseComplexMatrix solve (MatrixType &typ, const SparseComplexMatrix& b, |
10312
cbc402e64d83
untabify liboctave header files
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
311 octave_idx_type& info, double& rcond) const; |
5785 | 312 SparseComplexMatrix solve (MatrixType &typ, const SparseComplexMatrix& b, |
10312
cbc402e64d83
untabify liboctave header files
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
313 octave_idx_type& info, double& rcond, |
cbc402e64d83
untabify liboctave header files
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
314 solve_singularity_handler sing_handler, |
cbc402e64d83
untabify liboctave header files
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
315 bool singular_fallabck = true) const; |
5164 | 316 |
5785 | 317 ColumnVector solve (MatrixType &typ, const ColumnVector& b) const; |
318 ColumnVector solve (MatrixType &typ, const ColumnVector& b, | |
10312
cbc402e64d83
untabify liboctave header files
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
319 octave_idx_type& info) const; |
5785 | 320 ColumnVector solve (MatrixType &typ, const ColumnVector& b, |
10312
cbc402e64d83
untabify liboctave header files
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
321 octave_idx_type& info, double& rcond) const; |
5785 | 322 ColumnVector solve (MatrixType &typ, const ColumnVector& b, |
10312
cbc402e64d83
untabify liboctave header files
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
323 octave_idx_type& info, double& rcond, |
cbc402e64d83
untabify liboctave header files
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
324 solve_singularity_handler sing_handler) const; |
5164 | 325 |
5785 | 326 ComplexColumnVector solve (MatrixType &typ, |
10312
cbc402e64d83
untabify liboctave header files
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
327 const ComplexColumnVector& b) const; |
5785 | 328 ComplexColumnVector solve (MatrixType &typ, const ComplexColumnVector& b, |
10312
cbc402e64d83
untabify liboctave header files
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
329 octave_idx_type& info) const; |
5785 | 330 ComplexColumnVector solve (MatrixType &typ, const ComplexColumnVector& b, |
10312
cbc402e64d83
untabify liboctave header files
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
331 octave_idx_type& info, double& rcond) const; |
5785 | 332 ComplexColumnVector solve (MatrixType &typ, const ComplexColumnVector& b, |
10312
cbc402e64d83
untabify liboctave header files
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
333 octave_idx_type& info, double& rcond, |
cbc402e64d83
untabify liboctave header files
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
334 solve_singularity_handler sing_handler) const; |
5164 | 335 |
336 // Generic interface to solver with probing of type | |
337 Matrix solve (const Matrix& b) const; | |
5275 | 338 Matrix solve (const Matrix& b, octave_idx_type& info) const; |
339 Matrix solve (const Matrix& b, octave_idx_type& info, double& rcond) const; | |
340 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
|
341 solve_singularity_handler sing_handler) const; |
5164 | 342 |
343 ComplexMatrix solve (const ComplexMatrix& b) const; | |
5275 | 344 ComplexMatrix solve (const ComplexMatrix& b, octave_idx_type& info) const; |
345 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
|
346 double& rcond) const; |
5275 | 347 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
|
348 solve_singularity_handler sing_handler) const; |
5164 | 349 |
350 SparseMatrix solve (const SparseMatrix& b) const; | |
5275 | 351 SparseMatrix solve (const SparseMatrix& b, octave_idx_type& info) const; |
352 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
|
353 double& rcond) const; |
5275 | 354 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
|
355 solve_singularity_handler sing_handler) const; |
5164 | 356 |
357 SparseComplexMatrix solve (const SparseComplexMatrix& b) const; | |
5275 | 358 SparseComplexMatrix solve (const SparseComplexMatrix& b, octave_idx_type& info) const; |
359 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
|
360 double& rcond) const; |
5275 | 361 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
|
362 double& rcond, |
cbc402e64d83
untabify liboctave header files
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
363 solve_singularity_handler sing_handler) const; |
5164 | 364 |
365 ColumnVector solve (const ColumnVector& b) const; | |
5275 | 366 ColumnVector solve (const ColumnVector& b, octave_idx_type& info) const; |
367 ColumnVector solve (const ColumnVector& b, octave_idx_type& info, double& rcond) const; | |
368 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
|
369 solve_singularity_handler sing_handler) const; |
5164 | 370 |
371 ComplexColumnVector solve (const ComplexColumnVector& b) const; | |
5275 | 372 ComplexColumnVector solve (const ComplexColumnVector& b, octave_idx_type& info) const; |
373 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
|
374 double& rcond) const; |
5275 | 375 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
|
376 double& rcond, |
cbc402e64d83
untabify liboctave header files
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
377 solve_singularity_handler sing_handler) const; |
5164 | 378 |
379 // other operations | |
380 | |
381 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
|
382 bool any_element_is_nan (void) const; |
5164 | 383 bool any_element_is_inf_or_nan (void) const; |
9852
aabf7a8c2e57
implement sparse logical conversion
Jaroslav Hajek <highegg@gmail.com>
parents:
9812
diff
changeset
|
384 bool any_element_not_one_or_zero (void) const; |
6989 | 385 bool all_elements_are_zero (void) const; |
5164 | 386 bool all_elements_are_int_or_inf_or_nan (void) const; |
387 bool all_integers (double& max_val, double& min_val) const; | |
388 bool too_large_for_float (void) const; | |
389 | |
390 SparseBoolMatrix operator ! (void) const; | |
391 | |
392 SparseBoolMatrix all (int dim = -1) const; | |
393 SparseBoolMatrix any (int dim = -1) const; | |
394 | |
395 SparseMatrix cumprod (int dim = -1) const; | |
396 SparseMatrix cumsum (int dim = -1) const; | |
397 SparseMatrix prod (int dim = -1) const; | |
398 SparseMatrix sum (int dim = -1) const; | |
399 SparseMatrix sumsq (int dim = -1) const; | |
400 SparseMatrix abs (void) const; | |
401 | |
5275 | 402 SparseMatrix diag (octave_idx_type k = 0) const; |
5164 | 403 |
404 Matrix matrix_value (void) const; | |
405 | |
406 SparseMatrix squeeze (void) const; | |
407 | |
10421
99e9bae2d81e
improve sparse indexing interface
Jaroslav Hajek <highegg@gmail.com>
parents:
10312
diff
changeset
|
408 SparseMatrix index (const idx_vector& i, bool resize_ok) const; |
5164 | 409 |
10421
99e9bae2d81e
improve sparse indexing interface
Jaroslav Hajek <highegg@gmail.com>
parents:
10312
diff
changeset
|
410 SparseMatrix index (const idx_vector& i, const idx_vector& j, bool resize_ok) const; |
5164 | 411 |
412 SparseMatrix reshape (const dim_vector& new_dims) const; | |
413 | |
5275 | 414 SparseMatrix permute (const Array<octave_idx_type>& vec, bool inv = false) const; |
5164 | 415 |
5275 | 416 SparseMatrix ipermute (const Array<octave_idx_type>& vec) const; |
5164 | 417 |
418 // i/o | |
419 | |
6108 | 420 friend OCTAVE_API std::ostream& operator << (std::ostream& os, const SparseMatrix& a); |
421 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
|
422 |
5164 | 423 }; |
424 | |
5509 | 425 // Publish externally used friend functions. |
426 | |
6108 | 427 extern OCTAVE_API SparseMatrix real (const SparseComplexMatrix& a); |
428 extern OCTAVE_API SparseMatrix imag (const SparseComplexMatrix& a); | |
5509 | 429 |
430 // Other operators. | |
431 | |
6108 | 432 extern OCTAVE_API SparseMatrix operator * (const SparseMatrix& a, |
10312
cbc402e64d83
untabify liboctave header files
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
433 const SparseMatrix& b); |
6108 | 434 extern OCTAVE_API Matrix operator * (const Matrix& a, |
10312
cbc402e64d83
untabify liboctave header files
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
435 const SparseMatrix& b); |
7802
1a446f28ce68
implement optimized sparse-dense transposed multiplication
Jaroslav Hajek <highegg@gmail.com>
parents:
7503
diff
changeset
|
436 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
|
437 const SparseMatrix& b); |
6108 | 438 extern OCTAVE_API Matrix operator * (const SparseMatrix& a, |
10312
cbc402e64d83
untabify liboctave header files
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
439 const Matrix& b); |
7802
1a446f28ce68
implement optimized sparse-dense transposed multiplication
Jaroslav Hajek <highegg@gmail.com>
parents:
7503
diff
changeset
|
440 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
|
441 const Matrix& b); |
5164 | 442 |
8964
f4f4d65faaa0
Implement sparse * diagonal and diagonal * sparse operations, double-prec only.
Jason Riedy <jason@acm.org>
parents:
8920
diff
changeset
|
443 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
|
444 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
|
445 |
8966
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 DiagMatrix&, const SparseMatrix&); |
1bba53c0a38d
Implement diag + sparse, diag - sparse, sparse + diag, sparse - diag.
Jason Riedy <jason@acm.org>
parents:
8964
diff
changeset
|
447 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
|
448 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
|
449 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
|
450 |
8968
91d53dc37f79
Add perm * sparse, perm \ sparse, sparse * perm, and sparse / perm operations.
Jason Riedy <jason@acm.org>
parents:
8966
diff
changeset
|
451 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
|
452 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
|
453 |
6108 | 454 extern OCTAVE_API SparseMatrix min (double d, const SparseMatrix& m); |
455 extern OCTAVE_API SparseMatrix min (const SparseMatrix& m, double d); | |
456 extern OCTAVE_API SparseMatrix min (const SparseMatrix& a, const SparseMatrix& b); | |
5164 | 457 |
6108 | 458 extern OCTAVE_API SparseMatrix max (double d, const SparseMatrix& m); |
459 extern OCTAVE_API SparseMatrix max (const SparseMatrix& m, double d); | |
460 extern OCTAVE_API SparseMatrix max (const SparseMatrix& a, const SparseMatrix& b); | |
5164 | 461 |
6708 | 462 SPARSE_SMS_CMP_OP_DECLS (SparseMatrix, double, OCTAVE_API) |
463 SPARSE_SMS_BOOL_OP_DECLS (SparseMatrix, double, OCTAVE_API) | |
5164 | 464 |
6708 | 465 SPARSE_SSM_CMP_OP_DECLS (double, SparseMatrix, OCTAVE_API) |
466 SPARSE_SSM_BOOL_OP_DECLS (double, SparseMatrix, OCTAVE_API) | |
5164 | 467 |
6708 | 468 SPARSE_SMSM_CMP_OP_DECLS (SparseMatrix, SparseMatrix, OCTAVE_API) |
469 SPARSE_SMSM_BOOL_OP_DECLS (SparseMatrix, SparseMatrix, OCTAVE_API) | |
5164 | 470 |
471 SPARSE_FORWARD_DEFS (MSparse, SparseMatrix, Matrix, double) | |
472 | |
5351 | 473 #ifdef IDX_TYPE_LONG |
5322 | 474 #define UMFPACK_DNAME(name) umfpack_dl_ ## name |
475 #else | |
476 #define UMFPACK_DNAME(name) umfpack_di_ ## name | |
477 #endif | |
478 | |
5164 | 479 #endif |