Changeset 565
- Timestamp:
- 08/19/09 16:54:24 (15 years ago)
- Location:
- library
- Files:
-
- 2 added
- 39 modified
Legend:
- Unmodified
- Added
- Removed
-
library/bdm/CMakeLists.txt
r508 r565 12 12 SET(bdm_mex mex/mex_datasource.h mex/mex_parser.h mex/mex_logger.h ) 13 13 14 SET(bdm_support bdm root.cpp bdmroot.h itpp_ext.cpp itpp_ext.h osutils.cpp osutils.h shared_ptr.h)14 SET(bdm_support bdmerror.cpp bdmerror.h bdmroot.cpp bdmroot.h itpp_ext.cpp itpp_ext.h osutils.cpp osutils.h shared_ptr.h) 15 15 16 16 IF(WIN32) -
library/bdm/base/bdmbase.cpp
r545 r565 42 42 } else { 43 43 id = iter->second; 44 it_assert( RV_SIZES ( id ) == size, "RV " + name + " of different size already exists" );44 bdm_assert_debug ( RV_SIZES ( id ) == size, "RV " + name + " of different size already exists" ); 45 45 } 46 46 return id; … … 67 67 void RV::init ( const Array<std::string> &in_names, const ivec &in_sizes, const ivec &in_times ) { 68 68 len = in_names.length(); 69 it_assert_debug ( in_names.length() == in_times.length(), "check \"times\" " );70 it_assert_debug ( in_names.length() == in_sizes.length(), "check \"sizes\" " );69 bdm_assert_debug ( in_names.length() == in_times.length(), "check \"times\" " ); 70 bdm_assert_debug ( in_names.length() == in_sizes.length(), "check \"sizes\" " ); 71 71 72 72 times.set_length ( len ); … … 135 135 136 136 shared_ptr<mpdf> epdf::condition (const RV &rv) const { 137 it_warning ("Not implemented");137 bdm_warning ("Not implemented"); 138 138 return shared_ptr<mpdf>(); 139 139 } 140 140 141 141 shared_ptr<epdf> epdf::marginal (const RV &rv) const { 142 it_warning ("Not implemented");142 bdm_warning ("Not implemented"); 143 143 return shared_ptr<epdf>(); 144 144 } … … 194 194 v2v_up = rv.dataind (rv_up); 195 195 196 it_assert_debug (v2v_up.length() == downsize, "rv is not fully in rv_up");196 bdm_assert_debug (v2v_up.length() == downsize, "rv is not fully in rv_up"); 197 197 } 198 198 … … 202 202 v2v_up = upind; 203 203 204 it_assert_debug (v2v_up.length() == downsize, "rv is not fully in rv_up");204 bdm_assert_debug (v2v_up.length() == downsize, "rv is not fully in rv_up"); 205 205 } 206 206 … … 219 219 220 220 void datalink_m2e::pushup_cond (vec &val_up, const vec &val, const vec &cond) { 221 it_assert_debug (downsize == val.length(), "Wrong val");222 it_assert_debug (upsize == val_up.length(), "Wrong val_up");221 bdm_assert_debug (downsize == val.length(), "Wrong val"); 222 bdm_assert_debug (upsize == val_up.length(), "Wrong val_up"); 223 223 set_subvector (val_up, v2v_up, val); 224 224 set_subvector (val_up, v2c_up, cond); … … 259 259 } 260 260 } 261 it_assert_debug ( res.length() == dsize, "this rv is not fully present in crv!" ); 261 262 bdm_assert_debug ( res.length() == dsize, "this rv is not fully present in crv!" ); 262 263 return res; 263 264 … … 294 295 } 295 296 } 296 it_assert_debug ( selfi.length() == rv2i.length(), "this should not happen!" );297 bdm_assert_debug ( selfi.length() == rv2i.length(), "this should not happen!" ); 297 298 } 298 299 … … 322 323 void RV::from_setting ( const Setting &set ) { 323 324 Array<string> A; 324 it_assert ( !A.length(), "default array not empty" );325 325 UI::get ( A, set, "names" ); 326 326 … … 356 356 rvaddok = rv.add ( mpdfs ( i )->_rv() ); //add rv to common rvs. 357 357 // If rvaddok==false, mpdfs overlap => assert error. 358 it_assert_debug ( rvaddok || !checkoverlap, "mprod::mprod() input mpdfs overlap in rv!" );358 bdm_assert_debug ( rvaddok || !checkoverlap, "mprod::mprod() input mpdfs overlap in rv!" ); 359 359 } 360 360 -
library/bdm/base/bdmbase.h
r545 r565 44 44 //!Default constructor 45 45 str (ivec ids0, ivec times0) : ids (ids0), times (times0) { 46 it_assert_debug (times0.length() == ids0.length(), "Incompatible input");46 bdm_assert_debug (times0.length() == ids0.length(), "Incompatible input"); 47 47 }; 48 48 }; … … 298 298 //! Returns a sample, \f$ x \f$ from density \f$ f_x()\f$ 299 299 virtual vec sample() const { 300 it_error ("not implemented");301 return vec (0);300 bdm_error ("not implemented"); 301 return vec(); 302 302 } 303 303 … … 308 308 //! In case the argument is out of suport return -Infinity 309 309 virtual double evallog (const vec &val) const { 310 it_error ("not implemented");310 bdm_error ("not implemented"); 311 311 return 0.0; 312 312 } … … 326 326 //! return expected value 327 327 virtual vec mean() const { 328 it_error ("not implemneted");329 return vec (0);330 } ;328 bdm_error ("not implemneted"); 329 return vec(); 330 } 331 331 332 332 //! return expected variance (not covariance!) 333 333 virtual vec variance() const { 334 it_error ("not implemneted"); 335 return vec (0); 336 }; 334 bdm_error ("not implemneted"); 335 return vec(); 336 } 337 337 338 //! Lower and upper bounds of \c percentage % quantile, returns mean-2*sigma as default 338 339 virtual void qbounds (vec &lb, vec &ub, double percentage = 0.95) const { … … 353 354 void set_rv (const RV &rv0) { 354 355 rv = rv0; 355 } //it_assert_debug(isnamed(),""); }; 356 } 357 356 358 //! True if rv is assigned 357 359 bool isnamed() const { … … 359 361 return b; 360 362 } 363 361 364 //! Return name (fails when isnamed is false) 362 365 const RV& _rv() const { 363 it_assert_debug (isnamed(), "");366 bdm_assert_debug (isnamed(), ""); 364 367 return rv; 365 368 } … … 425 428 426 429 //! Returns a sample from the density conditioned on \c cond, \f$x \sim epdf(rv|cond)\f$. \param cond is numeric value of \c rv 427 virtual vec samplecond (const vec &cond) {it_error ("Not implemented");return vec (0);}; 430 virtual vec samplecond (const vec &cond) { 431 bdm_error ("Not implemented"); 432 return vec(); 433 } 428 434 429 435 //! Returns \param N samples from the density conditioned on \c cond, \f$x \sim epdf(rv|cond)\f$. \param cond is numeric value of \c rv … … 431 437 432 438 //! Shortcut for conditioning and evaluation of the internal epdf. In some cases, this operation can be implemented efficiently. 433 virtual double evallogcond (const vec &dt, const vec &cond) {it_error ("Not implemented");return 0.0;} 439 virtual double evallogcond (const vec &dt, const vec &cond) { 440 bdm_error ("Not implemented"); 441 return 0.0; 442 } 434 443 435 444 //! Matrix version of evallogcond … … 441 450 442 451 //! Array<vec> version of evallogcond 443 virtual vec evallogcond_m (const Array<vec> &Dt, const vec &cond) {it_error ("Not implemented");return vec (0);} 452 virtual vec evallogcond_m (const Array<vec> &Dt, const vec &cond) { 453 bdm_error ("Not implemented"); 454 return vec(); 455 } 444 456 445 457 //! \name Access to attributes … … 497 509 //! constructor 498 510 mpdf_internal() : mpdf(), iepdf() {set_ep (iepdf);} 511 499 512 //! Update \c iepdf so that it represents this mpdf conditioned on \c rvc = cond 500 513 //! This function provides convenient reimplementation in offsprings 501 514 virtual void condition (const vec &cond) { 502 it_error ("Not implemented"); 503 }; 515 bdm_error ("Not implemented"); 516 } 517 504 518 //!access function to iepdf 505 519 EPDF& e() {return iepdf;} … … 571 585 //! Get val for myself from val of "Up" 572 586 vec pushdown (const vec &val_up) { 573 it_assert_debug (upsize == val_up.length(), "Wrong val_up");587 bdm_assert_debug (upsize == val_up.length(), "Wrong val_up"); 574 588 return get_vec (val_up, v2v_up); 575 589 } … … 577 591 //! Fill val of "Up" by my pieces 578 592 void pushup (vec &val_up, const vec &val) { 579 it_assert_debug (downsize == val.length(), "Wrong val");580 it_assert_debug (upsize == val_up.length(), "Wrong val_up");593 bdm_assert_debug (downsize == val.length(), "Wrong val"); 594 bdm_assert_debug (upsize == val_up.length(), "Wrong val_up"); 581 595 set_subvector (val_up, v2v_up, val); 582 596 } … … 628 642 //establish c2c connection 629 643 rvc.dataind (rvc_up, c2c_lo, c2c_up); 630 it_assert_debug (c2c_lo.length() + v2c_lo.length() == condsize, "cond is not fully given");644 bdm_assert_debug (c2c_lo.length() + v2c_lo.length() == condsize, "cond is not fully given"); 631 645 } 632 646 … … 746 760 //! default constructors 747 761 DS() : Drv(), Urv() {}; 762 748 763 //! Returns full vector of observed data=[output, input] 749 764 virtual void getdata (vec &dt) { 750 it_error ("abstract class"); 751 }; 765 bdm_error ("abstract class"); 766 } 767 752 768 //! Returns data records at indeces. 753 769 virtual void getdata (vec &dt, const ivec &indeces) { 754 it_error ("abstract class"); 755 }; 770 bdm_error ("abstract class"); 771 } 772 756 773 //! Accepts action variable and schedule it for application. 757 774 virtual void write (vec &ut) { 758 it_error ("abstract class"); 759 }; 775 bdm_error ("abstract class"); 776 } 777 760 778 //! Accepts action variables at specific indeces 761 779 virtual void write (vec &ut, const ivec &indeces) { 762 it_error ("abstract class");763 } ;780 bdm_error ("abstract class"); 781 } 764 782 765 783 //! Moves from \f$ t \f$ to \f$ t+1 \f$, i.e. perfroms the actions and reads response of the system. … … 768 786 //! Register DS for logging into logger L 769 787 virtual void log_add (logger &L) { 770 it_assert_debug (dtsize == Drv._dsize(), "");771 it_assert_debug (utsize == Urv._dsize(), "");788 bdm_assert_debug (dtsize == Drv._dsize(), "invalid DS: dtsize different from Drv"); 789 bdm_assert_debug (utsize == Urv._dsize(), "invalid DS: utsize different from Urv"); 772 790 773 791 L_dt = L.add (Drv, ""); … … 857 875 //! I.e. marginal likelihood of the data with the posterior integrated out. 858 876 virtual double logpred (const vec &dt) const { 859 it_error ("Not implemented");877 bdm_error ("Not implemented"); 860 878 return 0.0; 861 879 } 880 862 881 //! Matrix version of logpred 863 882 vec logpred_m (const mat &dt) const { … … 871 890 //!Constructs a predictive density \f$ f(d_{t+1} |d_{t}, \ldots d_{0}) \f$ 872 891 virtual epdf* epredictor() const { 873 it_error ("Not implemented");892 bdm_error ("Not implemented"); 874 893 return NULL; 875 894 }; 876 895 //!Constructs conditional density of 1-step ahead predictor \f$ f(d_{t+1} |d_{t+h-1}, \ldots d_{t}) \f$ 877 896 virtual mpdf* predictor() const { 878 it_error ("Not implemented");897 bdm_error ("Not implemented"); 879 898 return NULL; 880 899 }; … … 895 914 //! Substitute \c val for \c rvc. 896 915 virtual void condition (const vec &val) { 897 it_error ("Not implemented!");898 } ;916 bdm_error ("Not implemented!"); 917 } 899 918 900 919 //!@} … … 1002 1021 condition (cond); 1003 1022 tmp = iepdf.evallog (dt); 1004 // it_assert_debug(std::isfinite(tmp), "Infinite value");1005 1023 return tmp; 1006 1024 } -
library/bdm/base/datasources.cpp
r527 r565 7 7 int i; 8 8 9 it_assert_debug ( dt.length() == rowid.length(), "MemDS:getdata incompatible dt" );9 bdm_assert_debug ( dt.length() == rowid.length(), "MemDS:getdata incompatible dt" ); 10 10 for ( i = 0; i < rowid.length(); i++ ) { 11 11 dt ( i ) = Data ( rowid ( i ), time - delays ( i ) ); … … 15 15 void MemDS::getdata ( vec &dt, const ivec &indeces ) { 16 16 int j, i; 17 it_assert_debug ( dt.length() == indeces.length(), "MemDS:getdata incompatible dt" );17 bdm_assert_debug ( dt.length() == indeces.length(), "MemDS:getdata incompatible dt" ); 18 18 for ( i = 0; i < indeces.length(); i++ ) { 19 19 j = indeces ( i ); … … 29 29 30 30 void MemDS::set_rvs ( RV &drv, RV &urv ) { 31 it_assert_debug ( drv._dsize() == rowid.length(), "MemDS::set_rvs incompatible drv" );32 it_assert_debug ( urv._dsize() == 0, "MemDS does not support urv." );31 bdm_assert_debug ( drv._dsize() == rowid.length(), "MemDS::set_rvs incompatible drv" ); 32 bdm_assert_debug ( urv._dsize() == 0, "MemDS does not support urv." ); 33 33 34 34 Drv = drv; … … 36 36 37 37 MemDS::MemDS ( mat &Dat, ivec &rowid0, ivec &delays0 ) : rowid ( rowid0 ), delays ( delays0 ) { 38 it_assert_debug ( max ( rowid ) <= Dat.rows(), "MemDS rowid is too high for given Dat." );39 it_assert_debug ( max ( delays ) < Dat.cols(), "MemDS delays are too high." );38 bdm_assert_debug ( max ( rowid ) <= Dat.rows(), "MemDS rowid is too high for given Dat." ); 39 bdm_assert_debug ( max ( delays ) < Dat.cols(), "MemDS delays are too high." ); 40 40 41 41 time = max ( delays ); -
library/bdm/base/datasources.h
r529 r565 42 42 void getdata ( vec &dt, const ivec &indeces ); 43 43 void set_rvs ( RV &drv, RV &urv ); 44 44 45 void write ( vec &ut ) { 45 it_error ( "MemDS::write is not supported" ); 46 } 46 bdm_error ( "MemDS::write is not supported" ); 47 } 48 47 49 void write ( vec &ut, ivec &indices ) { 48 it_error ( "MemDS::write is not supported" ); 49 } 50 bdm_error ( "MemDS::write is not supported" ); 51 } 52 50 53 void step(); 51 54 //!Default constructor … … 61 64 public: 62 65 void getdata ( vec &dt ) { 63 it_assert_debug ( dt.length() == Data.rows(), "" );64 66 dt = Data.get_col ( time ); 65 } ;66 void getdata ( vec &dt, const ivec &indeces ) { 67 it_assert_debug ( dt.length() == indeces.length(), "" );68 vec tmp ( indeces.length());69 tmp = Data.get_col ( time);70 dt = tmp ( indeces );71 }; 67 } 68 69 void getdata ( vec &dt, const ivec &indices ) { 70 vec tmp = Data.get_col ( time ); 71 dt = tmp ( indices ); 72 } 73 72 74 //! returns number of data in the file; 73 75 int ndat() { … … 151 153 public: 152 154 void getdata ( vec &dt ) { 153 //it_assert_debug ( dt.length() ==Drv.count(),"ArxDS" );154 155 dt = H; 155 }; 156 } 157 156 158 void getdata ( vec &dt, const ivec &indices ) { 157 it_assert_debug ( dt.length() == indices.length(), "ArxDS" );158 159 dt = H ( indices ); 159 }; 160 } 161 160 162 void write ( vec &ut ) { 161 //it_assert_debug ( ut.length() ==Urv.count(),"ArxDS" );162 163 U = ut; 163 }; 164 } 165 164 166 void write ( vec &ut, const ivec &indices ) { 165 it_assert_debug ( ut.length() == indices.length(), "ArxDS" );167 bdm_assert_debug ( ut.length() == indices.length(), "ArxDS" ); 166 168 set_subvector ( U, indices, ut ); 167 }; 169 } 170 168 171 void step(); 172 169 173 //!Default constructor 170 174 ArxDS ( ) {}; … … 288 292 dt0 = dt; 289 293 } 290 void getdata ( vec &dt0, const ivec &indeces ) { 291 dt0 = dt ( indeces ); 294 295 void getdata ( vec &dt0, const ivec &indices ) { 296 dt0 = dt ( indices ); 292 297 } 293 298 -
library/bdm/base/loggers.cpp
r554 r565 127 127 char filename[200]; 128 128 129 it_assert_debug ( Len <= maxlen, "diffilelog" );129 bdm_assert_debug ( Len <= maxlen, "diffilelog::write_buffers: Len too large" ); 130 130 131 131 ii = 0; -
library/bdm/base/loggers.h
r551 r565 45 45 void step() { 46 46 if ( ind < maxlen ) ind++; 47 else it_error ( "memlog::ind is too high;" );47 else bdm_error ( "memlog::ind is too high;" ); 48 48 } 49 49 50 void logit ( int id, const vec &v ) { 50 it_assert_debug ( id < vectors.length(), "Logger was not initialized, run init()." );51 bdm_assert_debug ( id < vectors.length(), "Logger was not initialized, run init()." ); 51 52 if ( id >= 0 ) { 52 53 vectors ( id ).set_row ( ind, v ); … … 54 55 } 55 56 void logit ( int id, const double &d ) { 56 it_assert_debug ( id < vectors.length(), "Logger was not initialized, run init()." );57 it_assert_debug ( vectors ( id ).cols() == 1, "Vector expected" );57 bdm_assert_debug ( id < vectors.length(), "Logger was not initialized, run init()." ); 58 bdm_assert_debug ( vectors ( id ).cols() == 1, "Vector expected" ); 58 59 if ( id >= 0 ) { 59 60 vectors ( id ) ( ind ) = d; -
library/bdm/base/user_info.cpp
r540 r565 33 33 setAutoConvert ( true ); 34 34 } catch ( FileIOException f ) { 35 it_error ( "UI error: file " + file_name + " not found." ); 35 string msg = "UI error: file "; 36 msg += file_name; 37 msg += " not found."; 38 bdm_error ( msg ); 36 39 } catch ( ParseException& P ) { 37 40 stringstream msg; 38 41 msg << "UI error: parsing error """ << P.getError() << """ in file " << file_name << " on line " << P.getLine() << "."; 39 it_error ( msg.str() );42 bdm_error ( msg.str() ); 40 43 } 41 44 } … … 46 49 writeFile ( file_name.c_str() ); 47 50 } catch ( FileIOException f ) { 48 it_error ( "UI error: file " + file_name + " is inacessible." ); 51 string msg = "UI error: file "; 52 msg += file_name; 53 msg += " is inacessible."; 54 bdm_error ( msg ); 49 55 } 50 56 } … … 94 100 msg << "There is not any registered class yet!" << endl; 95 101 96 it_error ( msg.str() );102 bdm_error ( msg.str() ); 97 103 } 98 104 -
library/bdm/base/user_info.h
r544 r565 321 321 322 322 root *typeless_instance = related_UI.new_instance(); 323 it_assert_debug ( typeless_instance, "UI::new_instance failed" );323 bdm_assert_debug ( typeless_instance, "UI::new_instance failed" ); 324 324 325 325 instance = dynamic_cast<T*> ( typeless_instance ); … … 351 351 T *tmp_inst = 0; 352 352 from_setting ( tmp_inst, element ); 353 it_assert_debug ( tmp_inst, "UI::from_setting failed" );353 bdm_assert_debug ( tmp_inst, "UI::from_setting failed" ); 354 354 instance = tmp_inst; 355 355 } -
library/bdm/design/ctrlbase.cpp
r508 r565 8 8 dimu = B0.cols(); 9 9 10 it_assert_debug ( A0.cols() == dimx, "LQG: A is not square" );11 it_assert_debug ( B0.rows() == dimx, "LQG: B is not compatible" );12 it_assert_debug ( C0.cols() == dimx, "LQG: C is not square" );10 bdm_assert_debug ( A0.cols() == dimx, "LQG: A is not square" ); 11 bdm_assert_debug ( B0.rows() == dimx, "LQG: B is not compatible" ); 12 bdm_assert_debug ( C0.cols() == dimx, "LQG: C is not square" ); 13 13 14 14 A=A0; … … 20 20 21 21 void LQG::set_control_parameters(const mat &Qy0, const mat &Qu0, const vec y_req0, int horizon0){ 22 it_assert_debug ( Qy0.cols() == dimy, "LQG: wrong dimensions of Qy " );23 it_assert_debug ( Qu0.cols() == dimu, "LQG: wrong dimensions of Qu " );24 it_assert_debug ( y_req0.length() == dimy, "LQG: wrong dimensions of y_req " );22 bdm_assert_debug ( Qy0.cols() == dimy, "LQG: wrong dimensions of Qy " ); 23 bdm_assert_debug ( Qu0.cols() == dimu, "LQG: wrong dimensions of Qu " ); 24 bdm_assert_debug ( y_req0.length() == dimy, "LQG: wrong dimensions of y_req " ); 25 25 26 26 Qy=Qy0; -
library/bdm/design/ctrlbase.h
r508 r565 19 19 public: 20 20 //! Redesign control strategy 21 virtual void redesign(){it_error("Not implemented"); }; 21 virtual void redesign() { 22 bdm_error("Not implemented"); 23 } 24 22 25 //! apply control strategy to obtain control input 23 virtual vec apply(const vec &cond){it_error("Not implemented"); return vec(0);} 26 virtual vec apply(const vec &cond) { 27 bdm_error("Not implemented"); 28 return vec(); 29 } 24 30 }; 25 31 … … 89 95 pre_qr.set_submatrix(0,0,s*pr); 90 96 pre_qr.set_submatrix(dimx+dimu+dimy, dimu+dimx, -Qy*y_req); 91 if (!qr(pre_qr,post_qr)) it_warning("QR in LQG unstable");97 if (!qr(pre_qr,post_qr)) bdm_warning("QR in LQG unstable"); 92 98 triu(post_qr); 93 99 // hn(m+1:2*m+n+r,m+1:2*m+n+r); -
library/bdm/estim/arx.cpp
r527 r565 54 54 const ARX* A0 = dynamic_cast<const ARX*> ( B0 ); 55 55 56 it_assert_debug ( V.rows() == A0->V.rows(), "ARX::set_statistics Statistics differ" );56 bdm_assert_debug ( V.rows() == A0->V.rows(), "ARX::set_statistics Statistics differ" ); 57 57 set_statistics ( A0->dimx, A0->V, A0->nu ); 58 58 } … … 80 80 int dim = est.dimension(); 81 81 int dif = V.rows() - dim ;///<----------- TODO 82 it_assert_debug ( ( dif == 0 ) || ( dif == 1 ), "Give RVs do not match" );82 bdm_assert_debug ( ( dif == 0 ) || ( dif == 1 ), "Give RVs do not match" ); 83 83 84 84 mat mu ( dim, V.rows() - dim ); … … 103 103 int dim = est.dimension(); 104 104 int dif = V.rows() - est.dimension();//-------------TODO 105 it_assert_debug ( ( dif == 0 ) || ( dif == 1 ), "Give RVs do not match" );105 bdm_assert_debug ( ( dif == 0 ) || ( dif == 1 ), "Give RVs do not match" ); 106 106 107 107 mat mu ( dim, V.rows() - dim ); -
library/bdm/estim/arx.h
r536 r565 98 98 //! Predictor for empty regressor 99 99 enorm<ldmat>* epredictor() const { 100 it_assert_debug ( dimx == V.rows() - 1, "Regressor is not only 1" );100 bdm_assert_debug ( dimx == V.rows() - 1, "Regressor is not only 1" ); 101 101 return epredictor ( vec_1 ( 1.0 ) ); 102 102 } … … 120 120 drv = drv0; 121 121 } 122 122 123 RV& get_yrv() { 123 124 //if yrv is not ready create it … … 130 131 } 131 132 //yrv should be ready by now 132 it_assert_debug ( _yrv._dsize() == dimx, "incompatible drv" );133 bdm_assert_debug ( _yrv._dsize() == dimx, "incompatible drv" ); 133 134 return _yrv; 134 135 } -
library/bdm/estim/kalman.cpp
r527 r565 11 11 dimy = C0.rows(); 12 12 13 it_assert_debug ( A0.cols() == dimx, "KalmanFull: A is not square" );14 it_assert_debug ( B0.rows() == dimx, "KalmanFull: B is not compatible" );15 it_assert_debug ( C0.cols() == dimx, "KalmanFull: C is not square" );16 it_assert_debug ( ( D0.rows() == dimy ) || ( D0.cols() == dimu ),"KalmanFull: D is not compatible" );17 it_assert_debug ( ( Q0.cols() == dimx ) || ( Q0.rows() == dimx ), "KalmanFull: Q is not compatible" );18 it_assert_debug ( ( R0.cols() == dimy ) || ( R0.rows() == dimy ), "KalmanFull: R is not compatible" );13 bdm_assert_debug ( A0.cols() == dimx, "KalmanFull: A is not square" ); 14 bdm_assert_debug ( B0.rows() == dimx, "KalmanFull: B is not compatible" ); 15 bdm_assert_debug ( C0.cols() == dimx, "KalmanFull: C is not square" ); 16 bdm_assert_debug ( ( D0.rows() == dimy ) || ( D0.cols() == dimu ), "KalmanFull: D is not compatible" ); 17 bdm_assert_debug ( ( Q0.cols() == dimx ) || ( Q0.rows() == dimx ), "KalmanFull: Q is not compatible" ); 18 bdm_assert_debug ( ( R0.cols() == dimy ) || ( R0.rows() == dimy ), "KalmanFull: R is not compatible" ); 19 19 20 20 A = A0; … … 32 32 33 33 void KalmanFull::bayes ( const vec &dt ) { 34 it_assert_debug ( dt.length() == ( dimy + dimu ), "KalmanFull::bayes wrong size of dt" );34 bdm_assert_debug ( dt.length() == ( dimy + dimu ), "KalmanFull::bayes wrong size of dt" ); 35 35 36 36 vec u = dt.get ( dimy, dimy + dimu - 1 ); … … 86 86 87 87 void EKFfull::bayes ( const vec &dt ) { 88 it_assert_debug ( dt.length() == ( dimy + dimu ), "KalmanFull::bayes wrong size of dt" );88 bdm_assert_debug ( dt.length() == ( dimy + dimu ), "EKFull::bayes wrong size of dt" ); 89 89 90 90 vec u = dt.get ( dimy, dimy + dimu - 1 ); … … 142 142 preA.set_submatrix ( dimy, dimy, ( _P._Ch() ) *A.T() ); 143 143 144 // if ( !qr ( preA,Q,postA ) ) it_warning ( "QR in kalman unstable!" );145 144 if ( !qr ( preA, postA ) ) { 146 it_warning ( "QR in kalmanunstable!" );145 bdm_warning ( "QR in KalmanCh unstable!" ); 147 146 } 148 147 … … 217 216 // cout << "_mu:" << _mu <<endl; 218 217 219 // if ( !qr ( preA,Q,postA ) ) it_warning ( "QR in kalman unstable!" );220 218 if ( !qr ( preA, postA ) ) { 221 it_warning ( "QR in kalmanunstable!" );219 bdm_warning ( "QR in EKFCh unstable!" ); 222 220 } 223 221 -
library/bdm/estim/kalman.h
r536 r565 286 286 public: 287 287 void condition ( const vec &QR ) { 288 it_assert_debug ( QR.length() == ( dimx + dimy ), "KFcondRQ: conditioning by incompatible vector" );288 bdm_assert_debug ( QR.length() == ( dimx + dimy ), "KFcondQR: conditioning by incompatible vector" ); 289 289 290 290 Q.setD ( QR ( 0, dimx - 1 ) ); … … 304 304 305 305 void condition ( const vec &R0 ) { 306 it_assert_debug ( R0.length() == ( dimy ), "KFcondR: conditioning by incompatible vector" );306 bdm_assert_debug ( R0.length() == ( dimy ), "KFcondR: conditioning by incompatible vector" ); 307 307 308 308 R.setD ( R0 ); … … 338 338 dimu = B0.cols(); 339 339 340 it_assert_debug ( A0.cols() == dimx, "Kalman: A is not square" );341 it_assert_debug ( B0.rows() == dimx, "Kalman: B is not compatible" );342 it_assert_debug ( C0.cols() == dimx, "Kalman: C is not square" );343 it_assert_debug ( ( D0.rows() == dimy ) || ( D0.cols() == dimu ), "Kalman: D is not compatible" );344 it_assert_debug ( ( R0.cols() == dimy ) || ( R0.rows() == dimy ), "Kalman: R is not compatible" );345 it_assert_debug ( ( Q0.cols() == dimx ) || ( Q0.rows() == dimx ), "Kalman: Q is not compatible" );340 bdm_assert_debug ( A0.cols() == dimx, "Kalman: A is not square" ); 341 bdm_assert_debug ( B0.rows() == dimx, "Kalman: B is not compatible" ); 342 bdm_assert_debug ( C0.cols() == dimx, "Kalman: C is not square" ); 343 bdm_assert_debug ( ( D0.rows() == dimy ) || ( D0.cols() == dimu ), "Kalman: D is not compatible" ); 344 bdm_assert_debug ( ( R0.cols() == dimy ) || ( R0.rows() == dimy ), "Kalman: R is not compatible" ); 345 bdm_assert_debug ( ( Q0.cols() == dimx ) || ( Q0.rows() == dimx ), "Kalman: Q is not compatible" ); 346 346 347 347 A = A0; … … 355 355 template<class sq_T> 356 356 void Kalman<sq_T>::bayes ( const vec &dt ) { 357 it_assert_debug ( dt.length() == ( dimy + dimu ), "KalmanFull::bayes wrong size of dt" );357 bdm_assert_debug ( dt.length() == ( dimy + dimu ), "Kalman::bayes wrong size of dt" ); 358 358 359 359 sq_T iRy ( dimy ); … … 439 439 break; 440 440 default: 441 it_error ( "unknown policy" );441 bdm_error ( "unknown policy" ); 442 442 } 443 443 // copy result to all models … … 486 486 template<class sq_T> 487 487 void EKF<sq_T>::bayes ( const vec &dt ) { 488 it_assert_debug ( dt.length() == ( dimy + dimu ), "KalmanFull::bayes wrong size of dt" );488 bdm_assert_debug ( dt.length() == ( dimy + dimu ), "EKF<>::bayes wrong size of dt" ); 489 489 490 490 sq_T iRy ( dimy, dimy ); -
library/bdm/estim/mixtures.cpp
r504 r565 154 154 void MixEF::flatten ( const BMEF* M2 ) { 155 155 const MixEF* Mix2 = dynamic_cast<const MixEF*> ( M2 ); 156 it_assert_debug ( Mix2->n == n, "Different no of coms" );156 bdm_assert_debug ( Mix2->n == n, "Different no of coms" ); 157 157 //Flatten each component 158 158 for ( int i = 0; i < n; i++ ) { -
library/bdm/estim/mixtures.h
r536 r565 61 61 Array<const epdf*> epdfs ( n + 1 ); 62 62 for ( int i = 0; i < Coms.length(); i++ ) { 63 // it_assert_debug(!x,"MixEF::MixEF : Incompatible components");64 63 epdfs ( i ) = & ( Coms ( i )->posterior() ); 65 64 } … … 75 74 BMEF ( ), n ( Coms0.length() ), Coms ( n ), 76 75 weights (), method ( QB ) { 77 // it_assert_debug ( n>0,"MixEF::MixEF : Empty Component list" );78 79 76 for ( int i = 0; i < n; i++ ) { 80 77 Coms ( i ) = ( BMEF* ) Coms0 ( i )->_copy_(); 81 78 } 82 79 build_est(); 83 }; 80 } 81 84 82 //! Constructor of empty mixture 85 83 MixEF () : … … 91 89 MixEF ( const MixEF &M2 ) : BMEF ( ), n ( M2.n ), Coms ( n ), 92 90 weights ( M2.weights ), method ( M2.method ) { 93 // it_assert_debug ( n>0,"MixEF::MixEF : Empty Component list" );94 95 91 for ( int i = 0; i < n; i++ ) { 96 92 Coms ( i ) = M2.Coms ( i )->_copy_(); … … 98 94 build_est(); 99 95 } 96 100 97 //! Initializing the mixture by a random pick of centroids from data 101 98 //! \param Com0 Initial component - necessary to determine its type. -
library/bdm/estim/particles.h
r536 r565 177 177 178 178 vec sample() const { 179 it_error ( "Not implemented" );180 return 0;179 bdm_error ( "Not implemented" ); 180 return vec(); 181 181 } 182 182 183 183 double evallog ( const vec &val ) const { 184 it_error ( "not implemented" );184 bdm_error ( "not implemented" ); 185 185 return 0.0; 186 186 } -
library/bdm/math/chmat.cpp
r495 r565 16 16 qr ( Z, R ); 17 17 Ch = R ( 0, Ch.rows() - 1, 0, Ch.cols() - 1 ); 18 }; 18 } 19 19 20 mat chmat::to_mat() const { 20 21 mat F = Ch.T() * Ch; 21 22 return F; 22 }; 23 } 24 23 25 void chmat::mult_sym ( const mat &C ) { 24 it_assert_debug ( C.rows() == dim, "Wrong dimension of U" );26 bdm_assert_debug ( C.rows() == dim, "Wrong dimension of U" ); 25 27 if ( !qr ( Ch*C.T(), Ch ) ) { 26 it_warning ( "QR unstable in chmat mult_sym" );28 bdm_warning ( "QR unstable in chmat mult_sym" ); 27 29 } 28 }; 30 } 31 29 32 void chmat::mult_sym ( const mat &C , chmat &U ) const { 30 it_assert_debug ( C.rows() == U.dim, "Wrong dimension of U" );33 bdm_assert_debug ( C.rows() == U.dim, "Wrong dimension of U" ); 31 34 if ( !qr ( Ch*C.T(), U.Ch ) ) { 32 it_warning ( "QR unstable in chmat mult_sym" );35 bdm_warning ( "QR unstable in chmat mult_sym" ); 33 36 } 34 }; 37 } 38 35 39 void chmat::mult_sym_t ( const mat &C ) { 36 it_assert_debug ( C.cols() == dim, "Wrong dimension of U" );40 bdm_assert_debug ( C.cols() == dim, "Wrong dimension of U" ); 37 41 if ( !qr ( Ch*C, Ch ) ) { 38 it_warning ( "QR unstable in chmat mult_sym" );42 bdm_warning ( "QR unstable in chmat mult_sym" ); 39 43 } 40 }; 44 } 45 41 46 void chmat::mult_sym_t ( const mat &C, chmat &U ) const { 42 it_assert_debug ( C.cols() == U.dim, "Wrong dimension of U" );47 bdm_assert_debug ( C.cols() == U.dim, "Wrong dimension of U" ); 43 48 if ( !qr ( Ch*C, U.Ch ) ) { 44 it_warning ( "QR unstable in chmat mult_sym" );49 bdm_warning ( "QR unstable in chmat mult_sym" ); 45 50 } 46 51 } -
library/bdm/math/chmat.h
r495 r565 14 14 #define CHMAT_H 15 15 16 16 #include "../bdmerror.h" 17 17 #include "square_mat.h" 18 18 … … 44 44 //! add another chmat \c A2 with weight \c w. 45 45 void add ( const chmat &A2, double w = 1.0 ) { 46 it_assert_debug ( dim == A2.dim, "Matrices of unequal dimension" );46 bdm_assert_debug ( dim == A2.dim, "Matrices of unequal dimension" ); 47 47 mat pre = concat_vertical ( Ch, sqrt ( w ) * A2.Ch ); 48 48 mat post = zeros ( pre.rows(), pre.cols() ); 49 49 if ( !qr ( pre, post ) ) { 50 it_warning ( "Unstable QR in chmat add" );50 bdm_warning ( "Unstable QR in chmat add" ); 51 51 } 52 52 Ch = post ( 0, dim - 1, 0, dim - 1 ); … … 70 70 chmat ( const chmat &Ch0 ) : sqmat ( Ch0.dim ), Ch ( Ch0.dim, Ch0.dim ) { 71 71 Ch = Ch0.Ch; 72 }; 72 } 73 73 74 //! Default constructor (m3k:cholform) 74 75 chmat ( const mat &M ) : sqmat ( M.rows() ), Ch ( M.rows(), M.cols() ) { 75 76 mat Q; 76 it_assert_debug ( M.rows() == M.cols(), "chmat:: input matrix must be square!" );77 bdm_assert_debug ( M.rows() == M.cols(), "chmat:: input matrix must be square!" ); 77 78 Ch = chol ( M ); 78 }; 79 //! Constructor 80 chmat ( const chmat &M, const ivec &perm ) : sqmat ( M.rows() ) { 81 it_error ( "not implemneted" ); 82 }; 79 } 80 81 /*! 82 Some templates require this constructor to compile, but 83 it shouldn't actually be called. 84 */ 85 chmat ( const chmat &M, const ivec &perm ) { 86 bdm_error ( "not implemented" ); 87 } 88 83 89 //! Access function 84 90 mat & _Ch() { … … 95 101 //! Access functions 96 102 void setCh ( const vec &chQ ) { 97 it_assert_debug ( chQ.length() == dim*dim, "" );103 bdm_assert_debug ( chQ.length() == dim * dim, "wrong length" ); 98 104 copy_vector ( dim*dim, chQ._data(), Ch._data() ); 99 105 } 106 100 107 //! Access functions 101 108 void setD ( const vec &nD, int i ) { -
library/bdm/math/functions.h
r477 r565 13 13 #define FN_H 14 14 15 #include "../bdmerror.h" 15 16 #include "../base/bdmbase.h" 16 17 … … 44 45 public : 45 46 vec eval ( const vec &cond ) { 46 it_assert_debug ( cond.length() == A.cols(), "linfn::eval Wrong cond." );47 return A *cond + B;48 } ;47 bdm_assert_debug ( cond.length() == A.cols(), "linfn::eval Wrong cond." ); 48 return A * cond + B; 49 } 49 50 50 51 // linfn evalsome ( ivec &rvind ); … … 82 83 //! Evaluates \f$f(x0,u0)\f$ (VS: Do we really need common eval? ) 83 84 vec eval ( const vec &cond ) { 84 it_assert_debug ( cond.length() == ( dimx + dimu ), "linfn::eval Wrong cond." );85 bdm_assert_debug ( cond.length() == ( dimx + dimu ), "linfn::eval Wrong cond." ); 85 86 return eval ( cond ( 0, dimx - 1 ), cond ( dimx, dimx + dimu - 1 ) );//-1 = end (in matlab) 86 } ;87 } 87 88 88 89 //! Evaluates \f$f(x0,u0)\f$ … … 115 116 //!@{ 116 117 117 bilinfn () : diffbifn () , A() , B() {}; 118 bilinfn ( const mat A0, const mat B0 ) { 118 bilinfn () : diffbifn (), A(), B() { } 119 120 bilinfn ( const mat &A0, const mat &B0 ) { 119 121 set_parameters ( A0, B0 ); 120 }; 121 //! Alternative constructor 122 void set_parameters ( const mat A0, const mat B0 ) { 123 it_assert_debug ( A0.rows() == B0.rows(), "" ); 122 } 123 124 //! Alternative initialization 125 void set_parameters ( const mat &A0, const mat &B0 ) { 126 bdm_assert_debug ( A0.rows() == B0.rows(), "bilinfn matrices must have the same number of rows" ); 124 127 A = A0; 125 128 B = B0; … … 133 136 //!@{ 134 137 inline vec eval ( const vec &x0, const vec &u0 ) { 135 it_assert_debug ( x0.length() == dimx, "linfn::eval Wrong xcond." );136 it_assert_debug ( u0.length() == dimu, "linfn::eval Wrong ucond." );138 bdm_assert_debug ( x0.length() == dimx, "bilinfn::eval Wrong xcond." ); 139 bdm_assert_debug ( u0.length() == dimu, "bilinfn::eval Wrong ucond." ); 137 140 return A*x0 + B*u0; 138 141 } 139 142 140 143 void dfdx_cond ( const vec &x0, const vec &u0, mat &F, bool full ) { 141 it_assert_debug ( ( F.cols() == A.cols() )& ( F.rows() == A.rows() ), "Allocated F is not compatible." );144 bdm_assert_debug ( ( F.cols() == A.cols() ) && ( F.rows() == A.rows() ), "Allocated F is not compatible." ); 142 145 if ( full ) F = A; //else : nothing has changed no need to regenerate 143 146 } 144 //! 147 145 148 void dfdu_cond ( const vec &x0, const vec &u0, mat &F, bool full = true ) { 146 it_assert_debug ( ( F.cols() == B.cols() )& ( F.rows() == B.rows() ), "Allocated F is not compatible." );149 bdm_assert_debug ( ( F.cols() == B.cols() ) && ( F.rows() == B.rows() ), "Allocated F is not compatible." ); 147 150 if ( full ) F = B; //else : nothing has changed no need to regenerate 148 151 } -
library/bdm/math/square_mat.cpp
r536 r565 35 35 }; 36 36 fsqmat::fsqmat ( const mat &M0 ) : sqmat ( M0.cols() ) { 37 it_assert_debug ( ( M0.cols() == M0.rows() ), "M0 must be square" );37 bdm_assert_debug ( ( M0.cols() == M0.rows() ), "M0 must be square" ); 38 38 M = M0; 39 39 }; … … 65 65 ldmat::ldmat ( const mat &V ) : sqmat ( V.cols() ) { 66 66 67 it_assert_debug ( dim == V.rows(), "ldmat::ldmat matrix V is not square!" );67 bdm_assert_debug ( dim == V.rows(), "ldmat::ldmat matrix V is not square!" ); 68 68 69 69 // L and D will be allocated by ldform() … … 81 81 double *rraw = r._data(); 82 82 83 it_assert_debug ( v.length() == dim, "LD::ldupdt vector v is not compatible with this ld." );83 bdm_assert_debug ( v.length() == dim, "LD::ldupdt vector v is not compatible with this ld." ); 84 84 85 85 for ( int i = dim - 1; i >= 0; i-- ) { … … 123 123 int dim = D.length(); 124 124 125 it_assert_debug ( ld2.D.length() == dim, "LD.add() incompatible sizes of LDs;" );125 bdm_assert_debug ( ld2.D.length() == dim, "LD.add() incompatible sizes of LDs" ); 126 126 127 127 //Fixme can be done more efficiently either via dydr or ldform … … 231 231 int mn = ( m < n ) ? m : n ; 232 232 233 // it_assert_debug( A.cols()==dim,"ldmat::ldform A is not compatible" ); 234 it_assert_debug ( D0.length() == A.rows(), "ldmat::ldform Vector D must have the length as row count of A" ); 233 bdm_assert_debug ( D0.length() == A.rows(), "ldmat::ldform Vector D must have the length as row count of A" ); 235 234 236 235 L = concat_vertical ( zeros ( n, n ), diag ( sqrt ( D0 ) ) * A ); … … 389 388 *kr = 0.0; 390 389 if ( *Df < -threshold ) { 391 it_warning ( "Problem in dydr: subraction of dyad results in negative definitness. Likely mistake in calling function." );390 bdm_warning ( "Problem in dydr: subraction of dyad results in negative definitness. Likely mistake in calling function." ); 392 391 } 393 392 *Df = 0.0; -
library/bdm/math/square_mat.h
r495 r565 16 16 17 17 #include "../itpp_ext.h" 18 #include "../bdmerror.h" 18 19 19 20 namespace bdm … … 138 139 //! Constructor 139 140 fsqmat ( const mat &M ); 140 //! Constructor 141 fsqmat ( const fsqmat &M, const ivec &perm ) : sqmat ( M.rows() ) { 142 it_error ( "not implemneted" ); 143 }; 141 142 /*! 143 Some templates require this constructor to compile, but 144 it shouldn't actually be called. 145 */ 146 fsqmat ( const fsqmat &M, const ivec &perm ) { 147 bdm_error ( "not implemented" ); 148 } 149 144 150 //! Constructor 145 151 fsqmat ( const vec &d ) : sqmat ( d.length() ) { -
library/bdm/mex/mex_datasource.h
r529 r565 1 #include "../bdm/bdmerror.h" 1 2 #include "../bdm/stat/datasources.h" 2 3 #include "mex_parser.h" … … 34 35 Data = mxArray2mat ( mexGetVariable ( "base", set["varname"] ) ); 35 36 UI::get ( rowid, set, "rids" , UI::compulsory ); 36 it_assert_debug ( max ( rowid ) <= Data.rows(), "MemDS rowid is too high for given Dat." );37 bdm_assert_debug ( max ( rowid ) <= Data.rows(), "MemDS rowid is too high for given Dat." ); 37 38 38 39 UI::get ( delays, set, "tds", UI::compulsory ); 39 40 time = max ( delays ); 40 it_assert_debug ( time < Data.cols(), "MemDS delays are too high." );41 bdm_assert_debug ( time < Data.cols(), "MemDS delays are too high." ); 41 42 42 43 shared_ptr<RV> r = UI::build<RV> ( set, "rv", UI::compulsory ); -
library/bdm/osutils.cpp
r497 r565 12 12 13 13 #include "osutils.h" 14 #include "bdmerror.h" 14 15 #include <iostream> 15 16 #include <stdexcept> … … 47 48 #endif 48 49 { 49 if ( ( rewrite ) && ( errno == EEXIST ) ) it_warning ( "rewriting directory" );50 else it_error ( "dirfilelog:: cannot create directory" );50 if ( ( rewrite ) && ( errno == EEXIST ) ) bdm_warning ( "rewriting directory" ); 51 else bdm_error ( "dirfilelog:: cannot create directory" ); 51 52 } 52 53 } … … 79 80 std::string msg = "can't remove dir "; 80 81 msg += path; 81 throw std::runtime_error ( msg );82 bdm_error ( msg ); 82 83 } 83 84 } else { … … 87 88 std::string msg = "can't remove file "; 88 89 msg += path; 89 throw std::runtime_error ( msg );90 bdm_error ( msg ); 90 91 } 91 92 } else { … … 93 94 std::string msg = "can't remove "; 94 95 msg += path; 95 throw std::runtime_error ( msg );96 bdm_error ( msg ); 96 97 } else { 97 98 // it wasn't there in the first place -
library/bdm/osutils.h
r497 r565 21 21 22 22 /*! 23 @brief Function creates a directory and raises it_error if it is not possible23 @brief Function creates a directory 24 24 25 25 @param dirname name of the directory to be created 26 26 @param rewrite if true then existence of the directory is not an error 27 28 Raises std::runtime_error if rewrite is false and dirname already exists. 27 29 */ 28 30 void makedir ( string &dirname, bool rewrite = true ); -
library/bdm/shared_ptr.h
r555 r565 18 18 #include <stdexcept> 19 19 #include <string> 20 #include " itpp_ext.h"20 #include "bdmerror.h" 21 21 22 22 namespace bdm { … … 123 123 */ 124 124 T *operator->() { 125 it_assert_debug ( payload, "dereferencing NULL" );125 bdm_assert_debug ( payload, "dereferencing NULL" ); 126 126 return payload; 127 127 } … … 131 131 //! isn't NULL. 132 132 T &operator*() { 133 it_assert_debug ( payload, "dereferencing NULL" );133 bdm_assert_debug ( payload, "dereferencing NULL" ); 134 134 return *payload; 135 135 } … … 147 147 //! pointer isn't NULL. 148 148 const T *operator->() const { 149 it_assert_debug ( payload, "dereferencing NULL" );149 bdm_assert_debug ( payload, "dereferencing NULL" ); 150 150 return payload; 151 151 } … … 155 155 //! isn't NULL. 156 156 const T &operator*() const { 157 it_assert_debug ( payload, "dereferencing NULL" );157 bdm_assert_debug ( payload, "dereferencing NULL" ); 158 158 return *payload; 159 159 } … … 254 254 */ 255 255 object_ptr ( const shared_ptr<T> &b ) : shared_ptr<T> ( b ) { 256 it_assert_debug ( this->get(), "object_ptr cannot be empty" );256 bdm_assert_debug ( this->get(), "object_ptr cannot be empty" ); 257 257 } 258 258 … … 262 262 */ 263 263 object_ptr ( T *p ) : shared_ptr<T> ( p ) { 264 it_assert_debug ( p, "object_ptr cannot be empty" );264 bdm_assert_debug ( p, "object_ptr cannot be empty" ); 265 265 } 266 266 -
library/bdm/stat/discrete.h
r564 r565 55 55 void initialize() { 56 56 dim = ranges.length(); 57 it_assert_debug(gridsizes.length()==dim,"Incompatible dimensions of input");57 bdm_assert_debug(gridsizes.length() == dim, "Incompatible dimensions of input"); 58 58 Npoints = prod(gridsizes); 59 it_assert_debug(Npoints>0,"Wrong input parameters");59 bdm_assert_debug(Npoints > 0, "Wrong input parameters"); 60 60 61 61 //precompute steps … … 71 71 vec v ( dim ); 72 72 for ( int j = 0; j < dim; j++ ) { 73 it_assert_debug(inds(j)<gridsizes(j), "Index out of bounds");73 bdm_assert_debug(inds(j) < gridsizes(j), "Index out of bounds"); 74 74 v ( j ) = ranges(j)(0) + (0.5+inds(j))*steps(j); 75 75 } … … 80 80 long linear_index (const ivec inds){ 81 81 long ind=0; 82 it_assert_debug(inds.length()==dim,"Improper indeces inds");82 bdm_assert_debug(inds.length() == dim, "Improper indices inds"); 83 83 int dim_skips=1; // skips in active dimension, in the first dimension, the skips are 1 index per value 84 84 -
library/bdm/stat/emix.cpp
r507 r565 12 12 13 13 for ( i = 0; i < w.length(); i++ ) { 14 it_assert_debug ( dim == ( Coms0 ( i )->dimension() ), "Component sizes do not match!" );15 it_assert_debug ( !isnamed || tmp_rv.equal ( Coms0 ( i )->_rv() ), "Component RVs do not match!" );14 bdm_assert_debug ( dim == ( Coms0 ( i )->dimension() ), "Component sizes do not match!" ); 15 bdm_assert_debug ( !isnamed || tmp_rv.equal ( Coms0 ( i )->_rv() ), "Component RVs do not match!" ); 16 16 } 17 17 … … 44 44 45 45 void emix::marginal ( const RV &rv, emix &target ) const { 46 it_assert_debug ( isnamed(), "rvs are not assigned" );46 bdm_assert_debug ( isnamed(), "rvs are not assigned" ); 47 47 48 48 Array<shared_ptr<epdf> > Cn ( Coms.length() ); … … 55 55 56 56 shared_ptr<mpdf> emix::condition ( const RV &rv ) const { 57 it_assert_debug ( isnamed(), "rvs are not assigned" );57 bdm_assert_debug ( isnamed(), "rvs are not assigned" ); 58 58 mratio *tmp = new mratio ( this, rv ); 59 59 return shared_ptr<mpdf>(tmp); … … 65 65 int i; 66 66 for ( i = 0; i < w.length(); i++ ) { 67 it_assert_debug ( dim == ( Coms0 ( i )->dimension() ), "Component sizes do not match!" );67 bdm_assert_debug ( dim == ( Coms0 ( i )->dimension() ), "Component sizes do not match!" ); 68 68 } 69 69 if ( copy ) { 70 70 Coms.set_length ( Coms0.length() ); 71 71 for ( i = 0; i < w.length(); i++ ) { 72 it_error ( "Not imp..." );73 *Coms ( i ) = *Coms0 ( i );72 bdm_error ( "Not implemented" ); 73 // *Coms ( i ) = *Coms0 ( i ); 74 74 } 75 75 destroyComs = true; … … 124 124 125 125 void egiwmix::marginal ( const RV &rv, emix &target ) const { 126 it_assert_debug ( isnamed(), "rvs are not assigned" );126 bdm_assert_debug ( isnamed(), "rvs are not assigned" ); 127 127 128 128 Array<shared_ptr<epdf> > Cn ( Coms.length() ); … … 247 247 // rvaddok=rv.add ( mpdfs ( i )->_rv() ); //add rv to common rvs. 248 248 // // If rvaddok==false, mpdfs overlap => assert error. 249 // it_assert_debug(rvaddok||overlap,"mprod::mprod() input mpdfs overlap in rv!");250 249 // epdfs ( i ) = & ( mpdfs ( i )->posterior() ); // add pointer to epdf 251 250 // }; -
library/bdm/stat/emix.h
r559 r565 62 62 //prepare data structures 63 63 if ( copy ) { 64 it_error ( "todo" );65 destroynom = true;64 bdm_error ( "todo" ); 65 // destroynom = true; 66 66 } else { 67 67 nom = nom0; 68 68 destroynom = false; 69 69 } 70 it_assert_debug ( rvc.length() > 0, "Makes no sense to use this object!" );70 bdm_assert_debug ( rvc.length() > 0, "Makes no sense to use this object!" ); 71 71 72 72 // build denominator … … 156 156 } 157 157 double tmp = log ( sum ); 158 it_assert_debug ( std::isfinite ( tmp ), "Infinite" );158 bdm_assert_debug ( std::isfinite ( tmp ), "Infinite" ); 159 159 return tmp; 160 160 }; … … 387 387 for ( int i = 0; i < epdfs.length(); i++ ) { 388 388 independent = rv.add ( epdfs ( i )->_rv() ); 389 it_assert_debug ( independent == true, "eprod:: given components are not independent." );389 bdm_assert_debug ( independent, "eprod:: given components are not independent." ); 390 390 } 391 391 dim = rv._dsize(); … … 441 441 tmp += epdfs ( i )->evallog ( dls ( i )->pushdown ( val ) ); 442 442 } 443 it_assert_debug ( std::isfinite ( tmp ), "Infinite" );443 bdm_assert_debug ( std::isfinite ( tmp ), "Infinite" ); 444 444 return tmp; 445 445 } 446 446 //!access function 447 447 const epdf* operator () ( int i ) const { 448 it_assert_debug ( i < epdfs.length(), "wrong index" );448 bdm_assert_debug ( i < epdfs.length(), "wrong index" ); 449 449 return epdfs ( i ); 450 450 } -
library/bdm/stat/exp_family.cpp
r488 r565 19 19 20 20 vec egiw::sample() const { 21 it_warning ( "Function not implemented" );21 bdm_warning ( "Function not implemented" ); 22 22 return vec_1 ( 0.0 ); 23 23 } … … 67 67 - 0.5 * dimx * ( m * log2 + 0.5 * ( dimx - 1 ) * log2pi ) - lg; 68 68 69 it_assert_debug ( ( ( -nkG - nkW ) > -Inf ) && ( ( -nkG - nkW ) < Inf ), "ARX improper" );69 bdm_assert_debug ( ( ( -nkG - nkW ) > -Inf ) && ( ( -nkG - nkW ) < Inf ), "ARX improper" ); 70 70 return -nkG - nkW; 71 71 } … … 82 82 return iLsub * L0 ( 1, end ); 83 83 } else { 84 it_error ( "ERROR: est_theta() not implemented for dimx>1" );85 return 0;84 bdm_error ( "ERROR: est_theta() not implemented for dimx>1" ); 85 return vec(); 86 86 } 87 87 } … … 99 99 100 100 } else { 101 it_error ( "ERROR: est_theta_cov() not implemented for dimx>1" );102 return 0;101 bdm_error ( "ERROR: est_theta_cov() not implemented for dimx>1" ); 102 return ldmat(); 103 103 } 104 104 … … 138 138 return var; 139 139 } else { 140 it_error ( "not implemented" );141 return vec ( 0);140 bdm_error ( "not implemented" ); 141 return vec(); 142 142 } 143 143 } … … 199 199 } 200 200 double tmp = res - lognc();; 201 it_assert_debug ( std::isfinite ( tmp ), "Infinite value" );201 bdm_assert_debug ( std::isfinite ( tmp ), "Infinite value" ); 202 202 return tmp; 203 203 } … … 256 256 257 257 default: 258 it_error ( "PF::resample(): Unknown resampling method" );258 bdm_error ( "PF::resample(): Unknown resampling method" ); 259 259 } 260 260 … … 306 306 307 307 void eEmp::set_statistics ( const vec &w0, const epdf &epdf0 ) { 308 //it_assert_debug(rv==epdf0->rv(),"Wrong epdf0");309 308 dim = epdf0.dimension(); 310 309 w = w0; … … 319 318 320 319 void eEmp::set_samples ( const epdf* epdf0 ) { 321 //it_assert_debug(rv==epdf0->rv(),"Wrong epdf0");322 320 w = 1; 323 321 w /= sum ( w );//renormalize -
library/bdm/stat/exp_family.h
r536 r565 44 44 //! logarithm of the normalizing constant, \f$\mathcal{I}\f$ 45 45 virtual double lognc() const = 0; 46 46 47 //!Evaluate normalized log-probability 47 virtual double evallog_nn (const vec &val) const{it_error ("Not implemented");return 0.0;}; 48 virtual double evallog_nn (const vec &val) const { 49 bdm_error ("Not implemented"); 50 return 0.0; 51 } 52 48 53 //!Evaluate normalized log-probability 49 54 virtual double evallog (const vec &val) const { 50 55 double tmp; 51 56 tmp = evallog_nn (val) - lognc(); 52 // it_assert_debug ( std::isfinite ( tmp ),"Infinite value" );53 57 return tmp; 54 58 } … … 65 69 return x -lognc(); 66 70 } 71 67 72 //!Power of the density, used e.g. to flatten the density 68 virtual void pow (double p) {it_error ("Not implemented");}; 73 virtual void pow (double p) { 74 bdm_error ("Not implemented"); 75 } 69 76 }; 70 77 … … 84 91 BMEF (const BMEF &B) : BM (B), frg (B.frg), last_lognc (B.last_lognc) {} 85 92 //!get statistics from another model 86 virtual void set_statistics (const BMEF* BM0) {it_error ("Not implemented");}; 93 virtual void set_statistics (const BMEF* BM0) { 94 bdm_error ("Not implemented"); 95 } 96 87 97 //! Weighted update of sufficient statistics (Bayes rule) 88 98 virtual void bayes (const vec &data, const double w) {}; 89 99 //original Bayes 90 100 void bayes (const vec &dt); 101 91 102 //!Flatten the posterior according to the given BMEF (of the same type!) 92 virtual void flatten (const BMEF * B) {it_error ("Not implemented");} 93 //!Flatten the posterior as if to keep nu0 data 94 // virtual void flatten ( double nu0 ) {it_error ( "Not implemented" );} 95 96 BMEF* _copy_ () const {it_error ("function _copy_ not implemented for this BM"); return NULL;}; 103 virtual void flatten (const BMEF * B) { 104 bdm_error ("Not implemented"); 105 } 106 107 BMEF* _copy_ () const { 108 bdm_error ("function _copy_ not implemented for this BM"); 109 return NULL; 110 } 97 111 }; 98 112 … … 122 136 void from_setting (const Setting &root); 123 137 void validate() { 124 it_assert(mu.length() == R.rows(), "parameters mismatch");138 bdm_assert_debug (mu.length() == R.rows(), "parameters mismatch"); 125 139 dim = mu.length(); 126 140 } … … 272 286 //!@} 273 287 274 vec sample() const {it_error ("Not implemented");return vec_1 (0.0);}; 288 vec sample() const { 289 bdm_error ("Not implemented"); 290 return vec(); 291 } 292 275 293 vec mean() const {return beta / sum (beta);}; 276 294 vec variance() const {double gamma = sum (beta); return elem_mult (beta, (beta + 1)) / (gamma* (gamma + 1));} … … 278 296 double evallog_nn (const vec &val) const { 279 297 double tmp; tmp = (beta - 1) * log (val); 280 // it_assert_debug ( std::isfinite ( tmp ),"Infinite value" );281 298 return tmp; 282 }; 299 } 300 283 301 double lognc () const { 284 302 double tmp; … … 287 305 for (int i = 0;i < beta.length();i++) {lgb += lgamma (beta (i));} 288 306 tmp = lgb - lgamma (gam); 289 // it_assert_debug ( std::isfinite ( tmp ),"Infinite value" );290 307 return tmp; 291 }; 308 } 309 292 310 //!access function 293 311 vec& _beta() {return beta;} … … 397 415 } 398 416 void validate() { 399 it_assert(alpha.length() == beta.length(), "parameters do not match");417 bdm_assert_debug (alpha.length() == beta.length(), "parameters do not match"); 400 418 dim = alpha.length(); 401 419 } … … 446 464 void set_parameters( int &i, double wi, epdf* ep){w(i)=wi;Coms(i)=ep;} 447 465 vec mean(){vec pom; for(int i=0;i<n;i++){pom+=Coms(i)->mean()*w(i);} return pom;}; 448 vec sample() {it_error ( "Not implemented" );return 0;}449 466 }; 450 467 */ … … 472 489 void set_parameters (const vec &low0, const vec &high0) { 473 490 distance = high0 - low0; 474 it_assert_debug (min (distance) > 0.0, "bad support");491 bdm_assert_debug (min (distance) > 0.0, "bad support"); 475 492 low = low0; 476 493 high = high0; … … 535 552 //! Set \c A and \c R 536 553 void set_parameters (const mat &A0, const vec &mu0, const sq_T &R0) { 537 it_assert_debug (A0.rows() == mu0.length(), "");538 it_assert_debug (A0.rows() == R0.rows(), "");554 bdm_assert_debug (A0.rows() == mu0.length(), "mlnorm: A vs. mu mismatch"); 555 bdm_assert_debug (A0.rows() == R0.rows(), "mlnorm: A vs. R mismatch"); 539 556 540 557 this->iepdf.set_parameters (zeros (A0.rows()), R0); … … 660 677 //! constructor function 661 678 void set_parameters (const mat &A0, const vec &mu0, const ldmat &R0, const ldmat& Lambda0) { 662 it_assert_debug (A0.rows() == mu0.length(), "");663 it_assert_debug (R0.rows() == A0.rows(), "");679 bdm_assert_debug (A0.rows() == mu0.length(), "mlstudent: A vs. mu mismatch"); 680 bdm_assert_debug (R0.rows() == A0.rows(), "mlstudent: A vs. R mismatch"); 664 681 665 682 iepdf.set_parameters (mu0, Lambda); // … … 1138 1155 //! Function performs resampling, i.e. removal of low-weight samples and duplication of high-weight samples such that the new samples represent the same density. 1139 1156 ivec resample (RESAMPLING_METHOD method = SYSTEMATIC); 1140 //! inherited operation : NOT implemneted 1141 vec sample() const {it_error ("Not implemented");return 0;} 1142 //! inherited operation : NOT implemneted 1143 double evallog (const vec &val) const {it_error ("Not implemented");return 0.0;} 1157 1158 //! inherited operation : NOT implemented 1159 vec sample() const { 1160 bdm_error ("Not implemented"); 1161 return vec(); 1162 } 1163 1164 //! inherited operation : NOT implemented 1165 double evallog (const vec &val) const { 1166 bdm_error ("Not implemented"); 1167 return 0.0; 1168 } 1169 1144 1170 vec mean() const { 1145 1171 vec pom = zeros (dim); … … 1279 1305 void enorm<sq_T>::marginal ( const RV &rvn, enorm<sq_T> &target ) const 1280 1306 { 1281 it_assert_debug (isnamed(), "rv description is not assigned");1307 bdm_assert_debug (isnamed(), "rv description is not assigned"); 1282 1308 ivec irvn = rvn.dataind (rv); 1283 1309 … … 1302 1328 typedef mlnorm<sq_T> TMlnorm; 1303 1329 1304 it_assert_debug (isnamed(), "rvs are not assigned");1330 bdm_assert_debug (isnamed(), "rvs are not assigned"); 1305 1331 TMlnorm &uptarget = dynamic_cast<TMlnorm &>(target); 1306 1332 1307 1333 RV rvc = rv.subt (rvn); 1308 it_assert_debug ( (rvc._dsize() + rvn._dsize() == rv._dsize()), "wrong rvn");1334 bdm_assert_debug ( (rvc._dsize() + rvn._dsize() == rv._dsize()), "wrong rvn"); 1309 1335 //Permutation vector of the new R 1310 1336 ivec irvn = rvn.dataind (rv); -
library/bdm/stat/merger.cpp
r561 r565 192 192 193 193 } 194 // it_assert_debug(std::isfinite(sum(lw_src)),"bad"); 194 195 195 lW.set_row ( i, lw_src ); // do not divide by mix 196 196 } -
library/bdm/stat/merger.h
r556 r565 200 200 eSmp._w() = wtmp / sum ( wtmp ); 201 201 } else { 202 it_error ( "Sources are not compatible - use merger_mix" );202 bdm_error ( "Sources are not compatible - use merger_mix" ); 203 203 } 204 204 }; … … 277 277 278 278 void validate() { 279 it_assert ( eSmp._w().length() > 0, "Empty support, use set_support()." );280 it_assert ( dim == eSmp._samples() ( 0 ).length(), "Support points and rv are not compatible!" );281 it_assert ( isnamed(), "mergers must be named" );279 bdm_assert ( eSmp._w().length() > 0, "Empty support, use set_support()." ); 280 bdm_assert ( dim == eSmp._samples() ( 0 ).length(), "Support points and rv are not compatible!" ); 281 bdm_assert ( isnamed(), "mergers must be named" ); 282 282 } 283 283 //!@} -
library/tests/shared_ptr_test.cpp
r499 r565 1 1 #include "shared_ptr.h" 2 2 #include "UnitTest++.h" 3 #include <stdexcept> 3 4 #include <vector> 4 5 … … 51 52 CHECK_EQUAL ( 2, v[2]->get_x() ); 52 53 } 54 55 TEST ( test_shared_ptr_error ) { 56 bdm::shared_ptr<Foo> empty; 57 try { 58 Foo x(*empty); 59 CHECK ( false ); 60 } catch ( std::runtime_error &exc ) { 61 CHECK ( exc.what() ); 62 } 63 } -
library/tests/test_kalman.cpp
r527 r565 21 21 bool xxx = fin.seek ( "d" ); 22 22 if ( !xxx ) { 23 it_error ( "testKF.it not found" );23 bdm_error ( "testKF.it not found" ); 24 24 } 25 25 fin >> Dt; -
library/tests/test_kalman_QR.cpp
r488 r565 22 22 bool xxx = fin.seek ( "d" ); 23 23 if ( !xxx ) { 24 it_error ( "testKF.it not found" );24 bdm_error ( "testKF.it not found" ); 25 25 } 26 26 fin >> Dt; -
library/tests/test_kalman_QRexh.cpp
r477 r565 23 23 24 24 if ( !xxx ) { 25 it_error ( "testKF.it not found" );25 bdm_error ( "testKF.it not found" ); 26 26 } 27 27 -
library/tests/testsuite.cpp
r496 r565 2 2 #include "TestReporterStdout.h" 3 3 #include "UnitTest++.h" 4 #include "bdmerror.h" 4 5 #include "itpp_ext.h" 6 #include <string.h> 5 7 6 8 using namespace itpp; … … 9 11 10 12 bool is_selected_test( const UnitTest::Test *test ) { 11 it_assert_debug ( test, "NULL test" );13 bdm_assert_debug ( test, "NULL test" ); 12 14 13 15 if (!selected_tests.length()) { … … 17 19 for (int i = 0; i < selected_tests.length(); ++i) { 18 20 const char *n = test->m_details.testName; 19 it_assert_debug ( n, "NULL test name" );21 bdm_assert_debug ( n, "NULL test name" ); 20 22 const char *sname = selected_tests(i); 21 it_assert_debug ( sname, "NULL selected test name" );23 bdm_assert_debug ( sname, "NULL selected test name" ); 22 24 if ( !strcmp ( n, sname ) ) { 23 25 return true;