Changeset 565 for library/bdm/math/functions.h
- Timestamp:
- 08/19/09 16:54:24 (15 years ago)
- Files:
-
- 1 modified
Legend:
- Unmodified
- Added
- Removed
-
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 }