Mercurial > hg > octave-nkf
annotate liboctave/dMatrix.h @ 14557:e8e86ae3abbc
make diag (x, m, n) return a proper diagonal matrix object (bug #36099)
* Array.h, Array.cc (Array<T>::diag (octave_idx_type, octave_idx_type)
const): New function.
* CMatrix.h, CMatrix.cc (ComplexMatrix::diag (octave_idx_type,
octave_idx_type) const): New function.
* dMatrix.h, dMatrix.cc (Matrix::diag (octave_idx_type,
octave_idx_type) const): New function.
* fCMatrix.h, fCMatrix.cc (FloatComplexMatrix::diag (octave_idx_type,
octave_idx_type) const): New function.
* fMatrix.h, fMatrix.cc (FloatMatrix::diag (octave_idx_type,
octave_idx_type) const): New function.
* CNDArray.cc, CNDArray.h (ComplexNDArray::diag (octave_idx_type,
octave_idx_type) const): New forwarding function.
* boolNDArray.cc, boolNDArray.h (boolNDArray::diag (octave_idx_type,
octave_idx_type) const): New forwarding function.
* chNDArray.cc, chNDArray.h (charNDArray::diag (octave_idx_type,
octave_idx_type) const): New forwarding function.
* dNDArray.cc, dNDArray.h (NDArray::diag (octave_idx_type,
octave_idx_type) const): New forwarding function.
* fCNDArray.cc, fCNDArray.h (FloatComplexNDArray::diag
(octave_idx_type, octave_idx_type) const): New forwarding function.
* fNDArray.cc, fNDArray.h (FloatNDArray::diag (octave_idx_type,
octave_idx_type) const): New forwarding function.
* intNDArray.cc, intNDArray.h (intNDArray<T>::diag (octave_idx_type,
octave_idx_type) const): New forwarding function.
* Cell.cc, Cell.h (Cell::diag (octave_idx_type, octave_idx_type)
const): New function.
* ov.h (octave_value::diag (octave_idx_type, octave_idx_type)):
New function.
* ov-base.h, ov-base.cc (octave_base_value::diag (octave_idx_type,
octave_idx_type) const): New virtual function and default implementation.
* ov-base-mat.h (octave_base_matrix<T>::diag (octave_idx_type,
octave_idx_type) const): New function.
* ov-base-scalar.cc, ov-base-scalar.h (octave_base_scalar<T>::diag
(octave_idx_type, octave_idx_type)): New function.
* ov-complex.cc, ov-complex.h (octave_complex::diag (octave_idx_type,
octave_idx_type) const): New function.
* ov-cx-mat.cc, ov-complex.h (octave_complex_matrix::diag
(octave_idx_type, octave_idx_type) const): New function.
* ov-float.cc, ov-float.h (octave_float_scalar::diag (octave_idx_type,
octave_idx_type) const): New function.
* ov-flt-complex.cc, ov-flt-complex.h (octave_float_complex::diag
(octave_idx_type, octave_idx_type) const): New function.
* ov-flt-cx-mat.cc, ov-flt-cx-mat.h (octave_float_complex_matrix::diag
(octave_idx_type, octave_idx_type) const): New function.
* ov-flt-re-mat.cc, ov-flt-re-mat.h (octave_float_matrix::diag
(octave_idx_type, octave_idx_type) const): New function.
* ov-range.cc, ov-range.h (octave_range::diag (octave_idx_type,
octave_idx_type) const): New function.
* ov-re-mat.cc, ov-re-mat.h (octave_matrix::diag (octave_idx_type,
octave_idx_type) const): New function.
* ov-scalar.cc, ov-scalar.h (octave_scalar::diag (octave_idx_type,
octave_idx_type) const): New function.
* data.cc (Fdiag): Use two-arg octave_value::diag method for
dispatching. New tests.
author | John W. Eaton <jwe@octave.org> |
---|---|
date | Thu, 12 Apr 2012 16:27:39 -0400 |
parents | 72c96de7a403 |
children | 13cc11418393 |
rev | line source |
---|---|
458 | 1 /* |
2 | |
14138
72c96de7a403
maint: update copyright notices for 2012
John W. Eaton <jwe@octave.org>
parents:
13756
diff
changeset
|
3 Copyright (C) 1994-2012 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 | |
23 #if !defined (octave_Matrix_int_h) | |
24 #define octave_Matrix_int_h 1 | |
25 | |
10350
12884915a8e4
merge MArray classes & improve Array interface
Jaroslav Hajek <highegg@gmail.com>
parents:
10312
diff
changeset
|
26 #include "MArray.h" |
1989 | 27 #include "MDiagArray2.h" |
5785 | 28 #include "MatrixType.h" |
458 | 29 |
30 #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
|
31 #include "mx-op-decl.h" |
8335 | 32 #include "DET.h" |
458 | 33 |
3585 | 34 class |
6108 | 35 OCTAVE_API |
10350
12884915a8e4
merge MArray classes & improve Array interface
Jaroslav Hajek <highegg@gmail.com>
parents:
10312
diff
changeset
|
36 Matrix : public MArray<double> |
458 | 37 { |
38 public: | |
39 | |
9656
b29504415a2e
provide NDArray->Matrix->Vector typedef mappers
Jaroslav Hajek <highegg@gmail.com>
parents:
9653
diff
changeset
|
40 typedef ColumnVector column_vector_type; |
b29504415a2e
provide NDArray->Matrix->Vector typedef mappers
Jaroslav Hajek <highegg@gmail.com>
parents:
9653
diff
changeset
|
41 typedef RowVector row_vector_type; |
b29504415a2e
provide NDArray->Matrix->Vector typedef mappers
Jaroslav Hajek <highegg@gmail.com>
parents:
9653
diff
changeset
|
42 |
7788 | 43 typedef void (*solve_singularity_handler) (double rcon); |
3480 | 44 |
10350
12884915a8e4
merge MArray classes & improve Array interface
Jaroslav Hajek <highegg@gmail.com>
parents:
10312
diff
changeset
|
45 Matrix (void) : MArray<double> () { } |
3585 | 46 |
11570
57632dea2446
attempt better backward compatibility for Array constructors
John W. Eaton <jwe@octave.org>
parents:
11523
diff
changeset
|
47 Matrix (octave_idx_type r, octave_idx_type c) |
57632dea2446
attempt better backward compatibility for Array constructors
John W. Eaton <jwe@octave.org>
parents:
11523
diff
changeset
|
48 : MArray<double> (dim_vector (r, c)) { } |
3585 | 49 |
11570
57632dea2446
attempt better backward compatibility for Array constructors
John W. Eaton <jwe@octave.org>
parents:
11523
diff
changeset
|
50 Matrix (octave_idx_type r, octave_idx_type c, double val) |
57632dea2446
attempt better backward compatibility for Array constructors
John W. Eaton <jwe@octave.org>
parents:
11523
diff
changeset
|
51 : MArray<double> (dim_vector (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 |
11570
57632dea2446
attempt better backward compatibility for Array constructors
John W. Eaton <jwe@octave.org>
parents:
11523
diff
changeset
|
55 Matrix (const dim_vector& dv, double val) |
57632dea2446
attempt better backward compatibility for Array constructors
John W. Eaton <jwe@octave.org>
parents:
11523
diff
changeset
|
56 : MArray<double> (dv.redim (2), val) { } |
6979 | 57 |
10350
12884915a8e4
merge MArray classes & improve Array interface
Jaroslav Hajek <highegg@gmail.com>
parents:
10312
diff
changeset
|
58 Matrix (const Matrix& a) : MArray<double> (a) { } |
3585 | 59 |
7789
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7788
diff
changeset
|
60 template <class U> |
10350
12884915a8e4
merge MArray classes & improve Array interface
Jaroslav Hajek <highegg@gmail.com>
parents:
10312
diff
changeset
|
61 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
|
62 |
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7788
diff
changeset
|
63 template <class U> |
10350
12884915a8e4
merge MArray classes & improve Array interface
Jaroslav Hajek <highegg@gmail.com>
parents:
10312
diff
changeset
|
64 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
|
65 |
3585 | 66 explicit Matrix (const RowVector& rv); |
458 | 67 |
3585 | 68 explicit Matrix (const ColumnVector& cv); |
69 | |
70 explicit Matrix (const DiagMatrix& a); | |
71 | |
8367
445d27d79f4e
support permutation matrix objects
Jaroslav Hajek <highegg@gmail.com>
parents:
8336
diff
changeset
|
72 explicit Matrix (const PermMatrix& a); |
445d27d79f4e
support permutation matrix objects
Jaroslav Hajek <highegg@gmail.com>
parents:
8336
diff
changeset
|
73 |
3585 | 74 explicit Matrix (const boolMatrix& a); |
75 | |
76 explicit Matrix (const charMatrix& a); | |
1574 | 77 |
458 | 78 Matrix& operator = (const Matrix& a) |
79 { | |
10350
12884915a8e4
merge MArray classes & improve Array interface
Jaroslav Hajek <highegg@gmail.com>
parents:
10312
diff
changeset
|
80 MArray<double>::operator = (a); |
458 | 81 return *this; |
82 } | |
83 | |
2385 | 84 bool operator == (const Matrix& a) const; |
85 bool operator != (const Matrix& a) const; | |
458 | 86 |
3354 | 87 bool is_symmetric (void) const; |
88 | |
1359 | 89 // destructive insert/delete/reorder operations |
458 | 90 |
5275 | 91 Matrix& insert (const Matrix& a, octave_idx_type r, octave_idx_type c); |
92 Matrix& insert (const RowVector& a, octave_idx_type r, octave_idx_type c); | |
93 Matrix& insert (const ColumnVector& a, octave_idx_type r, octave_idx_type c); | |
94 Matrix& insert (const DiagMatrix& a, octave_idx_type r, octave_idx_type c); | |
458 | 95 |
96 Matrix& fill (double val); | |
5275 | 97 Matrix& fill (double val, octave_idx_type r1, octave_idx_type c1, octave_idx_type r2, octave_idx_type c2); |
458 | 98 |
99 Matrix append (const Matrix& a) const; | |
100 Matrix append (const RowVector& a) const; | |
101 Matrix append (const ColumnVector& a) const; | |
102 Matrix append (const DiagMatrix& a) const; | |
103 | |
104 Matrix stack (const Matrix& a) const; | |
105 Matrix stack (const RowVector& a) const; | |
106 Matrix stack (const ColumnVector& a) const; | |
107 Matrix stack (const DiagMatrix& a) const; | |
108 | |
6108 | 109 friend OCTAVE_API Matrix real (const ComplexMatrix& a); |
110 friend OCTAVE_API Matrix imag (const ComplexMatrix& a); | |
1205 | 111 |
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
|
112 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
|
113 |
10350
12884915a8e4
merge MArray classes & improve Array interface
Jaroslav Hajek <highegg@gmail.com>
parents:
10312
diff
changeset
|
114 Matrix transpose (void) const { return MArray<double>::transpose (); } |
3225 | 115 |
1359 | 116 // resize is the destructive equivalent for this one |
458 | 117 |
5275 | 118 Matrix extract (octave_idx_type r1, octave_idx_type c1, octave_idx_type r2, octave_idx_type c2) const; |
458 | 119 |
5275 | 120 Matrix extract_n (octave_idx_type r1, octave_idx_type c1, octave_idx_type nr, octave_idx_type nc) const; |
4316 | 121 |
1359 | 122 // extract row or column i. |
458 | 123 |
5275 | 124 RowVector row (octave_idx_type i) const; |
458 | 125 |
5275 | 126 ColumnVector column (octave_idx_type i) const; |
458 | 127 |
11574
a83bad07f7e3
attempt better backward compatibility for Array resize functions
John W. Eaton <jwe@octave.org>
parents:
11570
diff
changeset
|
128 void resize (octave_idx_type nr, octave_idx_type nc, |
a83bad07f7e3
attempt better backward compatibility for Array resize functions
John W. Eaton <jwe@octave.org>
parents:
11570
diff
changeset
|
129 double rfv = resize_fill_value ()) |
a83bad07f7e3
attempt better backward compatibility for Array resize functions
John W. Eaton <jwe@octave.org>
parents:
11570
diff
changeset
|
130 { |
a83bad07f7e3
attempt better backward compatibility for Array resize functions
John W. Eaton <jwe@octave.org>
parents:
11570
diff
changeset
|
131 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
|
132 } |
a83bad07f7e3
attempt better backward compatibility for Array resize functions
John W. Eaton <jwe@octave.org>
parents:
11570
diff
changeset
|
133 |
6207 | 134 private: |
11586
12df7854fa7c
strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents:
11574
diff
changeset
|
135 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
|
136 int force, int calc_cond) const; |
6207 | 137 |
11586
12df7854fa7c
strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents:
11574
diff
changeset
|
138 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
|
139 int force, int calc_cond) const; |
6207 | 140 |
141 public: | |
458 | 142 Matrix inverse (void) const; |
6479 | 143 Matrix inverse (octave_idx_type& info) const; |
7788 | 144 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
|
145 int calc_cond = 1) const; |
6479 | 146 |
6207 | 147 Matrix inverse (MatrixType &mattype) const; |
148 Matrix inverse (MatrixType &mattype, octave_idx_type& info) const; | |
7788 | 149 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
|
150 int force = 0, int calc_cond = 1) const; |
458 | 151 |
4384 | 152 Matrix pseudo_inverse (double tol = 0.0) const; |
740 | 153 |
458 | 154 ComplexMatrix fourier (void) const; |
155 ComplexMatrix ifourier (void) const; | |
156 | |
677 | 157 ComplexMatrix fourier2d (void) const; |
158 ComplexMatrix ifourier2d (void) const; | |
159 | |
458 | 160 DET determinant (void) const; |
5275 | 161 DET determinant (octave_idx_type& info) const; |
7788 | 162 DET determinant (octave_idx_type& info, double& rcon, int calc_cond = 1) const; |
11586
12df7854fa7c
strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents:
11574
diff
changeset
|
163 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
|
164 double& rcon, int calc_cond = 1) const; |
7788 | 165 |
166 double rcond (void) const; | |
167 double rcond (MatrixType &mattype) const; | |
458 | 168 |
5785 | 169 private: |
170 // Upper triangular matrix solvers | |
171 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
|
172 double& rcon, solve_singularity_handler sing_handler, |
cbc402e64d83
untabify liboctave header files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
173 bool calc_cond = false, blas_trans_type transt = blas_no_trans) const; |
5785 | 174 |
175 // Lower triangular matrix solvers | |
176 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
|
177 double& rcon, solve_singularity_handler sing_handler, |
cbc402e64d83
untabify liboctave header files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
178 bool calc_cond = false, blas_trans_type transt = blas_no_trans) const; |
5785 | 179 |
180 // Full matrix solvers (lu/cholesky) | |
181 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
|
182 double& rcon, solve_singularity_handler sing_handler, |
cbc402e64d83
untabify liboctave header files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
183 bool calc_cond = false) const; |
5785 | 184 |
185 public: | |
186 // Generic interface to solver with no probing of type | |
187 Matrix solve (MatrixType &typ, const Matrix& b) const; | |
188 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
|
189 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
|
190 double& rcon) const; |
5785 | 191 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
|
192 double& rcon, solve_singularity_handler sing_handler, |
cbc402e64d83
untabify liboctave header files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
193 bool singular_fallback = true, blas_trans_type transt = blas_no_trans) const; |
5785 | 194 |
195 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
|
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) const; |
11586
12df7854fa7c
strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents:
11574
diff
changeset
|
198 ComplexMatrix solve (MatrixType &typ, const ComplexMatrix& b, |
10312
cbc402e64d83
untabify liboctave header files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
199 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
|
200 ComplexMatrix solve (MatrixType &typ, const ComplexMatrix& b, |
10312
cbc402e64d83
untabify liboctave header files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
201 octave_idx_type& info, double& rcon, |
cbc402e64d83
untabify liboctave header files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
202 solve_singularity_handler sing_handler, |
11586
12df7854fa7c
strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents:
11574
diff
changeset
|
203 bool singular_fallback = true, |
9661
afcf852256d2
optimize / and '\ for triangular matrices
Jaroslav Hajek <highegg@gmail.com>
parents:
9656
diff
changeset
|
204 blas_trans_type transt = blas_no_trans) const; |
5785 | 205 |
206 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
|
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) const; |
11586
12df7854fa7c
strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents:
11574
diff
changeset
|
209 ColumnVector solve (MatrixType &typ, const ColumnVector& b, |
10312
cbc402e64d83
untabify liboctave header files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
210 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
|
211 ColumnVector solve (MatrixType &typ, const ColumnVector& b, |
10312
cbc402e64d83
untabify liboctave header files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
212 octave_idx_type& info, double& rcon, |
11586
12df7854fa7c
strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents:
11574
diff
changeset
|
213 solve_singularity_handler sing_handler, |
9661
afcf852256d2
optimize / and '\ for triangular matrices
Jaroslav Hajek <highegg@gmail.com>
parents:
9656
diff
changeset
|
214 blas_trans_type transt = blas_no_trans) const; |
5785 | 215 |
11586
12df7854fa7c
strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents:
11574
diff
changeset
|
216 ComplexColumnVector solve (MatrixType &typ, |
10312
cbc402e64d83
untabify liboctave header files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
217 const ComplexColumnVector& b) const; |
11586
12df7854fa7c
strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents:
11574
diff
changeset
|
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) const; |
11586
12df7854fa7c
strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents:
11574
diff
changeset
|
220 ComplexColumnVector solve (MatrixType &typ, const ComplexColumnVector& b, |
10312
cbc402e64d83
untabify liboctave header files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
221 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
|
222 ComplexColumnVector solve (MatrixType &typ, const ComplexColumnVector& b, |
10312
cbc402e64d83
untabify liboctave header files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
223 octave_idx_type& info, double& rcon, |
11586
12df7854fa7c
strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents:
11574
diff
changeset
|
224 solve_singularity_handler sing_handler, |
9661
afcf852256d2
optimize / and '\ for triangular matrices
Jaroslav Hajek <highegg@gmail.com>
parents:
9656
diff
changeset
|
225 blas_trans_type transt = blas_no_trans) const; |
5785 | 226 |
227 // Generic interface to solver with probing of type | |
458 | 228 Matrix solve (const Matrix& b) const; |
5275 | 229 Matrix solve (const Matrix& b, octave_idx_type& info) const; |
7788 | 230 Matrix solve (const Matrix& b, octave_idx_type& info, double& rcon) const; |
231 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
|
232 solve_singularity_handler sing_handler, |
9661
afcf852256d2
optimize / and '\ for triangular matrices
Jaroslav Hajek <highegg@gmail.com>
parents:
9656
diff
changeset
|
233 blas_trans_type transt = blas_no_trans) const; |
458 | 234 |
235 ComplexMatrix solve (const ComplexMatrix& b) const; | |
5275 | 236 ComplexMatrix solve (const ComplexMatrix& b, octave_idx_type& info) const; |
7788 | 237 ComplexMatrix solve (const ComplexMatrix& b, octave_idx_type& info, double& rcon) const; |
238 ComplexMatrix solve (const ComplexMatrix& 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
|
239 solve_singularity_handler sing_handler, |
9661
afcf852256d2
optimize / and '\ for triangular matrices
Jaroslav Hajek <highegg@gmail.com>
parents:
9656
diff
changeset
|
240 blas_trans_type transt = blas_no_trans) const; |
458 | 241 |
242 ColumnVector solve (const ColumnVector& b) const; | |
5275 | 243 ColumnVector solve (const ColumnVector& b, octave_idx_type& info) const; |
7788 | 244 ColumnVector solve (const ColumnVector& b, octave_idx_type& info, double& rcon) const; |
245 ColumnVector solve (const ColumnVector& 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
|
246 solve_singularity_handler sing_handler, |
9661
afcf852256d2
optimize / and '\ for triangular matrices
Jaroslav Hajek <highegg@gmail.com>
parents:
9656
diff
changeset
|
247 blas_trans_type transt = blas_no_trans) const; |
458 | 248 |
249 ComplexColumnVector solve (const ComplexColumnVector& b) const; | |
5275 | 250 ComplexColumnVector solve (const ComplexColumnVector& b, octave_idx_type& info) const; |
251 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
|
252 double& rcon) const; |
5275 | 253 ComplexColumnVector solve (const ComplexColumnVector& b, octave_idx_type& info, |
11586
12df7854fa7c
strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents:
11574
diff
changeset
|
254 double& rcon, solve_singularity_handler sing_handler, |
9661
afcf852256d2
optimize / and '\ for triangular matrices
Jaroslav Hajek <highegg@gmail.com>
parents:
9656
diff
changeset
|
255 blas_trans_type transt = blas_no_trans) const; |
458 | 256 |
5785 | 257 // Singular solvers |
458 | 258 Matrix lssolve (const Matrix& b) const; |
5275 | 259 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
|
260 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
|
261 octave_idx_type& rank) const; |
11586
12df7854fa7c
strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents:
11574
diff
changeset
|
262 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
|
263 octave_idx_type& rank, double& rcon) const; |
458 | 264 |
265 ComplexMatrix lssolve (const ComplexMatrix& b) const; | |
5275 | 266 ComplexMatrix lssolve (const ComplexMatrix& b, octave_idx_type& info) const; |
267 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
|
268 octave_idx_type& rank) const; |
7076 | 269 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
|
270 octave_idx_type& rank, double &rcon) const; |
458 | 271 |
272 ColumnVector lssolve (const ColumnVector& b) const; | |
5275 | 273 ColumnVector lssolve (const ColumnVector& b, octave_idx_type& info) const; |
7076 | 274 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
|
275 octave_idx_type& rank) const; |
7076 | 276 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
|
277 octave_idx_type& rank, double& rcon) const; |
458 | 278 |
279 ComplexColumnVector lssolve (const ComplexColumnVector& b) const; | |
11586
12df7854fa7c
strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents:
11574
diff
changeset
|
280 ComplexColumnVector lssolve (const ComplexColumnVector& b, |
10312
cbc402e64d83
untabify liboctave header files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
281 octave_idx_type& info) const; |
7076 | 282 ComplexColumnVector lssolve (const ComplexColumnVector& b, |
10312
cbc402e64d83
untabify liboctave header files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
283 octave_idx_type& info, |
cbc402e64d83
untabify liboctave header files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
284 octave_idx_type& rank) const; |
11586
12df7854fa7c
strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents:
11574
diff
changeset
|
285 ComplexColumnVector lssolve (const ComplexColumnVector& b, |
10312
cbc402e64d83
untabify liboctave header files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
286 octave_idx_type& info, |
cbc402e64d83
untabify liboctave header files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
287 octave_idx_type& rank, double& rcon) const; |
458 | 288 |
289 Matrix& operator += (const DiagMatrix& a); | |
290 Matrix& operator -= (const DiagMatrix& a); | |
291 | |
1359 | 292 // unary operations |
458 | 293 |
2964 | 294 boolMatrix operator ! (void) const; |
458 | 295 |
1359 | 296 // other operations |
458 | 297 |
4431 | 298 bool any_element_is_negative (bool = false) const; |
13756
6dfebfa334cb
allow negative data log plots with OpenGL+FLTK graphics (bug #34232)
John W. Eaton <jwe@octave.org>
parents:
11586
diff
changeset
|
299 bool any_element_is_positive (bool = false) const; |
7922
935be827eaf8
error for NaN values in & and | expressions
John W. Eaton <jwe@octave.org>
parents:
7800
diff
changeset
|
300 bool any_element_is_nan (void) const; |
2385 | 301 bool any_element_is_inf_or_nan (void) const; |
5943 | 302 bool any_element_not_one_or_zero (void) const; |
2385 | 303 bool all_elements_are_int_or_inf_or_nan (void) const; |
304 bool all_integers (double& max_val, double& min_val) const; | |
305 bool too_large_for_float (void) const; | |
11586
12df7854fa7c
strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents:
11574
diff
changeset
|
306 |
4017 | 307 boolMatrix all (int dim = -1) const; |
308 boolMatrix any (int dim = -1) const; | |
458 | 309 |
4017 | 310 Matrix cumprod (int dim = -1) const; |
311 Matrix cumsum (int dim = -1) const; | |
312 Matrix prod (int dim = -1) const; | |
313 Matrix sum (int dim = -1) const; | |
314 Matrix sumsq (int dim = -1) const; | |
2385 | 315 Matrix abs (void) const; |
458 | 316 |
7620
36594d5bbe13
Move diag function into the octave_value class
David Bateman <dbateman@free.fr>
parents:
7503
diff
changeset
|
317 Matrix diag (octave_idx_type k = 0) const; |
458 | 318 |
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
|
319 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
|
320 |
458 | 321 ColumnVector row_min (void) const; |
2354 | 322 ColumnVector row_max (void) const; |
458 | 323 |
5275 | 324 ColumnVector row_min (Array<octave_idx_type>& index) const; |
325 ColumnVector row_max (Array<octave_idx_type>& index) const; | |
458 | 326 |
327 RowVector column_min (void) const; | |
2354 | 328 RowVector column_max (void) const; |
458 | 329 |
5275 | 330 RowVector column_min (Array<octave_idx_type>& index) const; |
331 RowVector column_max (Array<octave_idx_type>& index) const; | |
458 | 332 |
1359 | 333 // i/o |
458 | 334 |
6108 | 335 friend OCTAVE_API std::ostream& operator << (std::ostream& os, const Matrix& a); |
336 friend OCTAVE_API std::istream& operator >> (std::istream& is, Matrix& a); | |
458 | 337 |
3933 | 338 static double resize_fill_value (void) { return 0; } |
458 | 339 }; |
340 | |
5508 | 341 // Publish externally used friend functions. |
342 | |
6108 | 343 extern OCTAVE_API Matrix real (const ComplexMatrix& a); |
344 extern OCTAVE_API Matrix imag (const ComplexMatrix& a); | |
5508 | 345 |
346 // column vector by row vector -> matrix operations | |
347 | |
6108 | 348 extern OCTAVE_API Matrix operator * (const ColumnVector& a, const RowVector& b); |
5508 | 349 |
350 // Other functions. | |
351 | |
6108 | 352 extern OCTAVE_API Matrix Givens (double, double); |
1819 | 353 |
6108 | 354 extern OCTAVE_API Matrix Sylvester (const Matrix&, const Matrix&, const Matrix&); |
1959 | 355 |
9665
1dba57e9d08d
use blas_trans_type for xgemm
Jaroslav Hajek <highegg@gmail.com>
parents:
9661
diff
changeset
|
356 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
|
357 blas_trans_type transa = blas_no_trans, |
9665
1dba57e9d08d
use blas_trans_type for xgemm
Jaroslav Hajek <highegg@gmail.com>
parents:
9661
diff
changeset
|
358 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
|
359 |
6108 | 360 extern OCTAVE_API Matrix operator * (const Matrix& a, const Matrix& b); |
2828 | 361 |
6108 | 362 extern OCTAVE_API Matrix min (double d, const Matrix& m); |
363 extern OCTAVE_API Matrix min (const Matrix& m, double d); | |
364 extern OCTAVE_API Matrix min (const Matrix& a, const Matrix& b); | |
4309 | 365 |
6108 | 366 extern OCTAVE_API Matrix max (double d, const Matrix& m); |
367 extern OCTAVE_API Matrix max (const Matrix& m, double d); | |
368 extern OCTAVE_API Matrix max (const Matrix& a, const Matrix& b); | |
4309 | 369 |
11586
12df7854fa7c
strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents:
11574
diff
changeset
|
370 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
|
371 const ColumnVector& x2, |
9653
e087d7c77ff9
improve linspace in liboctave
Jaroslav Hajek <highegg@gmail.com>
parents:
8920
diff
changeset
|
372 octave_idx_type n); |
e087d7c77ff9
improve linspace in liboctave
Jaroslav Hajek <highegg@gmail.com>
parents:
8920
diff
changeset
|
373 |
6708 | 374 MS_CMP_OP_DECLS (Matrix, double, OCTAVE_API) |
375 MS_BOOL_OP_DECLS (Matrix, double, OCTAVE_API) | |
2870 | 376 |
6708 | 377 SM_CMP_OP_DECLS (double, Matrix, OCTAVE_API) |
378 SM_BOOL_OP_DECLS (double, Matrix, OCTAVE_API) | |
2870 | 379 |
6708 | 380 MM_CMP_OP_DECLS (Matrix, Matrix, OCTAVE_API) |
381 MM_BOOL_OP_DECLS (Matrix, Matrix, OCTAVE_API) | |
2870 | 382 |
10350
12884915a8e4
merge MArray classes & improve Array interface
Jaroslav Hajek <highegg@gmail.com>
parents:
10312
diff
changeset
|
383 MARRAY_FORWARD_DEFS (MArray, Matrix, double) |
3573 | 384 |
3689 | 385 template <class T> |
386 void read_int (std::istream& is, bool swap_bytes, T& val); | |
387 | |
458 | 388 #endif |