GNU Octave  3.8.0
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-2013 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 "MArray.h"
27 #include "MDiagArray2.h"
28 #include "MatrixType.h"
29 
30 #include "mx-defs.h"
31 #include "mx-op-decl.h"
32 #include "oct-cmplx.h"
33 #include "DET.h"
34 
35 class
36 OCTAVE_API
38 {
39 public:
40 
43 
44  typedef void (*solve_singularity_handler) (float rcon);
45 
47 
49  : MArray<FloatComplex> (dim_vector (r, c)) { }
50 
52  const FloatComplex& val)
53  : MArray<FloatComplex> (dim_vector (r, c), val) { }
54 
56  : MArray<FloatComplex> (dv.redim (2)) { }
57 
58  FloatComplexMatrix (const dim_vector& dv, const FloatComplex& val)
59  : MArray<FloatComplex> (dv.redim (2), val) { }
60 
62  : MArray<FloatComplex> (a) { }
63 
64  template <class U>
66  : MArray<FloatComplex> (a.as_matrix ()) { }
67 
68  template <class U>
70  : MArray<FloatComplex> (a.as_matrix ()) { }
71 
72  explicit FloatComplexMatrix (const FloatMatrix& a);
73 
74  explicit FloatComplexMatrix (const FloatRowVector& rv);
75 
76  explicit FloatComplexMatrix (const FloatColumnVector& cv);
77 
78  explicit FloatComplexMatrix (const FloatDiagMatrix& a);
79 
80  explicit FloatComplexMatrix (const FloatComplexRowVector& rv);
81 
82  explicit FloatComplexMatrix (const FloatComplexColumnVector& cv);
83 
84  explicit FloatComplexMatrix (const FloatComplexDiagMatrix& a);
85 
86  explicit FloatComplexMatrix (const boolMatrix& a);
87 
88  explicit FloatComplexMatrix (const charMatrix& a);
89 
90  FloatComplexMatrix (const FloatMatrix& re, const FloatMatrix& im);
91 
93  {
95  return *this;
96  }
97 
98  bool operator == (const FloatComplexMatrix& a) const;
99  bool operator != (const FloatComplexMatrix& a) const;
100 
101  bool is_hermitian (void) const;
102 
103  // destructive insert/delete/reorder operations
104 
113 
122 
123  FloatComplexMatrix& fill (float val);
124  FloatComplexMatrix& fill (const FloatComplex& val);
127  FloatComplexMatrix& fill (const FloatComplex& val,
130 
131  FloatComplexMatrix append (const FloatMatrix& a) const;
132  FloatComplexMatrix append (const FloatRowVector& a) const;
134  FloatComplexMatrix append (const FloatDiagMatrix& a) const;
135 
140 
141  FloatComplexMatrix stack (const FloatMatrix& a) const;
142  FloatComplexMatrix stack (const FloatRowVector& a) const;
143  FloatComplexMatrix stack (const FloatColumnVector& a) const;
144  FloatComplexMatrix stack (const FloatDiagMatrix& a) const;
145 
146  FloatComplexMatrix stack (const FloatComplexMatrix& a) const;
147  FloatComplexMatrix stack (const FloatComplexRowVector& a) const;
148  FloatComplexMatrix stack (const FloatComplexColumnVector& a) const;
149  FloatComplexMatrix stack (const FloatComplexDiagMatrix& a) const;
150 
154  { return MArray<FloatComplex>::transpose (); }
155 
156  friend OCTAVE_API FloatComplexMatrix conj (const FloatComplexMatrix& a);
157 
158  // resize is the destructive equivalent for this one
159 
162 
164  octave_idx_type nr, octave_idx_type nc) const;
165 
166  // extract row or column i.
167 
169 
171 
173  const FloatComplex& rfv = FloatComplex (0))
174  {
176  }
177 
178 private:
179  FloatComplexMatrix tinverse (MatrixType &mattype, octave_idx_type& info,
180  float& rcon, int force, int calc_cond) const;
181 
182  FloatComplexMatrix finverse (MatrixType &mattype, octave_idx_type& info,
183  float& rcon, int force, int calc_cond) const;
184 
185 public:
186  FloatComplexMatrix inverse (void) const;
187  FloatComplexMatrix inverse (octave_idx_type& info) const;
188  FloatComplexMatrix inverse (octave_idx_type& info, float& rcon,
189  int force = 0, int calc_cond = 1) const;
190 
191  FloatComplexMatrix inverse (MatrixType &mattype) const;
192  FloatComplexMatrix inverse (MatrixType &mattype, octave_idx_type& info) const;
193  FloatComplexMatrix inverse (MatrixType &mattype, octave_idx_type& info,
194  float& rcon, int force = 0,
195  int calc_cond = 1) const;
196 
197  FloatComplexMatrix pseudo_inverse (float tol = 0.0) const;
198 
199  FloatComplexMatrix fourier (void) const;
200  FloatComplexMatrix ifourier (void) const;
201 
202  FloatComplexMatrix fourier2d (void) const;
203  FloatComplexMatrix ifourier2d (void) const;
204 
205  FloatComplexDET determinant (void) const;
206  FloatComplexDET determinant (octave_idx_type& info) const;
207  FloatComplexDET determinant (octave_idx_type& info, float& rcon,
208  int calc_cond = 1) const;
209  FloatComplexDET determinant (MatrixType &mattype, octave_idx_type& info,
210  float& rcon, int calc_cond = 1) const;
211 
212  float rcond (void) const;
213  float rcond (MatrixType &mattype) const;
214 
215 private:
216  // Upper triangular matrix solvers
218  octave_idx_type& info, float& rcon,
219  solve_singularity_handler sing_handler,
220  bool calc_cond = false,
221  blas_trans_type transt = blas_no_trans) const;
222 
223  // Lower triangular matrix solvers
225  octave_idx_type& info, float& rcon,
226  solve_singularity_handler sing_handler,
227  bool calc_cond = false,
228  blas_trans_type transt = blas_no_trans) const;
229 
230  // Full matrix solvers (umfpack/cholesky)
231  FloatComplexMatrix fsolve (MatrixType &typ, const FloatComplexMatrix& b,
232  octave_idx_type& info, float& rcon,
233  solve_singularity_handler sing_handler,
234  bool calc_cond = false) const;
235 
236 public:
237  // Generic interface to solver with no probing of type
238  FloatComplexMatrix solve (MatrixType &typ, const FloatMatrix& b) const;
239  FloatComplexMatrix solve (MatrixType &typ, const FloatMatrix& b,
240  octave_idx_type& info) const;
241  FloatComplexMatrix solve (MatrixType &typ, const FloatMatrix& b,
242  octave_idx_type& info, float& rcon) const;
243  FloatComplexMatrix solve (MatrixType &typ, const FloatMatrix& b,
244  octave_idx_type& info,
245  float& rcon, solve_singularity_handler sing_handler,
246  bool singular_fallback = true,
247  blas_trans_type transt = blas_no_trans) const;
248 
249  FloatComplexMatrix solve (MatrixType &typ, const FloatComplexMatrix& b) const;
250  FloatComplexMatrix solve (MatrixType &typ, const FloatComplexMatrix& b,
251  octave_idx_type& info) const;
252  FloatComplexMatrix solve (MatrixType &typ, const FloatComplexMatrix& b,
253  octave_idx_type& info, float& rcon) const;
254  FloatComplexMatrix solve (MatrixType &typ, const FloatComplexMatrix& b,
255  octave_idx_type& info, float& rcon,
256  solve_singularity_handler sing_handler,
257  bool singular_fallback = true,
258  blas_trans_type transt = blas_no_trans) const;
259 
261  const FloatColumnVector& b) const;
263  octave_idx_type& info) const;
265  octave_idx_type& info, float& rcon) const;
267  octave_idx_type& info, float& rcon,
268  solve_singularity_handler sing_handler,
269  blas_trans_type transt = blas_no_trans) const;
270 
272  const FloatComplexColumnVector& b) const;
274  const FloatComplexColumnVector& b,
275  octave_idx_type& info) const;
277  const FloatComplexColumnVector& b,
278  octave_idx_type& info, float& rcon) const;
280  const FloatComplexColumnVector& b,
281  octave_idx_type& info, float& rcon,
282  solve_singularity_handler sing_handler,
283  blas_trans_type transt = blas_no_trans) const;
284 
285  // Generic interface to solver with probing of type
286  FloatComplexMatrix solve (const FloatMatrix& b) const;
287  FloatComplexMatrix solve (const FloatMatrix& b, octave_idx_type& info) const;
288  FloatComplexMatrix solve (const FloatMatrix& b, octave_idx_type& info,
289  float& rcon) const;
290  FloatComplexMatrix solve (const FloatMatrix& b, octave_idx_type& info,
291  float& rcon,
292  solve_singularity_handler sing_handler,
293  blas_trans_type transt = blas_no_trans) const;
294 
295  FloatComplexMatrix solve (const FloatComplexMatrix& b) const;
296  FloatComplexMatrix solve (const FloatComplexMatrix& b,
297  octave_idx_type& info) const;
299  float& rcon) const;
301  float& rcon,
302  solve_singularity_handler sing_handler,
303  blas_trans_type transt = blas_no_trans) const;
304 
305  FloatComplexColumnVector solve (const FloatColumnVector& b) const;
307  octave_idx_type& info) const;
309  octave_idx_type& info,
310  float& rcon) const;
312  octave_idx_type& info, float& rcon,
313  solve_singularity_handler sing_handler,
314  blas_trans_type transt = blas_no_trans) const;
315 
316  FloatComplexColumnVector solve (const FloatComplexColumnVector& b) const;
318  octave_idx_type& info) const;
320  octave_idx_type& info,
321  float& rcon) const;
323  octave_idx_type& info,
324  float& rcon,
325  solve_singularity_handler sing_handler,
326  blas_trans_type transt = blas_no_trans) const;
327 
328  FloatComplexMatrix lssolve (const FloatMatrix& b) const;
329  FloatComplexMatrix lssolve (const FloatMatrix& b,
330  octave_idx_type& info) const;
331  FloatComplexMatrix lssolve (const FloatMatrix& b, octave_idx_type& info,
332  octave_idx_type& rank) const;
333  FloatComplexMatrix lssolve (const FloatMatrix& b, octave_idx_type& info,
334  octave_idx_type& rank, float& rcon) const;
335 
336  FloatComplexMatrix lssolve (const FloatComplexMatrix& b) const;
337  FloatComplexMatrix lssolve (const FloatComplexMatrix& b,
338  octave_idx_type& info) const;
339  FloatComplexMatrix lssolve (const FloatComplexMatrix& b,
340  octave_idx_type& info, octave_idx_type& rank) const;
341  FloatComplexMatrix lssolve (const FloatComplexMatrix& b,
342  octave_idx_type& info, octave_idx_type& rank, float& rcon) const;
343 
344  FloatComplexColumnVector lssolve (const FloatColumnVector& b) const;
346  octave_idx_type& info) const;
348  octave_idx_type& info,
349  octave_idx_type& rank) const;
351  octave_idx_type& info,
352  octave_idx_type& rank, float& rcon) const;
353 
354  FloatComplexColumnVector lssolve (const FloatComplexColumnVector& b) const;
356  octave_idx_type& info) const;
358  octave_idx_type& info,
359  octave_idx_type& rank) const;
361  octave_idx_type& info,
362  octave_idx_type& rank, float& rcon) const;
363 
364  // matrix by diagonal matrix -> matrix operations
365 
368 
371 
372  // matrix by matrix -> matrix operations
373 
376 
377  // unary operations
378 
379  boolMatrix operator ! (void) const;
380 
381  // other operations
382 
383  bool any_element_is_nan (void) const;
384  bool any_element_is_inf_or_nan (void) const;
385  bool all_elements_are_real (void) const;
386  bool all_integers (float& max_val, float& min_val) const;
387  bool too_large_for_float (void) const;
388 
389  boolMatrix all (int dim = -1) const;
390  boolMatrix any (int dim = -1) const;
391 
392  FloatComplexMatrix cumprod (int dim = -1) const;
393  FloatComplexMatrix cumsum (int dim = -1) const;
394  FloatComplexMatrix prod (int dim = -1) const;
395  FloatComplexMatrix sum (int dim = -1) const;
396  FloatComplexMatrix sumsq (int dim = -1) const;
397  FloatMatrix abs (void) const;
398 
400 
402 
403  bool row_is_real_only (octave_idx_type) const;
404  bool column_is_real_only (octave_idx_type) const;
405 
406  FloatComplexColumnVector row_min (void) const;
407  FloatComplexColumnVector row_max (void) const;
408 
411 
412  FloatComplexRowVector column_min (void) const;
413  FloatComplexRowVector column_max (void) const;
414 
417 
418  // i/o
419 
420  friend OCTAVE_API std::ostream& operator << (std::ostream& os,
421  const FloatComplexMatrix& a);
422  friend OCTAVE_API std::istream& operator >> (std::istream& is,
423  FloatComplexMatrix& a);
424 };
425 
426 extern OCTAVE_API FloatComplexMatrix conj (const FloatComplexMatrix& a);
427 
428 // column vector by row vector -> matrix operations
429 
430 extern OCTAVE_API FloatComplexMatrix
432 
433 extern OCTAVE_API FloatComplexMatrix
435 
436 extern OCTAVE_API FloatComplexMatrix
438 
439 extern OCTAVE_API FloatComplexMatrix
440 Givens (const FloatComplex&, const FloatComplex&);
441 
442 extern OCTAVE_API FloatComplexMatrix
444  const FloatComplexMatrix&);
445 
446 extern OCTAVE_API FloatComplexMatrix
447 xgemm (const FloatComplexMatrix& a, const FloatComplexMatrix& b,
449  blas_trans_type transb = blas_no_trans);
450 
451 extern OCTAVE_API FloatComplexMatrix operator * (const FloatMatrix&,
452  const FloatComplexMatrix&);
453 extern OCTAVE_API FloatComplexMatrix operator * (const FloatComplexMatrix&,
454  const FloatMatrix&);
455 extern OCTAVE_API FloatComplexMatrix operator * (const FloatComplexMatrix&,
456  const FloatComplexMatrix&);
457 
458 extern OCTAVE_API FloatComplexMatrix min (const FloatComplex& c,
459  const FloatComplexMatrix& m);
460 extern OCTAVE_API FloatComplexMatrix min (const FloatComplexMatrix& m,
461  const FloatComplex& c);
462 extern OCTAVE_API FloatComplexMatrix min (const FloatComplexMatrix& a,
463  const FloatComplexMatrix& b);
464 
465 extern OCTAVE_API FloatComplexMatrix max (const FloatComplex& c,
466  const FloatComplexMatrix& m);
467 extern OCTAVE_API FloatComplexMatrix max (const FloatComplexMatrix& m,
468  const FloatComplex& c);
469 extern OCTAVE_API FloatComplexMatrix max (const FloatComplexMatrix& a,
470  const FloatComplexMatrix& b);
471 
472 extern OCTAVE_API FloatComplexMatrix
474  const FloatComplexColumnVector& x2,
475  octave_idx_type n);
476 
479 
480 SM_CMP_OP_DECLS (FloatComplex, FloatComplexMatrix, OCTAVE_API)
481 SM_BOOL_OP_DECLS (FloatComplex, FloatComplexMatrix, OCTAVE_API)
482 
483 MM_CMP_OP_DECLS (FloatComplexMatrix, FloatComplexMatrix, OCTAVE_API)
484 MM_BOOL_OP_DECLS (FloatComplexMatrix, FloatComplexMatrix, OCTAVE_API)
485 
486 MARRAY_FORWARD_DEFS (MArray, FloatComplexMatrix, FloatComplex)
487 
488 #endif