メインページ   クラス階層   構成   ファイル一覧   構成メンバ   ファイルメンバ  

dMatrix.h

解説を見る。
00001 /*
00002 
00003 Copyright (C) 1996, 1997 John W. Eaton
00004 
00005 This file is part of Octave.
00006 
00007 Octave is free software; you can redistribute it and/or modify it
00008 under the terms of the GNU General Public License as published by the
00009 Free Software Foundation; either version 2, or (at your option) any
00010 later version.
00011 
00012 Octave is distributed in the hope that it will be useful, but WITHOUT
00013 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
00014 FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
00015 for more details.
00016 
00017 You should have received a copy of the GNU General Public License
00018 along with Octave; see the file COPYING.  If not, write to the Free
00019 Software Foundation, 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
00020 
00021 */
00022 
00023 #if !defined (octave_Matrix_int_h)
00024 #define octave_Matrix_int_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 
00036 class
00037 Matrix : public MArray2<double>
00038 {
00039 public:
00040 
00041   typedef void (*solve_singularity_handler) (double rcond);
00042 
00043   Matrix (void) : MArray2<double> () { }
00044 
00045   Matrix (int r, int c) : MArray2<double> (r, c) { }
00046 
00047   Matrix (int r, int c, double val) : MArray2<double> (r, c, val) { }
00048 
00049   Matrix (const Matrix& a) : MArray2<double> (a) { }
00050 
00051   Matrix (const MArray2<double>& a) : MArray2<double> (a) { }
00052 
00053   explicit Matrix (const RowVector& rv);
00054 
00055   explicit Matrix (const ColumnVector& cv);
00056 
00057   explicit Matrix (const DiagMatrix& a);
00058 
00059   explicit Matrix (const boolMatrix& a);
00060 
00061   explicit Matrix (const charMatrix& a);
00062 
00063   Matrix& operator = (const Matrix& a)
00064     {
00065       MArray2<double>::operator = (a);
00066       return *this;
00067     }
00068 
00069   bool operator == (const Matrix& a) const;
00070   bool operator != (const Matrix& a) const;
00071 
00072   bool is_symmetric (void) const;
00073 
00074   // destructive insert/delete/reorder operations
00075 
00076   Matrix& insert (const Matrix& a, int r, int c);
00077   Matrix& insert (const RowVector& a, int r, int c);
00078   Matrix& insert (const ColumnVector& a, int r, int c);
00079   Matrix& insert (const DiagMatrix& a, int r, int c);
00080 
00081   Matrix& fill (double val);
00082   Matrix& fill (double val, int r1, int c1, int r2, int c2);
00083 
00084   Matrix append (const Matrix& a) const;
00085   Matrix append (const RowVector& a) const;
00086   Matrix append (const ColumnVector& a) const;
00087   Matrix append (const DiagMatrix& a) const;
00088 
00089   Matrix stack (const Matrix& a) const;
00090   Matrix stack (const RowVector& a) const;
00091   Matrix stack (const ColumnVector& a) const;
00092   Matrix stack (const DiagMatrix& a) const;
00093 
00094   friend Matrix real (const ComplexMatrix& a);
00095   friend Matrix imag (const ComplexMatrix& a);
00096 
00097   Matrix transpose (void) const { return MArray2<double>::transpose (); }
00098 
00099   // resize is the destructive equivalent for this one
00100 
00101   Matrix extract (int r1, int c1, int r2, int c2) const;
00102 
00103   Matrix extract_n (int r1, int c1, int nr, int nc) const;
00104 
00105   // extract row or column i.
00106 
00107   RowVector row (int i) const;
00108   RowVector row (char *s) const;
00109 
00110   ColumnVector column (int i) const;
00111   ColumnVector column (char *s) const;
00112 
00113   Matrix inverse (void) const;
00114   Matrix inverse (int& info) const;
00115   Matrix inverse (int& info, double& rcond, int force = 0, 
00116                   int calc_cond = 1) const;
00117 
00118   Matrix pseudo_inverse (double tol = 0.0) const;
00119 
00120   ComplexMatrix fourier (void) const;
00121   ComplexMatrix ifourier (void) const;
00122 
00123   ComplexMatrix fourier2d (void) const;
00124   ComplexMatrix ifourier2d (void) const;
00125 
00126   DET determinant (void) const;
00127   DET determinant (int& info) const;
00128   DET determinant (int& info, double& rcond, int calc_cond = 1) const;
00129 
00130   Matrix solve (const Matrix& b) const;
00131   Matrix solve (const Matrix& b, int& info) const;
00132   Matrix solve (const Matrix& b, int& info, double& rcond) const;
00133   Matrix solve (const Matrix& b, int& info, double& rcond,
00134                 solve_singularity_handler sing_handler) const;
00135 
00136   ComplexMatrix solve (const ComplexMatrix& b) const;
00137   ComplexMatrix solve (const ComplexMatrix& b, int& info) const;
00138   ComplexMatrix solve (const ComplexMatrix& b, int& info, double& rcond) const;
00139   ComplexMatrix solve (const ComplexMatrix& b, int& info, double& rcond,
00140                        solve_singularity_handler sing_handler) const;
00141 
00142   ColumnVector solve (const ColumnVector& b) const;
00143   ColumnVector solve (const ColumnVector& b, int& info) const;
00144   ColumnVector solve (const ColumnVector& b, int& info, double& rcond) const;
00145   ColumnVector solve (const ColumnVector& b, int& info, double& rcond,
00146                       solve_singularity_handler sing_handler) const;
00147 
00148   ComplexColumnVector solve (const ComplexColumnVector& b) const;
00149   ComplexColumnVector solve (const ComplexColumnVector& b, int& info) const;
00150   ComplexColumnVector solve (const ComplexColumnVector& b, int& info,
00151                              double& rcond) const;
00152   ComplexColumnVector solve (const ComplexColumnVector& b, int& info,
00153                              double& rcond,
00154                              solve_singularity_handler sing_handler) const;
00155 
00156   Matrix lssolve (const Matrix& b) const;
00157   Matrix lssolve (const Matrix& b, int& info) const;
00158   Matrix lssolve (const Matrix& b, int& info, int& rank) const;
00159 
00160   ComplexMatrix lssolve (const ComplexMatrix& b) const;
00161   ComplexMatrix lssolve (const ComplexMatrix& b, int& info) const;
00162   ComplexMatrix lssolve (const ComplexMatrix& b, int& info,
00163                          int& rank) const;
00164 
00165   ColumnVector lssolve (const ColumnVector& b) const;
00166   ColumnVector lssolve (const ColumnVector& b, int& info) const;
00167   ColumnVector lssolve (const ColumnVector& b, int& info, int& rank) const;
00168 
00169   ComplexColumnVector lssolve (const ComplexColumnVector& b) const;
00170   ComplexColumnVector lssolve (const ComplexColumnVector& b, int& info) const;
00171   ComplexColumnVector lssolve (const ComplexColumnVector& b, int& info,
00172                                int& rank) const;
00173 
00174   Matrix expm (void) const;
00175 
00176   Matrix& operator += (const DiagMatrix& a);
00177   Matrix& operator -= (const DiagMatrix& a);
00178 
00179   // unary operations
00180 
00181   boolMatrix operator ! (void) const;
00182 
00183   // column vector by row vector -> matrix operations
00184 
00185   friend Matrix operator * (const ColumnVector& a, const RowVector& b);
00186 
00187   // other operations
00188 
00189   Matrix map (d_d_Mapper f) const;
00190   boolMatrix map (b_d_Mapper f) const;
00191 
00192   Matrix& apply (d_d_Mapper f);
00193 
00194   bool any_element_is_negative (bool = false) const;
00195   bool any_element_is_inf_or_nan (void) const;
00196   bool all_elements_are_int_or_inf_or_nan (void) const;
00197   bool all_integers (double& max_val, double& min_val) const;
00198   bool too_large_for_float (void) const;
00199  
00200   boolMatrix all (int dim = -1) const;
00201   boolMatrix any (int dim = -1) const;
00202 
00203   Matrix cumprod (int dim = -1) const;
00204   Matrix cumsum (int dim = -1) const;
00205   Matrix prod (int dim = -1) const;
00206   Matrix sum (int dim = -1) const;
00207   Matrix sumsq (int dim = -1) const;
00208   Matrix abs (void) const;
00209 
00210   ColumnVector diag (void) const;
00211   ColumnVector diag (int k) const;
00212 
00213   ColumnVector row_min (void) const;
00214   ColumnVector row_max (void) const;
00215 
00216   ColumnVector row_min (Array<int>& index) const;
00217   ColumnVector row_max (Array<int>& index) const;
00218 
00219   RowVector column_min (void) const;
00220   RowVector column_max (void) const;
00221 
00222   RowVector column_min (Array<int>& index) const;
00223   RowVector column_max (Array<int>& index) const;
00224 
00225   // i/o
00226 
00227   friend std::ostream& operator << (std::ostream& os, const Matrix& a);
00228   friend std::istream& operator >> (std::istream& is, Matrix& a);
00229 
00230   static double resize_fill_value (void) { return 0; }
00231 
00232 private:
00233 
00234   Matrix (double *d, int r, int c) : MArray2<double> (d, r, c) { }
00235 };
00236 
00237 extern Matrix Givens (double, double);
00238 
00239 extern Matrix Sylvester (const Matrix&, const Matrix&, const Matrix&);
00240 
00241 extern Matrix operator * (const Matrix& a, const Matrix& b);
00242 
00243 extern Matrix min (double d, const Matrix& m);
00244 extern Matrix min (const Matrix& m, double d);
00245 extern Matrix min (const Matrix& a, const Matrix& b);
00246 
00247 extern Matrix max (double d, const Matrix& m);
00248 extern Matrix max (const Matrix& m, double d);
00249 extern Matrix max (const Matrix& a, const Matrix& b);
00250 
00251 MS_CMP_OP_DECLS (Matrix, double)
00252 MS_BOOL_OP_DECLS (Matrix, double)
00253 
00254 SM_CMP_OP_DECLS (double, Matrix)
00255 SM_BOOL_OP_DECLS (double, Matrix)
00256 
00257 MM_CMP_OP_DECLS (Matrix, Matrix)
00258 MM_BOOL_OP_DECLS (Matrix, Matrix)
00259 
00260 MARRAY_FORWARD_DEFS (MArray2, Matrix, double)
00261 
00262 template <class T>
00263 void read_int (std::istream& is, bool swap_bytes, T& val);
00264 
00265 #endif
00266 
00267 /*
00268 ;;; Local Variables: ***
00269 ;;; mode: C++ ***
00270 ;;; End: ***
00271 */

Wed Dec 29 11:51:23 2004に生成されました。 doxygen1.2.18
SEO [PR] 爆速!無料ブログ 無料ホームページ開設 無料ライブ放送