Ignore:
Timestamp:
Feb 6, 2008, 8:30:03 PM (14 years ago)
Author:
Peter
Message:

fixing #128 - iterators in Averger classes

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/yat/statistics/AveragerPairWeighted.h

    r1009 r1043  
    7373    void  add(const double x, const double y,
    7474              const double wx, const double wy);
    75 
    76     ///
    77     /// Adding two sequences of data @a x and @a y. The data
    78     /// should be paired so \f$ x(i) \f$ is associated to \f$ y(i) \f$
    79     /// @a x will be treated as having all weights equal to unity
    80     ///
    81     void add(const classifier::DataLookup1D& x,
    82              const classifier::DataLookupWeighted1D& y);
    83 
    84     ///
    85     /// Adding two sequences of data @a x and @a y. The data should be
    86     /// paired so \f$ x(i) \f$ is associated to \f$ y(i) \f$
    87     /// @a y will be treated as having all weights equal to unity
    88     ///
    89     void add(const classifier::DataLookupWeighted1D& x,
    90              const classifier::DataLookup1D& y);
    91 
    92     ///
    93     /// Adding two sequences of weighted data @a x and @a y. The data
    94     /// should be paired so \f$ x(i) \f$ is associated to \f$ y(i) \f$
    95     ///
    96     void add(const classifier::DataLookupWeighted1D& x,
    97              const classifier::DataLookupWeighted1D& y);
    98 
    99     ///
    100     /// Adding pair of data and corresponding pair of weights in arrays
    101     ///
    102     ///
    103     /// The requirements for the types T1, T2, T3 and T4 of the arrays
    104     /// are: operator[] returning an element and function /// size()
    105     /// returning the number of elements.
    106     ///
    107     template <typename T1,typename T2,typename T3,typename T4>
    108     void add_values(const T1& x,
    109                     const T2& y,
    110                     const T3& wx,
    111                     const T4& wy);
    11275
    11376    ///
     
    194157
    195158
    196   template <typename T1,typename T2,typename T3,typename T4>
    197   void  AveragerPairWeighted::add_values(const T1& x,
    198                                          const T2& y,
    199                                          const T3& wx,
    200                                          const T4& wy)
     159  /**
     160     \brief adding four ranges of values to AveragerPairWeighted \a ap
     161   */
     162  template <class Iter1, class Iter2, class Iter3, class Iter4>
     163  void add(AveragerPairWeighted& ap, Iter1 x, Iter1 xlast, Iter2 y, Iter3 wx,
     164           Iter4 wy)
    201165  {
    202     for (size_t i=0; i<x.size(); ++i){
    203       utility::yat_assert<std::runtime_error>(!std::isnan(x(i)));
    204       add(x[i],y[i],wx[i],wy[i]);
     166    utility::check_iterator_is_unweighted(x);
     167    utility::check_iterator_is_unweighted(y);
     168    utility::check_iterator_is_unweighted(wx);
     169    utility::check_iterator_is_unweighted(wy);
     170    while (x!=xlast) {
     171      ap.add(*x, *y, *wx, *wy);
     172      ++x;
     173      ++y;
     174      ++wx;
     175      ++wy;
    205176    }
    206177  }
     178
    207179
    208180}}} // of namespace statistics, yat, and theplu
Note: See TracChangeset for help on using the changeset viewer.