00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023 #if !defined (octave_ComplexMatrix_h)
00024 #define octave_ComplexMatrix_h 1
00025
00026 #if defined (__GNUG__) && defined (USE_PRAGMA_INTERFACE_IMPLEMENTATION)
00027 #pragma interface
00028 #endif
00029
00030 #include "MArray2.h"
00031 #include "MDiagArray2.h"
00032
00033 #include "mx-defs.h"
00034 #include "mx-op-defs.h"
00035 #include "oct-cmplx.h"
00036
00037 class
00038 ComplexMatrix : public MArray2<Complex>
00039 {
00040 public:
00041
00042 typedef void (*solve_singularity_handler) (double rcond);
00043
00044 ComplexMatrix (void) : MArray2<Complex> () { }
00045
00046 ComplexMatrix (int r, int c) : MArray2<Complex> (r, c) { }
00047
00048 ComplexMatrix (int r, int c, const Complex& val)
00049 : MArray2<Complex> (r, c, val) { }
00050
00051 ComplexMatrix (const ComplexMatrix& a) : MArray2<Complex> (a) { }
00052
00053 ComplexMatrix (const MArray2<Complex>& a) : MArray2<Complex> (a) { }
00054
00055 explicit ComplexMatrix (const Matrix& a);
00056
00057 explicit ComplexMatrix (const RowVector& rv);
00058
00059 explicit ComplexMatrix (const ColumnVector& cv);
00060
00061 explicit ComplexMatrix (const DiagMatrix& a);
00062
00063 explicit ComplexMatrix (const ComplexRowVector& rv);
00064
00065 explicit ComplexMatrix (const ComplexColumnVector& cv);
00066
00067 explicit ComplexMatrix (const ComplexDiagMatrix& a);
00068
00069 explicit ComplexMatrix (const boolMatrix& a);
00070
00071 explicit ComplexMatrix (const charMatrix& a);
00072
00073 ComplexMatrix& operator = (const ComplexMatrix& a)
00074 {
00075 MArray2<Complex>::operator = (a);
00076 return *this;
00077 }
00078
00079 bool operator == (const ComplexMatrix& a) const;
00080 bool operator != (const ComplexMatrix& a) const;
00081
00082 bool is_hermitian (void) const;
00083
00084
00085
00086 ComplexMatrix& insert (const Matrix& a, int r, int c);
00087 ComplexMatrix& insert (const RowVector& a, int r, int c);
00088 ComplexMatrix& insert (const ColumnVector& a, int r, int c);
00089 ComplexMatrix& insert (const DiagMatrix& a, int r, int c);
00090
00091 ComplexMatrix& insert (const ComplexMatrix& a, int r, int c);
00092 ComplexMatrix& insert (const ComplexRowVector& a, int r, int c);
00093 ComplexMatrix& insert (const ComplexColumnVector& a, int r, int c);
00094 ComplexMatrix& insert (const ComplexDiagMatrix& a, int r, int c);
00095
00096 ComplexMatrix& fill (double val);
00097 ComplexMatrix& fill (const Complex& val);
00098 ComplexMatrix& fill (double val, int r1, int c1, int r2, int c2);
00099 ComplexMatrix& fill (const Complex& val, int r1, int c1, int r2, int c2);
00100
00101 ComplexMatrix append (const Matrix& a) const;
00102 ComplexMatrix append (const RowVector& a) const;
00103 ComplexMatrix append (const ColumnVector& a) const;
00104 ComplexMatrix append (const DiagMatrix& a) const;
00105
00106 ComplexMatrix append (const ComplexMatrix& a) const;
00107 ComplexMatrix append (const ComplexRowVector& a) const;
00108 ComplexMatrix append (const ComplexColumnVector& a) const;
00109 ComplexMatrix append (const ComplexDiagMatrix& a) const;
00110
00111 ComplexMatrix stack (const Matrix& a) const;
00112 ComplexMatrix stack (const RowVector& a) const;
00113 ComplexMatrix stack (const ColumnVector& a) const;
00114 ComplexMatrix stack (const DiagMatrix& a) const;
00115
00116 ComplexMatrix stack (const ComplexMatrix& a) const;
00117 ComplexMatrix stack (const ComplexRowVector& a) const;
00118 ComplexMatrix stack (const ComplexColumnVector& a) const;
00119 ComplexMatrix stack (const ComplexDiagMatrix& a) const;
00120
00121 ComplexMatrix hermitian (void) const;
00122 ComplexMatrix transpose (void) const
00123 { return MArray2<Complex>::transpose (); }
00124
00125 friend ComplexMatrix conj (const ComplexMatrix& a);
00126
00127
00128
00129 ComplexMatrix extract (int r1, int c1, int r2, int c2) const;
00130
00131 ComplexMatrix extract_n (int r1, int c1, int nr, int nc) const;
00132
00133
00134
00135 ComplexRowVector row (int i) const;
00136 ComplexRowVector row (char *s) const;
00137
00138 ComplexColumnVector column (int i) const;
00139 ComplexColumnVector column (char *s) const;
00140
00141 ComplexMatrix inverse (void) const;
00142 ComplexMatrix inverse (int& info) const;
00143 ComplexMatrix inverse (int& info, double& rcond, int force = 0,
00144 int calc_cond = 1) const;
00145
00146 ComplexMatrix pseudo_inverse (double tol = 0.0) const;
00147
00148 ComplexMatrix fourier (void) const;
00149 ComplexMatrix ifourier (void) const;
00150
00151 ComplexMatrix fourier2d (void) const;
00152 ComplexMatrix ifourier2d (void) const;
00153
00154 ComplexDET determinant (void) const;
00155 ComplexDET determinant (int& info) const;
00156 ComplexDET determinant (int& info, double& rcond, int calc_cond = 1) const;
00157
00158 ComplexMatrix solve (const Matrix& b) const;
00159 ComplexMatrix solve (const Matrix& b, int& info) const;
00160 ComplexMatrix solve (const Matrix& b, int& info, double& rcond) const;
00161 ComplexMatrix solve (const Matrix& b, int& info, double& rcond,
00162 solve_singularity_handler sing_handler) const;
00163
00164 ComplexMatrix solve (const ComplexMatrix& b) const;
00165 ComplexMatrix solve (const ComplexMatrix& b, int& info) const;
00166 ComplexMatrix solve (const ComplexMatrix& b, int& info, double& rcond) const;
00167 ComplexMatrix solve (const ComplexMatrix& b, int& info, double& rcond,
00168 solve_singularity_handler sing_handler) const;
00169
00170 ComplexColumnVector solve (const ColumnVector& b) const;
00171 ComplexColumnVector solve (const ColumnVector& b, int& info) const;
00172 ComplexColumnVector solve (const ColumnVector& b, int& info,
00173 double& rcond) const;
00174 ComplexColumnVector solve (const ColumnVector& b, int& info, double& rcond,
00175 solve_singularity_handler sing_handler) const;
00176
00177 ComplexColumnVector solve (const ComplexColumnVector& b) const;
00178 ComplexColumnVector solve (const ComplexColumnVector& b, int& info) const;
00179 ComplexColumnVector solve (const ComplexColumnVector& b, int& info,
00180 double& rcond) const;
00181 ComplexColumnVector solve (const ComplexColumnVector& b, int& info,
00182 double& rcond,
00183 solve_singularity_handler sing_handler) const;
00184
00185 ComplexMatrix lssolve (const Matrix& b) const;
00186 ComplexMatrix lssolve (const Matrix& b, int& info) const;
00187 ComplexMatrix lssolve (const Matrix& b, int& info, int& rank) const;
00188
00189 ComplexMatrix lssolve (const ComplexMatrix& b) const;
00190 ComplexMatrix lssolve (const ComplexMatrix& b, int& info) const;
00191 ComplexMatrix lssolve (const ComplexMatrix& b, int& info,
00192 int& rank) const;
00193
00194 ComplexColumnVector lssolve (const ColumnVector& b) const;
00195 ComplexColumnVector lssolve (const ColumnVector& b, int& info) const;
00196 ComplexColumnVector lssolve (const ColumnVector& b, int& info,
00197 int& rank) const;
00198
00199 ComplexColumnVector lssolve (const ComplexColumnVector& b) const;
00200 ComplexColumnVector lssolve (const ComplexColumnVector& b, int& info) const;
00201 ComplexColumnVector lssolve (const ComplexColumnVector& b, int& info,
00202 int& rank) const;
00203
00204 ComplexMatrix expm (void) const;
00205
00206
00207
00208 friend ComplexMatrix operator * (const ColumnVector& a,
00209 const ComplexRowVector& b);
00210
00211 friend ComplexMatrix operator * (const ComplexColumnVector& a,
00212 const RowVector& b);
00213
00214 friend ComplexMatrix operator * (const ComplexColumnVector& a,
00215 const ComplexRowVector& b);
00216
00217
00218
00219 ComplexMatrix& operator += (const DiagMatrix& a);
00220 ComplexMatrix& operator -= (const DiagMatrix& a);
00221
00222 ComplexMatrix& operator += (const ComplexDiagMatrix& a);
00223 ComplexMatrix& operator -= (const ComplexDiagMatrix& a);
00224
00225
00226
00227 ComplexMatrix& operator += (const Matrix& a);
00228 ComplexMatrix& operator -= (const Matrix& a);
00229
00230
00231
00232 boolMatrix operator ! (void) const;
00233
00234
00235
00236 ComplexMatrix map (c_c_Mapper f) const;
00237 Matrix map (d_c_Mapper f) const;
00238 boolMatrix map (b_c_Mapper f) const;
00239
00240 ComplexMatrix& apply (c_c_Mapper f);
00241
00242 bool any_element_is_inf_or_nan (void) const;
00243 bool all_elements_are_real (void) const;
00244 bool all_integers (double& max_val, double& min_val) const;
00245 bool too_large_for_float (void) const;
00246
00247 boolMatrix all (int dim = -1) const;
00248 boolMatrix any (int dim = -1) const;
00249
00250 ComplexMatrix cumprod (int dim = -1) const;
00251 ComplexMatrix cumsum (int dim = -1) const;
00252 ComplexMatrix prod (int dim = -1) const;
00253 ComplexMatrix sum (int dim = -1) const;
00254 ComplexMatrix sumsq (int dim = -1) const;
00255 Matrix abs (void) const;
00256
00257 ComplexColumnVector diag (void) const;
00258 ComplexColumnVector diag (int k) const;
00259
00260 bool row_is_real_only (int) const;
00261 bool column_is_real_only (int) const;
00262
00263 ComplexColumnVector row_min (void) const;
00264 ComplexColumnVector row_max (void) const;
00265
00266 ComplexColumnVector row_min (Array<int>& index) const;
00267 ComplexColumnVector row_max (Array<int>& index) const;
00268
00269 ComplexRowVector column_min (void) const;
00270 ComplexRowVector column_max (void) const;
00271
00272 ComplexRowVector column_min (Array<int>& index) const;
00273 ComplexRowVector column_max (Array<int>& index) const;
00274
00275
00276
00277 friend std::ostream& operator << (std::ostream& os, const ComplexMatrix& a);
00278 friend std::istream& operator >> (std::istream& is, ComplexMatrix& a);
00279
00280 static Complex resize_fill_value (void) { return Complex (0.0, 0.0); }
00281
00282 private:
00283
00284 ComplexMatrix (Complex *d, int r, int c) : MArray2<Complex> (d, r, c) { }
00285 };
00286
00287 ComplexMatrix Givens (const Complex&, const Complex&);
00288
00289 ComplexMatrix Sylvester (const ComplexMatrix&, const ComplexMatrix&,
00290 const ComplexMatrix&);
00291
00292 extern ComplexMatrix operator * (const Matrix&, const ComplexMatrix&);
00293 extern ComplexMatrix operator * (const ComplexMatrix&, const Matrix&);
00294 extern ComplexMatrix operator * (const ComplexMatrix&, const ComplexMatrix&);
00295
00296 extern ComplexMatrix min (const Complex& c, const ComplexMatrix& m);
00297 extern ComplexMatrix min (const ComplexMatrix& m, const Complex& c);
00298 extern ComplexMatrix min (const ComplexMatrix& a, const ComplexMatrix& b);
00299
00300 extern ComplexMatrix max (const Complex& c, const ComplexMatrix& m);
00301 extern ComplexMatrix max (const ComplexMatrix& m, const Complex& c);
00302 extern ComplexMatrix max (const ComplexMatrix& a, const ComplexMatrix& b);
00303
00304 MS_CMP_OP_DECLS (ComplexMatrix, Complex)
00305 MS_BOOL_OP_DECLS (ComplexMatrix, Complex)
00306
00307 SM_CMP_OP_DECLS (Complex, ComplexMatrix)
00308 SM_BOOL_OP_DECLS (Complex, ComplexMatrix)
00309
00310 MM_CMP_OP_DECLS (ComplexMatrix, ComplexMatrix)
00311 MM_BOOL_OP_DECLS (ComplexMatrix, ComplexMatrix)
00312
00313 MARRAY_FORWARD_DEFS (MArray2, ComplexMatrix, Complex)
00314
00315 #endif
00316
00317
00318
00319
00320
00321