Changeset 256
- Timestamp:
- 01/28/09 10:01:18 (16 years ago)
- Files:
-
- 8 modified
Legend:
- Unmodified
- Added
- Removed
-
CMakeLists.txt
r247 r256 26 26 ELSE() 27 27 #This is for UNIX makefile which does only one release at a time. 28 SET(CMAKE_BUILD_TYPE Optimized)28 SET(CMAKE_BUILD_TYPE Debug) 29 29 SET(CMAKE_CXX_FLAGS "-Wall -pipe -Wno-unknown-pragmas") 30 30 SET(CMAKE_CXX_FLAGS_RELEASE " -DNDEBUG -O2") -
bdm/CMakeLists.txt
r249 r256 1 1 # Create a library called "bdm" which includes sources from all directories 2 3 #add_subdirectory(config)4 2 5 3 SET(BdmMath math/libDC.cpp math/libDC.h math/chmat.cpp math/chmat.h) -
bdm/stat/libBM.h
r254 r256 26 26 27 27 //! Root class of BDM objects 28 class b ase{};28 class bdmroot{}; 29 29 30 30 //! Structure of RV (used internally), i.e. expanded RVs … … 47 47 */ 48 48 49 class RV : base{49 class RV :public bdmroot{ 50 50 protected: 51 51 //! size = sum of sizes … … 139 139 //! Class representing function \f$f(x)\f$ of variable \f$x\f$ represented by \c rv 140 140 141 class fnc : base{141 class fnc :public bdmroot{ 142 142 protected: 143 143 //! Length of the output vector … … 165 165 //! Probability density function with numerical statistics, e.g. posterior density. 166 166 167 class epdf : base{167 class epdf :public bdmroot { 168 168 protected: 169 169 //! Identified of the random variable … … 217 217 //TODO Samplecond can be generalized 218 218 219 class mpdf {219 class mpdf : public bdmroot{ 220 220 protected: 221 221 //! modeled random variable … … 358 358 }; 359 359 360 //!\brief Abstract composition of pdfs, a basefor specific classes360 //!\brief Abstract composition of pdfs, will be used for specific classes 361 361 //!this abstract class is common to epdf and mpdf 362 362 class compositepdf { … … 381 381 */ 382 382 383 class DS {383 class DS : public bdmroot{ 384 384 protected: 385 385 //!Observed variables, returned by \c getdata(). … … 413 413 */ 414 414 415 class BM {415 class BM :public bdmroot{ 416 416 protected: 417 417 //!Random variable of the posterior … … 473 473 */ 474 474 475 class BMcond : base{475 class BMcond :public bdmroot{ 476 476 protected: 477 477 //! Identificator of the conditioning variable -
bdm/stat/libEF.h
r254 r256 345 345 \f] 346 346 347 Inverse Gamma can be converted to Gamma using \ [347 Inverse Gamma can be converted to Gamma using \f[ 348 348 x\sim iG(a,b) => 1/x\sim G(a,1/b) 349 \ ]349 \f] 350 350 This relation is used in sampling. 351 351 */ -
bdm/uibuilder.cpp
r254 r256 5 5 UImap __uimap__; 6 6 7 void UIexternal::build(Setting &S, void**result) const{7 void UIexternal::build(Setting &S, bdmroot* &result) const{ 8 8 Config C; 9 9 try{ … … 22 22 UIREGISTER(UIexternal); 23 23 24 void UIinternal::build(Setting &S, void**result) const{24 void UIinternal::build(Setting &S, bdmroot* &result) const{ 25 25 try { 26 26 Setting* Stmp = &S; -
bdm/uibuilder.h
r254 r256 2 2 #define UIBUILD 3 3 4 #include "libconfig/libconfig.h++"5 4 #include <itpp/itbase.h> 6 5 #include "stat/libBM.h" 6 #include "libconfig/libconfig.h++" 7 7 8 8 namespace bdm{ … … 76 76 }; 77 77 public: 78 //!Constructor needs to be run only once via REGISTERUI 78 79 UIbuilder(const string &typ){__uimap__.insert(make_pair(typ,this));} 79 virtual void build(Setting &S, void** result) const =0; 80 //! Function building the computational object 81 virtual void build(Setting &S, bdmroot* &result) const =0; 80 82 }; 81 83 … … 83 85 public: 84 86 UIexternal():UIbuilder("external"){} 85 void build(Setting &S, void**result) const;87 void build(Setting &S, bdmroot* &result) const; 86 88 }; 87 89 … … 89 91 public: 90 92 UIinternal():UIbuilder("internal"){} 91 void build(Setting &S, void**result) const;93 void build(Setting &S, bdmroot* &result) const; 92 94 }; 93 95 94 96 //! Prototype of a UI builder. Return value is by the second argument since it allows some type of type checking. 95 97 template<class T> 96 void UIbuild(Setting &S, T**ret){98 void UIbuild(Setting &S, T* &ret){ 97 99 CHECK_UITYPE(S,TypeGroup); 98 100 T* tmp; … … 101 103 102 104 const string typ=S["type"]; 105 103 106 // Find "type" in list of registred UI builders 104 107 UImap::const_iterator iter = __uimap__.find( typ ); 105 108 if( iter == __uimap__.end()) { 109 cout << "UI error" << endl; 106 110 it_error("UI of type \"" + typ + "\" is not registered!"); 107 111 } 108 else { 109 const UIbuilder* is= iter->second; 110 //BUILD the result 111 is->build(S,reinterpret_cast<void**>(&tmp)); 112 } 112 113 const UIbuilder* is= iter->second; 114 //BUILD the result 115 is->build(S,(bdmroot*&)(tmp)); 113 116 // make assignment 114 *ret=tmp;117 ret=tmp; 115 118 }; 116 119 -
tests/CMakeLists.txt
r249 r256 4 4 # Make sure the linker can find the Hello library once it is built. 5 5 link_directories (${BDM_BINARY_DIR}/bdm) 6 7 # Define macro for testing a file8 MACRO(TEST FN)9 add_executable (${FN} ${FN}.cpp)10 target_link_libraries (${FN} debug itpp_debug)11 target_link_libraries (${FN} optimized itpp)12 target_link_libraries (${FN} bdm ${AddLib})13 ENDMACRO(TEST)14 6 15 7 # Add executable called "helloDemo" that is built from the source files -
tests/UI/UIbuilder_test.cpp
r254 r256 5 5 using namespace bdm; 6 6 7 class cls {7 class cls :public bdmroot{ 8 8 public: 9 9 int a; … … 21 21 public: 22 22 UItest():UIbuilder("test"){} 23 void build(Setting &S, void**ret) const{23 void build(Setting &S, bdmroot* &ret) const{ 24 24 try{ 25 25 int a=S["a"]; … … 27 27 S.lookupValue("S",St); 28 28 cls* tmp = new cls(a,St); 29 *ret=tmp;29 ret=tmp; 30 30 } 31 31 catch (...){ … … 38 38 public: 39 39 UItest2():UIbuilder("test2"){} 40 void build(Setting &S, void**ret) const{40 void build(Setting &S, bdmroot* &ret) const{ 41 41 try{ 42 42 int a=S["a"]; … … 44 44 S.lookupValue("S",St); 45 45 cls* tmp = new cls2(a,St); 46 *ret=tmp;46 ret=tmp; 47 47 } 48 48 catch (...){ … … 59 59 60 60 int main(){ 61 62 61 UIFile UI("UIbuilder_test.cfg"); 63 62 64 63 cls* Cls; 65 UIbuild(UI.lookup("test"), &Cls);64 UIbuild(UI.lookup("test"),Cls); 66 65 cls* Cls2; 67 UIbuild(UI.lookup("test2"), &Cls2);66 UIbuild(UI.lookup("test2"),Cls2); 68 67 cls* Cls3; 69 UIbuild(UI.lookup("test3"), &Cls3);68 UIbuild(UI.lookup("test3"),Cls3); 70 69 71 70 Cls->print(); 72 71 Cls2->print(); 73 Cls3->print(); 74 return 0; 72 Cls3->print(); 73 74 delete Cls; 75 delete Cls2; 76 delete Cls3; 75 77 }