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