Main Page | Class Hierarchy | Class List | File List | Class Members | File Members | Related Pages

halinalg.h

Go to the documentation of this file.
00001 
00009 #ifndef HALINALG_H
00010 #define HALINALG_H
00011 
00012 #define TNT_BOUNDS_CHECK
00013 
00014 #include "haio.h" 
00015 #include "hastring.h"
00016 #include "const.h"       
00017 #include "vec.h"     //   TNT library
00018 #include "fmat.h"    
00019 #include "f2c.h"
00020 
00021 #include "cg_sngl.h" // include files for IML++
00022 
00023 // typedef NumVector<double>  HaVec_double ; //!< Numerical vector of double
00024 typedef NumVector<float>   HaVec_float ;  
00025 typedef NumVector<int>     HaVec_int;     
00026 typedef NumVector<short>   HaVec_short;   
00027 typedef NumVector<integer> HaVec_integer; 
00028 typedef NumVector<void*>   HaVec_ptr;     
00029 // typedef Fortran_matrix<double>  HaMat_double ;
00030 typedef Fortran_matrix<float>   HaMat_float ;
00031 typedef Fortran_matrix<int>     HaMat_int;
00032 typedef Fortran_matrix<integer> HaMat_integer;
00033 
00034 class Matrix; // Forward declaration for IPACK double-precision matrix
00035 
00036 class HaVec_double: public NumVector<double> 
00038 {
00039 public:
00040         HaVec_double() {}
00041         HaVec_double( const HaVec_double& A): NumVector<double>( (NumVector<double>) A) {}
00042         HaVec_double(Subscript N, const double& value = 0.0 ): NumVector<double>(N, value) {}
00043     HaVec_double(Subscript N, const double* v): NumVector<double>(N, v) {}
00044         HaVec_double(Subscript N, char *s): NumVector<double>(N, s) {}
00045 
00046         HaVec_double& operator=(const double& scalar) { set(scalar); return *this; } 
00047     HaVec_double& operator/(const HaVec_double &B) { return (*this)/B; } 
00048 
00049 };
00050 
00051 class HaMat_double : public Fortran_matrix<double>
00053 {
00054 public:
00055         HaMat_double() {}
00056         HaMat_double(Subscript M, Subscript N, const double& value = 0.0): 
00057                                                Fortran_matrix<double>(M,N,value) {} 
00058 
00059         HaMat_double(Subscript M, Subscript N, double* v, const int New_amode=0): 
00060                                                Fortran_matrix<double>(M,N,v,New_amode) {}
00061                                                                                    
00062         HaMat_double(Subscript M, Subscript N, char* s): 
00063                                                Fortran_matrix<double>(M,N,s) {}
00064 
00065         HaMat_double(const HaMat_double& A): 
00066                                                                                    Fortran_matrix<double>( (Fortran_matrix<double>) A) {}
00067 
00068         HaMat_double(const Fortran_matrix<double>& A): 
00069                                                                                    Fortran_matrix<double>(A) {}
00070 
00071         HaMat_double& operator=(const double& scalar) { set(scalar); return *this; } 
00072 
00073         int set_from(Matrix& ipack_mat); 
00074 
00075         int SetFromStr(const char* str); 
00076 
00077     static int mat_inverse(HaMat_double& aa);   
00078     static int mat_transpose(HaMat_double& aa); 
00079     static int mat_sdiag(const HaMat_double& aa, HaMat_double& cc, 
00080                                      HaVec_double& eig);  
00081 
00082         int SqRoot(const int isign=1); 
00083 
00084         static int solv_lin_syst_1(HaMat_double& a, HaMat_double& b); 
00085 
00086 protected:
00087 
00088 };
00089 
00090 typedef  map<HaString,HaVec_double,less<HaString> >  StrVecMap;
00091 
00092 class MultiVarFunctor
00094 {
00095   public:
00096       MultiVarFunctor(); 
00097       virtual ~MultiVarFunctor();
00098       virtual double operator() (const HaVec_double& xv) = 0;
00099           virtual int CalcGrad(HaVec_double& grad,const HaVec_double& xv) = 0;
00100 };
00101 
00102 const int BFGS_MIN_METH = 0;
00103 
00104 typedef void (*ptrMinFunc1)(integer* iptr,integer* n, double*x, double* f, double* g);
00105 
00106 extern "C" { 
00107 extern void va13ad_ ( integer* iptr, ptrMinFunc1 pfunc, 
00108                                           integer* n, double* x, double* f ,double* g,double* scale,double* acc,double* w);
00109 }
00110 
00111 class HaMinimizer
00113 {
00114 public:
00115         HaMinimizer();
00116         ~HaMinimizer();
00117 
00118         int min_method;
00119 
00120         int GetNVar();              
00121         void SetNVar( int nvar);    
00122 
00123         int SetInitPoint(HaVec_double& init_pt); 
00124         virtual int CalcValGrad(HaVec_double& x, double& val, HaVec_double& grad); 
00125                                                                                        
00126         int Minimize(); 
00127 
00128         HaVec_double vvar;  
00129         HaVec_double scale; 
00130         double fun_val;     
00131 
00132         int nitr;
00133         double flast;
00134         HaVec_double glast;
00135 
00136 
00137 };
00138 
00139 
00140 // Matrix operations as global functions:
00141 
00142 #ifdef HALINALG_CPP
00143 
00144 Subscript ij_indx0(Subscript i, Subscript j);
00145 Subscript ij_indx1(Subscript i, Subscript j);
00146 
00147 #else
00148 
00149 extern Subscript ij_indx0(Subscript i, Subscript j);
00150 extern Subscript ij_indx1(Subscript i, Subscript j);
00151 
00152 extern "C" int write_dbl_array_chuncks( FILE* fp, HaVec_double& dvec, int chunck_size,  const char* form_str);
00153 extern "C" int write_float_array_chuncks( FILE* fp, HaVec_float& fvec, int chunck_size,  const char* form_str);
00154 extern "C" int write_int_array_chuncks( FILE* fp, HaVec_int& ivec, int chunck_size,  const char* form_str);
00155 
00156 extern "C" int rot_vec(double a[], double n[], double cosa, double sina); 
00157 
00158 #endif
00159 
00160 class LanzPars
00161 {
00162 public:
00163 // INPARI array:
00164 
00165    LanzPars();
00166    ~LanzPars();
00167 
00168    integer mat_order;       
00169    integer max_eigv_store;  
00170    integer num_eigv_search; 
00171    integer num_steps;       
00172 
00173    integer iret;            
00174    integer nfound;          
00175 
00176    integer debug_lvl;       
00177 
00178    integer problem_type;    
00179 
00180    integer inertia_check;   
00181    integer output_amount;   
00182                             //  PRINT EIGENVALUES AND INERTIAS =  64 + 4
00183                             //  PRINT EIGENVALUES, ESTIMATED ERRORS AND INERTIAS = 32 + 4
00184                             //  PRINT EIGENVALUES, ESTIMATED ERRORS, CALCULATED ERROR AND INERTIAS = 16 + 4
00185                             //  PRINT EIGENVALUES, ESTIMATED ERRORS,
00186                             //  CALCULATED ERROR, Y-ORTHOGONALITY AND INERTIAS = 16 + 4 + 2
00187                             //  PRINT EIGENVALUES, ESTIMATED ERRORS,
00188                             //  CALCULATED ERROR, Y-ORTHOGONALITY AND INERTIAS
00189                             //  AND THROW IN SOME FREQUENCIES 128 + 16 + 4 + 2
00190    integer max_steps_shift; 
00191 
00192 //   integer buckling_flag;     //!< VIBRATION (0) OR BUCKLING (1 W/ SHIFT) (2 W/O SHIFT)
00193    integer search_in_boundary;  
00194 
00195    integer fc_mat_fmt;      
00196    integer m_mat_fmt;       
00197    integer loop_unroll_lvl; 
00198 
00199 
00200 
00201    integer factor_type;     
00202 
00203 
00204 
00205 
00206 
00207    integer dyn_shift_off;   
00208    integer init_guess;      
00209    integer lead_y_idx;      
00210    integer num_delay_piv;   
00211 
00212 // INPARR array:
00213    double init_val;     
00214    double accuracy;     
00215    double left_bound;   
00216    double right_bound;  
00217    double store_factor;  
00218 
00219 };
00220 
00221 // LANZ - soubroutine to solve eigen vaalue problem with Lancos Algorithm
00222 extern "C" {
00223 void lanz_(integer* ldi,  
00224                    integer* inpari, double* inparr, 
00225                    double* otheta, 
00226                    double* oldbj,  
00227                    double* y,      
00228                    integer* onumt, 
00229                    double* kaux,   
00230                    integer* krp,   
00231            integer* kcp,   
00232                    double* maux,   
00233                    integer* mrp,   
00234                    integer* mcp,   
00235                    double*  r1j    
00236                    );
00237 }
00238 
00239 // LAPACK subroutines prototypes
00240 extern "C" {
00241 
00242 void dgesv_( integer* n,  integer* nrhs , double* a, 
00243                          integer* lda, integer* ipiv , double* b, 
00244                          integer* ldb, integer* info );
00245 }
00246 
00247 
00248 
00249 #endif /* !HALINALG_H */

Generated on Tue Feb 17 02:03:05 2004 for harlem by doxygen 1.3.6