Mercurial > octave
annotate liboctave/array/dMatrix.h @ 21273:cbced1c09916
better use of templates for svd classes
* liboctave/numeric/svd.h, liboctave/numeric/svd.cc: New files for svd
classes generated from CmplxSVD.cc, CmplxSVD.h, dbleSVD.cc, dbleSVD.h,
fCmplxSVD.cc, fCmplxSVD.h, floatSVD.cc, and floatSVD.h and converted
to templates.
* liboctave/numeric/module.mk: Update.
* __qp__.cc, svd.cc, CMatrix.cc, CMatrix.h, dDiagMatrix.h, dMatrix.cc,
dMatrix.h, fCMatrix.cc, fCMatrix.h, fDiagMatrix.h, fMatrix.cc,
fMatrix.h, oct-norm.cc, mx-defs.h, mx-ext.h: Use new classes.
author | John W. Eaton <jwe@octave.org> |
---|---|
date | Tue, 16 Feb 2016 14:41:06 -0500 |
parents | 230e186e292d |
children | ff054947d132 |
rev | line source |
---|---|
458 | 1 /* |
2 | |
19697
4197fc428c7d
maint: Update copyright notices for 2015.
John W. Eaton <jwe@octave.org>
parents:
19391
diff
changeset
|
3 Copyright (C) 1994-2015 John W. Eaton |
458 | 4 |
5 This file is part of Octave. | |
6 | |
7 Octave is free software; you can redistribute it and/or modify it | |
8 under the terms of the GNU General Public License as published by the | |
7016 | 9 Free Software Foundation; either version 3 of the License, or (at your |
10 option) any later version. | |
458 | 11 |
12 Octave is distributed in the hope that it will be useful, but WITHOUT | |
13 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or | |
14 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License | |
15 for more details. | |
16 | |
17 You should have received a copy of the GNU General Public License | |
7016 | 18 along with Octave; see the file COPYING. If not, see |
19 <http://www.gnu.org/licenses/>. | |
458 | 20 |
21 */ | |
22 | |
20791
f7084eae3318
maint: Use Octave coding conventions for #if statements.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
23 #if ! defined (octave_dMatrix_h) |
17822
ebb3ef964372
maint: Use common #define syntax "octave_filename_h" in h_files.
Rik <rik@octave.org>
parents:
17769
diff
changeset
|
24 #define octave_dMatrix_h 1 |
458 | 25 |
21244
1473547f50f5
include octave-config.h in public header files
John W. Eaton <jwe@octave.org>
parents:
21139
diff
changeset
|
26 #include "octave-config.h" |
1473547f50f5
include octave-config.h in public header files
John W. Eaton <jwe@octave.org>
parents:
21139
diff
changeset
|
27 |
19320
d0c73e23a505
Change inheritance tree so that <T>Matrix inherit from <T>NDArray.
Carnë Draug <carandraug@octave.org>
parents:
17822
diff
changeset
|
28 #include "dNDArray.h" |
10350
12884915a8e4
merge MArray classes & improve Array interface
Jaroslav Hajek <highegg@gmail.com>
parents:
10312
diff
changeset
|
29 #include "MArray.h" |
1989 | 30 #include "MDiagArray2.h" |
5785 | 31 #include "MatrixType.h" |
458 | 32 |
33 #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
|
34 #include "mx-op-decl.h" |
8335 | 35 #include "DET.h" |
458 | 36 |
3585 | 37 class |
6108 | 38 OCTAVE_API |
19320
d0c73e23a505
Change inheritance tree so that <T>Matrix inherit from <T>NDArray.
Carnë Draug <carandraug@octave.org>
parents:
17822
diff
changeset
|
39 Matrix : public NDArray |
458 | 40 { |
41 public: | |
42 | |
9656
b29504415a2e
provide NDArray->Matrix->Vector typedef mappers
Jaroslav Hajek <highegg@gmail.com>
parents:
9653
diff
changeset
|
43 typedef ColumnVector column_vector_type; |
b29504415a2e
provide NDArray->Matrix->Vector typedef mappers
Jaroslav Hajek <highegg@gmail.com>
parents:
9653
diff
changeset
|
44 typedef RowVector row_vector_type; |
b29504415a2e
provide NDArray->Matrix->Vector typedef mappers
Jaroslav Hajek <highegg@gmail.com>
parents:
9653
diff
changeset
|
45 |
21268
f08ae27289e4
better use of templates for balance classes
John W. Eaton <jwe@octave.org>
parents:
21244
diff
changeset
|
46 typedef ColumnVector real_column_vector_type; |
f08ae27289e4
better use of templates for balance classes
John W. Eaton <jwe@octave.org>
parents:
21244
diff
changeset
|
47 typedef RowVector real_row_vector_type; |
f08ae27289e4
better use of templates for balance classes
John W. Eaton <jwe@octave.org>
parents:
21244
diff
changeset
|
48 |
f08ae27289e4
better use of templates for balance classes
John W. Eaton <jwe@octave.org>
parents:
21244
diff
changeset
|
49 typedef Matrix real_matrix_type; |
f08ae27289e4
better use of templates for balance classes
John W. Eaton <jwe@octave.org>
parents:
21244
diff
changeset
|
50 typedef ComplexMatrix complex_matrix_type; |
f08ae27289e4
better use of templates for balance classes
John W. Eaton <jwe@octave.org>
parents:
21244
diff
changeset
|
51 |
21273
cbced1c09916
better use of templates for svd classes
John W. Eaton <jwe@octave.org>
parents:
21270
diff
changeset
|
52 typedef DiagMatrix real_diag_matrix_type; |
cbced1c09916
better use of templates for svd classes
John W. Eaton <jwe@octave.org>
parents:
21270
diff
changeset
|
53 typedef ComplexDiagMatrix complex_diag_matrix_type; |
cbced1c09916
better use of templates for svd classes
John W. Eaton <jwe@octave.org>
parents:
21270
diff
changeset
|
54 |
21269
3c8a3d35661a
better use of templates for Cholesky factorization
John W. Eaton <jwe@octave.org>
parents:
21268
diff
changeset
|
55 typedef double real_elt_type; |
3c8a3d35661a
better use of templates for Cholesky factorization
John W. Eaton <jwe@octave.org>
parents:
21268
diff
changeset
|
56 typedef Complex complex_elt_type; |
3c8a3d35661a
better use of templates for Cholesky factorization
John W. Eaton <jwe@octave.org>
parents:
21268
diff
changeset
|
57 |
7788 | 58 typedef void (*solve_singularity_handler) (double rcon); |
3480 | 59 |
19320
d0c73e23a505
Change inheritance tree so that <T>Matrix inherit from <T>NDArray.
Carnë Draug <carandraug@octave.org>
parents:
17822
diff
changeset
|
60 Matrix (void) : NDArray () { } |
3585 | 61 |
11570
57632dea2446
attempt better backward compatibility for Array constructors
John W. Eaton <jwe@octave.org>
parents:
11523
diff
changeset
|
62 Matrix (octave_idx_type r, octave_idx_type c) |
19320
d0c73e23a505
Change inheritance tree so that <T>Matrix inherit from <T>NDArray.
Carnë Draug <carandraug@octave.org>
parents:
17822
diff
changeset
|
63 : NDArray (dim_vector (r, c)) { } |
3585 | 64 |
11570
57632dea2446
attempt better backward compatibility for Array constructors
John W. Eaton <jwe@octave.org>
parents:
11523
diff
changeset
|
65 Matrix (octave_idx_type r, octave_idx_type c, double val) |
19320
d0c73e23a505
Change inheritance tree so that <T>Matrix inherit from <T>NDArray.
Carnë Draug <carandraug@octave.org>
parents:
17822
diff
changeset
|
66 : NDArray (dim_vector (r, c), val) { } |
3585 | 67 |
19320
d0c73e23a505
Change inheritance tree so that <T>Matrix inherit from <T>NDArray.
Carnë Draug <carandraug@octave.org>
parents:
17822
diff
changeset
|
68 Matrix (const dim_vector& dv) : NDArray (dv.redim (2)) { } |
6979 | 69 |
11570
57632dea2446
attempt better backward compatibility for Array constructors
John W. Eaton <jwe@octave.org>
parents:
11523
diff
changeset
|
70 Matrix (const dim_vector& dv, double val) |
19320
d0c73e23a505
Change inheritance tree so that <T>Matrix inherit from <T>NDArray.
Carnë Draug <carandraug@octave.org>
parents:
17822
diff
changeset
|
71 : NDArray (dv.redim (2), val) { } |
6979 | 72 |
19320
d0c73e23a505
Change inheritance tree so that <T>Matrix inherit from <T>NDArray.
Carnë Draug <carandraug@octave.org>
parents:
17822
diff
changeset
|
73 Matrix (const Matrix& a) : NDArray (a) { } |
3585 | 74 |
21139
538b57866b90
consistently use "typename" intead of "class" in template declarations
John W. Eaton <jwe@octave.org>
parents:
20791
diff
changeset
|
75 template <typename U> |
19320
d0c73e23a505
Change inheritance tree so that <T>Matrix inherit from <T>NDArray.
Carnë Draug <carandraug@octave.org>
parents:
17822
diff
changeset
|
76 Matrix (const MArray<U>& a) : NDArray (a.as_matrix ()) { } |
7789
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7788
diff
changeset
|
77 |
21139
538b57866b90
consistently use "typename" intead of "class" in template declarations
John W. Eaton <jwe@octave.org>
parents:
20791
diff
changeset
|
78 template <typename U> |
19320
d0c73e23a505
Change inheritance tree so that <T>Matrix inherit from <T>NDArray.
Carnë Draug <carandraug@octave.org>
parents:
17822
diff
changeset
|
79 Matrix (const Array<U>& a) : NDArray (a.as_matrix ()) { } |
10301
9e0ec19df4bc
commit accidentally omitted parts of previous change
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
80 |
3585 | 81 explicit Matrix (const RowVector& rv); |
458 | 82 |
3585 | 83 explicit Matrix (const ColumnVector& cv); |
84 | |
85 explicit Matrix (const DiagMatrix& a); | |
86 | |
19391
385499581a5e
allow disabling of permutation and diagonal matrices
John W. Eaton <jwe@octave.org>
parents:
19321
diff
changeset
|
87 explicit Matrix (const MDiagArray2<double>& a); |
385499581a5e
allow disabling of permutation and diagonal matrices
John W. Eaton <jwe@octave.org>
parents:
19321
diff
changeset
|
88 |
385499581a5e
allow disabling of permutation and diagonal matrices
John W. Eaton <jwe@octave.org>
parents:
19321
diff
changeset
|
89 explicit Matrix (const DiagArray2<double>& a); |
385499581a5e
allow disabling of permutation and diagonal matrices
John W. Eaton <jwe@octave.org>
parents:
19321
diff
changeset
|
90 |
8367
445d27d79f4e
support permutation matrix objects
Jaroslav Hajek <highegg@gmail.com>
parents:
8336
diff
changeset
|
91 explicit Matrix (const PermMatrix& a); |
445d27d79f4e
support permutation matrix objects
Jaroslav Hajek <highegg@gmail.com>
parents:
8336
diff
changeset
|
92 |
3585 | 93 explicit Matrix (const boolMatrix& a); |
94 | |
95 explicit Matrix (const charMatrix& a); | |
1574 | 96 |
2385 | 97 bool operator == (const Matrix& a) const; |
98 bool operator != (const Matrix& a) const; | |
458 | 99 |
3354 | 100 bool is_symmetric (void) const; |
101 | |
1359 | 102 // destructive insert/delete/reorder operations |
458 | 103 |
5275 | 104 Matrix& insert (const Matrix& a, octave_idx_type r, octave_idx_type c); |
105 Matrix& insert (const RowVector& a, octave_idx_type r, octave_idx_type c); | |
106 Matrix& insert (const ColumnVector& a, octave_idx_type r, octave_idx_type c); | |
107 Matrix& insert (const DiagMatrix& a, octave_idx_type r, octave_idx_type c); | |
458 | 108 |
109 Matrix& fill (double val); | |
17769
49a5a4be04a1
maint: Use GNU style coding conventions for code in liboctave/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
110 Matrix& fill (double val, octave_idx_type r1, octave_idx_type c1, |
49a5a4be04a1
maint: Use GNU style coding conventions for code in liboctave/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
111 octave_idx_type r2, octave_idx_type c2); |
458 | 112 |
113 Matrix append (const Matrix& a) const; | |
114 Matrix append (const RowVector& a) const; | |
115 Matrix append (const ColumnVector& a) const; | |
116 Matrix append (const DiagMatrix& a) const; | |
117 | |
118 Matrix stack (const Matrix& a) const; | |
119 Matrix stack (const RowVector& a) const; | |
120 Matrix stack (const ColumnVector& a) const; | |
121 Matrix stack (const DiagMatrix& a) const; | |
122 | |
6108 | 123 friend OCTAVE_API Matrix real (const ComplexMatrix& a); |
124 friend OCTAVE_API Matrix imag (const ComplexMatrix& a); | |
1205 | 125 |
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
|
126 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
|
127 |
21270
230e186e292d
make building without qrupdate work again
John W. Eaton <jwe@octave.org>
parents:
21269
diff
changeset
|
128 Matrix hermitian (void) const { return MArray<double>::transpose (); } |
10350
12884915a8e4
merge MArray classes & improve Array interface
Jaroslav Hajek <highegg@gmail.com>
parents:
10312
diff
changeset
|
129 Matrix transpose (void) const { return MArray<double>::transpose (); } |
3225 | 130 |
1359 | 131 // resize is the destructive equivalent for this one |
458 | 132 |
17769
49a5a4be04a1
maint: Use GNU style coding conventions for code in liboctave/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
133 Matrix extract (octave_idx_type r1, octave_idx_type c1, |
49a5a4be04a1
maint: Use GNU style coding conventions for code in liboctave/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
134 octave_idx_type r2, octave_idx_type c2) const; |
458 | 135 |
17769
49a5a4be04a1
maint: Use GNU style coding conventions for code in liboctave/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
136 Matrix extract_n (octave_idx_type r1, octave_idx_type c1, |
49a5a4be04a1
maint: Use GNU style coding conventions for code in liboctave/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
137 octave_idx_type nr, octave_idx_type nc) const; |
4316 | 138 |
1359 | 139 // extract row or column i. |
458 | 140 |
5275 | 141 RowVector row (octave_idx_type i) const; |
458 | 142 |
5275 | 143 ColumnVector column (octave_idx_type i) const; |
458 | 144 |
14616
13cc11418393
improve handling of default resize fill value for arrays
John W. Eaton <jwe@octave.org>
parents:
14557
diff
changeset
|
145 void resize (octave_idx_type nr, octave_idx_type nc, double rfv = 0) |
11574
a83bad07f7e3
attempt better backward compatibility for Array resize functions
John W. Eaton <jwe@octave.org>
parents:
11570
diff
changeset
|
146 { |
a83bad07f7e3
attempt better backward compatibility for Array resize functions
John W. Eaton <jwe@octave.org>
parents:
11570
diff
changeset
|
147 MArray<double>::resize (dim_vector (nr, nc), rfv); |
a83bad07f7e3
attempt better backward compatibility for Array resize functions
John W. Eaton <jwe@octave.org>
parents:
11570
diff
changeset
|
148 } |
a83bad07f7e3
attempt better backward compatibility for Array resize functions
John W. Eaton <jwe@octave.org>
parents:
11570
diff
changeset
|
149 |
6207 | 150 private: |
11586
12df7854fa7c
strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents:
11574
diff
changeset
|
151 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
|
152 int force, int calc_cond) const; |
6207 | 153 |
11586
12df7854fa7c
strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents:
11574
diff
changeset
|
154 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
|
155 int force, int calc_cond) const; |
6207 | 156 |
157 public: | |
458 | 158 Matrix inverse (void) const; |
6479 | 159 Matrix inverse (octave_idx_type& info) const; |
7788 | 160 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
|
161 int calc_cond = 1) const; |
6479 | 162 |
6207 | 163 Matrix inverse (MatrixType &mattype) const; |
164 Matrix inverse (MatrixType &mattype, octave_idx_type& info) const; | |
7788 | 165 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
|
166 int force = 0, int calc_cond = 1) const; |
458 | 167 |
4384 | 168 Matrix pseudo_inverse (double tol = 0.0) const; |
740 | 169 |
458 | 170 ComplexMatrix fourier (void) const; |
171 ComplexMatrix ifourier (void) const; | |
172 | |
677 | 173 ComplexMatrix fourier2d (void) const; |
174 ComplexMatrix ifourier2d (void) const; | |
175 | |
458 | 176 DET determinant (void) const; |
5275 | 177 DET determinant (octave_idx_type& info) const; |
17769
49a5a4be04a1
maint: Use GNU style coding conventions for code in liboctave/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
178 DET determinant (octave_idx_type& info, double& rcon, |
49a5a4be04a1
maint: Use GNU style coding conventions for code in liboctave/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
179 int calc_cond = 1) const; |
11586
12df7854fa7c
strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents:
11574
diff
changeset
|
180 DET determinant (MatrixType &mattype, octave_idx_type& info, |
8336
9813c07ca946
make det take advantage of matrix type
Jaroslav Hajek <highegg@gmail.com>
parents:
8335
diff
changeset
|
181 double& rcon, int calc_cond = 1) const; |
7788 | 182 |
183 double rcond (void) const; | |
184 double rcond (MatrixType &mattype) const; | |
458 | 185 |
5785 | 186 private: |
187 // Upper triangular matrix solvers | |
188 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
|
189 double& rcon, solve_singularity_handler sing_handler, |
17769
49a5a4be04a1
maint: Use GNU style coding conventions for code in liboctave/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
190 bool calc_cond = false, |
49a5a4be04a1
maint: Use GNU style coding conventions for code in liboctave/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
191 blas_trans_type transt = blas_no_trans) const; |
5785 | 192 |
193 // Lower triangular matrix solvers | |
194 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
|
195 double& rcon, solve_singularity_handler sing_handler, |
17769
49a5a4be04a1
maint: Use GNU style coding conventions for code in liboctave/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
196 bool calc_cond = false, |
49a5a4be04a1
maint: Use GNU style coding conventions for code in liboctave/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
197 blas_trans_type transt = blas_no_trans) const; |
5785 | 198 |
199 // Full matrix solvers (lu/cholesky) | |
200 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
|
201 double& rcon, solve_singularity_handler sing_handler, |
cbc402e64d83
untabify liboctave header files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
202 bool calc_cond = false) const; |
5785 | 203 |
204 public: | |
205 // Generic interface to solver with no probing of type | |
206 Matrix solve (MatrixType &typ, const Matrix& b) const; | |
207 Matrix solve (MatrixType &typ, const Matrix& b, octave_idx_type& info) const; | |
11586
12df7854fa7c
strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents:
11574
diff
changeset
|
208 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
|
209 double& rcon) const; |
5785 | 210 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
|
211 double& rcon, solve_singularity_handler sing_handler, |
17769
49a5a4be04a1
maint: Use GNU style coding conventions for code in liboctave/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
212 bool singular_fallback = true, |
49a5a4be04a1
maint: Use GNU style coding conventions for code in liboctave/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
213 blas_trans_type transt = blas_no_trans) const; |
5785 | 214 |
215 ComplexMatrix solve (MatrixType &typ, const ComplexMatrix& b) const; | |
11586
12df7854fa7c
strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents:
11574
diff
changeset
|
216 ComplexMatrix solve (MatrixType &typ, const ComplexMatrix& b, |
10312
cbc402e64d83
untabify liboctave header files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
217 octave_idx_type& info) const; |
11586
12df7854fa7c
strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents:
11574
diff
changeset
|
218 ComplexMatrix solve (MatrixType &typ, const ComplexMatrix& b, |
10312
cbc402e64d83
untabify liboctave header files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
219 octave_idx_type& info, double& rcon) const; |
11586
12df7854fa7c
strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents:
11574
diff
changeset
|
220 ComplexMatrix solve (MatrixType &typ, const ComplexMatrix& b, |
10312
cbc402e64d83
untabify liboctave header files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
221 octave_idx_type& info, double& rcon, |
cbc402e64d83
untabify liboctave header files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
222 solve_singularity_handler sing_handler, |
11586
12df7854fa7c
strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents:
11574
diff
changeset
|
223 bool singular_fallback = true, |
9661
afcf852256d2
optimize / and '\ for triangular matrices
Jaroslav Hajek <highegg@gmail.com>
parents:
9656
diff
changeset
|
224 blas_trans_type transt = blas_no_trans) const; |
5785 | 225 |
226 ColumnVector solve (MatrixType &typ, const ColumnVector& b) const; | |
11586
12df7854fa7c
strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents:
11574
diff
changeset
|
227 ColumnVector solve (MatrixType &typ, const ColumnVector& b, |
10312
cbc402e64d83
untabify liboctave header files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
228 octave_idx_type& info) const; |
11586
12df7854fa7c
strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents:
11574
diff
changeset
|
229 ColumnVector solve (MatrixType &typ, const ColumnVector& b, |
10312
cbc402e64d83
untabify liboctave header files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
230 octave_idx_type& info, double& rcon) const; |
11586
12df7854fa7c
strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents:
11574
diff
changeset
|
231 ColumnVector solve (MatrixType &typ, const ColumnVector& b, |
10312
cbc402e64d83
untabify liboctave header files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
232 octave_idx_type& info, double& rcon, |
11586
12df7854fa7c
strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents:
11574
diff
changeset
|
233 solve_singularity_handler sing_handler, |
9661
afcf852256d2
optimize / and '\ for triangular matrices
Jaroslav Hajek <highegg@gmail.com>
parents:
9656
diff
changeset
|
234 blas_trans_type transt = blas_no_trans) const; |
5785 | 235 |
11586
12df7854fa7c
strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents:
11574
diff
changeset
|
236 ComplexColumnVector solve (MatrixType &typ, |
10312
cbc402e64d83
untabify liboctave header files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
237 const ComplexColumnVector& b) const; |
11586
12df7854fa7c
strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents:
11574
diff
changeset
|
238 ComplexColumnVector solve (MatrixType &typ, const ComplexColumnVector& b, |
10312
cbc402e64d83
untabify liboctave header files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
239 octave_idx_type& info) const; |
11586
12df7854fa7c
strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents:
11574
diff
changeset
|
240 ComplexColumnVector solve (MatrixType &typ, const ComplexColumnVector& b, |
10312
cbc402e64d83
untabify liboctave header files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
241 octave_idx_type& info, double& rcon) const; |
11586
12df7854fa7c
strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents:
11574
diff
changeset
|
242 ComplexColumnVector solve (MatrixType &typ, const ComplexColumnVector& b, |
10312
cbc402e64d83
untabify liboctave header files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
243 octave_idx_type& info, double& rcon, |
11586
12df7854fa7c
strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents:
11574
diff
changeset
|
244 solve_singularity_handler sing_handler, |
9661
afcf852256d2
optimize / and '\ for triangular matrices
Jaroslav Hajek <highegg@gmail.com>
parents:
9656
diff
changeset
|
245 blas_trans_type transt = blas_no_trans) const; |
5785 | 246 |
247 // Generic interface to solver with probing of type | |
458 | 248 Matrix solve (const Matrix& b) const; |
5275 | 249 Matrix solve (const Matrix& b, octave_idx_type& info) const; |
7788 | 250 Matrix solve (const Matrix& b, octave_idx_type& info, double& rcon) const; |
251 Matrix solve (const Matrix& b, octave_idx_type& info, double& rcon, | |
11586
12df7854fa7c
strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents:
11574
diff
changeset
|
252 solve_singularity_handler sing_handler, |
9661
afcf852256d2
optimize / and '\ for triangular matrices
Jaroslav Hajek <highegg@gmail.com>
parents:
9656
diff
changeset
|
253 blas_trans_type transt = blas_no_trans) const; |
458 | 254 |
255 ComplexMatrix solve (const ComplexMatrix& b) const; | |
5275 | 256 ComplexMatrix solve (const ComplexMatrix& b, octave_idx_type& info) const; |
17769
49a5a4be04a1
maint: Use GNU style coding conventions for code in liboctave/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
257 ComplexMatrix solve (const ComplexMatrix& b, octave_idx_type& info, |
49a5a4be04a1
maint: Use GNU style coding conventions for code in liboctave/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
258 double& rcon) const; |
49a5a4be04a1
maint: Use GNU style coding conventions for code in liboctave/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
259 ComplexMatrix solve (const ComplexMatrix& b, octave_idx_type& info, |
49a5a4be04a1
maint: Use GNU style coding conventions for code in liboctave/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
260 double& rcon, |
11586
12df7854fa7c
strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents:
11574
diff
changeset
|
261 solve_singularity_handler sing_handler, |
9661
afcf852256d2
optimize / and '\ for triangular matrices
Jaroslav Hajek <highegg@gmail.com>
parents:
9656
diff
changeset
|
262 blas_trans_type transt = blas_no_trans) const; |
458 | 263 |
264 ColumnVector solve (const ColumnVector& b) const; | |
5275 | 265 ColumnVector solve (const ColumnVector& b, octave_idx_type& info) const; |
17769
49a5a4be04a1
maint: Use GNU style coding conventions for code in liboctave/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
266 ColumnVector solve (const ColumnVector& b, octave_idx_type& info, |
49a5a4be04a1
maint: Use GNU style coding conventions for code in liboctave/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
267 double& rcon) const; |
49a5a4be04a1
maint: Use GNU style coding conventions for code in liboctave/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
268 ColumnVector solve (const ColumnVector& b, octave_idx_type& info, |
49a5a4be04a1
maint: Use GNU style coding conventions for code in liboctave/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
269 double& rcon, |
11586
12df7854fa7c
strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents:
11574
diff
changeset
|
270 solve_singularity_handler sing_handler, |
9661
afcf852256d2
optimize / and '\ for triangular matrices
Jaroslav Hajek <highegg@gmail.com>
parents:
9656
diff
changeset
|
271 blas_trans_type transt = blas_no_trans) const; |
458 | 272 |
273 ComplexColumnVector solve (const ComplexColumnVector& b) const; | |
17769
49a5a4be04a1
maint: Use GNU style coding conventions for code in liboctave/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
274 ComplexColumnVector solve (const ComplexColumnVector& b, |
49a5a4be04a1
maint: Use GNU style coding conventions for code in liboctave/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
275 octave_idx_type& info) const; |
49a5a4be04a1
maint: Use GNU style coding conventions for code in liboctave/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
276 ComplexColumnVector solve (const ComplexColumnVector& b, |
49a5a4be04a1
maint: Use GNU style coding conventions for code in liboctave/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
277 octave_idx_type& info, double& rcon) const; |
49a5a4be04a1
maint: Use GNU style coding conventions for code in liboctave/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
278 ComplexColumnVector solve (const ComplexColumnVector& b, |
49a5a4be04a1
maint: Use GNU style coding conventions for code in liboctave/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
279 octave_idx_type& info, double& rcon, |
49a5a4be04a1
maint: Use GNU style coding conventions for code in liboctave/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
280 solve_singularity_handler sing_handler, |
9661
afcf852256d2
optimize / and '\ for triangular matrices
Jaroslav Hajek <highegg@gmail.com>
parents:
9656
diff
changeset
|
281 blas_trans_type transt = blas_no_trans) const; |
458 | 282 |
5785 | 283 // Singular solvers |
458 | 284 Matrix lssolve (const Matrix& b) const; |
5275 | 285 Matrix lssolve (const Matrix& b, octave_idx_type& info) const; |
11586
12df7854fa7c
strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents:
11574
diff
changeset
|
286 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
|
287 octave_idx_type& rank) const; |
11586
12df7854fa7c
strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents:
11574
diff
changeset
|
288 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
|
289 octave_idx_type& rank, double& rcon) const; |
458 | 290 |
291 ComplexMatrix lssolve (const ComplexMatrix& b) const; | |
5275 | 292 ComplexMatrix lssolve (const ComplexMatrix& b, octave_idx_type& info) const; |
293 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
|
294 octave_idx_type& rank) const; |
7076 | 295 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
|
296 octave_idx_type& rank, double &rcon) const; |
458 | 297 |
298 ColumnVector lssolve (const ColumnVector& b) const; | |
5275 | 299 ColumnVector lssolve (const ColumnVector& b, octave_idx_type& info) const; |
7076 | 300 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
|
301 octave_idx_type& rank) const; |
7076 | 302 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
|
303 octave_idx_type& rank, double& rcon) const; |
458 | 304 |
305 ComplexColumnVector lssolve (const ComplexColumnVector& b) const; | |
11586
12df7854fa7c
strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents:
11574
diff
changeset
|
306 ComplexColumnVector lssolve (const ComplexColumnVector& b, |
10312
cbc402e64d83
untabify liboctave header files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
307 octave_idx_type& info) const; |
7076 | 308 ComplexColumnVector lssolve (const ComplexColumnVector& b, |
10312
cbc402e64d83
untabify liboctave header files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
309 octave_idx_type& info, |
cbc402e64d83
untabify liboctave header files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
310 octave_idx_type& rank) const; |
11586
12df7854fa7c
strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents:
11574
diff
changeset
|
311 ComplexColumnVector lssolve (const ComplexColumnVector& b, |
10312
cbc402e64d83
untabify liboctave header files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
312 octave_idx_type& info, |
cbc402e64d83
untabify liboctave header files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
313 octave_idx_type& rank, double& rcon) const; |
458 | 314 |
315 Matrix& operator += (const DiagMatrix& a); | |
316 Matrix& operator -= (const DiagMatrix& a); | |
317 | |
1359 | 318 // unary operations |
458 | 319 |
1359 | 320 // other operations |
458 | 321 |
4017 | 322 boolMatrix all (int dim = -1) const; |
323 boolMatrix any (int dim = -1) const; | |
458 | 324 |
4017 | 325 Matrix cumprod (int dim = -1) const; |
326 Matrix cumsum (int dim = -1) const; | |
327 Matrix prod (int dim = -1) const; | |
328 Matrix sum (int dim = -1) const; | |
329 Matrix sumsq (int dim = -1) const; | |
2385 | 330 Matrix abs (void) const; |
458 | 331 |
7620
36594d5bbe13
Move diag function into the octave_value class
David Bateman <dbateman@free.fr>
parents:
7503
diff
changeset
|
332 Matrix diag (octave_idx_type k = 0) const; |
458 | 333 |
14557
e8e86ae3abbc
make diag (x, m, n) return a proper diagonal matrix object (bug #36099)
John W. Eaton <jwe@octave.org>
parents:
14138
diff
changeset
|
334 DiagMatrix diag (octave_idx_type m, octave_idx_type n) const; |
e8e86ae3abbc
make diag (x, m, n) return a proper diagonal matrix object (bug #36099)
John W. Eaton <jwe@octave.org>
parents:
14138
diff
changeset
|
335 |
458 | 336 ColumnVector row_min (void) const; |
2354 | 337 ColumnVector row_max (void) const; |
458 | 338 |
5275 | 339 ColumnVector row_min (Array<octave_idx_type>& index) const; |
340 ColumnVector row_max (Array<octave_idx_type>& index) const; | |
458 | 341 |
342 RowVector column_min (void) const; | |
2354 | 343 RowVector column_max (void) const; |
458 | 344 |
5275 | 345 RowVector column_min (Array<octave_idx_type>& index) const; |
346 RowVector column_max (Array<octave_idx_type>& index) const; | |
458 | 347 |
1359 | 348 // i/o |
458 | 349 |
17769
49a5a4be04a1
maint: Use GNU style coding conventions for code in liboctave/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
350 friend OCTAVE_API std::ostream& operator << (std::ostream& os, |
49a5a4be04a1
maint: Use GNU style coding conventions for code in liboctave/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
351 const Matrix& a); |
6108 | 352 friend OCTAVE_API std::istream& operator >> (std::istream& is, Matrix& a); |
458 | 353 }; |
354 | |
5508 | 355 // Publish externally used friend functions. |
356 | |
6108 | 357 extern OCTAVE_API Matrix real (const ComplexMatrix& a); |
358 extern OCTAVE_API Matrix imag (const ComplexMatrix& a); | |
5508 | 359 |
360 // column vector by row vector -> matrix operations | |
361 | |
17769
49a5a4be04a1
maint: Use GNU style coding conventions for code in liboctave/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
362 extern OCTAVE_API Matrix operator * (const ColumnVector& a, |
49a5a4be04a1
maint: Use GNU style coding conventions for code in liboctave/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
363 const RowVector& b); |
5508 | 364 |
365 // Other functions. | |
366 | |
6108 | 367 extern OCTAVE_API Matrix Givens (double, double); |
1819 | 368 |
17769
49a5a4be04a1
maint: Use GNU style coding conventions for code in liboctave/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
369 extern OCTAVE_API Matrix Sylvester (const Matrix&, const Matrix&, |
49a5a4be04a1
maint: Use GNU style coding conventions for code in liboctave/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
370 const Matrix&); |
1959 | 371 |
9665
1dba57e9d08d
use blas_trans_type for xgemm
Jaroslav Hajek <highegg@gmail.com>
parents:
9661
diff
changeset
|
372 extern OCTAVE_API Matrix xgemm (const Matrix& a, const Matrix& b, |
11586
12df7854fa7c
strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents:
11574
diff
changeset
|
373 blas_trans_type transa = blas_no_trans, |
9665
1dba57e9d08d
use blas_trans_type for xgemm
Jaroslav Hajek <highegg@gmail.com>
parents:
9661
diff
changeset
|
374 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
|
375 |
6108 | 376 extern OCTAVE_API Matrix operator * (const Matrix& a, const Matrix& b); |
2828 | 377 |
6108 | 378 extern OCTAVE_API Matrix min (double d, const Matrix& m); |
379 extern OCTAVE_API Matrix min (const Matrix& m, double d); | |
380 extern OCTAVE_API Matrix min (const Matrix& a, const Matrix& b); | |
4309 | 381 |
6108 | 382 extern OCTAVE_API Matrix max (double d, const Matrix& m); |
383 extern OCTAVE_API Matrix max (const Matrix& m, double d); | |
384 extern OCTAVE_API Matrix max (const Matrix& a, const Matrix& b); | |
4309 | 385 |
11586
12df7854fa7c
strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents:
11574
diff
changeset
|
386 extern OCTAVE_API Matrix linspace (const ColumnVector& x1, |
12df7854fa7c
strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents:
11574
diff
changeset
|
387 const ColumnVector& x2, |
9653
e087d7c77ff9
improve linspace in liboctave
Jaroslav Hajek <highegg@gmail.com>
parents:
8920
diff
changeset
|
388 octave_idx_type n); |
e087d7c77ff9
improve linspace in liboctave
Jaroslav Hajek <highegg@gmail.com>
parents:
8920
diff
changeset
|
389 |
6708 | 390 MS_CMP_OP_DECLS (Matrix, double, OCTAVE_API) |
391 MS_BOOL_OP_DECLS (Matrix, double, OCTAVE_API) | |
2870 | 392 |
6708 | 393 SM_CMP_OP_DECLS (double, Matrix, OCTAVE_API) |
394 SM_BOOL_OP_DECLS (double, Matrix, OCTAVE_API) | |
2870 | 395 |
6708 | 396 MM_CMP_OP_DECLS (Matrix, Matrix, OCTAVE_API) |
397 MM_BOOL_OP_DECLS (Matrix, Matrix, OCTAVE_API) | |
2870 | 398 |
10350
12884915a8e4
merge MArray classes & improve Array interface
Jaroslav Hajek <highegg@gmail.com>
parents:
10312
diff
changeset
|
399 MARRAY_FORWARD_DEFS (MArray, Matrix, double) |
3573 | 400 |
21139
538b57866b90
consistently use "typename" intead of "class" in template declarations
John W. Eaton <jwe@octave.org>
parents:
20791
diff
changeset
|
401 template <typename T> |
3689 | 402 void read_int (std::istream& is, bool swap_bytes, T& val); |
403 | |
458 | 404 #endif |