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_FloatMatrix_int_h)
00025 #define octave_FloatMatrix_int_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 "DET.h"
00034
00035 class
00036 OCTAVE_API
00037 FloatMatrix : public MArray2<float>
00038 {
00039 public:
00040
00041 typedef FloatColumnVector column_vector_type;
00042 typedef FloatRowVector row_vector_type;
00043
00044 typedef void (*solve_singularity_handler) (float rcon);
00045
00046 FloatMatrix (void) : MArray2<float> () { }
00047
00048 FloatMatrix (octave_idx_type r, octave_idx_type c) : MArray2<float> (r, c) { }
00049
00050 FloatMatrix (octave_idx_type r, octave_idx_type c, float val) : MArray2<float> (r, c, val) { }
00051
00052 FloatMatrix (const dim_vector& dv) : MArray2<float> (dv) { }
00053
00054 FloatMatrix (const dim_vector& dv, float val) : MArray2<float> (dv, val) { }
00055
00056 FloatMatrix (const FloatMatrix& a) : MArray2<float> (a) { }
00057
00058 template <class U>
00059 FloatMatrix (const MArray2<U>& a) : MArray2<float> (a) { }
00060
00061 template <class U>
00062 FloatMatrix (const Array2<U>& a) : MArray2<float> (a) { }
00063
00064 explicit FloatMatrix (const FloatRowVector& rv);
00065
00066 explicit FloatMatrix (const FloatColumnVector& cv);
00067
00068 explicit FloatMatrix (const FloatDiagMatrix& a);
00069
00070 explicit FloatMatrix (const PermMatrix& a);
00071
00072 explicit FloatMatrix (const boolMatrix& a);
00073
00074 explicit FloatMatrix (const charMatrix& a);
00075
00076
00077 FloatMatrix& operator = (const FloatMatrix& a)
00078 {
00079 MArray2<float>::operator = (a);
00080 return *this;
00081 }
00082
00083 bool operator == (const FloatMatrix& a) const;
00084 bool operator != (const FloatMatrix& a) const;
00085
00086 bool is_symmetric (void) const;
00087
00088
00089
00090 FloatMatrix& insert (const FloatMatrix& a, octave_idx_type r, octave_idx_type c);
00091 FloatMatrix& insert (const FloatRowVector& a, octave_idx_type r, octave_idx_type c);
00092 FloatMatrix& insert (const FloatColumnVector& a, octave_idx_type r, octave_idx_type c);
00093 FloatMatrix& insert (const FloatDiagMatrix& a, octave_idx_type r, octave_idx_type c);
00094
00095 FloatMatrix& fill (float val);
00096 FloatMatrix& fill (float val, octave_idx_type r1, octave_idx_type c1, octave_idx_type r2, octave_idx_type c2);
00097
00098 FloatMatrix append (const FloatMatrix& a) const;
00099 FloatMatrix append (const FloatRowVector& a) const;
00100 FloatMatrix append (const FloatColumnVector& a) const;
00101 FloatMatrix append (const FloatDiagMatrix& a) const;
00102
00103 FloatMatrix stack (const FloatMatrix& a) const;
00104 FloatMatrix stack (const FloatRowVector& a) const;
00105 FloatMatrix stack (const FloatColumnVector& a) const;
00106 FloatMatrix stack (const FloatDiagMatrix& a) const;
00107
00108 friend OCTAVE_API FloatMatrix real (const FloatComplexMatrix& a);
00109 friend OCTAVE_API FloatMatrix imag (const FloatComplexMatrix& a);
00110
00111 friend class FloatComplexMatrix;
00112
00113 FloatMatrix transpose (void) const { return MArray2<float>::transpose (); }
00114
00115
00116
00117 FloatMatrix extract (octave_idx_type r1, octave_idx_type c1, octave_idx_type r2, octave_idx_type c2) const;
00118
00119 FloatMatrix extract_n (octave_idx_type r1, octave_idx_type c1, octave_idx_type nr, octave_idx_type nc) const;
00120
00121
00122
00123 FloatRowVector row (octave_idx_type i) const;
00124
00125 FloatColumnVector column (octave_idx_type i) const;
00126
00127 private:
00128 FloatMatrix tinverse (MatrixType &mattype, octave_idx_type& info, float& rcon,
00129 int force, int calc_cond) const;
00130
00131 FloatMatrix finverse (MatrixType &mattype, octave_idx_type& info, float& rcon,
00132 int force, int calc_cond) const;
00133
00134 public:
00135 FloatMatrix inverse (void) const;
00136 FloatMatrix inverse (octave_idx_type& info) const;
00137 FloatMatrix inverse (octave_idx_type& info, float& rcon, int force = 0,
00138 int calc_cond = 1) const;
00139
00140 FloatMatrix inverse (MatrixType &mattype) const;
00141 FloatMatrix inverse (MatrixType &mattype, octave_idx_type& info) const;
00142 FloatMatrix inverse (MatrixType &mattype, octave_idx_type& info, float& rcon,
00143 int force = 0, int calc_cond = 1) const;
00144
00145 FloatMatrix pseudo_inverse (float tol = 0.0) const;
00146
00147 FloatComplexMatrix fourier (void) const;
00148 FloatComplexMatrix ifourier (void) const;
00149
00150 FloatComplexMatrix fourier2d (void) const;
00151 FloatComplexMatrix ifourier2d (void) const;
00152
00153 FloatDET determinant (void) const;
00154 FloatDET determinant (octave_idx_type& info) const;
00155 FloatDET determinant (octave_idx_type& info, float& rcon, int calc_cond = 1) const;
00156 FloatDET determinant (MatrixType &mattype, octave_idx_type& info,
00157 float& rcon, int calc_cond = 1) const;
00158
00159 float rcond (void) const;
00160 float rcond (MatrixType &mattype) const;
00161
00162 private:
00163
00164 FloatMatrix utsolve (MatrixType &typ, const FloatMatrix& b, octave_idx_type& info,
00165 float& rcon, solve_singularity_handler sing_handler,
00166 bool calc_cond = false, blas_trans_type transt = blas_no_trans) const;
00167
00168
00169 FloatMatrix ltsolve (MatrixType &typ, const FloatMatrix& b, octave_idx_type& info,
00170 float& rcon, solve_singularity_handler sing_handler,
00171 bool calc_cond = false, blas_trans_type transt = blas_no_trans) const;
00172
00173
00174 FloatMatrix fsolve (MatrixType &typ, const FloatMatrix& b, octave_idx_type& info,
00175 float& rcon, solve_singularity_handler sing_handler,
00176 bool calc_cond = false) const;
00177
00178 public:
00179
00180 FloatMatrix solve (MatrixType &typ, const FloatMatrix& b) const;
00181 FloatMatrix solve (MatrixType &typ, const FloatMatrix& b, octave_idx_type& info) const;
00182 FloatMatrix solve (MatrixType &typ, const FloatMatrix& b, octave_idx_type& info,
00183 float& rcon) const;
00184 FloatMatrix solve (MatrixType &typ, const FloatMatrix& b, octave_idx_type& info,
00185 float& rcon, solve_singularity_handler sing_handler,
00186 bool singular_fallback = true, blas_trans_type transt = blas_no_trans) const;
00187
00188 FloatComplexMatrix solve (MatrixType &typ, const FloatComplexMatrix& b) const;
00189 FloatComplexMatrix solve (MatrixType &typ, const FloatComplexMatrix& b,
00190 octave_idx_type& info) const;
00191 FloatComplexMatrix solve (MatrixType &typ, const FloatComplexMatrix& b,
00192 octave_idx_type& info, float& rcon) const;
00193 FloatComplexMatrix solve (MatrixType &typ, const FloatComplexMatrix& b,
00194 octave_idx_type& info, float& rcon,
00195 solve_singularity_handler sing_handler,
00196 bool singular_fallback = true,
00197 blas_trans_type transt = blas_no_trans) const;
00198
00199 FloatColumnVector solve (MatrixType &typ, const FloatColumnVector& b) const;
00200 FloatColumnVector solve (MatrixType &typ, const FloatColumnVector& b,
00201 octave_idx_type& info) const;
00202 FloatColumnVector solve (MatrixType &typ, const FloatColumnVector& b,
00203 octave_idx_type& info, float& rcon) const;
00204 FloatColumnVector solve (MatrixType &typ, const FloatColumnVector& b,
00205 octave_idx_type& info, float& rcon,
00206 solve_singularity_handler sing_handler,
00207 blas_trans_type transt = blas_no_trans) const;
00208
00209 FloatComplexColumnVector solve (MatrixType &typ,
00210 const FloatComplexColumnVector& b) const;
00211 FloatComplexColumnVector solve (MatrixType &typ, const FloatComplexColumnVector& b,
00212 octave_idx_type& info) const;
00213 FloatComplexColumnVector solve (MatrixType &typ, const FloatComplexColumnVector& b,
00214 octave_idx_type& info, float& rcon) const;
00215 FloatComplexColumnVector solve (MatrixType &typ, const FloatComplexColumnVector& b,
00216 octave_idx_type& info, float& rcon,
00217 solve_singularity_handler sing_handler, blas_trans_type transt = blas_no_trans) const;
00218
00219
00220 FloatMatrix solve (const FloatMatrix& b) const;
00221 FloatMatrix solve (const FloatMatrix& b, octave_idx_type& info) const;
00222 FloatMatrix solve (const FloatMatrix& b, octave_idx_type& info, float& rcon) const;
00223 FloatMatrix solve (const FloatMatrix& b, octave_idx_type& info, float& rcon,
00224 solve_singularity_handler sing_handler,
00225 blas_trans_type transt = blas_no_trans) const;
00226
00227 FloatComplexMatrix solve (const FloatComplexMatrix& b) const;
00228 FloatComplexMatrix solve (const FloatComplexMatrix& b, octave_idx_type& info) const;
00229 FloatComplexMatrix solve (const FloatComplexMatrix& b, octave_idx_type& info, float& rcon) const;
00230 FloatComplexMatrix solve (const FloatComplexMatrix& b, octave_idx_type& info, float& rcon,
00231 solve_singularity_handler sing_handler,
00232 blas_trans_type transt = blas_no_trans) const;
00233
00234 FloatColumnVector solve (const FloatColumnVector& b) const;
00235 FloatColumnVector solve (const FloatColumnVector& b, octave_idx_type& info) const;
00236 FloatColumnVector solve (const FloatColumnVector& b, octave_idx_type& info, float& rcon) const;
00237 FloatColumnVector solve (const FloatColumnVector& b, octave_idx_type& info, float& rcon,
00238 solve_singularity_handler sing_handler,
00239 blas_trans_type transt = blas_no_trans) const;
00240
00241 FloatComplexColumnVector solve (const FloatComplexColumnVector& b) const;
00242 FloatComplexColumnVector solve (const FloatComplexColumnVector& b, octave_idx_type& info) const;
00243 FloatComplexColumnVector solve (const FloatComplexColumnVector& b, octave_idx_type& info,
00244 float& rcon) const;
00245 FloatComplexColumnVector solve (const FloatComplexColumnVector& b, octave_idx_type& info,
00246 float& rcon, solve_singularity_handler sing_handler,
00247 blas_trans_type transt = blas_no_trans) const;
00248
00249
00250 FloatMatrix lssolve (const FloatMatrix& b) const;
00251 FloatMatrix lssolve (const FloatMatrix& b, octave_idx_type& info) const;
00252 FloatMatrix lssolve (const FloatMatrix& b, octave_idx_type& info,
00253 octave_idx_type& rank) const;
00254 FloatMatrix lssolve (const FloatMatrix& b, octave_idx_type& info,
00255 octave_idx_type& rank, float& rcon) const;
00256
00257 FloatComplexMatrix lssolve (const FloatComplexMatrix& b) const;
00258 FloatComplexMatrix lssolve (const FloatComplexMatrix& b, octave_idx_type& info) const;
00259 FloatComplexMatrix lssolve (const FloatComplexMatrix& b, octave_idx_type& info,
00260 octave_idx_type& rank) const;
00261 FloatComplexMatrix lssolve (const FloatComplexMatrix& b, octave_idx_type& info,
00262 octave_idx_type& rank, float &rcon) const;
00263
00264 FloatColumnVector lssolve (const FloatColumnVector& b) const;
00265 FloatColumnVector lssolve (const FloatColumnVector& b, octave_idx_type& info) const;
00266 FloatColumnVector lssolve (const FloatColumnVector& b, octave_idx_type& info,
00267 octave_idx_type& rank) const;
00268 FloatColumnVector lssolve (const FloatColumnVector& b, octave_idx_type& info,
00269 octave_idx_type& rank, float& rcon) const;
00270
00271 FloatComplexColumnVector lssolve (const FloatComplexColumnVector& b) const;
00272 FloatComplexColumnVector lssolve (const FloatComplexColumnVector& b,
00273 octave_idx_type& info) const;
00274 FloatComplexColumnVector lssolve (const FloatComplexColumnVector& b,
00275 octave_idx_type& info,
00276 octave_idx_type& rank) const;
00277 FloatComplexColumnVector lssolve (const FloatComplexColumnVector& b,
00278 octave_idx_type& info,
00279 octave_idx_type& rank, float& rcon) const;
00280
00281 FloatMatrix& operator += (const FloatDiagMatrix& a);
00282 FloatMatrix& operator -= (const FloatDiagMatrix& a);
00283
00284
00285
00286 boolMatrix operator ! (void) const;
00287
00288
00289
00290 typedef float (*dmapper) (float);
00291 typedef FloatComplex (*cmapper) (const FloatComplex&);
00292 typedef bool (*bmapper) (float);
00293
00294 FloatMatrix map (dmapper fcn) const;
00295 FloatComplexMatrix map (cmapper fcn) const;
00296 boolMatrix map (bmapper fcn) const;
00297
00298 bool any_element_is_negative (bool = false) const;
00299 bool any_element_is_nan (void) const;
00300 bool any_element_is_inf_or_nan (void) const;
00301 bool any_element_not_one_or_zero (void) const;
00302 bool all_elements_are_int_or_inf_or_nan (void) const;
00303 bool all_integers (float& max_val, float& min_val) const;
00304 bool too_large_for_float (void) const;
00305
00306 boolMatrix all (int dim = -1) const;
00307 boolMatrix any (int dim = -1) const;
00308
00309 FloatMatrix cumprod (int dim = -1) const;
00310 FloatMatrix cumsum (int dim = -1) const;
00311 FloatMatrix prod (int dim = -1) const;
00312 FloatMatrix sum (int dim = -1) const;
00313 FloatMatrix sumsq (int dim = -1) const;
00314 FloatMatrix abs (void) const;
00315
00316 FloatMatrix diag (octave_idx_type k = 0) const;
00317
00318 FloatColumnVector row_min (void) const;
00319 FloatColumnVector row_max (void) const;
00320
00321 FloatColumnVector row_min (Array<octave_idx_type>& index) const;
00322 FloatColumnVector row_max (Array<octave_idx_type>& index) const;
00323
00324 FloatRowVector column_min (void) const;
00325 FloatRowVector column_max (void) const;
00326
00327 FloatRowVector column_min (Array<octave_idx_type>& index) const;
00328 FloatRowVector column_max (Array<octave_idx_type>& index) const;
00329
00330
00331
00332 friend OCTAVE_API std::ostream& operator << (std::ostream& os, const FloatMatrix& a);
00333 friend OCTAVE_API std::istream& operator >> (std::istream& is, FloatMatrix& a);
00334
00335 static float resize_fill_value (void) { return 0; }
00336
00337 private:
00338
00339 FloatMatrix (float *d, octave_idx_type r, octave_idx_type c) : MArray2<float> (d, r, c) { }
00340 };
00341
00342
00343
00344 extern OCTAVE_API FloatMatrix real (const FloatComplexMatrix& a);
00345 extern OCTAVE_API FloatMatrix imag (const FloatComplexMatrix& a);
00346
00347
00348
00349 extern OCTAVE_API FloatMatrix operator * (const FloatColumnVector& a, const FloatRowVector& b);
00350
00351
00352
00353 extern OCTAVE_API FloatMatrix Givens (float, float);
00354
00355 extern OCTAVE_API FloatMatrix Sylvester (const FloatMatrix&, const FloatMatrix&, const FloatMatrix&);
00356
00357 extern OCTAVE_API FloatMatrix xgemm (const FloatMatrix& a, const FloatMatrix& b,
00358 blas_trans_type transa = blas_no_trans,
00359 blas_trans_type transb = blas_no_trans);
00360
00361 extern OCTAVE_API FloatMatrix operator * (const FloatMatrix& a, const FloatMatrix& b);
00362
00363 extern OCTAVE_API FloatMatrix min (float d, const FloatMatrix& m);
00364 extern OCTAVE_API FloatMatrix min (const FloatMatrix& m, float d);
00365 extern OCTAVE_API FloatMatrix min (const FloatMatrix& a, const FloatMatrix& b);
00366
00367 extern OCTAVE_API FloatMatrix max (float d, const FloatMatrix& m);
00368 extern OCTAVE_API FloatMatrix max (const FloatMatrix& m, float d);
00369 extern OCTAVE_API FloatMatrix max (const FloatMatrix& a, const FloatMatrix& b);
00370
00371 extern OCTAVE_API FloatMatrix linspace (const FloatColumnVector& x1,
00372 const FloatColumnVector& x2,
00373 octave_idx_type n);
00374
00375
00376 MS_CMP_OP_DECLS (FloatMatrix, float, OCTAVE_API)
00377 MS_BOOL_OP_DECLS (FloatMatrix, float, OCTAVE_API)
00378
00379 SM_CMP_OP_DECLS (float, FloatMatrix, OCTAVE_API)
00380 SM_BOOL_OP_DECLS (float, FloatMatrix, OCTAVE_API)
00381
00382 MM_CMP_OP_DECLS (FloatMatrix, FloatMatrix, OCTAVE_API)
00383 MM_BOOL_OP_DECLS (FloatMatrix, FloatMatrix, OCTAVE_API)
00384
00385 MARRAY_FORWARD_DEFS (MArray2, FloatMatrix, float)
00386
00387 template <class T>
00388 void read_int (std::istream& is, bool swap_bytes, T& val);
00389
00390 #endif
00391
00392
00393
00394
00395
00396