Changeset 870
- Timestamp:
- 03/18/10 19:13:02 (15 years ago)
- Location:
- library
- Files:
-
- 10 modified
Legend:
- Unmodified
- Added
- Removed
-
library/Doxyfile
r838 r870 1239 1239 # way by setting EXPAND_ONLY_PREDEF to YES. 1240 1240 1241 MACRO_EXPANSION = NO1241 MACRO_EXPANSION = YES 1242 1242 1243 1243 # If the EXPAND_ONLY_PREDEF and MACRO_EXPANSION tags are both set to YES … … 1245 1245 # PREDEFINED and EXPAND_AS_DEFINED tags. 1246 1246 1247 EXPAND_ONLY_PREDEF = NO1247 EXPAND_ONLY_PREDEF = YES 1248 1248 1249 1249 # If the SEARCH_INCLUDES tag is set to YES (the default) the includes files … … 1280 1280 # Use the PREDEFINED tag if you want to use a different macro definition. 1281 1281 1282 EXPAND_AS_DEFINED = 1282 EXPAND_AS_DEFINED = LOG_LEVEL 1283 1283 1284 1284 # If the SKIP_FUNCTION_MACROS tag is set to YES (the default) then -
library/Doxyfile_server
r839 r870 1003 1003 # generate Latex output. 1004 1004 1005 GENERATE_LATEX = NO1005 GENERATE_LATEX = YES 1006 1006 1007 1007 # The LATEX_OUTPUT tag is used to specify where the LaTeX docs will be put. … … 1239 1239 # way by setting EXPAND_ONLY_PREDEF to YES. 1240 1240 1241 MACRO_EXPANSION = NO1241 MACRO_EXPANSION = YES 1242 1242 1243 1243 # If the EXPAND_ONLY_PREDEF and MACRO_EXPANSION tags are both set to YES … … 1245 1245 # PREDEFINED and EXPAND_AS_DEFINED tags. 1246 1246 1247 EXPAND_ONLY_PREDEF = NO1247 EXPAND_ONLY_PREDEF = YES 1248 1248 1249 1249 # If the SEARCH_INCLUDES tag is set to YES (the default) the includes files … … 1280 1280 # Use the PREDEFINED tag if you want to use a different macro definition. 1281 1281 1282 EXPAND_AS_DEFINED = 1282 EXPAND_AS_DEFINED = LOG_LEVEL 1283 1283 1284 1284 # If the SKIP_FUNCTION_MACROS tag is set to YES (the default) then -
library/bdm/base/bdmbase.cpp
r863 r870 563 563 } 564 564 565 if (log_level[ bounds]){565 if (log_level[logbounds]){ 566 566 prior().log_level[epdf::loglb]=true; 567 567 prior().log_level[epdf::logub]=true; 568 568 } 569 if (log_level[ full]){569 if (log_level[logfull]){ 570 570 prior().log_level[epdf::logfull]=true; 571 571 } -
library/bdm/base/bdmbase.h
r864 r870 492 492 //! Probability density function with numerical statistics, e.g. posterior density. 493 493 class epdf : public pdf { 494 LOG_LEVEL(epdf, logmean, loglb, logub, logfull); 494 //! \var log_level_enums logmean 495 //! TODO DOPLNIT 496 497 //! \var log_level_enums loglb 498 //! TODO DOPLNIT 499 500 //! \var log_level_enums logub 501 //! TODO DOPLNIT 502 503 //! \var log_level_enums logfull 504 //! TODO DOPLNIT 505 LOG_LEVEL(epdf,logmean,loglb,logub,logfull); 495 506 496 507 public: … … 895 906 896 907 class DS : public root { 908 //! \var log_level_enums dt 909 //! TODO DOPLNIT 897 910 LOG_LEVEL(DS, dt); 911 898 912 protected: 899 913 //! size of data returned by \c getdata() … … 983 997 984 998 class BM : public root { 985 LOG_LEVEL(BM, full, likelihood, bounds); 999 //! \var log_level_enums logfull 1000 //! TODO DOPLNIT 1001 1002 //! \var log_level_enums logevidence 1003 //! TODO DOPLNIT 1004 1005 //! \var log_level_enums logbounds 1006 //! TODO DOPLNIT 1007 LOG_LEVEL(BM,logfull,logevidence,logbounds); 986 1008 987 1009 protected: … … 1145 1167 void validate() 1146 1168 { 1147 if ( log_level[ full] ) {1169 if ( log_level[logfull] ) { 1148 1170 const_cast<epdf&> ( posterior() ).log_level[epdf::logfull] = true; 1149 1171 } else { 1150 if ( log_level[ bounds] ) {1172 if ( log_level[logbounds] ) { 1151 1173 const_cast<epdf&> ( posterior() ).log_level[epdf::loglb] = true; 1152 1174 } else { 1153 1175 const_cast<epdf&> ( posterior() ).log_level[epdf::logmean] = true;; 1154 1176 } 1155 if ( log_level[likelihood] ) { 1156 // TODO testovat tedy likelyhood misto 1.. log_level = 1; 1177 if ( log_level[logevidence] ) { 1157 1178 } 1158 1179 } -
library/bdm/base/user_info.h
r863 r870 305 305 static void from_setting ( double &real, const Setting &element ); 306 306 307 //! This method converts a Setting into a specific log ged_options<T> variant and initialize options properly308 template< class T> static void from_setting ( log ged_options<T> &options, const Setting &element )307 //! This method converts a Setting into a specific log_level_template<T> variant and initialize options properly 308 template< class T> static void from_setting ( log_level_template<T> &log_level, const Setting &element ) 309 309 { 310 options.values.reset(); 311 Array<string> true_options; 312 UI::get( true_options, element ); 313 for( int i = 0; i < true_options.length(); i++ ) 314 for( int j = 0; j < options.names().length(); j++ ){ 315 if( true_options(i) == options.names()(j) ) 310 string raw_log_level; 311 UI::get( raw_log_level, element ); 312 Array<string> loaded_log_level = log_level_template<T>::string2Array( raw_log_level ); 313 314 log_level.values.reset(); 315 316 for( int i = 0; i < loaded_log_level.length(); i++ ) 317 for( int j = 0; j < log_level.names().length(); j++ ){ 318 if( loaded_log_level(i) == log_level.names()(j) ) 316 319 { 317 options.values[j] = true;320 log_level.values[j] = true; 318 321 break; 319 322 } … … 324 327 template<class T> static void from_setting ( T* &instance, const Setting &element ) { 325 328 const SettingResolver link ( element ); 326 assert_type 329 assert_type( link.result, Setting::TypeGroup ); 327 330 328 331 // we get a value stored in the "class" attribute … … 600 603 } 601 604 602 // The only difference from classical UserInfo approach to log ged_optionsis the fact603 // that the actual element related to logged_optionscould possibly exists yet. In this case,605 // The only difference from classical UserInfo approach to log_level_template is the fact 606 // that the actual UI element related to log_level_template could possibly exists yet. In this case, 604 607 // we do not want to throw an exception like in the case of any other type being loaded 605 // from Setting. Here, we rather add our optionsinto this existig element. This way, it is606 // possible that more instances of log ged_options class (all contained in one wrapping instance of607 // a particular class!)can be stored in only one line in a configuration file608 template< class T> static void save ( const log ged_options<T> &options, Setting &element, const string &name = "options" ) {608 // from Setting. We rather fill the current log_level into this existig element. This way, it is 609 // possible that more instances of log_level_template class (templated with different classes) 610 // can be stored in only one line in a configuration file 611 template< class T> static void save ( const log_level_template<T> &log_level, Setting &element, const string &name = "log_level" ) { 609 612 assert_type ( element, Setting::TypeGroup ); 613 614 string string_to_write; 610 615 611 616 Setting *list; … … 613 618 { 614 619 list = &element[name]; 615 assert_type ( *list, Setting::TypeList ); 620 assert_type ( *list, Setting::TypeString ); 621 string_to_write = ( const char* ) *list; 616 622 } 617 623 else 618 list = &element.add ( name, Setting::TypeList ); 619 620 Array<string> true_options; 621 int true_options_count = 0; 622 true_options.set_length( options.values.size() ); 623 for( unsigned int i = 0; i < options.values.size(); i++ ) 624 if( options.values[i] ) 625 true_options( true_options_count++ ) = options.names()(i); 626 save( true_options, *list, name ); 624 list = &element.add ( name, Setting::TypeString ); 625 626 for( unsigned int i = 0; i < log_level.values.size(); i++ ) 627 if( log_level.values[i] ) // a jeste zkontrolovat zda to jmeno uz neni obsazeno? 628 { 629 if( string_to_write.length() > 0 ) 630 string_to_write = string_to_write + ','; 631 string_to_write = string_to_write + log_level.names()(i); 632 } 633 634 *list = string_to_write; 627 635 } 628 636 -
library/bdm/bdmroot.h
r865 r870 38 38 void UI_DBG (const Setting &S, const string &spc, ostream &out ); 39 39 40 //! level of details that will be logged to a logger 41 // DULEZITE TODO - zde musi respektovat aktualne ulozene hodnoty, tj. nacist je, pak pridat 42 // ty co se maji v tomto kroku ulozit a pak vse ulozit.. protoze to delame kompozici a ne dedenim DODELAT 43 // ALE HOUBY, TAKHLE TO NEJDE, musime nechat jako samostatny objekt, kazda uroven tedy zvlast, 44 // jednoznacne jmeno atd.. 45 // 46 //! information about connection to a logger 47 template<class T> class logged_options { 40 //! This class stores a details that will be logged to a logger 41 template<class T> class log_level_template { 48 42 private: 43 // UserInfo class have to be able to read all the internal 44 // attributes to be able to write/read log_level to/from a Setting structure 49 45 friend class UI; 50 46 … … 52 48 bitset<32> values; 53 49 50 //! string equivalents of the used enumerations which are filled with a help of #LOG_LEVEL macro within class T 54 51 const Array<string> &names() const 55 52 { 56 return T:: option_names();53 return T::log_level_names(); 57 54 } 58 55 59 56 public: 60 57 58 //! a general utility transforming a comma-separated sequence of strings into an instance of Array<strings> 59 static Array<string> string2Array( const string &input ) 60 { 61 string result = input; 62 string::size_type loc; 63 while( loc = result.find( ',' ), loc != string::npos ) 64 result[loc] = ' '; 65 return Array<string>("{ " + result + " }" ); 66 } 67 68 //! is any field of log_level active? 61 69 bool any() const 62 70 { … … 64 72 } 65 73 66 bool operator [] (const enum T::possible_options &option ) const 67 { 68 return values[option]; 69 } 70 71 bitset<32>::reference operator [] (const enum T::possible_options &option ) 72 { 73 return values[option]; 74 //! read only operator for testing individual fields of log_level 75 //! 76 //! it is necessary to acces it with a proper enumeration type, thus this approach is type-safe 77 bool operator [] (const enum T::log_level_enums &log_level ) const 78 { 79 return values[log_level]; 80 } 81 82 //! operator for setting an individual field of log_level 83 //! 84 //! it is necessary to acces it with a proper enumeration type, thus this approach is type-safe 85 bitset<32>::reference operator [] (const enum T::log_level_enums &log_level ) 86 { 87 return values[log_level]; 74 88 } 75 89 }; 76 90 77 // MUZEME INTERNE POUZIVAT ENUMY, A KLIDNE MENIT JEJICH PORADI, DIKY TOMUHLE MAKRU SE VZDY NAMAPUJI NA TY SPRAVNE STRINGY 78 #define LOG_LEVEL(CLASSNAME,...) private: friend class logged_options<CLASSNAME>; static const Array<string> &option_names() { static const Array<string> option_names( "{"#__VA_ARGS__" }" ); return option_names; }; public: enum possible_options { __VA_ARGS__ }; logged_options<CLASSNAME> log_level; 91 /*! 92 \def LOG_LEVEL(classname,...) 93 \brief Macro for defining a log_level attribute with a specific set of enumerations related to a specific class 94 95 This macro has to be called within a class declaration. Its argument \a classname has to correspond to that wrapping class. 96 This macro defines a log_level instance which can be modified either directly or by the means of #UI class. 97 98 One of the main purposes of this macro is to allow variability in using enumerations. By relating them to their names through 99 an array of strings, we are no more dependant on their precise ordering. What is more, we can add or remove any without harming 100 any applications which are using this library. 101 102 \todo Write a more detailed explanation including also examples 103 104 \ref ui 105 */ 106 #define LOG_LEVEL(classname,...) public: enum log_level_enums { __VA_ARGS__ }; log_level_template<classname> log_level; private: friend class log_level_template<classname>; static const Array<string> &log_level_names() { static const Array<string> log_level_names = log_level_template<classname>::string2Array( #__VA_ARGS__ ); return log_level_names; } 79 107 80 108 //forward declaration … … 99 127 friend class UI; 100 128 101 // TODO okomentovat102 static const Array<string> &option_names()129 //! This method is a dummy method closely related to to the #LOG_LEVEL macro, do not remove it 130 static const string &log_level_names() 103 131 { 104 static const Array<string> option_names;105 return option_names;132 static const string log_level_names; 133 return log_level_names; 106 134 }; 107 135 … … 189 217 190 218 public: 191 // TODO okomentovat 192 enum possible_options { }; 219 //! This enumeration defines all possible options specifing the level of details logged by a logger about this specific class 220 //! 221 //! It has to be reimplemented in descendant classes using the #LOG_LEVEL macro 222 enum log_level_enums { }; 193 223 194 224 //!default constructor -
library/bdm/estim/particles.h
r850 r870 26 26 27 27 class PF : public BM { 28 //! Introduces two new options: 29 //! \li weights - meaning that all weightes will be logged 30 //! \li samples - all samples will be also logged 28 //! \var log_level_enums weights 29 //! all weightes will be logged 30 31 //! \var log_level_enums samples 32 //! all samples will be logged 31 33 LOG_LEVEL(PF,weights,samples); 32 34 33 35 protected: 34 36 //!number of particles; … … 221 223 222 224 class MPF : public BM { 223 //! Introduces new option224 //! \li means - meaning TODO225 //! \var log_level_enums means 226 //! TODO DOPLNIT 225 227 LOG_LEVEL(MPF,means); 228 226 229 protected: 227 230 //! particle filter on non-linear variable -
library/bdm/stat/exp_family.h
r850 r870 350 350 */ 351 351 class egiw : public eEF { 352 //! \var log_level_enums tri 353 //! TODO DOPLNIT 352 354 LOG_LEVEL(egiw,tri); 355 353 356 protected: 354 357 //! Extended information matrix of sufficient statistics -
library/doc/tutorial/02userguide2.dox
r693 r870 52 52 A1.rv = y; 53 53 A1.rgr = RVtimes([y,y],[-3,-1]) ; 54 A1. options = 'logbounds,logll';54 A1.log_level = 'logbounds,logevidence'; 55 55 \endcode 56 56 This is the minimal configuration of an ARX estimator. Optional elements of bdm::ARX::from_setting() were set using their default values: 57 57 58 58 The first three fileds are self explanatory, they identify which data are predicted (field \c rv) and which are in regressor (field \c rgr). 59 The field \c optionsis a string of options passed to the object. In particular, class \c BM understand only options related to storing results:59 The field \c log_level is a string of options passed to the object. In particular, class \c BM understand only options related to storing results: 60 60 - logbounds - store also lower and upper bounds on estimates (obtained by calling BM::posterior().qbounds()), 61 - log ll- store also loglikelihood of each step of the Bayes rule.61 - logevidence - store also loglikelihood of each step of the Bayes rule. 62 62 These values are stored in given logger (\ref ug_loggers). By default, only mean values of the estimate are stored. 63 63 … … 129 129 A1.rv = y; 130 130 A1.rgr = RVtimes([y,u],[-3,-1]) ; 131 A1. options ='logbounds,logll';131 A1.log_level ='logbounds,logevidence'; 132 132 A1.frg = 0.9; 133 133 A1.name = 'A1'; … … 146 146 E.prior.class = 'eDirich'; % prior on non-linear part 147 147 E.prior.beta = [1 1]; % 148 E. options ='logbounds,logll';148 E.log_level ='logbounds,logevidence'; 149 149 E.name = 'MPF'; 150 150 -
library/tests/stresssuite/blas_stress.cpp
r721 r870 56 56 57 57 for ( int i = 0; i < vn.length(); i++ ) { 58 n = vn ( i );58 n = (int) vn ( i ); 59 59 A = randu ( n, n ); 60 60 B = randu ( n, n );