Changeset 347
- Timestamp:
- 05/27/09 21:37:49 (16 years ago)
- Files:
-
- 5 modified
Legend:
- Unmodified
- Added
- Removed
-
bdm/stat/libBM.h
r345 r347 522 522 //! returns an identifier which will be later needed for calling the \c logit() function 523 523 //! For empty RV it returns -1, this entry will be ignored by \c logit(). 524 virtual int add ( const RV &rv, string name="" ) {524 virtual int add ( const RV &rv, string prefix="" ) { 525 525 int id; 526 526 if ( rv._dsize() >0 ) { 527 527 id=entries.length(); 528 names=concat ( names, name); // diff528 names=concat ( names, prefix); // diff 529 529 entries.set_length ( id+1,true ); 530 530 entries ( id ) = rv; … … 746 746 747 747 // Add mean value 748 if (LFlags(0)) LIDs ( 0 ) =L.add ( r,name );749 if (LFlags(1)) LIDs ( 1 ) =L.add ( r,name+" _lb" );750 if (LFlags(2)) LIDs ( 2 ) =L.add ( r,name+" _ub" );751 if (LFlags(3)) LIDs ( 3 ) =L.add ( RV("ll",1 ,0),r.name(0)+name ); //TODO: "local" RV748 if (LFlags(0)) LIDs ( 0 ) =L.add ( r,name+"mean_" ); 749 if (LFlags(1)) LIDs ( 1 ) =L.add ( r,name+"lb_" ); 750 if (LFlags(2)) LIDs ( 2 ) =L.add ( r,name+"ub_" ); 751 if (LFlags(3)) LIDs ( 3 ) =L.add ( RV("ll",1),name ); //TODO: "local" RV 752 752 } 753 753 virtual void logit ( logger &L ) { -
bdm/stat/loggers.cpp
r270 r347 12 12 it_file itf ( fname ); 13 13 int i; 14 string vec_name=""; 15 int istart, iend; 14 16 for ( i=0; i<entries.length();i++ ) { 15 if ( names ( i ).length() <1 ) { 16 std::ostringstream o; 17 o<<"Variable"<<i; 18 itf << Name ( o.str() ) << vectors ( i ); 17 istart=0; 18 for (int j=0; j<entries(i).length(); j++){ // same for as in add!!! 19 vec_name = names(i) + entries(i).name(j); 20 iend=istart+entries(i).size(j)-1; 21 itf << Name ( vec_name ) << vectors ( i ).get_cols(istart,iend); 22 // move start after current end... 23 istart=iend+1; 19 24 } 20 else { 21 itf << Name ( names ( i ) ) << vectors ( i ); 22 } 25 23 26 } 24 27 } -
bdm/stat/loggers.h
r338 r347 34 34 //! Storage 35 35 Array<mat> vectors; 36 //! 36 //! name of it file to save results 37 string itfilename; 37 38 public: 38 39 //!Default constructor 39 memlog ( int maxlen0 ) : logger(),maxlen ( maxlen0 ),ind ( 0 ),vectors ( 0) {}40 memlog ( int maxlen0, string itf="" ) : logger(),maxlen ( maxlen0 ),ind ( 0 ),vectors ( 0 ),itfilename(itf) {} 40 41 //! Initialize storage 41 42 void init() { … … 43 44 vectors.set_size ( n ); 44 45 for ( i=0;i<n;i++ ) {vectors(i).set_size (maxlen,entries(i)._dsize() );} 45 ;46 46 } 47 47 void step() {if ( ind<maxlen ) ind++; else it_error ( "memlog::ind is too high;" );} … … 57 57 //! Save values into an itfile named after \c fname. 58 58 void itsave(const char* fname); 59 //! 60 void finalize() {if (itfilename.length()>0) itsave(itfilename.c_str());}; 61 59 62 }; 60 63 -
bdm/stat/loggers_ui.h
r278 r347 75 75 76 76 UIREGISTER(UIdirfilelog); 77 78 79 /*! \brief UI for memlog 80 \code 81 logger = { 82 type = "itpplog"; 83 filename = "file_name.it"; // resulting filename with results in it format 84 maxlen = 100; // size of memory buffer 85 } 86 \endcode 87 */ 88 class UIitpplog : public UIbuilder { 89 public: 90 UIitpplog():UIbuilder("itpplog"){}; 91 bdmroot* build(Setting &S) const{ 92 return new memlog(S["maxlen"],S["filename"]); 93 }; 94 }; 95 96 UIREGISTER(UIitpplog); 77 97 #endif // LGR_H -
library/mex/mexlog.h
r342 r347 22 22 public: 23 23 //! constructor 24 mexlog(int maxlen): memlog(maxlen ){};24 mexlog(int maxlen): memlog(maxlen,"mx"){}; 25 25 //! 26 26 mxArray* toCell(){ 27 27 mxArray* tmp = mxCreateStructMatrix(1,1,0,NULL); 28 28 29 //copy vectors to mxStruct 30 for (int i=0; i<names.length();i++){ 31 mat& M=vectors(i); 32 mxArray* fld=mxCreateDoubleMatrix(M.rows(), M.cols(), mxREAL); 33 mat2mxArray(M,fld); 34 mxReplaceFieldNM(tmp, names(i).c_str(), fld); 29 //copied from itsave 30 int i; 31 string vec_name=""; 32 int istart, iend; 33 34 mat M; //temporary matrix 35 for ( i=0; i<entries.length();i++ ) { 36 istart=0; 37 for (int j=0; j<entries(i).length(); j++){ // same for as in add!!! 38 vec_name = names(i) + entries(i).name(j); 39 iend=istart+entries(i).size(j)-1; 40 M=vectors(i).get_cols(istart,iend); 41 istart=iend+1; 42 // copy the selection to mx 43 mxArray* fld=mxCreateDoubleMatrix(M.rows(), M.cols(), mxREAL); 44 mat2mxArray(M,fld); 45 mxReplaceFieldNM(tmp, vec_name.c_str(), fld); 46 } 35 47 } 36 48 return tmp;