00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024 #if !defined (octave_ComplexMatrix_h)
00025 #define octave_ComplexMatrix_h 1
00026
00027 #include "MArray2.h"
00028 #include "MDiagArray2.h"
00029 #include "MatrixType.h"
00030
00031 #include "mx-defs.h"
00032 #include "mx-op-decl.h"
00033 #include "oct-cmplx.h"
00034 #include "DET.h"
00035
00036 class
00037 OCTAVE_API
00038 ComplexMatrix : public MArray2<Complex>
00039 {
00040 public:
00041
00042 typedef ComplexColumnVector column_vector_type;
00043 typedef ComplexRowVector row_vector_type;
00044
00045 typedef void (*solve_singularity_handler) (double rcon);
00046
00047 ComplexMatrix (void) : MArray2<Complex> () { }
00048
00049 ComplexMatrix (octave_idx_type r, octave_idx_type c) : MArray2<Complex> (r, c) { }
00050
00051 ComplexMatrix (octave_idx_type r, octave_idx_type c, const Complex& val)
00052 : MArray2<Complex> (r, c, val) { }
00053
00054 ComplexMatrix (const dim_vector& dv) : MArray2<Complex> (dv) { }
00055
00056 ComplexMatrix (const dim_vector& dv, const Complex& val)
00057 : MArray2<Complex> (dv, val) { }
00058
00059 ComplexMatrix (const ComplexMatrix& a) : MArray2<Complex> (a) { }
00060
00061 template <class U>
00062 ComplexMatrix (const MArray2<U>& a) : MArray2<Complex> (a) { }
00063
00064 template <class U>
00065 ComplexMatrix (const Array2<U>& a) : MArray2<Complex> (a) { }
00066
00067 ComplexMatrix (const Matrix& re, const Matrix& im);
00068
00069 explicit ComplexMatrix (const Matrix& a);
00070
00071 explicit ComplexMatrix (const RowVector& rv);
00072
00073 explicit ComplexMatrix (const ColumnVector& cv);
00074
00075 explicit ComplexMatrix (const DiagMatrix& a);
00076
00077 explicit ComplexMatrix (const ComplexRowVector& rv);
00078
00079 explicit ComplexMatrix (const ComplexColumnVector& cv);
00080
00081 explicit ComplexMatrix (const ComplexDiagMatrix& a);
00082
00083 explicit ComplexMatrix (const boolMatrix& a);
00084
00085 explicit ComplexMatrix (const charMatrix& a);
00086
00087 ComplexMatrix& operator = (const ComplexMatrix& a)
00088 {
00089 MArray2<Complex>::operator = (a);
00090 return *this;
00091 }
00092
00093 bool operator == (const ComplexMatrix& a) const;
00094 bool operator != (const ComplexMatrix& a) const;
00095
00096 bool is_hermitian (void) const;
00097
00098
00099
00100 ComplexMatrix& insert (const Matrix& a, octave_idx_type r, octave_idx_type c);
00101 ComplexMatrix& insert (const RowVector& a, octave_idx_type r, octave_idx_type c);
00102 ComplexMatrix& insert (const ColumnVector& a, octave_idx_type r, octave_idx_type c);
00103 ComplexMatrix& insert (const DiagMatrix& a, octave_idx_type r, octave_idx_type c);
00104
00105 ComplexMatrix& insert (const ComplexMatrix& a, octave_idx_type r, octave_idx_type c);
00106 ComplexMatrix& insert (const ComplexRowVector& a, octave_idx_type r, octave_idx_type c);
00107 ComplexMatrix& insert (const ComplexColumnVector& a, octave_idx_type r, octave_idx_type c);
00108 ComplexMatrix& insert (const ComplexDiagMatrix& a, octave_idx_type r, octave_idx_type c);
00109
00110 ComplexMatrix& fill (double val);
00111 ComplexMatrix& fill (const Complex& val);
00112 ComplexMatrix& fill (double val, octave_idx_type r1, octave_idx_type c1, octave_idx_type r2, octave_idx_type c2);
00113 ComplexMatrix& fill (const Complex& val, octave_idx_type r1, octave_idx_type c1, octave_idx_type r2, octave_idx_type c2);
00114
00115 ComplexMatrix append (const Matrix& a) const;
00116 ComplexMatrix append (const RowVector& a) const;
00117 ComplexMatrix append (const ColumnVector& a) const;
00118 ComplexMatrix append (const DiagMatrix& a) const;
00119
00120 ComplexMatrix append (const ComplexMatrix& a) const;
00121 ComplexMatrix append (const ComplexRowVector& a) const;
00122 ComplexMatrix append (const ComplexColumnVector& a) const;
00123 ComplexMatrix append (const ComplexDiagMatrix& a) const;
00124
00125 ComplexMatrix stack (const Matrix& a) const;
00126 ComplexMatrix stack (const RowVector& a) const;
00127 ComplexMatrix stack (const ColumnVector& a) const;
00128 ComplexMatrix stack (const DiagMatrix& a) const;
00129
00130 ComplexMatrix stack (const ComplexMatrix& a) const;
00131 ComplexMatrix stack (const ComplexRowVector& a) const;
00132 ComplexMatrix stack (const ComplexColumnVector& a) const;
00133 ComplexMatrix stack (const ComplexDiagMatrix& a) const;
00134
00135 ComplexMatrix hermitian (void) const
00136 { return MArray2<Complex>::hermitian (std::conj); }
00137 ComplexMatrix transpose (void) const
00138 { return MArray2<Complex>::transpose (); }
00139
00140 friend OCTAVE_API ComplexMatrix conj (const ComplexMatrix& a);
00141
00142
00143
00144 ComplexMatrix extract (octave_idx_type r1, octave_idx_type c1, octave_idx_type r2, octave_idx_type c2) const;
00145
00146 ComplexMatrix extract_n (octave_idx_type r1, octave_idx_type c1, octave_idx_type nr, octave_idx_type nc) const;
00147
00148
00149
00150 ComplexRowVector row (octave_idx_type i) const;
00151
00152 ComplexColumnVector column (octave_idx_type i) const;
00153
00154 private:
00155 ComplexMatrix tinverse (MatrixType &mattype, octave_idx_type& info,
00156 double& rcon, int force, int calc_cond) const;
00157
00158 ComplexMatrix finverse (MatrixType &mattype, octave_idx_type& info,
00159 double& rcon, int force, int calc_cond) const;
00160
00161 public:
00162 ComplexMatrix inverse (void) const;
00163 ComplexMatrix inverse (octave_idx_type& info) const;
00164 ComplexMatrix inverse (octave_idx_type& info, double& rcon, int force = 0,
00165 int calc_cond = 1) const;
00166
00167 ComplexMatrix inverse (MatrixType &mattype) const;
00168 ComplexMatrix inverse (MatrixType &mattype, octave_idx_type& info) const;
00169 ComplexMatrix inverse (MatrixType &mattype, octave_idx_type& info,
00170 double& rcon, int force = 0,
00171 int calc_cond = 1) const;
00172
00173 ComplexMatrix pseudo_inverse (double tol = 0.0) const;
00174
00175 ComplexMatrix fourier (void) const;
00176 ComplexMatrix ifourier (void) const;
00177
00178 ComplexMatrix fourier2d (void) const;
00179 ComplexMatrix ifourier2d (void) const;
00180
00181 ComplexDET determinant (void) const;
00182 ComplexDET determinant (octave_idx_type& info) const;
00183 ComplexDET determinant (octave_idx_type& info, double& rcon, int calc_cond = 1) const;
00184 ComplexDET determinant (MatrixType &mattype, octave_idx_type& info,
00185 double& rcon, int calc_cond = 1) const;
00186
00187 double rcond (void) const;
00188 double rcond (MatrixType &mattype) const;
00189
00190 private:
00191
00192 ComplexMatrix utsolve (MatrixType &typ, const ComplexMatrix& b,
00193 octave_idx_type& info, double& rcon,
00194 solve_singularity_handler sing_handler,
00195 bool calc_cond = false,
00196 blas_trans_type transt = blas_no_trans) const;
00197
00198
00199 ComplexMatrix ltsolve (MatrixType &typ, const ComplexMatrix& b,
00200 octave_idx_type& info, double& rcon,
00201 solve_singularity_handler sing_handler,
00202 bool calc_cond = false, blas_trans_type transt = blas_no_trans) const;
00203
00204
00205 ComplexMatrix fsolve (MatrixType &typ, const ComplexMatrix& b,
00206 octave_idx_type& info, double& rcon,
00207 solve_singularity_handler sing_handler,
00208 bool calc_cond = false) const;
00209
00210 public:
00211
00212 ComplexMatrix solve (MatrixType &typ, const Matrix& b) const;
00213 ComplexMatrix solve (MatrixType &typ, const Matrix& b,
00214 octave_idx_type& info) const;
00215 ComplexMatrix solve (MatrixType &typ, const Matrix& b,
00216 octave_idx_type& info, double& rcon) const;
00217 ComplexMatrix solve (MatrixType &typ, const Matrix& b, octave_idx_type& info,
00218 double& rcon, solve_singularity_handler sing_handler,
00219 bool singular_fallback = true,
00220 blas_trans_type transt = blas_no_trans) const;
00221
00222 ComplexMatrix solve (MatrixType &typ, const ComplexMatrix& b) const;
00223 ComplexMatrix solve (MatrixType &typ, const ComplexMatrix& b,
00224 octave_idx_type& info) const;
00225 ComplexMatrix solve (MatrixType &typ, const ComplexMatrix& b,
00226 octave_idx_type& info, double& rcon) const;
00227 ComplexMatrix solve (MatrixType &typ, const ComplexMatrix& b,
00228 octave_idx_type& info, double& rcon,
00229 solve_singularity_handler sing_handler,
00230 bool singular_fallback = true,
00231 blas_trans_type transt = blas_no_trans) const;
00232
00233 ComplexColumnVector solve (MatrixType &typ, const ColumnVector& b) const;
00234 ComplexColumnVector solve (MatrixType &typ, const ColumnVector& b,
00235 octave_idx_type& info) const;
00236 ComplexColumnVector solve (MatrixType &typ, const ColumnVector& b,
00237 octave_idx_type& info, double& rcon) const;
00238 ComplexColumnVector solve (MatrixType &typ, const ColumnVector& b,
00239 octave_idx_type& info, double& rcon,
00240 solve_singularity_handler sing_handler,
00241 blas_trans_type transt = blas_no_trans) const;
00242
00243 ComplexColumnVector solve (MatrixType &typ,
00244 const ComplexColumnVector& b) const;
00245 ComplexColumnVector solve (MatrixType &typ, const ComplexColumnVector& b,
00246 octave_idx_type& info) const;
00247 ComplexColumnVector solve (MatrixType &typ, const ComplexColumnVector& b,
00248 octave_idx_type& info, double& rcon) const;
00249 ComplexColumnVector solve (MatrixType &typ, const ComplexColumnVector& b,
00250 octave_idx_type& info, double& rcon,
00251 solve_singularity_handler sing_handler,
00252 blas_trans_type transt = blas_no_trans) const;
00253
00254
00255 ComplexMatrix solve (const Matrix& b) const;
00256 ComplexMatrix solve (const Matrix& b, octave_idx_type& info) const;
00257 ComplexMatrix solve (const Matrix& b, octave_idx_type& info, double& rcon) const;
00258 ComplexMatrix solve (const Matrix& b, octave_idx_type& info, double& rcon,
00259 solve_singularity_handler sing_handler,
00260 blas_trans_type transt = blas_no_trans) const;
00261
00262 ComplexMatrix solve (const ComplexMatrix& b) const;
00263 ComplexMatrix solve (const ComplexMatrix& b, octave_idx_type& info) const;
00264 ComplexMatrix solve (const ComplexMatrix& b, octave_idx_type& info, double& rcon) const;
00265 ComplexMatrix solve (const ComplexMatrix& b, octave_idx_type& info, double& rcon,
00266 solve_singularity_handler sing_handler,
00267 blas_trans_type transt = blas_no_trans) const;
00268
00269 ComplexColumnVector solve (const ColumnVector& b) const;
00270 ComplexColumnVector solve (const ColumnVector& b, octave_idx_type& info) const;
00271 ComplexColumnVector solve (const ColumnVector& b, octave_idx_type& info,
00272 double& rcon) const;
00273 ComplexColumnVector solve (const ColumnVector& b, octave_idx_type& info, double& rcon,
00274 solve_singularity_handler sing_handler,
00275 blas_trans_type transt = blas_no_trans) const;
00276
00277 ComplexColumnVector solve (const ComplexColumnVector& b) const;
00278 ComplexColumnVector solve (const ComplexColumnVector& b, octave_idx_type& info) const;
00279 ComplexColumnVector solve (const ComplexColumnVector& b, octave_idx_type& info,
00280 double& rcon) const;
00281 ComplexColumnVector solve (const ComplexColumnVector& b, octave_idx_type& info,
00282 double& rcon, solve_singularity_handler sing_handler,
00283 blas_trans_type transt = blas_no_trans) const;
00284
00285 ComplexMatrix lssolve (const Matrix& b) const;
00286 ComplexMatrix lssolve (const Matrix& b, octave_idx_type& info) const;
00287 ComplexMatrix lssolve (const Matrix& b, octave_idx_type& info,
00288 octave_idx_type& rank) const;
00289 ComplexMatrix lssolve (const Matrix& b, octave_idx_type& info,
00290 octave_idx_type& rank, double& rcon) const;
00291
00292 ComplexMatrix lssolve (const ComplexMatrix& b) const;
00293 ComplexMatrix lssolve (const ComplexMatrix& b, octave_idx_type& info) const;
00294 ComplexMatrix lssolve (const ComplexMatrix& b, octave_idx_type& info,
00295 octave_idx_type& rank) const;
00296 ComplexMatrix lssolve (const ComplexMatrix& b, octave_idx_type& info,
00297 octave_idx_type& rank, double& rcon) const;
00298
00299 ComplexColumnVector lssolve (const ColumnVector& b) const;
00300 ComplexColumnVector lssolve (const ColumnVector& b,
00301 octave_idx_type& info) const;
00302 ComplexColumnVector lssolve (const ColumnVector& b, octave_idx_type& info,
00303 octave_idx_type& rank) const;
00304 ComplexColumnVector lssolve (const ColumnVector& b, octave_idx_type& info,
00305 octave_idx_type& rank, double& rcon) const;
00306
00307 ComplexColumnVector lssolve (const ComplexColumnVector& b) const;
00308 ComplexColumnVector lssolve (const ComplexColumnVector& b,
00309 octave_idx_type& info) const;
00310 ComplexColumnVector lssolve (const ComplexColumnVector& b,
00311 octave_idx_type& info,
00312 octave_idx_type& rank) const;
00313 ComplexColumnVector lssolve (const ComplexColumnVector& b,
00314 octave_idx_type& info,
00315 octave_idx_type& rank, double& rcon) const;
00316
00317
00318
00319 ComplexMatrix& operator += (const DiagMatrix& a);
00320 ComplexMatrix& operator -= (const DiagMatrix& a);
00321
00322 ComplexMatrix& operator += (const ComplexDiagMatrix& a);
00323 ComplexMatrix& operator -= (const ComplexDiagMatrix& a);
00324
00325
00326
00327 ComplexMatrix& operator += (const Matrix& a);
00328 ComplexMatrix& operator -= (const Matrix& a);
00329
00330
00331
00332 boolMatrix operator ! (void) const;
00333
00334
00335
00336 typedef double (*dmapper) (const Complex&);
00337 typedef Complex (*cmapper) (const Complex&);
00338 typedef bool (*bmapper) (const Complex&);
00339
00340 Matrix map (dmapper fcn) const;
00341 ComplexMatrix map (cmapper fcn) const;
00342 boolMatrix map (bmapper fcn) const;
00343
00344 bool any_element_is_nan (void) const;
00345 bool any_element_is_inf_or_nan (void) const;
00346 bool all_elements_are_real (void) const;
00347 bool all_integers (double& max_val, double& min_val) const;
00348 bool too_large_for_float (void) const;
00349
00350 boolMatrix all (int dim = -1) const;
00351 boolMatrix any (int dim = -1) const;
00352
00353 ComplexMatrix cumprod (int dim = -1) const;
00354 ComplexMatrix cumsum (int dim = -1) const;
00355 ComplexMatrix prod (int dim = -1) const;
00356 ComplexMatrix sum (int dim = -1) const;
00357 ComplexMatrix sumsq (int dim = -1) const;
00358 Matrix abs (void) const;
00359
00360 ComplexMatrix diag (octave_idx_type k = 0) const;
00361
00362 bool row_is_real_only (octave_idx_type) const;
00363 bool column_is_real_only (octave_idx_type) const;
00364
00365 ComplexColumnVector row_min (void) const;
00366 ComplexColumnVector row_max (void) const;
00367
00368 ComplexColumnVector row_min (Array<octave_idx_type>& index) const;
00369 ComplexColumnVector row_max (Array<octave_idx_type>& index) const;
00370
00371 ComplexRowVector column_min (void) const;
00372 ComplexRowVector column_max (void) const;
00373
00374 ComplexRowVector column_min (Array<octave_idx_type>& index) const;
00375 ComplexRowVector column_max (Array<octave_idx_type>& index) const;
00376
00377
00378
00379 friend OCTAVE_API std::ostream& operator << (std::ostream& os, const ComplexMatrix& a);
00380 friend OCTAVE_API std::istream& operator >> (std::istream& is, ComplexMatrix& a);
00381
00382 static Complex resize_fill_value (void) { return Complex (0.0, 0.0); }
00383
00384 private:
00385
00386 ComplexMatrix (Complex *d, octave_idx_type r, octave_idx_type c) : MArray2<Complex> (d, r, c) { }
00387 };
00388
00389 extern OCTAVE_API ComplexMatrix conj (const ComplexMatrix& a);
00390
00391
00392
00393 extern OCTAVE_API ComplexMatrix
00394 operator * (const ColumnVector& a, const ComplexRowVector& b);
00395
00396 extern OCTAVE_API ComplexMatrix
00397 operator * (const ComplexColumnVector& a, const RowVector& b);
00398
00399 extern OCTAVE_API ComplexMatrix
00400 operator * (const ComplexColumnVector& a, const ComplexRowVector& b);
00401
00402 extern OCTAVE_API ComplexMatrix
00403 Givens (const Complex&, const Complex&);
00404
00405 extern OCTAVE_API ComplexMatrix
00406 Sylvester (const ComplexMatrix&, const ComplexMatrix&, const ComplexMatrix&);
00407
00408 extern OCTAVE_API ComplexMatrix
00409 xgemm (const ComplexMatrix& a, const ComplexMatrix& b,
00410 blas_trans_type transa = blas_no_trans,
00411 blas_trans_type transb = blas_no_trans);
00412
00413 extern OCTAVE_API ComplexMatrix operator * (const Matrix&, const ComplexMatrix&);
00414 extern OCTAVE_API ComplexMatrix operator * (const ComplexMatrix&, const Matrix&);
00415 extern OCTAVE_API ComplexMatrix operator * (const ComplexMatrix&, const ComplexMatrix&);
00416
00417 extern OCTAVE_API ComplexMatrix min (const Complex& c, const ComplexMatrix& m);
00418 extern OCTAVE_API ComplexMatrix min (const ComplexMatrix& m, const Complex& c);
00419 extern OCTAVE_API ComplexMatrix min (const ComplexMatrix& a, const ComplexMatrix& b);
00420
00421 extern OCTAVE_API ComplexMatrix max (const Complex& c, const ComplexMatrix& m);
00422 extern OCTAVE_API ComplexMatrix max (const ComplexMatrix& m, const Complex& c);
00423 extern OCTAVE_API ComplexMatrix max (const ComplexMatrix& a, const ComplexMatrix& b);
00424
00425 extern OCTAVE_API ComplexMatrix linspace (const ComplexColumnVector& x1,
00426 const ComplexColumnVector& x2,
00427 octave_idx_type n);
00428
00429
00430 MS_CMP_OP_DECLS (ComplexMatrix, Complex, OCTAVE_API)
00431 MS_BOOL_OP_DECLS (ComplexMatrix, Complex, OCTAVE_API)
00432
00433 SM_CMP_OP_DECLS (Complex, ComplexMatrix, OCTAVE_API)
00434 SM_BOOL_OP_DECLS (Complex, ComplexMatrix, OCTAVE_API)
00435
00436 MM_CMP_OP_DECLS (ComplexMatrix, ComplexMatrix, OCTAVE_API)
00437 MM_BOOL_OP_DECLS (ComplexMatrix, ComplexMatrix, OCTAVE_API)
00438
00439 MARRAY_FORWARD_DEFS (MArray2, ComplexMatrix, Complex)
00440
00441 #endif
00442
00443
00444
00445
00446
00447