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