Changeset 1271 for trunk/yat/utility


Ignore:
Timestamp:
Apr 9, 2008, 6:11:07 PM (13 years ago)
Author:
Peter
Message:

replaced u_int with unsigned int or size_t

Location:
trunk/yat/utility
Files:
9 edited

Legend:

Unmodified
Added
Removed
  • trunk/yat/utility/Matrix.cc

    r1260 r1271  
    3737#include <vector>
    3838
    39 #include <sys/types.h>
    40 
    4139#include <gsl/gsl_blas.h>
    4240
     
    7876    // expandable)
    7977    std::vector<std::vector<double> > data_matrix;
    80     u_int nof_columns=0;
    81     u_int nof_rows = 0;
     78    unsigned int nof_columns=0;
     79    unsigned int nof_rows = 0;
    8280    std::string line;
    8381    while(getline(is, line, '\n')){
     
    140138    // if gsl error handler disabled, out of bounds index will not
    141139    // abort the program.
    142     for(u_int i=0;i<nof_rows;i++)
    143       for(u_int j=0;j<nof_columns;j++)
     140    for(size_t i=0;i<nof_rows;i++)
     141      for(size_t j=0;j<nof_columns;j++)
    144142        gsl_matrix_set( m_, i, j, data_matrix[i][j] );
    145143  }
  • trunk/yat/utility/NNI.cc

    r1121 r1271  
    3939  // documentation.
    4040  NNI::NNI(const utility::Matrix& matrix,const utility::Matrix& weight,
    41            const u_int neighbours)
     41           const unsigned int neighbours)
    4242    : data_(matrix), imputed_data_(matrix), neighbours_(neighbours),
    4343      weight_(weight)
     
    4949  //                {\sum_{k=l,C} w_{ik} w_{jk} }
    5050  // where C is the number of columns
    51   std::vector<std::pair<u_int,double> >
    52   NNI::calculate_distances(const u_int row) const
     51  std::vector<std::pair<size_t,double> >
     52  NNI::calculate_distances(const size_t row) const
    5353  {
    54     std::vector<std::pair<u_int,double> > distance;
     54    std::vector<std::pair<size_t,double> > distance;
    5555    for (size_t i=0; i<data_.rows(); i++)
    5656      if (i!=row) {
    5757        double contribs=0;
    58         std::pair<u_int,double> this_distance(i,0.0);
     58        std::pair<size_t,double> this_distance(i,0.0);
    5959        for (size_t j=0; j<data_.columns(); j++)
    6060          // 0 contribution for missing values
     
    9090  // number, and neighbours are disqualified if their element (column)
    9191  // weight is zero
    92   std::vector<u_int>
    93   NNI::nearest_neighbours(const u_int column,
    94                           const std::vector<std::pair<u_int,double> >& d) const
     92  std::vector<size_t>
     93  NNI::nearest_neighbours(const size_t column,
     94                          const std::vector<std::pair<size_t,double> >& d) const
    9595  {
    96     std::vector<u_int> index;
     96    std::vector<size_t> index;
    9797    double contribs=0;
    98     for (u_int i=0; ((i<d.size()) &&
     98    for (size_t i=0; ((i<d.size()) &&
    9999                     (contribs+=weight_(d[i].first,column))<=neighbours_); i++)
    100100      if (weight_(d[i].first,column))
  • trunk/yat/utility/NNI.h

    r1260 r1271  
    3333#include <utility>
    3434#include <vector>
    35 
    36 #include <sys/types.h>
    3735
    3836namespace theplu {
     
    9290    ///
    9391    NNI(const utility::Matrix& matrix,const utility::Matrix& weight,
    94         const u_int neighbours);
     92        const unsigned int neighbours);
    9593
    9694    virtual ~NNI(void) {};
     
    10199    /// @return number of rows not imputed
    102100    ///
    103     virtual u_int estimate(void)=0;
     101    virtual unsigned int estimate(void)=0;
    104102
    105103    ///
     
    118116       }{\sum_{k=l}^C w_{ik} w_{jk} } \f$ where C is the number of columns
    119117    */
    120     std::vector<std::pair<u_int,double> > calculate_distances(const u_int) const;
     118    std::vector<std::pair<size_t,double> >
     119    calculate_distances(const size_t) const;
    121120    /// Contributing nearest neighbours are added up to the user set
    122121    /// number, and neighbours are disqualified if their element
    123122    /// (column) weight is zero
    124     std::vector<u_int> nearest_neighbours(const u_int,
    125                              const std::vector<std::pair<u_int,double> >&) const;
     123    std::vector<size_t>
     124    nearest_neighbours(const size_t,
     125                       const std::vector<std::pair<size_t,double> >&) const;
    126126    ///
    127127    /// original data matrix
     
    137137    /// number of neighbor to use
    138138    ///
    139     u_int neighbours_;
     139    unsigned int neighbours_;
    140140
    141141    ///
  • trunk/yat/utility/SmartPtr.h

    r1260 r1271  
    2626
    2727#include "yat_assert.h"
    28 
    29 // debug
    30 #include <iostream>
    31 
    32 #include <sys/types.h>
    3328
    3429namespace theplu {
     
    7469    {
    7570      if (owner)
    76         ref_count_ = new u_int(1);
     71        ref_count_ = new unsigned int(1);
    7772      else
    7873        ref_count_ = NULL;
     
    134129  private:
    135130    T* pointee_;
    136     u_int* ref_count_;
     131    unsigned int* ref_count_;
    137132
    138133    void detach(void)
  • trunk/yat/utility/Vector.cc

    r1268 r1271  
    2727#include "Vector.h"
    2828#include "utility.h"
    29 #include "yat/random/random.h"
    3029
    3130#include <algorithm>
     
    8079    // expandable)
    8180    std::vector<std::vector<double> > data_matrix;
    82     u_int nof_columns=0;
    83     u_int nof_rows=0;
     81    unsigned int nof_columns=0;
     82    unsigned int nof_rows=0;
    8483    std::string line;
    8584    while(getline(is, line, '\n')) {
  • trunk/yat/utility/WeNNI.cc

    r1121 r1271  
    3838
    3939  WeNNI::WeNNI(const utility::Matrix& matrix,const utility::Matrix& flag,
    40                const u_int neighbours)
     40               const unsigned int neighbours)
    4141    : NNI(matrix,flag,neighbours), imputed_data_raw_(matrix)
    4242  {
     
    5050  // where N is defined in the paper cited in the NNI class definition
    5151  // documentation.
    52   u_int WeNNI::estimate(void)
     52  unsigned int WeNNI::estimate(void)
    5353  {
    54     for (unsigned int i=0; i<data_.rows(); i++) {
    55       std::vector<std::pair<u_int,double> > distance(calculate_distances(i));
     54    for (size_t i=0; i<data_.rows(); i++) {
     55      std::vector<std::pair<size_t,double> > distance(calculate_distances(i));
    5656      std::sort(distance.begin(),distance.end(),
    57                 pair_value_compare<u_int,double>());
     57                pair_value_compare<size_t,double>());
    5858      bool row_imputed=true;
    59       for (unsigned int j=0; j<data_.columns(); j++) {
    60         std::vector<u_int> knn=nearest_neighbours(j,distance);
     59      for (size_t j=0; j<data_.columns(); j++) {
     60        std::vector<size_t> knn=nearest_neighbours(j,distance);
    6161        double new_value=0.0;
    6262        double norm=0.0;
    63         for (std::vector<u_int>::const_iterator k=knn.begin(); k!=knn.end();
     63        for (std::vector<size_t>::const_iterator k=knn.begin(); k!=knn.end();
    6464             ++k) {
    6565          // Avoid division with zero (perfect match vectors)
  • trunk/yat/utility/WeNNI.h

    r1121 r1271  
    5555    ///
    5656    WeNNI(const utility::Matrix& matrix,const utility::Matrix& weight,
    57           const u_int neighbours);
     57          const unsigned int neighbours);
    5858
    5959    ///
     
    6262    /// value.
    6363    ///
    64     u_int estimate(void);
     64    unsigned int estimate(void);
    6565
    6666    ///
  • trunk/yat/utility/kNNI.cc

    r1121 r1271  
    3737
    3838  kNNI::kNNI(const utility::Matrix& matrix,const utility::Matrix& flag,
    39              const u_int neighbours)
     39             const unsigned int neighbours)
    4040    : NNI(matrix,flag,neighbours)
    4141  {
     
    5555  // where N is defined in the paper cited in the NNI class definition
    5656  // documentation.
    57   u_int kNNI::estimate(void)
     57  unsigned int kNNI::estimate(void)
    5858  {
    59     for (unsigned int i=0; i<mv_rows_.size(); i++) {
    60       std::vector<std::pair<u_int,double> >
     59    for (size_t i=0; i<mv_rows_.size(); i++) {
     60      std::vector<std::pair<size_t,double> >
    6161        distance(calculate_distances(mv_rows_[i]));
    6262      std::sort(distance.begin(),distance.end(),
    63                 pair_value_compare<u_int,double>());
    64       for (unsigned int j=0; j<data_.columns(); j++)
     63                pair_value_compare<size_t,double>());
     64      for (size_t j=0; j<data_.columns(); j++)
    6565        if (!weight_(mv_rows_[i],j)) {
    66           std::vector<u_int> knn=nearest_neighbours(j,distance);
     66          std::vector<size_t> knn=nearest_neighbours(j,distance);
    6767          double new_value=0.0;
    6868          double norm=0.0;
    69           for (std::vector<u_int>::const_iterator k=knn.begin(); k!=knn.end();
     69          for (std::vector<size_t>::const_iterator k=knn.begin(); k!=knn.end();
    7070               ++k) {
    7171            // Avoid division with zero (perfect match vectors)
  • trunk/yat/utility/kNNI.h

    r1121 r1271  
    5656    ///
    5757    kNNI(const utility::Matrix& matrix,const utility::Matrix& weight,
    58          const u_int neighbours);
     58         const unsigned int neighbours);
    5959
    6060    ///
     
    6363    /// value.
    6464    ///
    65     u_int estimate(void);
     65    unsigned int estimate(void);
    6666
    6767  private:
    68     std::vector<u_int> mv_rows_;  // index to rows that have values to estimate
     68    std::vector<size_t> mv_rows_; // index to rows that have values to estimate
    6969  };
    7070
Note: See TracChangeset for help on using the changeset viewer.