Mercurial > octave-nkf
annotate liboctave/dMatrix.h @ 10350:12884915a8e4
merge MArray classes & improve Array interface
author | Jaroslav Hajek <highegg@gmail.com> |
---|---|
date | Sat, 23 Jan 2010 21:41:03 +0100 |
parents | cbc402e64d83 |
children | a3635bc1ea19 |
rev | line source |
---|---|
458 | 1 /* |
2 | |
7017 | 3 Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2002, 2003, |
8920 | 4 2004, 2005, 2006, 2007, 2008, 2009 John W. Eaton |
458 | 5 |
6 This file is part of Octave. | |
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. | |
458 | 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/>. | |
458 | 21 |
22 */ | |
23 | |
24 #if !defined (octave_Matrix_int_h) | |
25 #define octave_Matrix_int_h 1 | |
26 | |
10350
12884915a8e4
merge MArray classes & improve Array interface
Jaroslav Hajek <highegg@gmail.com>
parents:
10312
diff
changeset
|
27 #include "MArray.h" |
12884915a8e4
merge MArray classes & improve Array interface
Jaroslav Hajek <highegg@gmail.com>
parents:
10312
diff
changeset
|
28 #include "Array2.h" |
1989 | 29 #include "MDiagArray2.h" |
5785 | 30 #include "MatrixType.h" |
458 | 31 |
32 #include "mx-defs.h" | |
8774
b756ce0002db
split implementation and interface in mx-op-defs and MArray-defs
Jaroslav Hajek <highegg@gmail.com>
parents:
8650
diff
changeset
|
33 #include "mx-op-decl.h" |
8335 | 34 #include "DET.h" |
458 | 35 |
3585 | 36 class |
6108 | 37 OCTAVE_API |
10350
12884915a8e4
merge MArray classes & improve Array interface
Jaroslav Hajek <highegg@gmail.com>
parents:
10312
diff
changeset
|
38 Matrix : public MArray<double> |
458 | 39 { |
40 public: | |
41 | |
9656
b29504415a2e
provide NDArray->Matrix->Vector typedef mappers
Jaroslav Hajek <highegg@gmail.com>
parents:
9653
diff
changeset
|
42 typedef ColumnVector column_vector_type; |
b29504415a2e
provide NDArray->Matrix->Vector typedef mappers
Jaroslav Hajek <highegg@gmail.com>
parents:
9653
diff
changeset
|
43 typedef RowVector row_vector_type; |
b29504415a2e
provide NDArray->Matrix->Vector typedef mappers
Jaroslav Hajek <highegg@gmail.com>
parents:
9653
diff
changeset
|
44 |
7788 | 45 typedef void (*solve_singularity_handler) (double rcon); |
3480 | 46 |
10350
12884915a8e4
merge MArray classes & improve Array interface
Jaroslav Hajek <highegg@gmail.com>
parents:
10312
diff
changeset
|
47 Matrix (void) : MArray<double> () { } |
3585 | 48 |
10350
12884915a8e4
merge MArray classes & improve Array interface
Jaroslav Hajek <highegg@gmail.com>
parents:
10312
diff
changeset
|
49 Matrix (octave_idx_type r, octave_idx_type c) : MArray<double> (r, c) { } |
3585 | 50 |
10350
12884915a8e4
merge MArray classes & improve Array interface
Jaroslav Hajek <highegg@gmail.com>
parents:
10312
diff
changeset
|
51 Matrix (octave_idx_type r, octave_idx_type c, double val) : MArray<double> (r, c, val) { } |
3585 | 52 |
10350
12884915a8e4
merge MArray classes & improve Array interface
Jaroslav Hajek <highegg@gmail.com>
parents:
10312
diff
changeset
|
53 Matrix (const dim_vector& dv) : MArray<double> (dv.redim (2)) { } |
6979 | 54 |
10350
12884915a8e4
merge MArray classes & improve Array interface
Jaroslav Hajek <highegg@gmail.com>
parents:
10312
diff
changeset
|
55 Matrix (const dim_vector& dv, double val) : MArray<double> (dv.redim (2), val) { } |
6979 | 56 |
10350
12884915a8e4
merge MArray classes & improve Array interface
Jaroslav Hajek <highegg@gmail.com>
parents:
10312
diff
changeset
|
57 Matrix (const Matrix& a) : MArray<double> (a) { } |
3585 | 58 |
7789
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7788
diff
changeset
|
59 template <class U> |
10350
12884915a8e4
merge MArray classes & improve Array interface
Jaroslav Hajek <highegg@gmail.com>
parents:
10312
diff
changeset
|
60 Matrix (const MArray<U>& a) : MArray<double> (a.as_matrix ()) { } |
7789
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7788
diff
changeset
|
61 |
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7788
diff
changeset
|
62 template <class U> |
10350
12884915a8e4
merge MArray classes & improve Array interface
Jaroslav Hajek <highegg@gmail.com>
parents:
10312
diff
changeset
|
63 Matrix (const Array2<U>& a) : MArray<double> (a) { } |
3585 | 64 |
10301
9e0ec19df4bc
commit accidentally omitted parts of previous change
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
65 template <class U> |
10350
12884915a8e4
merge MArray classes & improve Array interface
Jaroslav Hajek <highegg@gmail.com>
parents:
10312
diff
changeset
|
66 Matrix (const Array<U>& a) : MArray<double> (a.as_matrix ()) { } |
10301
9e0ec19df4bc
commit accidentally omitted parts of previous change
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
67 |
3585 | 68 explicit Matrix (const RowVector& rv); |
458 | 69 |
3585 | 70 explicit Matrix (const ColumnVector& cv); |
71 | |
72 explicit Matrix (const DiagMatrix& a); | |
73 | |
8367
445d27d79f4e
support permutation matrix objects
Jaroslav Hajek <highegg@gmail.com>
parents:
8336
diff
changeset
|
74 explicit Matrix (const PermMatrix& a); |
445d27d79f4e
support permutation matrix objects
Jaroslav Hajek <highegg@gmail.com>
parents:
8336
diff
changeset
|
75 |
3585 | 76 explicit Matrix (const boolMatrix& a); |
77 | |
78 explicit Matrix (const charMatrix& a); | |
1574 | 79 |
458 | 80 Matrix& operator = (const Matrix& a) |
81 { | |
10350
12884915a8e4
merge MArray classes & improve Array interface
Jaroslav Hajek <highegg@gmail.com>
parents:
10312
diff
changeset
|
82 MArray<double>::operator = (a); |
458 | 83 return *this; |
84 } | |
85 | |
2385 | 86 bool operator == (const Matrix& a) const; |
87 bool operator != (const Matrix& a) const; | |
458 | 88 |
3354 | 89 bool is_symmetric (void) const; |
90 | |
1359 | 91 // destructive insert/delete/reorder operations |
458 | 92 |
5275 | 93 Matrix& insert (const Matrix& a, octave_idx_type r, octave_idx_type c); |
94 Matrix& insert (const RowVector& a, octave_idx_type r, octave_idx_type c); | |
95 Matrix& insert (const ColumnVector& a, octave_idx_type r, octave_idx_type c); | |
96 Matrix& insert (const DiagMatrix& a, octave_idx_type r, octave_idx_type c); | |
458 | 97 |
98 Matrix& fill (double val); | |
5275 | 99 Matrix& fill (double val, octave_idx_type r1, octave_idx_type c1, octave_idx_type r2, octave_idx_type c2); |
458 | 100 |
101 Matrix append (const Matrix& a) const; | |
102 Matrix append (const RowVector& a) const; | |
103 Matrix append (const ColumnVector& a) const; | |
104 Matrix append (const DiagMatrix& a) const; | |
105 | |
106 Matrix stack (const Matrix& a) const; | |
107 Matrix stack (const RowVector& a) const; | |
108 Matrix stack (const ColumnVector& a) const; | |
109 Matrix stack (const DiagMatrix& a) const; | |
110 | |
6108 | 111 friend OCTAVE_API Matrix real (const ComplexMatrix& a); |
112 friend OCTAVE_API Matrix imag (const ComplexMatrix& a); | |
1205 | 113 |
8650
a1ae2aae903e
abs,real,imag,conj: use code from mx-inlines rather than the generic map
Jaroslav Hajek <highegg@gmail.com>
parents:
8392
diff
changeset
|
114 friend class ComplexMatrix; |
a1ae2aae903e
abs,real,imag,conj: use code from mx-inlines rather than the generic map
Jaroslav Hajek <highegg@gmail.com>
parents:
8392
diff
changeset
|
115 |
10350
12884915a8e4
merge MArray classes & improve Array interface
Jaroslav Hajek <highegg@gmail.com>
parents:
10312
diff
changeset
|
116 Matrix transpose (void) const { return MArray<double>::transpose (); } |
3225 | 117 |
1359 | 118 // resize is the destructive equivalent for this one |
458 | 119 |
5275 | 120 Matrix extract (octave_idx_type r1, octave_idx_type c1, octave_idx_type r2, octave_idx_type c2) const; |
458 | 121 |
5275 | 122 Matrix extract_n (octave_idx_type r1, octave_idx_type c1, octave_idx_type nr, octave_idx_type nc) const; |
4316 | 123 |
1359 | 124 // extract row or column i. |
458 | 125 |
5275 | 126 RowVector row (octave_idx_type i) const; |
458 | 127 |
5275 | 128 ColumnVector column (octave_idx_type i) const; |
458 | 129 |
6207 | 130 private: |
7788 | 131 Matrix tinverse (MatrixType &mattype, octave_idx_type& info, double& rcon, |
10312
cbc402e64d83
untabify liboctave header files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
132 int force, int calc_cond) const; |
6207 | 133 |
7788 | 134 Matrix finverse (MatrixType &mattype, octave_idx_type& info, double& rcon, |
10312
cbc402e64d83
untabify liboctave header files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
135 int force, int calc_cond) const; |
6207 | 136 |
137 public: | |
458 | 138 Matrix inverse (void) const; |
6479 | 139 Matrix inverse (octave_idx_type& info) const; |
7788 | 140 Matrix inverse (octave_idx_type& info, double& rcon, int force = 0, |
10312
cbc402e64d83
untabify liboctave header files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
141 int calc_cond = 1) const; |
6479 | 142 |
6207 | 143 Matrix inverse (MatrixType &mattype) const; |
144 Matrix inverse (MatrixType &mattype, octave_idx_type& info) const; | |
7788 | 145 Matrix inverse (MatrixType &mattype, octave_idx_type& info, double& rcon, |
10312
cbc402e64d83
untabify liboctave header files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
146 int force = 0, int calc_cond = 1) const; |
458 | 147 |
4384 | 148 Matrix pseudo_inverse (double tol = 0.0) const; |
740 | 149 |
458 | 150 ComplexMatrix fourier (void) const; |
151 ComplexMatrix ifourier (void) const; | |
152 | |
677 | 153 ComplexMatrix fourier2d (void) const; |
154 ComplexMatrix ifourier2d (void) const; | |
155 | |
458 | 156 DET determinant (void) const; |
5275 | 157 DET determinant (octave_idx_type& info) const; |
7788 | 158 DET determinant (octave_idx_type& info, double& rcon, int calc_cond = 1) const; |
8336
9813c07ca946
make det take advantage of matrix type
Jaroslav Hajek <highegg@gmail.com>
parents:
8335
diff
changeset
|
159 DET determinant (MatrixType &mattype, octave_idx_type& info, |
9813c07ca946
make det take advantage of matrix type
Jaroslav Hajek <highegg@gmail.com>
parents:
8335
diff
changeset
|
160 double& rcon, int calc_cond = 1) const; |
7788 | 161 |
162 double rcond (void) const; | |
163 double rcond (MatrixType &mattype) const; | |
458 | 164 |
5785 | 165 private: |
166 // Upper triangular matrix solvers | |
167 Matrix utsolve (MatrixType &typ, const Matrix& b, octave_idx_type& info, | |
10312
cbc402e64d83
untabify liboctave header files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
168 double& rcon, solve_singularity_handler sing_handler, |
cbc402e64d83
untabify liboctave header files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
169 bool calc_cond = false, blas_trans_type transt = blas_no_trans) const; |
5785 | 170 |
171 // Lower triangular matrix solvers | |
172 Matrix ltsolve (MatrixType &typ, const Matrix& b, octave_idx_type& info, | |
10312
cbc402e64d83
untabify liboctave header files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
173 double& rcon, solve_singularity_handler sing_handler, |
cbc402e64d83
untabify liboctave header files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
174 bool calc_cond = false, blas_trans_type transt = blas_no_trans) const; |
5785 | 175 |
176 // Full matrix solvers (lu/cholesky) | |
177 Matrix fsolve (MatrixType &typ, const Matrix& b, octave_idx_type& info, | |
10312
cbc402e64d83
untabify liboctave header files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
178 double& rcon, solve_singularity_handler sing_handler, |
cbc402e64d83
untabify liboctave header files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
179 bool calc_cond = false) const; |
5785 | 180 |
181 public: | |
182 // Generic interface to solver with no probing of type | |
183 Matrix solve (MatrixType &typ, const Matrix& b) const; | |
184 Matrix solve (MatrixType &typ, const Matrix& b, octave_idx_type& info) const; | |
185 Matrix solve (MatrixType &typ, const Matrix& b, octave_idx_type& info, | |
10312
cbc402e64d83
untabify liboctave header files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
186 double& rcon) const; |
5785 | 187 Matrix solve (MatrixType &typ, const Matrix& b, octave_idx_type& info, |
10312
cbc402e64d83
untabify liboctave header files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
188 double& rcon, solve_singularity_handler sing_handler, |
cbc402e64d83
untabify liboctave header files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
189 bool singular_fallback = true, blas_trans_type transt = blas_no_trans) const; |
5785 | 190 |
191 ComplexMatrix solve (MatrixType &typ, const ComplexMatrix& b) const; | |
192 ComplexMatrix solve (MatrixType &typ, const ComplexMatrix& b, | |
10312
cbc402e64d83
untabify liboctave header files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
193 octave_idx_type& info) const; |
5785 | 194 ComplexMatrix solve (MatrixType &typ, const ComplexMatrix& b, |
10312
cbc402e64d83
untabify liboctave header files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
195 octave_idx_type& info, double& rcon) const; |
5785 | 196 ComplexMatrix solve (MatrixType &typ, const ComplexMatrix& b, |
10312
cbc402e64d83
untabify liboctave header files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
197 octave_idx_type& info, double& rcon, |
cbc402e64d83
untabify liboctave header files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
198 solve_singularity_handler sing_handler, |
cbc402e64d83
untabify liboctave header files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
199 bool singular_fallback = true, |
9661
afcf852256d2
optimize / and '\ for triangular matrices
Jaroslav Hajek <highegg@gmail.com>
parents:
9656
diff
changeset
|
200 blas_trans_type transt = blas_no_trans) const; |
5785 | 201 |
202 ColumnVector solve (MatrixType &typ, const ColumnVector& b) const; | |
203 ColumnVector solve (MatrixType &typ, const ColumnVector& b, | |
10312
cbc402e64d83
untabify liboctave header files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
204 octave_idx_type& info) const; |
5785 | 205 ColumnVector solve (MatrixType &typ, const ColumnVector& b, |
10312
cbc402e64d83
untabify liboctave header files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
206 octave_idx_type& info, double& rcon) const; |
5785 | 207 ColumnVector solve (MatrixType &typ, const ColumnVector& b, |
10312
cbc402e64d83
untabify liboctave header files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
208 octave_idx_type& info, double& rcon, |
cbc402e64d83
untabify liboctave header files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
209 solve_singularity_handler sing_handler, |
9661
afcf852256d2
optimize / and '\ for triangular matrices
Jaroslav Hajek <highegg@gmail.com>
parents:
9656
diff
changeset
|
210 blas_trans_type transt = blas_no_trans) const; |
5785 | 211 |
212 ComplexColumnVector solve (MatrixType &typ, | |
10312
cbc402e64d83
untabify liboctave header files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
213 const ComplexColumnVector& b) const; |
5785 | 214 ComplexColumnVector solve (MatrixType &typ, const ComplexColumnVector& b, |
10312
cbc402e64d83
untabify liboctave header files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
215 octave_idx_type& info) const; |
5785 | 216 ComplexColumnVector solve (MatrixType &typ, const ComplexColumnVector& b, |
10312
cbc402e64d83
untabify liboctave header files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
217 octave_idx_type& info, double& rcon) const; |
5785 | 218 ComplexColumnVector solve (MatrixType &typ, const ComplexColumnVector& b, |
10312
cbc402e64d83
untabify liboctave header files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
219 octave_idx_type& info, double& rcon, |
cbc402e64d83
untabify liboctave header files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
220 solve_singularity_handler sing_handler, |
9661
afcf852256d2
optimize / and '\ for triangular matrices
Jaroslav Hajek <highegg@gmail.com>
parents:
9656
diff
changeset
|
221 blas_trans_type transt = blas_no_trans) const; |
5785 | 222 |
223 // Generic interface to solver with probing of type | |
458 | 224 Matrix solve (const Matrix& b) const; |
5275 | 225 Matrix solve (const Matrix& b, octave_idx_type& info) const; |
7788 | 226 Matrix solve (const Matrix& b, octave_idx_type& info, double& rcon) const; |
227 Matrix solve (const Matrix& b, octave_idx_type& info, double& rcon, | |
10312
cbc402e64d83
untabify liboctave header files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
228 solve_singularity_handler sing_handler, |
9661
afcf852256d2
optimize / and '\ for triangular matrices
Jaroslav Hajek <highegg@gmail.com>
parents:
9656
diff
changeset
|
229 blas_trans_type transt = blas_no_trans) const; |
458 | 230 |
231 ComplexMatrix solve (const ComplexMatrix& b) const; | |
5275 | 232 ComplexMatrix solve (const ComplexMatrix& b, octave_idx_type& info) const; |
7788 | 233 ComplexMatrix solve (const ComplexMatrix& b, octave_idx_type& info, double& rcon) const; |
234 ComplexMatrix solve (const ComplexMatrix& b, octave_idx_type& info, double& rcon, | |
10312
cbc402e64d83
untabify liboctave header files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
235 solve_singularity_handler sing_handler, |
9661
afcf852256d2
optimize / and '\ for triangular matrices
Jaroslav Hajek <highegg@gmail.com>
parents:
9656
diff
changeset
|
236 blas_trans_type transt = blas_no_trans) const; |
458 | 237 |
238 ColumnVector solve (const ColumnVector& b) const; | |
5275 | 239 ColumnVector solve (const ColumnVector& b, octave_idx_type& info) const; |
7788 | 240 ColumnVector solve (const ColumnVector& b, octave_idx_type& info, double& rcon) const; |
241 ColumnVector solve (const ColumnVector& b, octave_idx_type& info, double& rcon, | |
10312
cbc402e64d83
untabify liboctave header files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
242 solve_singularity_handler sing_handler, |
9661
afcf852256d2
optimize / and '\ for triangular matrices
Jaroslav Hajek <highegg@gmail.com>
parents:
9656
diff
changeset
|
243 blas_trans_type transt = blas_no_trans) const; |
458 | 244 |
245 ComplexColumnVector solve (const ComplexColumnVector& b) const; | |
5275 | 246 ComplexColumnVector solve (const ComplexColumnVector& b, octave_idx_type& info) const; |
247 ComplexColumnVector solve (const ComplexColumnVector& b, octave_idx_type& info, | |
10312
cbc402e64d83
untabify liboctave header files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
248 double& rcon) const; |
5275 | 249 ComplexColumnVector solve (const ComplexColumnVector& b, octave_idx_type& info, |
10312
cbc402e64d83
untabify liboctave header files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
250 double& rcon, solve_singularity_handler sing_handler, |
9661
afcf852256d2
optimize / and '\ for triangular matrices
Jaroslav Hajek <highegg@gmail.com>
parents:
9656
diff
changeset
|
251 blas_trans_type transt = blas_no_trans) const; |
458 | 252 |
5785 | 253 // Singular solvers |
458 | 254 Matrix lssolve (const Matrix& b) const; |
5275 | 255 Matrix lssolve (const Matrix& b, octave_idx_type& info) const; |
7076 | 256 Matrix lssolve (const Matrix& b, octave_idx_type& info, |
10312
cbc402e64d83
untabify liboctave header files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
257 octave_idx_type& rank) const; |
7076 | 258 Matrix lssolve (const Matrix& b, octave_idx_type& info, |
10312
cbc402e64d83
untabify liboctave header files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
259 octave_idx_type& rank, double& rcon) const; |
458 | 260 |
261 ComplexMatrix lssolve (const ComplexMatrix& b) const; | |
5275 | 262 ComplexMatrix lssolve (const ComplexMatrix& b, octave_idx_type& info) const; |
263 ComplexMatrix lssolve (const ComplexMatrix& b, octave_idx_type& info, | |
10312
cbc402e64d83
untabify liboctave header files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
264 octave_idx_type& rank) const; |
7076 | 265 ComplexMatrix lssolve (const ComplexMatrix& b, octave_idx_type& info, |
10312
cbc402e64d83
untabify liboctave header files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
266 octave_idx_type& rank, double &rcon) const; |
458 | 267 |
268 ColumnVector lssolve (const ColumnVector& b) const; | |
5275 | 269 ColumnVector lssolve (const ColumnVector& b, octave_idx_type& info) const; |
7076 | 270 ColumnVector lssolve (const ColumnVector& b, octave_idx_type& info, |
10312
cbc402e64d83
untabify liboctave header files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
271 octave_idx_type& rank) const; |
7076 | 272 ColumnVector lssolve (const ColumnVector& b, octave_idx_type& info, |
10312
cbc402e64d83
untabify liboctave header files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
273 octave_idx_type& rank, double& rcon) const; |
458 | 274 |
275 ComplexColumnVector lssolve (const ComplexColumnVector& b) const; | |
7076 | 276 ComplexColumnVector lssolve (const ComplexColumnVector& b, |
10312
cbc402e64d83
untabify liboctave header files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
277 octave_idx_type& info) const; |
7076 | 278 ComplexColumnVector lssolve (const ComplexColumnVector& b, |
10312
cbc402e64d83
untabify liboctave header files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
279 octave_idx_type& info, |
cbc402e64d83
untabify liboctave header files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
280 octave_idx_type& rank) const; |
7076 | 281 ComplexColumnVector lssolve (const ComplexColumnVector& b, |
10312
cbc402e64d83
untabify liboctave header files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
282 octave_idx_type& info, |
cbc402e64d83
untabify liboctave header files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
283 octave_idx_type& rank, double& rcon) const; |
458 | 284 |
285 Matrix& operator += (const DiagMatrix& a); | |
286 Matrix& operator -= (const DiagMatrix& a); | |
287 | |
1359 | 288 // unary operations |
458 | 289 |
2964 | 290 boolMatrix operator ! (void) const; |
458 | 291 |
1359 | 292 // other operations |
458 | 293 |
4431 | 294 bool any_element_is_negative (bool = false) const; |
7922
935be827eaf8
error for NaN values in & and | expressions
John W. Eaton <jwe@octave.org>
parents:
7800
diff
changeset
|
295 bool any_element_is_nan (void) const; |
2385 | 296 bool any_element_is_inf_or_nan (void) const; |
5943 | 297 bool any_element_not_one_or_zero (void) const; |
2385 | 298 bool all_elements_are_int_or_inf_or_nan (void) const; |
299 bool all_integers (double& max_val, double& min_val) const; | |
300 bool too_large_for_float (void) const; | |
1963 | 301 |
4017 | 302 boolMatrix all (int dim = -1) const; |
303 boolMatrix any (int dim = -1) const; | |
458 | 304 |
4017 | 305 Matrix cumprod (int dim = -1) const; |
306 Matrix cumsum (int dim = -1) const; | |
307 Matrix prod (int dim = -1) const; | |
308 Matrix sum (int dim = -1) const; | |
309 Matrix sumsq (int dim = -1) const; | |
2385 | 310 Matrix abs (void) const; |
458 | 311 |
7620
36594d5bbe13
Move diag function into the octave_value class
David Bateman <dbateman@free.fr>
parents:
7503
diff
changeset
|
312 Matrix diag (octave_idx_type k = 0) const; |
458 | 313 |
314 ColumnVector row_min (void) const; | |
2354 | 315 ColumnVector row_max (void) const; |
458 | 316 |
5275 | 317 ColumnVector row_min (Array<octave_idx_type>& index) const; |
318 ColumnVector row_max (Array<octave_idx_type>& index) const; | |
458 | 319 |
320 RowVector column_min (void) const; | |
2354 | 321 RowVector column_max (void) const; |
458 | 322 |
5275 | 323 RowVector column_min (Array<octave_idx_type>& index) const; |
324 RowVector column_max (Array<octave_idx_type>& index) const; | |
458 | 325 |
1359 | 326 // i/o |
458 | 327 |
6108 | 328 friend OCTAVE_API std::ostream& operator << (std::ostream& os, const Matrix& a); |
329 friend OCTAVE_API std::istream& operator >> (std::istream& is, Matrix& a); | |
458 | 330 |
3933 | 331 static double resize_fill_value (void) { return 0; } |
332 | |
458 | 333 private: |
334 | |
10350
12884915a8e4
merge MArray classes & improve Array interface
Jaroslav Hajek <highegg@gmail.com>
parents:
10312
diff
changeset
|
335 Matrix (double *d, octave_idx_type r, octave_idx_type c) : MArray<double> (d, r, c) { } |
458 | 336 }; |
337 | |
5508 | 338 // Publish externally used friend functions. |
339 | |
6108 | 340 extern OCTAVE_API Matrix real (const ComplexMatrix& a); |
341 extern OCTAVE_API Matrix imag (const ComplexMatrix& a); | |
5508 | 342 |
343 // column vector by row vector -> matrix operations | |
344 | |
6108 | 345 extern OCTAVE_API Matrix operator * (const ColumnVector& a, const RowVector& b); |
5508 | 346 |
347 // Other functions. | |
348 | |
6108 | 349 extern OCTAVE_API Matrix Givens (double, double); |
1819 | 350 |
6108 | 351 extern OCTAVE_API Matrix Sylvester (const Matrix&, const Matrix&, const Matrix&); |
1959 | 352 |
9665
1dba57e9d08d
use blas_trans_type for xgemm
Jaroslav Hajek <highegg@gmail.com>
parents:
9661
diff
changeset
|
353 extern OCTAVE_API Matrix xgemm (const Matrix& a, const Matrix& b, |
1dba57e9d08d
use blas_trans_type for xgemm
Jaroslav Hajek <highegg@gmail.com>
parents:
9661
diff
changeset
|
354 blas_trans_type transa = blas_no_trans, |
1dba57e9d08d
use blas_trans_type for xgemm
Jaroslav Hajek <highegg@gmail.com>
parents:
9661
diff
changeset
|
355 blas_trans_type transb = blas_no_trans); |
7800
5861b95e9879
support for compound operators, implement trans_mul, mul_trans, herm_mul and mul_herm
Jaroslav Hajek <highegg@gmail.com>
parents:
7789
diff
changeset
|
356 |
6108 | 357 extern OCTAVE_API Matrix operator * (const Matrix& a, const Matrix& b); |
2828 | 358 |
6108 | 359 extern OCTAVE_API Matrix min (double d, const Matrix& m); |
360 extern OCTAVE_API Matrix min (const Matrix& m, double d); | |
361 extern OCTAVE_API Matrix min (const Matrix& a, const Matrix& b); | |
4309 | 362 |
6108 | 363 extern OCTAVE_API Matrix max (double d, const Matrix& m); |
364 extern OCTAVE_API Matrix max (const Matrix& m, double d); | |
365 extern OCTAVE_API Matrix max (const Matrix& a, const Matrix& b); | |
4309 | 366 |
9653
e087d7c77ff9
improve linspace in liboctave
Jaroslav Hajek <highegg@gmail.com>
parents:
8920
diff
changeset
|
367 extern OCTAVE_API Matrix linspace (const ColumnVector& x1, |
e087d7c77ff9
improve linspace in liboctave
Jaroslav Hajek <highegg@gmail.com>
parents:
8920
diff
changeset
|
368 const ColumnVector& x2, |
e087d7c77ff9
improve linspace in liboctave
Jaroslav Hajek <highegg@gmail.com>
parents:
8920
diff
changeset
|
369 octave_idx_type n); |
e087d7c77ff9
improve linspace in liboctave
Jaroslav Hajek <highegg@gmail.com>
parents:
8920
diff
changeset
|
370 |
6708 | 371 MS_CMP_OP_DECLS (Matrix, double, OCTAVE_API) |
372 MS_BOOL_OP_DECLS (Matrix, double, OCTAVE_API) | |
2870 | 373 |
6708 | 374 SM_CMP_OP_DECLS (double, Matrix, OCTAVE_API) |
375 SM_BOOL_OP_DECLS (double, Matrix, OCTAVE_API) | |
2870 | 376 |
6708 | 377 MM_CMP_OP_DECLS (Matrix, Matrix, OCTAVE_API) |
378 MM_BOOL_OP_DECLS (Matrix, Matrix, OCTAVE_API) | |
2870 | 379 |
10350
12884915a8e4
merge MArray classes & improve Array interface
Jaroslav Hajek <highegg@gmail.com>
parents:
10312
diff
changeset
|
380 MARRAY_FORWARD_DEFS (MArray, Matrix, double) |
3573 | 381 |
3689 | 382 template <class T> |
383 void read_int (std::istream& is, bool swap_bytes, T& val); | |
384 | |
458 | 385 #endif |