Changeset 33 for bdm/stat/libFN.h

Show
Ignore:
Timestamp:
03/05/08 16:01:56 (16 years ago)
Author:
smidl
Message:

Oprava PF a MPF + jejich implementace pro pmsm system

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • bdm/stat/libFN.h

    r22 r33  
    1010// 
    1111// 
     12#ifndef FN_H 
     13#define FN_H 
     14 
    1215#include <itpp/itbase.h> 
    1316#include "libBM.h" 
     
    1821class constfn : public fnc 
    1922{ 
    20                 RV rv; 
     23                //! value of the function 
    2124                vec val; 
    2225 
    23  
    2426        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;}; 
    2730                //!Default constructor 
    28                 constfn ( const vec &val0 ) :rv(),val ( val0 ) {}; 
     31                constfn ( const vec &val0 ) :val ( val0 ) {}; 
    2932}; 
    3033 
     
    3235class linfn: public fnc 
    3336{ 
     37                //! Identification of $x$ 
    3438                RV rv; 
    35                 ivec indexlist; // needed by evalsome 
     39                //! Matrix A 
    3640                mat A; 
     41                //! Matrix B 
    3742                vec B; 
    3843        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;}; 
    4045 
    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;}; 
    4551}; 
    4652 
     
    5864{ 
    5965        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() 
    6171                int dimx; 
     72                //! cache for rvu.count() 
    6273                int dimu; 
    6374        public: 
     
    7182                //! Evaluates $f(x0,u0)$ 
    7283                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. 
    7485                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. 
    7687                virtual void dfdu_cond ( const vec &x0, const vec &u0, mat &A, bool full=true ) {}; 
    7788                //!Default constructor (dimy is not set!) 
     
    94105                //! Default constructor 
    95106                bilinfn ( const RV &rvx0, const RV &rvu0 ) : diffbifn ( rvx0,rvu0 ) ,A ( eye ( dimx ) ),B ( zeros ( dimx,dimu ) )       {}; 
    96                 // 
     107                //! Alternative constructor 
    97108                bilinfn ( const RV &rvx0, const RV &rvu0, const mat &A0, const mat &B0 ); 
    98                 // 
     109                //! 
    99110                void dfdx_cond ( const vec &x0, const vec &u0, mat &F, bool full ) 
    100111                { 
     
    102113                        if ( full ) F=A;        //else : nothing has changed no need to regenerate 
    103114                } 
    104                 // 
     115                //! 
    105116                void dfdu_cond ( const vec &x0, const vec &u0, mat &F,  bool full=true ) 
    106117                { 
     
    109120                } 
    110121}; 
     122 
     123#endif // FN_H