GNU Octave  4.2.1
A high-level interpreted language, primarily intended for numerical computations, mostly compatible with Matlab
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
fCMatrix.h
Go to the documentation of this file.
1 /*
2 
3 Copyright (C) 1994-2017 John W. Eaton
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
9 Free Software Foundation; either version 3 of the License, or (at your
10 option) any later version.
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
18 along with Octave; see the file COPYING. If not, see
19 <http://www.gnu.org/licenses/>.
20 
21 */
22 
23 #if ! defined (octave_fCMatrix_h)
24 #define octave_fCMatrix_h 1
25 
26 #include "octave-config.h"
27 
28 #include "fCNDArray.h"
29 #include "MArray.h"
30 #include "MDiagArray2.h"
31 #include "MatrixType.h"
32 
33 #include "mx-defs.h"
34 #include "mx-op-decl.h"
35 #include "oct-cmplx.h"
36 #include "DET.h"
37 
38 class
39 OCTAVE_API
41 {
42 public:
43 
46 
49 
52 
55 
56  typedef float real_elt_type;
58 
59  typedef void (*solve_singularity_handler) (float rcon);
60 
62 
64  : FloatComplexNDArray (dim_vector (r, c)) { }
65 
67  const FloatComplex& val)
68  : FloatComplexNDArray (dim_vector (r, c), val) { }
69 
71  : FloatComplexNDArray (dv.redim (2)) { }
72 
74  : FloatComplexNDArray (dv.redim (2), val) { }
75 
77  : FloatComplexNDArray (a) { }
78 
79  template <typename U>
81  : FloatComplexNDArray (a.as_matrix ()) { }
82 
83  template <typename U>
85  : FloatComplexNDArray (a.as_matrix ()) { }
86 
87  explicit FloatComplexMatrix (const FloatMatrix& a);
88 
89  explicit FloatComplexMatrix (const FloatRowVector& rv);
90 
91  explicit FloatComplexMatrix (const FloatColumnVector& cv);
92 
93  explicit FloatComplexMatrix (const FloatDiagMatrix& a);
94 
95  explicit FloatComplexMatrix (const MDiagArray2<float>& a);
96 
97  explicit FloatComplexMatrix (const DiagArray2<float>& a);
98 
99  explicit FloatComplexMatrix (const FloatComplexRowVector& rv);
100 
101  explicit FloatComplexMatrix (const FloatComplexColumnVector& cv);
102 
103  explicit FloatComplexMatrix (const FloatComplexDiagMatrix& a);
104 
106 
108 
109  explicit FloatComplexMatrix (const boolMatrix& a);
110 
111  explicit FloatComplexMatrix (const charMatrix& a);
112 
113  FloatComplexMatrix (const FloatMatrix& re, const FloatMatrix& im);
114 
115  bool operator == (const FloatComplexMatrix& a) const;
116  bool operator != (const FloatComplexMatrix& a) const;
117 
118  bool is_hermitian (void) const;
119 
120  // destructive insert/delete/reorder operations
121 
130 
139 
140  FloatComplexMatrix& fill (float val);
147 
148  FloatComplexMatrix append (const FloatMatrix& a) const;
149  FloatComplexMatrix append (const FloatRowVector& a) const;
152 
157 
158  FloatComplexMatrix stack (const FloatMatrix& a) const;
159  FloatComplexMatrix stack (const FloatRowVector& a) const;
160  FloatComplexMatrix stack (const FloatColumnVector& a) const;
161  FloatComplexMatrix stack (const FloatDiagMatrix& a) const;
162 
163  FloatComplexMatrix stack (const FloatComplexMatrix& a) const;
164  FloatComplexMatrix stack (const FloatComplexRowVector& a) const;
165  FloatComplexMatrix stack (const FloatComplexColumnVector& a) const;
166  FloatComplexMatrix stack (const FloatComplexDiagMatrix& a) const;
167 
171  { return MArray<FloatComplex>::transpose (); }
172 
173  friend OCTAVE_API FloatComplexMatrix conj (const FloatComplexMatrix& a);
174 
175  // resize is the destructive equivalent for this one
176 
178  octave_idx_type r2, octave_idx_type c2) const;
179 
181  octave_idx_type nr, octave_idx_type nc) const;
182 
183  // extract row or column i.
184 
186 
188 
190  const FloatComplex& rfv = FloatComplex (0))
191  {
193  }
194 
195 private:
196  FloatComplexMatrix tinverse (MatrixType &mattype, octave_idx_type& info,
197  float& rcon, bool force, bool calc_cond) const;
198 
199  FloatComplexMatrix finverse (MatrixType &mattype, octave_idx_type& info,
200  float& rcon, bool force, bool calc_cond) const;
201 
202 public:
203  FloatComplexMatrix inverse (void) const;
204  FloatComplexMatrix inverse (octave_idx_type& info) const;
205  FloatComplexMatrix inverse (octave_idx_type& info, float& rcon,
206  bool force = false, bool calc_cond = true) const;
207 
208  FloatComplexMatrix inverse (MatrixType &mattype) const;
209  FloatComplexMatrix inverse (MatrixType &mattype, octave_idx_type& info) const;
210  FloatComplexMatrix inverse (MatrixType &mattype, octave_idx_type& info,
211  float& rcon, bool force = false,
212  bool calc_cond = true) const;
213 
214  FloatComplexMatrix pseudo_inverse (float tol = 0.0) const;
215 
216  FloatComplexMatrix fourier (void) const;
217  FloatComplexMatrix ifourier (void) const;
218 
219  FloatComplexMatrix fourier2d (void) const;
220  FloatComplexMatrix ifourier2d (void) const;
221 
222  FloatComplexDET determinant (void) const;
223  FloatComplexDET determinant (octave_idx_type& info) const;
224  FloatComplexDET determinant (octave_idx_type& info, float& rcon,
225  bool calc_cond = true) const;
226  FloatComplexDET determinant (MatrixType &mattype, octave_idx_type& info,
227  float& rcon, bool calc_cond = true) const;
228 
229  float rcond (void) const;
230  float rcond (MatrixType &mattype) const;
231 
232 private:
233  // Upper triangular matrix solvers
235  octave_idx_type& info, float& rcon,
236  solve_singularity_handler sing_handler,
237  bool calc_cond = false,
238  blas_trans_type transt = blas_no_trans) const;
239 
240  // Lower triangular matrix solvers
242  octave_idx_type& info, float& rcon,
243  solve_singularity_handler sing_handler,
244  bool calc_cond = false,
245  blas_trans_type transt = blas_no_trans) const;
246 
247  // Full matrix solvers (umfpack/cholesky)
248  FloatComplexMatrix fsolve (MatrixType &typ, const FloatComplexMatrix& b,
249  octave_idx_type& info, float& rcon,
250  solve_singularity_handler sing_handler,
251  bool calc_cond = false) const;
252 
253 public:
254  // Generic interface to solver with no probing of type
255  FloatComplexMatrix solve (MatrixType &typ, const FloatMatrix& b) const;
256  FloatComplexMatrix solve (MatrixType &typ, const FloatMatrix& b,
257  octave_idx_type& info) const;
258  FloatComplexMatrix solve (MatrixType &typ, const FloatMatrix& b,
259  octave_idx_type& info, float& rcon) const;
260  FloatComplexMatrix solve (MatrixType &typ, const FloatMatrix& b,
261  octave_idx_type& info,
262  float& rcon, solve_singularity_handler sing_handler,
263  bool singular_fallback = true,
264  blas_trans_type transt = blas_no_trans) const;
265 
266  FloatComplexMatrix solve (MatrixType &typ, const FloatComplexMatrix& b) const;
268  octave_idx_type& info) const;
270  octave_idx_type& info, float& rcon) const;
272  octave_idx_type& info, float& rcon,
273  solve_singularity_handler sing_handler,
274  bool singular_fallback = true,
275  blas_trans_type transt = blas_no_trans) const;
276 
278  const FloatColumnVector& b) const;
280  octave_idx_type& info) const;
282  octave_idx_type& info, float& rcon) const;
284  octave_idx_type& info, float& rcon,
285  solve_singularity_handler sing_handler,
286  blas_trans_type transt = blas_no_trans) const;
287 
289  const FloatComplexColumnVector& b) const;
292  octave_idx_type& info) const;
295  octave_idx_type& info, float& rcon) const;
298  octave_idx_type& info, float& rcon,
299  solve_singularity_handler sing_handler,
300  blas_trans_type transt = blas_no_trans) const;
301 
302  // Generic interface to solver with probing of type
303  FloatComplexMatrix solve (const FloatMatrix& b) const;
304  FloatComplexMatrix solve (const FloatMatrix& b, octave_idx_type& info) const;
305  FloatComplexMatrix solve (const FloatMatrix& b, octave_idx_type& info,
306  float& rcon) const;
307  FloatComplexMatrix solve (const FloatMatrix& b, octave_idx_type& info,
308  float& rcon,
309  solve_singularity_handler sing_handler,
310  blas_trans_type transt = blas_no_trans) const;
311 
312  FloatComplexMatrix solve (const FloatComplexMatrix& b) const;
314  octave_idx_type& info) const;
316  float& rcon) const;
318  float& rcon,
319  solve_singularity_handler sing_handler,
320  blas_trans_type transt = blas_no_trans) const;
321 
322  FloatComplexColumnVector solve (const FloatColumnVector& b) const;
324  octave_idx_type& info) const;
326  octave_idx_type& info,
327  float& rcon) const;
329  octave_idx_type& info, float& rcon,
330  solve_singularity_handler sing_handler,
331  blas_trans_type transt = blas_no_trans) const;
332 
335  octave_idx_type& info) const;
337  octave_idx_type& info,
338  float& rcon) const;
340  octave_idx_type& info,
341  float& rcon,
342  solve_singularity_handler sing_handler,
343  blas_trans_type transt = blas_no_trans) const;
344 
345  FloatComplexMatrix lssolve (const FloatMatrix& b) const;
346  FloatComplexMatrix lssolve (const FloatMatrix& b,
347  octave_idx_type& info) const;
348  FloatComplexMatrix lssolve (const FloatMatrix& b, octave_idx_type& info,
349  octave_idx_type& rank) const;
350  FloatComplexMatrix lssolve (const FloatMatrix& b, octave_idx_type& info,
351  octave_idx_type& rank, float& rcon) const;
352 
353  FloatComplexMatrix lssolve (const FloatComplexMatrix& b) const;
354  FloatComplexMatrix lssolve (const FloatComplexMatrix& b,
355  octave_idx_type& info) const;
356  FloatComplexMatrix lssolve (const FloatComplexMatrix& b,
357  octave_idx_type& info, octave_idx_type& rank) const;
358  FloatComplexMatrix lssolve (const FloatComplexMatrix& b,
359  octave_idx_type& info, octave_idx_type& rank, float& rcon) const;
360 
361  FloatComplexColumnVector lssolve (const FloatColumnVector& b) const;
363  octave_idx_type& info) const;
365  octave_idx_type& info,
366  octave_idx_type& rank) const;
368  octave_idx_type& info,
369  octave_idx_type& rank, float& rcon) const;
370 
371  FloatComplexColumnVector lssolve (const FloatComplexColumnVector& b) const;
373  octave_idx_type& info) const;
375  octave_idx_type& info,
376  octave_idx_type& rank) const;
378  octave_idx_type& info,
379  octave_idx_type& rank, float& rcon) const;
380 
381  // matrix by diagonal matrix -> matrix operations
382 
385 
388 
389  // matrix by matrix -> matrix operations
390 
393 
394  // unary operations
395 
396  boolMatrix operator ! (void) const;
397 
398  // other operations
399 
400  boolMatrix all (int dim = -1) const;
401  boolMatrix any (int dim = -1) const;
402 
403  FloatComplexMatrix cumprod (int dim = -1) const;
404  FloatComplexMatrix cumsum (int dim = -1) const;
405  FloatComplexMatrix prod (int dim = -1) const;
406  FloatComplexMatrix sum (int dim = -1) const;
407  FloatComplexMatrix sumsq (int dim = -1) const;
408  FloatMatrix abs (void) const;
409 
411 
413 
414  bool row_is_real_only (octave_idx_type) const;
415  bool column_is_real_only (octave_idx_type) const;
416 
417  FloatComplexColumnVector row_min (void) const;
418  FloatComplexColumnVector row_max (void) const;
419 
422 
423  FloatComplexRowVector column_min (void) const;
424  FloatComplexRowVector column_max (void) const;
425 
428 
429  // i/o
430 
431  friend OCTAVE_API std::ostream& operator << (std::ostream& os,
432  const FloatComplexMatrix& a);
433  friend OCTAVE_API std::istream& operator >> (std::istream& is,
435 };
436 
437 extern OCTAVE_API FloatComplexMatrix conj (const FloatComplexMatrix& a);
438 
439 // column vector by row vector -> matrix operations
440 
441 extern OCTAVE_API FloatComplexMatrix
443 
444 extern OCTAVE_API FloatComplexMatrix
446 
447 extern OCTAVE_API FloatComplexMatrix
449 
450 extern OCTAVE_API FloatComplexMatrix
451 Givens (const FloatComplex&, const FloatComplex&);
452 
453 extern OCTAVE_API FloatComplexMatrix
455  const FloatComplexMatrix&);
456 
457 extern OCTAVE_API FloatComplexMatrix
460  blas_trans_type transb = blas_no_trans);
461 
462 extern OCTAVE_API FloatComplexMatrix operator * (const FloatMatrix&,
463  const FloatComplexMatrix&);
464 extern OCTAVE_API FloatComplexMatrix operator * (const FloatComplexMatrix&,
465  const FloatMatrix&);
466 extern OCTAVE_API FloatComplexMatrix operator * (const FloatComplexMatrix&,
467  const FloatComplexMatrix&);
468 
469 extern OCTAVE_API FloatComplexMatrix min (const FloatComplex& c,
470  const FloatComplexMatrix& m);
471 extern OCTAVE_API FloatComplexMatrix min (const FloatComplexMatrix& m,
472  const FloatComplex& c);
473 extern OCTAVE_API FloatComplexMatrix min (const FloatComplexMatrix& a,
474  const FloatComplexMatrix& b);
475 
476 extern OCTAVE_API FloatComplexMatrix max (const FloatComplex& c,
477  const FloatComplexMatrix& m);
478 extern OCTAVE_API FloatComplexMatrix max (const FloatComplexMatrix& m,
479  const FloatComplex& c);
480 extern OCTAVE_API FloatComplexMatrix max (const FloatComplexMatrix& a,
481  const FloatComplexMatrix& b);
482 
483 extern OCTAVE_API FloatComplexMatrix
485  const FloatComplexColumnVector& x2,
486  octave_idx_type n);
487 
490 
491 SM_CMP_OP_DECLS (FloatComplex, FloatComplexMatrix, OCTAVE_API)
492 SM_BOOL_OP_DECLS (FloatComplex, FloatComplexMatrix, OCTAVE_API)
493 
494 MM_CMP_OP_DECLS (FloatComplexMatrix, FloatComplexMatrix, OCTAVE_API)
495 MM_BOOL_OP_DECLS (FloatComplexMatrix, FloatComplexMatrix, OCTAVE_API)
496 
497 MARRAY_FORWARD_DEFS (MArray, FloatComplexMatrix, FloatComplex)
498 
499 #endif
FloatComplexMatrix transpose(void) const
Definition: fCMatrix.h:170
Array< FloatComplex > as_matrix(void) const
Return the array as a matrix.
Definition: Array.h:387
FloatComplexMatrix complex_matrix_type
Definition: fCMatrix.h:51
void resize(octave_idx_type nr, octave_idx_type nc, const FloatComplex &rfv=FloatComplex(0))
Definition: fCMatrix.h:189
FloatRowVector real_row_vector_type
Definition: fCMatrix.h:48
OCTAVE_EXPORT octave_value_list column
Definition: sparse.cc:123
FloatComplexRowVector row_vector_type
Definition: fCMatrix.h:45
FloatComplexRowVector & fill(float val)
Definition: fCRowVector.cc:97
bool operator!=(const dim_vector &a, const dim_vector &b)
Definition: dim-vector.h:567
FloatComplexMatrix(void)
Definition: fCMatrix.h:61
std::istream & operator>>(std::istream &is, SparseBoolMatrix &a)
Definition: boolSparse.cc:279
FloatComplexMatrix hermitian(void) const
Definition: fCMatrix.h:168
OCTAVE_API FloatComplexMatrix operator*(const FloatColumnVector &a, const FloatComplexRowVector &b)
Definition: fCMatrix.cc:2693
identity matrix If supplied two scalar respectively For allows like xample val
Definition: data.cc:5068
OCTAVE_API FloatComplexMatrix linspace(const FloatComplexColumnVector &x1, const FloatComplexColumnVector &x2, octave_idx_type n)
Definition: fCMatrix.cc:3699
OCTAVE_API FloatComplexMatrix conj(const FloatComplexMatrix &a)
Definition: fCMatrix.cc:681
OCTAVE_API FloatComplexMatrix min(const FloatComplex &c, const FloatComplexMatrix &m)
Definition: fCMatrix.cc:3553
for large enough k
Definition: lu.cc:606
FloatComplex complex_elt_type
Definition: fCMatrix.h:57
Array< FloatComplex > diag(octave_idx_type k=0) const
Get the kth super or subdiagonal.
MArray< T > transpose(void) const
Definition: MArray.h:103
FloatComplexRowVector extract_n(octave_idx_type c1, octave_idx_type n) const
Definition: fCRowVector.cc:229
Template for N-dimensional array classes with like-type math operators.
Definition: MArray.h:32
#define SM_CMP_OP_DECLS(S, M, API)
Definition: mx-op-decl.h:114
OCTAVE_API FloatComplexMatrix Sylvester(const FloatComplexMatrix &, const FloatComplexMatrix &, const FloatComplexMatrix &)
Definition: fCMatrix.cc:3318
#define MARRAY_FORWARD_DEFS(B, R, T)
Definition: MArray.h:126
FloatComplexMatrix(const dim_vector &dv, const FloatComplex &val)
Definition: fCMatrix.h:73
calling an anonymous function involves an overhead quite comparable to the overhead of an m file function Passing a handle to a built in function is because the interpreter is not involved in the internal loop For a
Definition: cellfun.cc:398
FloatComplexMatrix(const MArray< U > &a)
Definition: fCMatrix.h:80
FloatComplexRowVector extract(octave_idx_type c1, octave_idx_type c2) const
Definition: fCRowVector.cc:214
#define SM_BOOL_OP_DECLS(S, M, API)
Definition: mx-op-decl.h:122
nd deftypefn *octave_map m
Definition: ov-struct.cc:2058
Definition: DET.h:33
#define MM_CMP_OP_DECLS(M1, M2, API)
Definition: mx-op-decl.h:139
FloatColumnVector real_column_vector_type
Definition: fCMatrix.h:47
#define MM_BOOL_OP_DECLS(M1, M2, API)
Definition: mx-op-decl.h:147
void resize(const dim_vector &dv, const T &rfv)
Definition: Array.cc:1028
bool append
Definition: load-save.cc:1582
static M ltsolve(const SM &L, const ColumnVector &Q, const M &m)
Definition: eigs-base.cc:79
float real_elt_type
Definition: fCMatrix.h:56
FloatComplexMatrix(octave_idx_type r, octave_idx_type c)
Definition: fCMatrix.h:63
the sparsity preserving column transformation such that that defines the pivoting threshold can be given in which case it defines the c
Definition: lu.cc:138
FloatComplexMatrix(octave_idx_type r, octave_idx_type c, const FloatComplex &val)
Definition: fCMatrix.h:66
MArray< T > hermitian(T(*fcn)(const T &)=0) const
Definition: MArray.h:106
FloatComplexMatrix operator-=(FloatComplexMatrix &x, const FloatComplex &y)
Definition: fCMatrix.h:497
FloatComplexColumnVector column_vector_type
Definition: fCMatrix.h:44
bool operator==(const dim_vector &a, const dim_vector &b)
Definition: dim-vector.h:538
FloatComplexMatrix(const FloatComplexMatrix &a)
Definition: fCMatrix.h:76
#define MS_CMP_OP_DECLS(M, S, API)
Definition: mx-op-decl.h:89
FloatDiagMatrix real_diag_matrix_type
Definition: fCMatrix.h:53
N Dimensional Array with copy-on-write semantics.
Definition: Array.h:126
FloatComplexMatrix(const Array< U > &a)
Definition: fCMatrix.h:84
FloatComplexMatrix(const dim_vector &dv)
Definition: fCMatrix.h:70
=val(i)}if ode{val(i)}occurs in table i
Definition: lookup.cc:239
OCTAVE_EXPORT octave_value_list return the value of the option it must match the dimension of the state and the relative tolerance must also be a vector of the same length tem it must match the dimension of the state and the absolute tolerance must also be a vector of the same length The local error test applied at each integration step is xample roup abs(local error in x(i))<
FloatMatrix real_matrix_type
Definition: fCMatrix.h:50
template OCTAVE_API std::ostream & operator<<(std::ostream &, const Array< bool > &)
#define MS_BOOL_OP_DECLS(M, S, API)
Definition: mx-op-decl.h:97
b
Definition: cellfun.cc:398
static M utsolve(const SM &U, const ColumnVector &Q, const M &m)
Definition: eigs-base.cc:106
std::complex< float > FloatComplex
Definition: oct-cmplx.h:32
FloatComplexDiagMatrix complex_diag_matrix_type
Definition: fCMatrix.h:54
blas_trans_type
Definition: mx-defs.h:103
octave_value operator!(const octave_value &a)
Definition: ov.h:1484
FloatComplexRowVector & insert(const FloatRowVector &a, octave_idx_type c)
Definition: fCRowVector.cc:58
write the output to stdout if nargout is
Definition: load-save.cc:1576
OCTAVE_API 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:3418
OCTAVE_API FloatComplexMatrix Givens(const FloatComplex &, const FloatComplex &)
Definition: fCMatrix.cc:3299
Vector representing the dimensions (size) of an Array.
Definition: dim-vector.h:87
the second is matched to the second specifier and placed in the second column and so forth If there are more words than specifiers then the process is repeated until all words have been processed or the limit imposed by any(non-whitespace) text in the format that is not one of these specifiers is considered a literal.If there is a literal between two format specifiers then that same literal must appear in the input stream between the matching words.The following specifiers are valid
Definition: file-io.cc:1491
FloatComplexMatrix operator+=(FloatComplexMatrix &x, const FloatComplex &y)
Definition: fCMatrix.h:497
OCTAVE_API FloatComplexMatrix max(const FloatComplex &c, const FloatComplexMatrix &m)
Definition: fCMatrix.cc:3625
dim_vector dv
Definition: sub2ind.cc:263
where the brackets indicate optional arguments and and character or cell array For character arrays the conversion is repeated for every row
Definition: str2double.cc:342
Array< FloatComplex > index(const idx_vector &i) const
Indexing without resizing.