Changeset 565 for library/bdm/stat

Show
Ignore:
Timestamp:
08/19/09 16:54:24 (15 years ago)
Author:
vbarta
Message:

using own error macros (basically copied from IT++, but never aborting)

Location:
library/bdm/stat
Files:
7 modified

Legend:

Unmodified
Added
Removed
  • library/bdm/stat/discrete.h

    r564 r565  
    5555                        void initialize() { 
    5656                                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"); 
    5858                                Npoints = prod(gridsizes); 
    59                                 it_assert_debug(Npoints>0,"Wrong input parameters"); 
     59                                bdm_assert_debug(Npoints > 0, "Wrong input parameters"); 
    6060                                 
    6161                                //precompute steps 
     
    7171                                vec v ( dim ); 
    7272                                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"); 
    7474                                        v ( j ) = ranges(j)(0) + (0.5+inds(j))*steps(j); 
    7575                                } 
     
    8080                        long linear_index (const ivec inds){ 
    8181                                long ind=0; 
    82                                 it_assert_debug(inds.length()==dim,"Improper indeces inds"); 
     82                                bdm_assert_debug(inds.length() == dim, "Improper indices inds"); 
    8383                                int dim_skips=1; // skips in active dimension, in the first dimension, the skips are 1 index per value 
    8484                                                 
  • library/bdm/stat/emix.cpp

    r507 r565  
    1212 
    1313        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!" ); 
    1616        } 
    1717 
     
    4444 
    4545void 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" ); 
    4747 
    4848        Array<shared_ptr<epdf> > Cn ( Coms.length() ); 
     
    5555 
    5656shared_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" ); 
    5858        mratio *tmp = new mratio ( this, rv ); 
    5959        return shared_ptr<mpdf>(tmp); 
     
    6565        int i; 
    6666        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!" ); 
    6868        } 
    6969        if ( copy ) { 
    7070                Coms.set_length ( Coms0.length() ); 
    7171                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 ); 
    7474                } 
    7575                destroyComs = true; 
     
    124124 
    125125void 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" ); 
    127127 
    128128        Array<shared_ptr<epdf> > Cn ( Coms.length() ); 
     
    247247//                      rvaddok=rv.add ( mpdfs ( i )->_rv() ); //add rv to common rvs. 
    248248//                      // If rvaddok==false, mpdfs overlap => assert error. 
    249 //                      it_assert_debug(rvaddok||overlap,"mprod::mprod() input mpdfs overlap in rv!"); 
    250249//                      epdfs ( i ) = & ( mpdfs ( i )->posterior() ); // add pointer to epdf 
    251250//              }; 
  • library/bdm/stat/emix.h

    r559 r565  
    6262                //prepare data structures 
    6363                if ( copy ) { 
    64                         it_error ( "todo" ); 
    65                         destroynom = true; 
     64                        bdm_error ( "todo" ); 
     65                        // destroynom = true; 
    6666                } else { 
    6767                        nom = nom0; 
    6868                        destroynom = false; 
    6969                } 
    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!" ); 
    7171 
    7272                // build denominator 
     
    156156                } 
    157157                double tmp = log ( sum ); 
    158                 it_assert_debug ( std::isfinite ( tmp ), "Infinite" ); 
     158                bdm_assert_debug ( std::isfinite ( tmp ), "Infinite" ); 
    159159                return tmp; 
    160160        }; 
     
    387387                        for ( int i = 0; i < epdfs.length(); i++ ) { 
    388388                                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." ); 
    390390                        } 
    391391                        dim = rv._dsize(); 
     
    441441                        tmp += epdfs ( i )->evallog ( dls ( i )->pushdown ( val ) ); 
    442442                } 
    443                 it_assert_debug ( std::isfinite ( tmp ), "Infinite" ); 
     443                bdm_assert_debug ( std::isfinite ( tmp ), "Infinite" ); 
    444444                return tmp; 
    445445        } 
    446446        //!access function 
    447447        const epdf* operator () ( int i ) const { 
    448                 it_assert_debug ( i < epdfs.length(), "wrong index" ); 
     448                bdm_assert_debug ( i < epdfs.length(), "wrong index" ); 
    449449                return epdfs ( i ); 
    450450        } 
  • library/bdm/stat/exp_family.cpp

    r488 r565  
    1919 
    2020vec egiw::sample() const { 
    21         it_warning ( "Function not implemented" ); 
     21        bdm_warning ( "Function not implemented" ); 
    2222        return vec_1 ( 0.0 ); 
    2323} 
     
    6767                     - 0.5 * dimx * ( m * log2 + 0.5 * ( dimx - 1 ) * log2pi )  - lg; 
    6868 
    69         it_assert_debug ( ( ( -nkG - nkW ) > -Inf ) && ( ( -nkG - nkW ) < Inf ), "ARX improper" ); 
     69        bdm_assert_debug ( ( ( -nkG - nkW ) > -Inf ) && ( ( -nkG - nkW ) < Inf ), "ARX improper" ); 
    7070        return -nkG - nkW; 
    7171} 
     
    8282                return iLsub * L0 ( 1, end ); 
    8383        } 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(); 
    8686        } 
    8787} 
     
    9999 
    100100        } 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(); 
    103103        } 
    104104 
     
    138138                return var; 
    139139        } else { 
    140                 it_error ( "not implemented" ); 
    141                 return vec ( 0 ); 
     140                bdm_error ( "not implemented" ); 
     141                return vec(); 
    142142        } 
    143143} 
     
    199199        } 
    200200        double tmp = res - lognc();; 
    201         it_assert_debug ( std::isfinite ( tmp ), "Infinite value" ); 
     201        bdm_assert_debug ( std::isfinite ( tmp ), "Infinite value" ); 
    202202        return tmp; 
    203203} 
     
    256256 
    257257        default: 
    258                 it_error ( "PF::resample(): Unknown resampling method" ); 
     258                bdm_error ( "PF::resample(): Unknown resampling method" ); 
    259259        } 
    260260 
     
    306306 
    307307void eEmp::set_statistics ( const vec &w0, const epdf &epdf0 ) { 
    308         //it_assert_debug(rv==epdf0->rv(),"Wrong epdf0"); 
    309308        dim = epdf0.dimension(); 
    310309        w = w0; 
     
    319318 
    320319void eEmp::set_samples ( const epdf* epdf0 ) { 
    321         //it_assert_debug(rv==epdf0->rv(),"Wrong epdf0"); 
    322320        w = 1; 
    323321        w /= sum ( w );//renormalize 
  • library/bdm/stat/exp_family.h

    r536 r565  
    4444                //! logarithm of the normalizing constant, \f$\mathcal{I}\f$ 
    4545                virtual double lognc() const = 0; 
     46 
    4647                //!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 
    4853                //!Evaluate normalized log-probability 
    4954                virtual double evallog (const vec &val) const { 
    5055                        double tmp; 
    5156                        tmp = evallog_nn (val) - lognc(); 
    52 //                              it_assert_debug ( std::isfinite ( tmp ),"Infinite value" ); 
    5357                        return tmp; 
    5458                } 
     
    6569                        return x -lognc(); 
    6670                } 
     71 
    6772                //!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                } 
    6976}; 
    7077 
     
    8491                BMEF (const BMEF &B) : BM (B), frg (B.frg), last_lognc (B.last_lognc) {} 
    8592                //!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 
    8797                //! Weighted update of sufficient statistics (Bayes rule) 
    8898                virtual void bayes (const vec &data, const double w) {}; 
    8999                //original Bayes 
    90100                void bayes (const vec &dt); 
     101 
    91102                //!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                } 
    97111}; 
    98112 
     
    122136                void from_setting (const Setting &root); 
    123137                void validate() { 
    124                         it_assert (mu.length() == R.rows(), "parameters mismatch"); 
     138                        bdm_assert_debug (mu.length() == R.rows(), "parameters mismatch"); 
    125139                        dim = mu.length(); 
    126140                } 
     
    272286                //!@} 
    273287 
    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 
    275293                vec mean() const {return beta / sum (beta);}; 
    276294                vec variance() const {double gamma = sum (beta); return elem_mult (beta, (beta + 1)) / (gamma* (gamma + 1));} 
     
    278296                double evallog_nn (const vec &val) const { 
    279297                        double tmp; tmp = (beta - 1) * log (val); 
    280 //                              it_assert_debug ( std::isfinite ( tmp ),"Infinite value" ); 
    281298                        return tmp; 
    282                 }; 
     299                } 
     300 
    283301                double lognc () const { 
    284302                        double tmp; 
     
    287305                        for (int i = 0;i < beta.length();i++) {lgb += lgamma (beta (i));} 
    288306                        tmp = lgb - lgamma (gam); 
    289 //                              it_assert_debug ( std::isfinite ( tmp ),"Infinite value" ); 
    290307                        return tmp; 
    291                 }; 
     308                } 
     309 
    292310                //!access function 
    293311                vec& _beta()  {return beta;} 
     
    397415                } 
    398416                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"); 
    400418                        dim = alpha.length(); 
    401419                } 
     
    446464        void set_parameters( int &i, double wi, epdf* ep){w(i)=wi;Coms(i)=ep;} 
    447465        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;} 
    449466}; 
    450467*/ 
     
    472489                void set_parameters (const vec &low0, const vec &high0) { 
    473490                        distance = high0 - low0; 
    474                         it_assert_debug (min (distance) > 0.0, "bad support"); 
     491                        bdm_assert_debug (min (distance) > 0.0, "bad support"); 
    475492                        low = low0; 
    476493                        high = high0; 
     
    535552                //! Set \c A and \c R 
    536553                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"); 
    539556 
    540557                        this->iepdf.set_parameters (zeros (A0.rows()), R0); 
     
    660677                //! constructor function 
    661678                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"); 
    664681 
    665682                        iepdf.set_parameters (mu0, Lambda);  // 
     
    11381155                //! 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. 
    11391156                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 
    11441170                vec mean() const { 
    11451171                        vec pom = zeros (dim); 
     
    12791305void enorm<sq_T>::marginal ( const RV &rvn, enorm<sq_T> &target ) const 
    12801306{ 
    1281         it_assert_debug (isnamed(), "rv description is not assigned"); 
     1307        bdm_assert_debug (isnamed(), "rv description is not assigned"); 
    12821308        ivec irvn = rvn.dataind (rv); 
    12831309 
     
    13021328        typedef mlnorm<sq_T> TMlnorm; 
    13031329 
    1304         it_assert_debug (isnamed(), "rvs are not assigned"); 
     1330        bdm_assert_debug (isnamed(), "rvs are not assigned"); 
    13051331        TMlnorm &uptarget = dynamic_cast<TMlnorm &>(target); 
    13061332 
    13071333        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"); 
    13091335        //Permutation vector of the new R 
    13101336        ivec irvn = rvn.dataind (rv); 
  • library/bdm/stat/merger.cpp

    r561 r565  
    192192 
    193193                        } 
    194                         //                      it_assert_debug(std::isfinite(sum(lw_src)),"bad"); 
     194 
    195195                        lW.set_row ( i, lw_src ); // do not divide by mix 
    196196                } 
  • library/bdm/stat/merger.h

    r556 r565  
    200200                        eSmp._w() = wtmp / sum ( wtmp ); 
    201201                } else { 
    202                         it_error ( "Sources are not compatible - use merger_mix" ); 
     202                        bdm_error ( "Sources are not compatible - use merger_mix" ); 
    203203                } 
    204204        }; 
     
    277277 
    278278        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" ); 
    282282        } 
    283283        //!@}