GNU Octave 10.1.0
A high-level interpreted language, primarily intended for numerical computations, mostly compatible with Matlab
 
Loading...
Searching...
No Matches
fCMatrix.h
Go to the documentation of this file.
1////////////////////////////////////////////////////////////////////////
2//
3// Copyright (C) 1994-2025 The Octave Project Developers
4//
5// See the file COPYRIGHT.md in the top-level directory of this
6// distribution or <https://octave.org/copyright/>.
7//
8// This file is part of Octave.
9//
10// Octave is free software: you can redistribute it and/or modify it
11// under the terms of the GNU General Public License as published by
12// the Free Software Foundation, either version 3 of the License, or
13// (at your option) any later version.
14//
15// Octave is distributed in the hope that it will be useful, but
16// WITHOUT ANY WARRANTY; without even the implied warranty of
17// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18// GNU General Public License for more details.
19//
20// You should have received a copy of the GNU General Public License
21// along with Octave; see the file COPYING. If not, see
22// <https://www.gnu.org/licenses/>.
23//
24////////////////////////////////////////////////////////////////////////
25
26#if ! defined (octave_fCMatrix_h)
27#define octave_fCMatrix_h 1
28
29#include "octave-config.h"
30
31#include "DET.h"
32#include "MArray.h"
33#include "MDiagArray2.h"
34#include "MatrixType.h"
35#include "fCNDArray.h"
36#include "mx-defs.h"
37#include "mx-op-decl.h"
38#include "oct-cmplx.h"
39
41{
42public:
43
46
49
52
55
56 typedef float real_elt_type;
58
59 typedef void (*solve_singularity_handler) (float rcon);
60
61 FloatComplexMatrix () = default;
62
64
66
67 ~FloatComplexMatrix () = default;
68
71
75
77 : FloatComplexNDArray (dv.redim (2)) { }
78
80 : FloatComplexNDArray (dv.redim (2), val) { }
81
82 template <typename U>
84 : FloatComplexNDArray (a.as_matrix ()) { }
85
86 template <typename U>
88 : FloatComplexNDArray (a.as_matrix ()) { }
89
90 explicit OCTAVE_API FloatComplexMatrix (const FloatMatrix& a);
91
92 explicit OCTAVE_API FloatComplexMatrix (const FloatRowVector& rv);
93
95
97
99
101
103
105
107
109
111
112 explicit OCTAVE_API FloatComplexMatrix (const boolMatrix& a);
113
114 explicit OCTAVE_API FloatComplexMatrix (const charMatrix& a);
115
117
118 OCTAVE_API bool operator == (const FloatComplexMatrix& a) const;
119 OCTAVE_API bool operator != (const FloatComplexMatrix& a) const;
120
121 OCTAVE_API bool ishermitian () const;
122
123 // destructive insert/delete/reorder operations
124
126 insert (const FloatMatrix& a, octave_idx_type r, octave_idx_type c);
128 insert (const FloatRowVector& a, octave_idx_type r, octave_idx_type c);
130 insert (const FloatColumnVector& a, octave_idx_type r, octave_idx_type c);
132 insert (const FloatDiagMatrix& a, octave_idx_type r, octave_idx_type c);
133
135 insert (const FloatComplexMatrix& a, octave_idx_type r, octave_idx_type c);
137 insert (const FloatComplexRowVector& a, octave_idx_type r,
140 insert (const FloatComplexColumnVector& a, octave_idx_type r,
143 insert (const FloatComplexDiagMatrix& a, octave_idx_type r,
145
146 OCTAVE_API FloatComplexMatrix& fill (float val);
147 OCTAVE_API FloatComplexMatrix& fill (const FloatComplex& val);
149 fill (float val, octave_idx_type r1, octave_idx_type c1,
152 fill (const FloatComplex& val, octave_idx_type r1, octave_idx_type c1,
154
155 OCTAVE_API FloatComplexMatrix append (const FloatMatrix& a) const;
156 OCTAVE_API FloatComplexMatrix append (const FloatRowVector& a) const;
157 OCTAVE_API FloatComplexMatrix append (const FloatColumnVector& a) const;
158 OCTAVE_API FloatComplexMatrix append (const FloatDiagMatrix& a) const;
159
160 OCTAVE_API FloatComplexMatrix append (const FloatComplexMatrix& a) const;
163 append (const FloatComplexColumnVector& a) const;
165
166 OCTAVE_API FloatComplexMatrix stack (const FloatMatrix& a) const;
167 OCTAVE_API FloatComplexMatrix stack (const FloatRowVector& a) const;
168 OCTAVE_API FloatComplexMatrix stack (const FloatColumnVector& a) const;
169 OCTAVE_API FloatComplexMatrix stack (const FloatDiagMatrix& a) const;
170
171 OCTAVE_API FloatComplexMatrix stack (const FloatComplexMatrix& a) const;
175
180
182
183 // resize is the destructive equivalent for this one
184
186 extract (octave_idx_type r1, octave_idx_type c1,
187 octave_idx_type r2, octave_idx_type c2) const;
188
190 extract_n (octave_idx_type r1, octave_idx_type c1,
191 octave_idx_type nr, octave_idx_type nc) const;
192
193 // extract row or column i.
194
196
198
200 const FloatComplex& rfv = FloatComplex (0))
201 {
203 }
204
205private:
206 FloatComplexMatrix tinverse (MatrixType& mattype, octave_idx_type& info,
207 float& rcon, bool force, bool calc_cond) const;
208
209 FloatComplexMatrix finverse (MatrixType& mattype, octave_idx_type& info,
210 float& rcon, bool force, bool calc_cond) const;
211
212public:
213 OCTAVE_API FloatComplexMatrix inverse () const;
214 OCTAVE_API FloatComplexMatrix inverse (octave_idx_type& info) const;
216 inverse (octave_idx_type& info, float& rcon,
217 bool force = false, bool calc_cond = true) const;
218
219 OCTAVE_API FloatComplexMatrix inverse (MatrixType& mattype) const;
221 inverse (MatrixType& mattype, octave_idx_type& info) const;
223 inverse (MatrixType& mattype, octave_idx_type& info, float& rcon,
224 bool force = false, bool calc_cond = true) const;
225
226 OCTAVE_API FloatComplexMatrix pseudo_inverse (float tol = 0.0) const;
227
228 OCTAVE_API FloatComplexMatrix fourier () const;
229 OCTAVE_API FloatComplexMatrix ifourier () const;
230
231 OCTAVE_API FloatComplexMatrix fourier2d () const;
232 OCTAVE_API FloatComplexMatrix ifourier2d () const;
233
234 OCTAVE_API FloatComplexDET determinant () const;
235 OCTAVE_API FloatComplexDET determinant (octave_idx_type& info) const;
237 determinant (octave_idx_type& info, float& rcon,
238 bool calc_cond = true) const;
240 determinant (MatrixType& mattype, octave_idx_type& info,
241 float& rcon, bool calc_cond = true) const;
242
243 OCTAVE_API float rcond () const;
244 OCTAVE_API float rcond (MatrixType& mattype) const;
245
246private:
247 // Upper triangular matrix solvers
248 FloatComplexMatrix utsolve (MatrixType& mattype, const FloatComplexMatrix& b,
249 octave_idx_type& info, float& rcon,
250 solve_singularity_handler sing_handler,
251 bool calc_cond = false,
252 blas_trans_type transt = blas_no_trans) const;
253
254 // Lower triangular matrix solvers
255 FloatComplexMatrix ltsolve (MatrixType& mattype, const FloatComplexMatrix& b,
256 octave_idx_type& info, float& rcon,
257 solve_singularity_handler sing_handler,
258 bool calc_cond = false,
259 blas_trans_type transt = blas_no_trans) const;
260
261 // Full matrix solvers (umfpack/cholesky)
262 FloatComplexMatrix fsolve (MatrixType& mattype, const FloatComplexMatrix& b,
263 octave_idx_type& info, float& rcon,
264 solve_singularity_handler sing_handler,
265 bool calc_cond = false) const;
266
267public:
268 // Generic interface to solver with no probing of type
270 solve (MatrixType& mattype, const FloatMatrix& b) const;
272 solve (MatrixType& mattype, const FloatMatrix& b,
273 octave_idx_type& info) const;
275 solve (MatrixType& mattype, const FloatMatrix& b, octave_idx_type& info,
276 float& rcon) const;
278 solve (MatrixType& mattype, const FloatMatrix& b, octave_idx_type& info,
279 float& rcon, solve_singularity_handler sing_handler,
280 bool singular_fallback = true,
281 blas_trans_type transt = blas_no_trans) const;
282
284 solve (MatrixType& mattype, const FloatComplexMatrix& b) const;
286 solve (MatrixType& mattype, const FloatComplexMatrix& b,
287 octave_idx_type& info) const;
289 solve (MatrixType& mattype, const FloatComplexMatrix& b,
290 octave_idx_type& info, float& rcon) const;
292 solve (MatrixType& mattype, const FloatComplexMatrix& b,
293 octave_idx_type& info, float& rcon,
294 solve_singularity_handler sing_handler,
295 bool singular_fallback = true,
296 blas_trans_type transt = blas_no_trans) const;
297
299 solve (MatrixType& mattype, const FloatColumnVector& b) const;
301 solve (MatrixType& mattype, const FloatColumnVector& b,
302 octave_idx_type& info) const;
304 solve (MatrixType& mattype, const FloatColumnVector& b,
305 octave_idx_type& info, float& rcon) const;
307 solve (MatrixType& mattype, const FloatColumnVector& b,
308 octave_idx_type& info, float& rcon,
309 solve_singularity_handler sing_handler,
310 blas_trans_type transt = blas_no_trans) const;
311
313 solve (MatrixType& mattype, const FloatComplexColumnVector& b) const;
315 solve (MatrixType& mattype, const FloatComplexColumnVector& b,
316 octave_idx_type& info) const;
318 solve (MatrixType& mattype, const FloatComplexColumnVector& b,
319 octave_idx_type& info, float& rcon) const;
321 solve (MatrixType& mattype, const FloatComplexColumnVector& b,
322 octave_idx_type& info, float& rcon,
323 solve_singularity_handler sing_handler,
324 blas_trans_type transt = blas_no_trans) const;
325
326 // Generic interface to solver with probing of type
327 OCTAVE_API FloatComplexMatrix solve (const FloatMatrix& b) const;
329 solve (const FloatMatrix& b, octave_idx_type& info) const;
331 solve (const FloatMatrix& b, octave_idx_type& info, float& rcon) const;
333 solve (const FloatMatrix& b, octave_idx_type& info, float& rcon,
334 solve_singularity_handler sing_handler,
335 blas_trans_type transt = blas_no_trans) const;
336
337 OCTAVE_API FloatComplexMatrix solve (const FloatComplexMatrix& b) const;
339 solve (const FloatComplexMatrix& b, octave_idx_type& info) const;
341 solve (const FloatComplexMatrix& b, octave_idx_type& info,
342 float& rcon) const;
344 solve (const FloatComplexMatrix& b, octave_idx_type& info, float& rcon,
345 solve_singularity_handler sing_handler,
346 blas_trans_type transt = blas_no_trans) const;
347
350 solve (const FloatColumnVector& b, octave_idx_type& info) const;
352 solve (const FloatColumnVector& b, octave_idx_type& info,
353 float& rcon) const;
355 solve (const FloatColumnVector& b, octave_idx_type& info, float& rcon,
356 solve_singularity_handler sing_handler,
357 blas_trans_type transt = blas_no_trans) const;
358
360 solve (const FloatComplexColumnVector& b) const;
362 solve (const FloatComplexColumnVector& b, octave_idx_type& info) const;
364 solve (const FloatComplexColumnVector& b, octave_idx_type& info,
365 float& rcon) const;
367 solve (const FloatComplexColumnVector& b, octave_idx_type& info, float& rcon,
368 solve_singularity_handler sing_handler,
369 blas_trans_type transt = blas_no_trans) const;
370
371 OCTAVE_API FloatComplexMatrix lssolve (const FloatMatrix& b) const;
373 lssolve (const FloatMatrix& b, octave_idx_type& info) const;
375 lssolve (const FloatMatrix& b, octave_idx_type& info, octave_idx_type& rank) const;
377 lssolve (const FloatMatrix& b, octave_idx_type& info, octave_idx_type& rank,
378 float& rcon) const;
379
380 OCTAVE_API FloatComplexMatrix lssolve (const FloatComplexMatrix& b) const;
382 lssolve (const FloatComplexMatrix& b, octave_idx_type& info) const;
384 lssolve (const FloatComplexMatrix& b, octave_idx_type& info,
385 octave_idx_type& rank) const;
387 lssolve (const FloatComplexMatrix& b, octave_idx_type& info,
388 octave_idx_type& rank, float& rcon) const;
389
391 lssolve (const FloatColumnVector& b) const;
393 lssolve (const FloatColumnVector& b, octave_idx_type& info) const;
395 lssolve (const FloatColumnVector& b, octave_idx_type& info,
396 octave_idx_type& rank) const;
398 lssolve (const FloatColumnVector& b, octave_idx_type& info,
399 octave_idx_type& rank, float& rcon) const;
400
402 lssolve (const FloatComplexColumnVector& b) const;
404 lssolve (const FloatComplexColumnVector& b, octave_idx_type& info) const;
406 lssolve (const FloatComplexColumnVector& b, octave_idx_type& info,
407 octave_idx_type& rank) const;
409 lssolve (const FloatComplexColumnVector& b, octave_idx_type& info,
410 octave_idx_type& rank, float& rcon) const;
411
412 // matrix by diagonal matrix -> matrix operations
413
416
419
420 // matrix by matrix -> matrix operations
421
424
425 // unary operations
426
428
429 // other operations
430
431 OCTAVE_API boolMatrix all (int dim = -1) const;
432 OCTAVE_API boolMatrix any (int dim = -1) const;
433
434 OCTAVE_API FloatComplexMatrix cumprod (int dim = -1) const;
435 OCTAVE_API FloatComplexMatrix cumsum (int dim = -1) const;
436 OCTAVE_API FloatComplexMatrix prod (int dim = -1) const;
437 OCTAVE_API FloatComplexMatrix sum (int dim = -1) const;
438 OCTAVE_API FloatComplexMatrix sumsq (int dim = -1) const;
439 OCTAVE_API FloatMatrix abs () const;
440
442
444 diag (octave_idx_type m, octave_idx_type n) const;
445
446 OCTAVE_API bool row_is_real_only (octave_idx_type) const;
447 OCTAVE_API bool column_is_real_only (octave_idx_type) const;
448
449 OCTAVE_API FloatComplexColumnVector row_min () const;
450 OCTAVE_API FloatComplexColumnVector row_max () const;
451
453 row_min (Array<octave_idx_type>& index) const;
455 row_max (Array<octave_idx_type>& index) const;
456
457 OCTAVE_API FloatComplexRowVector column_min () const;
458 OCTAVE_API FloatComplexRowVector column_max () const;
459
461 column_min (Array<octave_idx_type>& index) const;
463 column_max (Array<octave_idx_type>& index) const;
464
465 // i/o
466
467 friend OCTAVE_API std::ostream&
468 operator << (std::ostream& os, const FloatComplexMatrix& a);
469 friend OCTAVE_API std::istream&
470 operator >> (std::istream& is, FloatComplexMatrix& a);
471};
472
474
475// column vector by row vector -> matrix operations
476
479
482
485
487Givens (const FloatComplex&, const FloatComplex&);
488
491 const FloatComplexMatrix&);
492
497
499 const FloatComplexMatrix&);
501 const FloatMatrix&);
503 const FloatComplexMatrix&);
504
506 const FloatComplexMatrix& m);
508 const FloatComplex& c);
510 const FloatComplexMatrix& b);
511
513 const FloatComplexMatrix& m);
515 const FloatComplex& c);
517 const FloatComplexMatrix& b);
518
521 const FloatComplexColumnVector& x2,
523
526
529
532
534
535#endif
template std::ostream & operator<<(std::ostream &, const Array< bool > &)
ComplexColumnVector conj(const ComplexColumnVector &a)
ComplexColumnVector operator+=(ComplexColumnVector &x, const Complex &y)
Definition CColVector.h:156
ComplexColumnVector operator-=(ComplexColumnVector &x, const Complex &y)
Definition CColVector.h:156
#define MARRAY_FORWARD_DEFS(B, R, T)
Definition MArray.h:128
std::istream & operator>>(std::istream &is, SparseBoolMatrix &a)
N Dimensional Array with copy-on-write semantics.
Definition Array.h:130
void resize(const dim_vector &dv, const T &rfv)
FloatComplexMatrix hermitian() const
Definition fCMatrix.h:176
FloatComplexMatrix(const dim_vector &dv, const FloatComplex &val)
Definition fCMatrix.h:79
FloatComplexMatrix(const FloatComplexMatrix &a)=default
FloatComplexMatrix(const dim_vector &dv)
Definition fCMatrix.h:76
FloatComplexDiagMatrix complex_diag_matrix_type
Definition fCMatrix.h:54
FloatColumnVector real_column_vector_type
Definition fCMatrix.h:47
FloatRowVector real_row_vector_type
Definition fCMatrix.h:48
FloatComplexMatrix complex_matrix_type
Definition fCMatrix.h:51
FloatComplexMatrix(const Array< U > &a)
Definition fCMatrix.h:87
FloatMatrix real_matrix_type
Definition fCMatrix.h:50
void resize(octave_idx_type nr, octave_idx_type nc, const FloatComplex &rfv=FloatComplex(0))
Definition fCMatrix.h:199
FloatComplex complex_elt_type
Definition fCMatrix.h:57
FloatComplexMatrix transpose() const
Definition fCMatrix.h:178
FloatComplexMatrix(octave_idx_type r, octave_idx_type c, const FloatComplex &val)
Definition fCMatrix.h:72
FloatComplexRowVector row_vector_type
Definition fCMatrix.h:45
FloatComplexMatrix()=default
FloatComplexMatrix(octave_idx_type r, octave_idx_type c)
Definition fCMatrix.h:69
FloatDiagMatrix real_diag_matrix_type
Definition fCMatrix.h:53
FloatComplexColumnVector column_vector_type
Definition fCMatrix.h:44
FloatComplexMatrix(const MArray< U > &a)
Definition fCMatrix.h:83
~FloatComplexMatrix()=default
FloatComplexNDArray & operator=(const FloatComplexNDArray &a)
Definition fCNDArray.h:58
Template for N-dimensional array classes with like-type math operators.
Definition MArray.h:61
MArray< T > transpose() const
Definition MArray.h:97
MArray< T > hermitian(T(*fcn)(const T &)=nullptr) const
Definition MArray.h:100
Template for two dimensional diagonal array with math operators.
Definition MDiagArray2.h:54
Definition DET.h:38
Vector representing the dimensions (size) of an Array.
Definition dim-vector.h:90
bool operator!=(const dim_vector &a, const dim_vector &b)
Definition dim-vector.h:532
bool operator==(const dim_vector &a, const dim_vector &b)
Definition dim-vector.h:516
FloatComplexMatrix xgemm(const FloatComplexMatrix &a, const FloatComplexMatrix &b, blas_trans_type transa=blas_no_trans, blas_trans_type transb=blas_no_trans)
Definition fCMatrix.cc:3379
FloatComplexMatrix max(const FloatComplex &c, const FloatComplexMatrix &m)
Definition fCMatrix.cc:3586
FloatComplexMatrix linspace(const FloatComplexColumnVector &x1, const FloatComplexColumnVector &x2, octave_idx_type n)
Definition fCMatrix.cc:3661
FloatComplexMatrix Sylvester(const FloatComplexMatrix &, const FloatComplexMatrix &, const FloatComplexMatrix &)
Definition fCMatrix.cc:3279
FloatComplexMatrix min(const FloatComplex &c, const FloatComplexMatrix &m)
Definition fCMatrix.cc:3514
FloatComplexMatrix conj(const FloatComplexMatrix &a)
Definition fCMatrix.cc:679
FloatComplexMatrix operator*(const FloatColumnVector &a, const FloatComplexRowVector &b)
Definition fCMatrix.cc:2653
FloatComplexMatrix Givens(const FloatComplex &, const FloatComplex &)
Definition fCMatrix.cc:3260
#define OCTAVE_API
Definition main.in.cc:55
blas_trans_type
Definition mx-defs.h:80
@ blas_no_trans
Definition mx-defs.h:81
#define SM_BOOL_OP_DECLS(S, M, API)
Definition mx-op-decl.h:122
#define MS_CMP_OP_DECLS(M, S, API)
Definition mx-op-decl.h:89
#define SM_CMP_OP_DECLS(S, M, API)
Definition mx-op-decl.h:114
#define MS_BOOL_OP_DECLS(M, S, API)
Definition mx-op-decl.h:97
#define MM_CMP_OP_DECLS(M1, M2, API)
Definition mx-op-decl.h:139
#define MM_BOOL_OP_DECLS(M1, M2, API)
Definition mx-op-decl.h:147
std::complex< float > FloatComplex
Definition oct-cmplx.h:34
octave_value operator!(const octave_value &a)
Definition ov.h:1648
template int8_t abs(int8_t)