Show
Ignore:
Timestamp:
06/09/10 14:00:40 (14 years ago)
Author:
mido
Message:

astyle applied all over the library

Files:
1 modified

Legend:

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

    r896 r1064  
    2626class rectangular_support: public root { 
    2727protected: 
    28         //! Array of boundaries (2D vectors: [begining,end]) for each dimension 
    29         Array<vec> ranges; 
    30         //! Number of support points in each dimension 
    31         ivec gridsizes; 
    32         //! dimension 
    33         int dim; 
    34         //! Number of data points 
    35         int Npoints; 
    36         //! active vector for first_vec and next_vec 
    37         vec actvec; 
    38         //! indices of active vector 
    39         vec actvec_ind; 
    40         //! length of steps in each dimension 
    41         vec steps; 
     28    //! Array of boundaries (2D vectors: [begining,end]) for each dimension 
     29    Array<vec> ranges; 
     30    //! Number of support points in each dimension 
     31    ivec gridsizes; 
     32    //! dimension 
     33    int dim; 
     34    //! Number of data points 
     35    int Npoints; 
     36    //! active vector for first_vec and next_vec 
     37    vec actvec; 
     38    //! indices of active vector 
     39    vec actvec_ind; 
     40    //! length of steps in each dimension 
     41    vec steps; 
    4242public: 
    43         //! default constructor 
    44         rectangular_support() : dim ( 0 ), Npoints ( 0 ) { 
    45         } 
     43    //! default constructor 
     44    rectangular_support() : dim ( 0 ), Npoints ( 0 ) { 
     45    } 
    4646 
    47         //! set parameters 
    48         void set_parameters ( const Array<vec> &ranges0, const ivec &gridsize0 ); 
     47    //! set parameters 
     48    void set_parameters ( const Array<vec> &ranges0, const ivec &gridsize0 ); 
    4949 
    50         //! Internal functio to set temporaries correctly 
    51         void initialize(); 
     50    //! Internal functio to set temporaries correctly 
     51    void initialize(); 
    5252 
    53         //! return vector at position given by vector of indices 
    54         vec get_vec ( const ivec &inds ); 
     53    //! return vector at position given by vector of indices 
     54    vec get_vec ( const ivec &inds ); 
    5555 
    56         //! convert dimension indices into linear index, the indexing is in the same way as in \c next_vec() 
    57         long linear_index ( const ivec inds ); 
     56    //! convert dimension indices into linear index, the indexing is in the same way as in \c next_vec() 
     57    long linear_index ( const ivec inds ); 
    5858 
    59         //! set the first vector to corner and store result in actvec 
    60         const vec& first_vec(); 
     59    //! set the first vector to corner and store result in actvec 
     60    const vec& first_vec(); 
    6161 
    62         //! Get next active vector, call ONLY after first_vector()! 
    63         const vec& next_vec(); 
     62    //! Get next active vector, call ONLY after first_vector()! 
     63    const vec& next_vec(); 
    6464 
    65         //! return active vector, call ONLY after first_vector()! 
    66         const vec& act_vec() { 
    67                 return actvec; 
    68         }; 
     65    //! return active vector, call ONLY after first_vector()! 
     66    const vec& act_vec() { 
     67        return actvec; 
     68    }; 
    6969 
    70         //! \todo to je asi navic .. v predkovi! 
    71         ivec nearest_point ( const vec &val ); 
     70    //! \todo to je asi navic .. v predkovi! 
     71    ivec nearest_point ( const vec &val ); 
    7272 
    73         //! Access function 
    74         int points() const { 
    75                 return Npoints; 
    76         } 
     73    //! Access function 
     74    int points() const { 
     75        return Npoints; 
     76    } 
    7777 
    78         //! access function 
    79         //! \todo opet pouze do potomka.. 
    80         const vec& _steps() const { 
    81                 return steps; 
    82         } 
     78    //! access function 
     79    //! \todo opet pouze do potomka.. 
     80    const vec& _steps() const { 
     81        return steps; 
     82    } 
    8383 
    84         void from_setting ( const Setting &set ); 
     84    void from_setting ( const Setting &set ); 
    8585}; 
    8686UIREGISTER ( rectangular_support ); 
     
    8989class discrete_support: public root { 
    9090protected: 
    91         //! storage of support points 
    92         Array<vec> Spoints; 
    93         //! index in iterators 
    94         int idx; 
     91    //! storage of support points 
     92    Array<vec> Spoints; 
     93    //! index in iterators 
     94    int idx; 
    9595public: 
    96         //! Default constructor 
    97         discrete_support() : Spoints ( 0 ), idx ( 0 ) {} 
    98         //! Access function 
    99         int points() const { 
    100                 return Spoints.length(); 
    101         } 
    102         //! set the first vector to corner and store result in actvec 
    103         const vec& first_vec() { 
    104                 bdm_assert_debug ( Spoints.length() > 0, "Empty support" ); 
    105                 idx = 0; 
    106                 return Spoints ( idx ); 
    107         } 
    108         //! set next vector after calling first_vec() 
    109         const vec& next_vec() { 
    110                 bdm_assert_debug ( Spoints.length() > idx - 1, "Out of support points" ); 
    111                 return Spoints ( ++idx ); 
    112         } 
     96    //! Default constructor 
     97    discrete_support() : Spoints ( 0 ), idx ( 0 ) {} 
     98    //! Access function 
     99    int points() const { 
     100        return Spoints.length(); 
     101    } 
     102    //! set the first vector to corner and store result in actvec 
     103    const vec& first_vec() { 
     104        bdm_assert_debug ( Spoints.length() > 0, "Empty support" ); 
     105        idx = 0; 
     106        return Spoints ( idx ); 
     107    } 
     108    //! set next vector after calling first_vec() 
     109    const vec& next_vec() { 
     110        bdm_assert_debug ( Spoints.length() > idx - 1, "Out of support points" ); 
     111        return Spoints ( ++idx ); 
     112    } 
    113113 
    114         /*! 
    115         \code 
    116           class = "discrete_support"; 
    117           points = ( [1,2..], [2,2..], ...); // list of points 
    118            === OR === 
    119           epdf = {class="epdf_offspring",...}; // epdf rfom which to sample 
    120           npoints = 100;                     // number of samples 
    121         \endcode 
    122         */ 
    123         void from_setting ( const Setting &set ); 
     114    /*! 
     115    \code 
     116      class = "discrete_support"; 
     117      points = ( [1,2..], [2,2..], ...); // list of points 
     118       === OR === 
     119      epdf = {class="epdf_offspring",...}; // epdf rfom which to sample 
     120      npoints = 100;                     // number of samples 
     121    \endcode 
     122    */ 
     123    void from_setting ( const Setting &set ); 
    124124 
    125         //! access function 
    126         Array<vec> & _Spoints() { 
    127                 return Spoints; 
    128         } 
     125    //! access function 
     126    Array<vec> & _Spoints() { 
     127        return Spoints; 
     128    } 
    129129}; 
    130130UIREGISTER ( discrete_support ); 
     
    133133class grid_fnc: public fnc { 
    134134protected: 
    135         //! grid - function support 
    136         rectangular_support sup; 
    137         //! function values on the grid 
    138         vec values; 
     135    //! grid - function support 
     136    rectangular_support sup; 
     137    //! function values on the grid 
     138    vec values; 
    139139public: 
    140         //! constructor function 
    141         void set_support ( rectangular_support &sup0 ) { 
    142                 sup = sup0; 
    143                 values = zeros ( sup.points() ); 
    144         } 
    145         //! constructor function fills values by calling function \c f , double f(vec&), given by a pointer 
    146         void set_values ( double ( *evalptr ) ( const vec& ) ); 
     140    //! constructor function 
     141    void set_support ( rectangular_support &sup0 ) { 
     142        sup = sup0; 
     143        values = zeros ( sup.points() ); 
     144    } 
     145    //! constructor function fills values by calling function \c f , double f(vec&), given by a pointer 
     146    void set_values ( double ( *evalptr ) ( const vec& ) ); 
    147147 
    148         //! constructor function fills values by calling function \c f , double f(vec&), given by a pointer 
    149         void set_values ( const epdf &ep ); 
     148    //! constructor function fills values by calling function \c f , double f(vec&), given by a pointer 
     149    void set_values ( const epdf &ep ); 
    150150 
    151         //! get value nearest to the given point 
    152         double nearest_val ( const vec &val ) { 
    153                 return values ( sup.linear_index ( sup.nearest_point ( val ) ) ); 
    154         } 
     151    //! get value nearest to the given point 
     152    double nearest_val ( const vec &val ) { 
     153        return values ( sup.linear_index ( sup.nearest_point ( val ) ) ); 
     154    } 
    155155 
    156         vec eval ( const vec &val ) { 
    157                 return vec_1 ( nearest_val ( val ) ); 
    158         } 
    159         const vec & _values() const { 
    160                 return values; 
    161         } 
     156    vec eval ( const vec &val ) { 
     157        return vec_1 ( nearest_val ( val ) ); 
     158    } 
     159    const vec & _values() const { 
     160        return values; 
     161    } 
    162162}; 
    163163UIREGISTER ( grid_fnc ); 
     
    168168class egrid: public epdf { 
    169169protected: 
    170         //! support of the pdf - grid 
    171         rectangular_support sup; 
    172         //! values at the grid 
    173         vec values; 
     170    //! support of the pdf - grid 
     171    rectangular_support sup; 
     172    //! values at the grid 
     173    vec values; 
    174174public: 
    175         //! we assume that evallog is not called too often otherwise we should cache log(values) 
    176         double evallog ( const vec &val ) { 
    177                 return log ( values ( sup.linear_index ( sup.nearest_point ( val ) ) ) ); 
    178         } 
     175    //! we assume that evallog is not called too often otherwise we should cache log(values) 
     176    double evallog ( const vec &val ) { 
     177        return log ( values ( sup.linear_index ( sup.nearest_point ( val ) ) ) ); 
     178    } 
    179179 
    180180};