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