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)

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • library/bdm/math/functions.h

    r477 r565  
    1313#define FN_H 
    1414 
     15#include "../bdmerror.h" 
    1516#include "../base/bdmbase.h" 
    1617 
     
    4445public : 
    4546        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        } 
    4950 
    5051//              linfn evalsome ( ivec &rvind ); 
     
    8283        //! Evaluates \f$f(x0,u0)\f$ (VS: Do we really need common eval? ) 
    8384        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." ); 
    8586                return eval ( cond ( 0, dimx - 1 ), cond ( dimx, dimx + dimu - 1 ) );//-1 = end (in matlab) 
    86         }; 
     87        } 
    8788 
    8889        //! Evaluates \f$f(x0,u0)\f$ 
     
    115116        //!@{ 
    116117 
    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 ) { 
    119121                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" ); 
    124127                A = A0; 
    125128                B = B0; 
     
    133136        //!@{ 
    134137        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." ); 
    137140                return A*x0 + B*u0; 
    138141        } 
    139142 
    140143        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." ); 
    142145                if ( full ) F = A;      //else : nothing has changed no need to regenerate 
    143146        } 
    144         //! 
     147 
    145148        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." ); 
    147150                if ( full ) F = B;      //else : nothing has changed no need to regenerate 
    148151        }