Changeset 33 for bdm/stat/libFN.h
- Timestamp:
- 03/05/08 16:01:56 (16 years ago)
- Files:
-
- 1 modified
Legend:
- Unmodified
- Added
- Removed
-
bdm/stat/libFN.h
r22 r33 10 10 // 11 11 // 12 #ifndef FN_H 13 #define FN_H 14 12 15 #include <itpp/itbase.h> 13 16 #include "libBM.h" … … 18 21 class constfn : public fnc 19 22 { 20 RV rv;23 //! value of the function 21 24 vec val; 22 25 23 24 26 public: 25 vec eval() {return val;}; 26 vec eval ( vec &cond ) {return val;}; 27 //vec eval() {return val;}; 28 //! inherited 29 vec eval ( const vec &cond ) {return val;}; 27 30 //!Default constructor 28 constfn ( const vec &val0 ) : rv(),val ( val0 ) {};31 constfn ( const vec &val0 ) :val ( val0 ) {}; 29 32 }; 30 33 … … 32 35 class linfn: public fnc 33 36 { 37 //! Identification of $x$ 34 38 RV rv; 35 ivec indexlist; // needed by evalsome39 //! Matrix A 36 40 mat A; 41 //! Matrix B 37 42 vec B; 38 43 public : 39 vec eval ( vec &cond ) {it_assert_debug ( cond.length() ==rv.count(), "linfn::eval Wrong cond." );return A*cond+B;};44 vec eval (const vec &cond ) {it_assert_debug ( cond.length() ==rv.count(), "linfn::eval Wrong cond." );return A*cond+B;}; 40 45 41 linfn evalsome ( ivec &rvind ); 42 linfn ( const RV &rv0 ) :rv ( rv0 ),A ( eye ( rv0.count() ) ),B ( zeros ( rv0.count() ) ) { indexlist=rv.indexlist();}; 43 linfn ( const RV &rv0, const mat &A0 ) : rv ( rv0 ), A ( A0 ), B ( zeros ( rv0.count() ) ) { indexlist=rv.indexlist();}; 44 linfn ( const RV &rv0, const mat &A0, const vec &B0 ) :rv ( rv0 ), A ( A0 ), B ( B0 ) { indexlist=rv.indexlist();}; 46 // linfn evalsome ( ivec &rvind ); 47 //!default constructor 48 linfn ( const RV &rv0 ) :rv ( rv0 ),A ( eye ( rv0.count() ) ),B ( zeros ( rv0.count() ) ) { }; 49 //! Set values of \c A and \c B 50 void set_parameters ( const mat &A0 , const vec &B0 ) {A=A0; B=B0;}; 45 51 }; 46 52 … … 58 64 { 59 65 protected: 60 RV rvx,rvu; 66 //! Indentifier of the first rv. 67 RV rvx; 68 //! Indentifier of the second rv. 69 RV rvu; 70 //! cache for rvx.count() 61 71 int dimx; 72 //! cache for rvu.count() 62 73 int dimu; 63 74 public: … … 71 82 //! Evaluates $f(x0,u0)$ 72 83 virtual vec eval ( const vec &x0, const vec &u0 ) {return zeros ( dimy );}; 73 //! Evaluates \f$A=\frac{d}{dx}f(x,u)|_{x0,u0}\f$ and writes result into \c A . @param full denotes that even unchanged entries are to be rewritten. When, false only the changed elements are computed. 84 //! Evaluates \f$A=\frac{d}{dx}f(x,u)|_{x0,u0}\f$ and writes result into \c A . @param full denotes that even unchanged entries are to be rewritten. When, false only the changed elements are computed. @param x0 numeric value of $x$, @param u0 numeric value of $u$ @param A a place where the result will be stored. 74 85 virtual void dfdx_cond ( const vec &x0, const vec &u0, mat &A , bool full=true ) {}; 75 //! Evaluates \f$A=\frac{d}{du}f(x,u)|_{x0,u0}\f$ and writes result into \c A . @param full denotes that even unchanged entries are to be rewritten. When, false only the changed elements are computed. 86 //! Evaluates \f$A=\frac{d}{du}f(x,u)|_{x0,u0}\f$ and writes result into \c A . @param full denotes that even unchanged entries are to be rewritten. When, false only the changed elements are computed. @param x0 numeric value of $x$, @param u0 numeric value of $u$ @param A a place where the result will be stored. 76 87 virtual void dfdu_cond ( const vec &x0, const vec &u0, mat &A, bool full=true ) {}; 77 88 //!Default constructor (dimy is not set!) … … 94 105 //! Default constructor 95 106 bilinfn ( const RV &rvx0, const RV &rvu0 ) : diffbifn ( rvx0,rvu0 ) ,A ( eye ( dimx ) ),B ( zeros ( dimx,dimu ) ) {}; 96 // 107 //! Alternative constructor 97 108 bilinfn ( const RV &rvx0, const RV &rvu0, const mat &A0, const mat &B0 ); 98 // 109 //! 99 110 void dfdx_cond ( const vec &x0, const vec &u0, mat &F, bool full ) 100 111 { … … 102 113 if ( full ) F=A; //else : nothing has changed no need to regenerate 103 114 } 104 // 115 //! 105 116 void dfdu_cond ( const vec &x0, const vec &u0, mat &F, bool full=true ) 106 117 { … … 109 120 } 110 121 }; 122 123 #endif // FN_H