Changeset 1382 for trunk/yat


Ignore:
Timestamp:
Jul 17, 2008, 4:32:16 PM (13 years ago)
Author:
Peter
Message:

fixing problems with MatrixWeighted? iterators

Location:
trunk/yat/utility
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/yat/utility/DataWeight.h

    r1380 r1382  
    2424  02111-1307, USA.
    2525*/
    26 
    27 #include "iterator_traits.h"
    28 
    29 #include <vector>
    3026
    3127namespace theplu {
     
    117113
    118114
    119   /**
    120      Specialization for std::vector<DataWeight>::iterator
    121    */
    122   template<>
    123   struct weighted_iterator_traits<std::vector<DataWeight>::iterator> {
    124     /**
    125        iterator to vector<DataWeight> is weighted
    126     */
    127     typedef weighted_iterator_tag type;
    128   };
    129 
    130 
    131   /**
    132      Specialization for std::vector<DataWeight>::const_iterator
    133    */
    134   template<>
    135   struct weighted_iterator_traits<std::vector<DataWeight>::const_iterator> {
    136     /**
    137        const_iterator to vector<DataWeight> is weighted
    138     */
    139     typedef weighted_iterator_tag type;
    140   };
    141 
    142115}}} // of namespace utility, yat, and theplu
    143116
  • trunk/yat/utility/MatrixWeighted.cc

    r1381 r1382  
    6262    columns_ = data.columns();
    6363    resize(data.columns(), data.rows());
    64     // FIXME
    65     //std::copy(data.begin(), data.end(), make_data_iterator(vec_.begin()));
    66     //std::copy(weight.begin(), weight.end(), make_weight_iterator(vec_.begin()));
     64    std::copy(data.begin(), data.end(), make_data_iterator(vec_.begin()));
     65    std::copy(weight.begin(), weight.end(), make_weight_iterator(vec_.begin()));
    6766  }
    6867
  • trunk/yat/utility/iterator_traits.h

    r1373 r1382  
    2626*/
    2727
     28#include "DataWeight.h"
     29
    2830#include <iterator>
     31#include <vector>
    2932
    3033namespace theplu {
     
    6063    typedef unweighted_iterator_tag type;
    6164  };
     65
     66  /**
     67     Specialization for std::vector<DataWeight>::iterator
     68   */
     69  template<>
     70  struct weighted_iterator_traits<std::vector<DataWeight>::iterator> {
     71    /**
     72       iterator to vector<DataWeight> is weighted
     73    */
     74    typedef weighted_iterator_tag type;
     75  };
     76
     77
     78  /**
     79     Specialization for std::vector<DataWeight>::const_iterator
     80   */
     81  template<>
     82  struct weighted_iterator_traits<std::vector<DataWeight>::const_iterator> {
     83    /**
     84       const_iterator to vector<DataWeight> is weighted
     85    */
     86    typedef weighted_iterator_tag type;
     87  };
     88
    6289
    6390  /**
     
    175202  };
    176203
     204
     205  /**
     206     Specialization for std::vector<DataWeight>::iterator
     207   */
     208  template <>
     209  struct iterator_traits<std::vector<DataWeight>::iterator> {
     210    /**
     211       mutable iterator
     212     */
     213    typedef double& data_reference;
     214
     215    /**
     216       mutable iterator
     217     */
     218    typedef double& weight_reference;
     219
     220    /**
     221       \return data using DataWeight::data()
     222    */
     223    data_reference data(std::vector<DataWeight>::iterator iter) const
     224    { return iter->data(); }
     225
     226    /**
     227       \return weight using DataWeight::weight()
     228    */
     229    weight_reference weight(std::vector<DataWeight>::iterator iter) const
     230    { return iter->weight(); }
     231
     232  };
     233
     234
     235  /**
     236     Specialization for std::vector<DataWeight>::const_iterator
     237   */
     238  template <>
     239  struct iterator_traits<std::vector<DataWeight>::const_iterator> {
     240    /**
     241       const iterator
     242     */
     243    typedef const double& data_reference;
     244
     245    /**
     246       const iterator
     247     */
     248    typedef const double& weight_reference;
     249
     250    /**
     251       \return data using DataWeight::data()
     252    */
     253    data_reference data(std::vector<DataWeight>::iterator iter) const
     254    { return iter->data(); }
     255
     256    /**
     257       \return weight using DataWeight::weight()
     258    */
     259    weight_reference weight(std::vector<DataWeight>::iterator iter) const
     260    { return iter->weight(); }
     261
     262  };
     263
    177264}}} // of namespace utility, yat, and theplu
    178265
Note: See TracChangeset for help on using the changeset viewer.