Changeset 1271
- Timestamp:
- Apr 9, 2008, 6:11:07 PM (15 years ago)
- Location:
- trunk/yat
- Files:
-
- 32 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/yat/classifier/IGP.h
r1158 r1271 116 116 igp_ = utility::Vector(target_.nof_classes()); 117 117 118 for( u_int i=0; i<target_.size(); i++) {119 u_int neighbor=i;118 for(size_t i=0; i<target_.size(); i++) { 119 size_t neighbor=i; 120 120 double mindist=std::numeric_limits<double>::max(); 121 121 const DataLookup1D a(matrix_,i,false); 122 for( u_int j=0; j<target_.size(); j++) {122 for(size_t j=0; j<target_.size(); j++) { 123 123 DataLookup1D b(matrix_,j,false); 124 124 double dist=distance_(a.begin, a.end(), b.begin()); … … 132 132 133 133 } 134 for( u_int i=0; i<target_.nof_classes(); i++) {134 for(size_t i=0; i<target_.nof_classes(); i++) { 135 135 igp_(i)/=static_cast<double>(target_.size(i)); 136 136 } -
trunk/yat/classifier/KNN.h
r1189 r1271 96 96 \return The number of neighbors. 97 97 */ 98 u _int k() const;98 unsigned int k() const; 99 99 100 100 /** … … 103 103 Sets the number of neighbors to \a k_in. 104 104 */ 105 void k(u _int k_in);105 void k(unsigned int k_in); 106 106 107 107 … … 166 166 167 167 // The number of neighbors 168 u _int k_;168 unsigned int k_; 169 169 170 170 Distance distance_; … … 240 240 241 241 template <typename Distance, typename NeighborWeighting> 242 u _int KNN<Distance, NeighborWeighting>::k() const242 unsigned int KNN<Distance, NeighborWeighting>::k() const 243 243 { 244 244 return k_; … … 246 246 247 247 template <typename Distance, typename NeighborWeighting> 248 void KNN<Distance, NeighborWeighting>::k(u _intk)248 void KNN<Distance, NeighborWeighting>::k(unsigned k) 249 249 { 250 250 k_=k; -
trunk/yat/classifier/Kernel.cc
r1168 r1271 42 42 { 43 43 if (own) 44 ref_count_ = new u _int(1);44 ref_count_ = new unsigned int(1); 45 45 else 46 46 ref_count_ = NULL; … … 53 53 { 54 54 if (own){ 55 ref_count_w_ = new u _int(1);55 ref_count_w_ = new unsigned int(1); 56 56 } 57 57 else { … … 68 68 if (other.weighted()){ 69 69 mlw_ = new MatrixLookupWeighted(*other.mlw_, utility::Index(index),true); 70 ref_count_w_ = new u _int(1);70 ref_count_w_ = new unsigned int(1); 71 71 ml_=NULL; 72 72 ref_count_ = NULL; … … 74 74 else{ 75 75 ml_ = new MatrixLookup(*other.ml_, utility::Index(index),true); 76 ref_count_ = new u _int(1);76 ref_count_ = new unsigned int(1); 77 77 mlw_=NULL; 78 78 ref_count_w_ = NULL; -
trunk/yat/classifier/Kernel.h
r1260 r1271 30 30 #include "KernelFunction.h" 31 31 32 #include <c ctype>32 #include <cstddef> 33 33 #include <vector> 34 35 #include <sys/types.h>36 34 37 35 namespace theplu { … … 183 181 /// (data_). NULL if this is not an owner. 184 182 /// 185 u _int* ref_count_;183 unsigned int* ref_count_; 186 184 187 185 /// … … 189 187 /// (data_w_). NULL if this is not an owner. 190 188 /// 191 u _int* ref_count_w_;189 unsigned int* ref_count_w_; 192 190 193 191 private: -
trunk/yat/classifier/SupervisedClassifier.h
r1188 r1271 27 27 */ 28 28 29 #include < stddef.h>29 #include <cstddef> 30 30 31 31 namespace theplu { -
trunk/yat/classifier/utility.cc
r1120 r1271 36 36 { 37 37 vector = utility::Vector(lookup.size()); 38 for( u_int i=0; i<lookup.size(); i++)38 for(size_t i=0; i<lookup.size(); i++) 39 39 vector(i)=lookup(i); 40 40 } … … 46 46 value = utility::Vector(lookup.size()); 47 47 weight = utility::Vector(lookup.size()); 48 for( u_int i=0; i<lookup.size(); i++){48 for(size_t i=0; i<lookup.size(); i++){ 49 49 value(i)=lookup.data(i); 50 50 weight(i)=lookup.weight(i); -
trunk/yat/random/random.cc
r1000 r1271 61 61 62 62 63 u _long RNG::max(void) const63 unsigned long RNG::max(void) const 64 64 { 65 65 return gsl_rng_max(rng_); … … 67 67 68 68 69 u _long RNG::min(void) const69 unsigned long RNG::min(void) const 70 70 { 71 71 return gsl_rng_min(rng_); … … 85 85 86 86 87 void RNG::seed(u _long s) const87 void RNG::seed(unsigned long s) const 88 88 { 89 89 gsl_rng_set(rng_,s); … … 91 91 92 92 93 u _long RNG::seed_from_devurandom(void)94 { 95 u _char ulongsize=sizeof(u_long);93 unsigned long RNG::seed_from_devurandom(void) 94 { 95 unsigned char ulongsize=sizeof(unsigned long); 96 96 char* buffer=new char[ulongsize]; 97 97 std::ifstream is("/dev/urandom"); 98 98 is.read(buffer,ulongsize); 99 99 is.close(); 100 u _long s=0;101 for (u _int i=0; i<ulongsize; i++) {102 u _char ch=buffer[i];100 unsigned long s=0; 101 for (unsigned int i=0; i<ulongsize; i++) { 102 unsigned char ch=buffer[i]; 103 103 s+=ch<<((ulongsize-1-i)*8); 104 104 } … … 146 146 147 147 148 void Discrete::seed(u _long s) const148 void Discrete::seed(unsigned long s) const 149 149 { 150 150 rng_->seed(s); 151 } 152 153 154 unsigned long Discrete::seed_from_devurandom(void) 155 { 156 return rng_->seed_from_devurandom(); 151 157 } 152 158 … … 172 178 173 179 174 u _long DiscreteGeneral::operator()(void) const180 unsigned long DiscreteGeneral::operator()(void) const 175 181 { 176 182 return gsl_ran_discrete(rng_->rng(), gen_); … … 178 184 179 185 180 DiscreteUniform::DiscreteUniform(u _long n)186 DiscreteUniform::DiscreteUniform(unsigned long n) 181 187 : range_(n) 182 188 { … … 189 195 190 196 191 u _long DiscreteUniform::operator()(void) const197 unsigned long DiscreteUniform::operator()(void) const 192 198 { 193 199 return (range_ ? … … 196 202 197 203 198 u _long DiscreteUniform::operator()(u_long n) const204 unsigned long DiscreteUniform::operator()(unsigned long n) const 199 205 { 200 206 // making sure that n is not larger than the range of the 201 207 // underlying RNG 202 208 if (n>rng_->max()) { 203 std::stringstream ss("DiscreteUniform::operator(u _long): ");209 std::stringstream ss("DiscreteUniform::operator(unsigned long): "); 204 210 ss << n << " is too large for RNG " << rng_->name(); 205 211 throw utility::GSL_error(ss.str()); … … 214 220 } 215 221 216 u _long Poisson::operator()(void) const222 unsigned long Poisson::operator()(void) const 217 223 { 218 224 return gsl_ran_poisson(rng_->rng(), m_); … … 220 226 221 227 222 u _long Poisson::operator()(const double m) const228 unsigned long Poisson::operator()(const double m) const 223 229 { 224 230 return gsl_ran_poisson(rng_->rng(), m); … … 238 244 239 245 240 void Continuous::seed(u _long s) const246 void Continuous::seed(unsigned long s) const 241 247 { 242 248 rng_->seed(s); -
trunk/yat/random/random.h
r1004 r1271 98 98 /// generator can return. 99 99 /// 100 u _long max(void) const;100 unsigned long max(void) const; 101 101 102 102 /// … … 104 104 /// generator can return. 105 105 /// 106 u _long min(void) const;106 unsigned long min(void) const; 107 107 108 108 /// … … 125 125 /// @see seed_from_devurandom 126 126 /// 127 void seed(u _long s) const;127 void seed(unsigned long s) const; 128 128 129 129 /// … … 132 132 /// @return The seed acquired from /dev/urandom. 133 133 /// 134 u _long seed_from_devurandom(void);134 unsigned long seed_from_devurandom(void); 135 135 136 136 /** … … 221 221 /// @see seed_from_devurandom, RNG::seed_from_devurandom, RNG::seed 222 222 /// 223 void seed(u _long s) const;223 void seed(unsigned long s) const; 224 224 225 225 /// … … 230 230 /// @see seed, RNG::seed_from_devurandom, RNG::seed 231 231 /// 232 u _long seed_from_devurandom(void) { return rng_->seed_from_devurandom(); }232 unsigned long seed_from_devurandom(void); 233 233 234 234 /// 235 235 /// @return A random number. 236 236 /// 237 virtual u _long operator()(void) const = 0;237 virtual unsigned long operator()(void) const = 0; 238 238 239 239 protected: … … 268 268 /// @return A random number. 269 269 /// 270 u _long operator()(void) const;270 unsigned long operator()(void) const; 271 271 272 272 private: … … 302 302 is thrown. 303 303 */ 304 DiscreteUniform(u _long n=0);304 DiscreteUniform(unsigned long n=0); 305 305 306 306 /** … … 311 311 created. 312 312 313 \see DiscreteUniform(const u _long n=0)313 \see DiscreteUniform(const unsigned long n=0) 314 314 */ 315 u _long operator()(void) const;315 unsigned long operator()(void) const; 316 316 317 317 /** … … 325 325 underlying generator. 326 326 */ 327 u _long operator()(u_long n) const;328 329 private: 330 u _long range_;327 unsigned long operator()(unsigned long n) const; 328 329 private: 330 unsigned long range_; 331 331 }; 332 332 … … 359 359 /// @return A Poisson distributed number. 360 360 /// 361 u _long operator()(void) const;361 unsigned long operator()(void) const; 362 362 363 363 /// … … 367 367 /// @note this operator ignores parameters set in Constructor 368 368 /// 369 u _long operator()(const double m) const;369 unsigned long operator()(const double m) const; 370 370 371 371 private: … … 403 403 /// @see seed_from_devurandom, RNG::seed_from_devurandom, RNG::seed 404 404 /// 405 void seed(u _long s) const;405 void seed(unsigned long s) const; 406 406 407 407 /// … … 412 412 /// @see seed, RNG::seed_from_devurandom, RNG::seed 413 413 /// 414 u _long seed_from_devurandom(void) { return rng_->seed_from_devurandom(); }414 unsigned long seed_from_devurandom(void) { return rng_->seed_from_devurandom(); } 415 415 416 416 /// -
trunk/yat/regression/OneDimensional.cc
r1000 r1271 53 53 54 54 std::ostream& OneDimensional::print(std::ostream& os, const double min, 55 double max, const u _int n) const55 double max, const unsigned int n) const 56 56 { 57 57 double dx; -
trunk/yat/regression/OneDimensional.h
r1019 r1271 106 106 /// 107 107 std::ostream& print(std::ostream& os,const double min, 108 double max, const u _int n) const;108 double max, const unsigned int n) const; 109 109 110 110 /** -
trunk/yat/regression/Polynomial.cc
r1121 r1271 55 55 utility::Matrix X=utility::Matrix(x.size(),power_+1,1); 56 56 for (size_t i=0; i<X.rows(); ++i) 57 for ( u_int j=1; j<X.columns(); j++)57 for (size_t j=1; j<X.columns(); ++j) 58 58 X(i,j)=X(i,j-1)*x(i); 59 59 md_.fit(X,y); -
trunk/yat/regression/PolynomialWeighted.cc
r1121 r1271 56 56 utility::Matrix X=utility::Matrix(x.size(),power_+1,1); 57 57 for (size_t i=0; i<X.rows(); ++i) 58 for ( u_int j=1; j<X.columns(); j++)58 for (size_t j=1; j<X.columns(); ++j) 59 59 X(i,j)=X(i,j-1)*x(i); 60 60 md_.fit(X,y,w); -
trunk/yat/statistics/Averager.cc
r1122 r1271 37 37 } 38 38 39 Averager::Averager(double x, double xx, u _long n)39 Averager::Averager(double x, double xx, unsigned long n) 40 40 : n_(n), x_(x), xx_(xx) 41 41 { … … 47 47 } 48 48 49 void Averager::add(double d, u _long n)49 void Averager::add(double d, unsigned long n) 50 50 { 51 51 assert(!std::isnan(d)); … … 65 65 } 66 66 67 u _long Averager::n(void) const67 unsigned long Averager::n(void) const 68 68 { 69 69 return n_; -
trunk/yat/statistics/Averager.h
r1186 r1271 30 30 31 31 #include <cmath> 32 #include <sys/types.h>33 32 34 33 namespace theplu{ … … 56 55 /// number of samples \a n. 57 56 /// 58 Averager(double x, double xx, u _long n);57 Averager(double x, double xx, unsigned long n); 59 58 60 59 /// … … 66 65 /// Adding \a n (default=1) number of data point(s) with value \a d. 67 66 /// 68 void add(double d, u _long n=1);67 void add(double d, unsigned long n=1); 69 68 70 69 /** … … 86 85 /// @return Number of data points 87 86 /// 88 u _long n(void) const;87 unsigned long n(void) const; 89 88 90 89 /// … … 179 178 180 179 private: 181 u _long n_;180 unsigned long n_; 182 181 double x_, xx_; 183 182 }; -
trunk/yat/statistics/Fisher.cc
r1000 r1271 72 72 73 73 74 u _int& Fisher::minimum_size(void)74 unsigned int& Fisher::minimum_size(void) 75 75 { 76 76 return minimum_size_; … … 78 78 79 79 80 const u _int& Fisher::minimum_size(void) const80 const unsigned int& Fisher::minimum_size(void) const 81 81 { 82 82 return minimum_size_; … … 84 84 85 85 86 double Fisher::oddsratio(const u _int a,87 const u _int b,88 const u _int c,89 const u _int d)86 double Fisher::oddsratio(const unsigned int a, 87 const unsigned int b, 88 const unsigned int c, 89 const unsigned int d) 90 90 { 91 91 // If a column sum or a row sum is zero, the table is nonsense -
trunk/yat/statistics/Fisher.h
r1000 r1271 28 28 29 29 #include "Score.h" 30 31 #include <sys/types.h>32 30 33 31 #include <cmath> … … 106 104 /// @return reference to minimum_size 107 105 /// 108 u _int& minimum_size(void);106 unsigned int& minimum_size(void); 109 107 110 108 /// … … 114 112 /// @return const reference to minimum_size 115 113 /// 116 const u _int& minimum_size(void) const;114 const unsigned int& minimum_size(void) const; 117 115 118 116 /// … … 150 148 is invalid if a row or column sum is zero. 151 149 */ 152 double oddsratio(const u _int a, const u_int b,153 const u _int c, const u_int d);150 double oddsratio(const unsigned a, const unsigned int b, 151 const unsigned int c, const unsigned int d); 154 152 155 153 private: … … 161 159 double p_value_exact(void) const; 162 160 163 u _int a_;164 u _int b_;165 u _int c_;166 u _int d_;167 u _int minimum_size_;161 unsigned int a_; 162 unsigned int b_; 163 unsigned int c_; 164 unsigned int d_; 165 unsigned int minimum_size_; 168 166 double oddsratio_; 169 167 }; -
trunk/yat/statistics/Histogram.cc
r1203 r1271 118 118 void Histogram::reset(void) 119 119 { 120 for ( u_int i=0; i<histogram_.size(); i++)120 for (size_t i=0; i<histogram_.size(); i++) 121 121 histogram_[i]=0; 122 122 sum_all_.reset(); … … 174 174 << "# column 2: frequency\n"; 175 175 176 for ( u_int i=0; i<histogram.nof_bins(); i++) {176 for (size_t i=0; i<histogram.nof_bins(); i++) { 177 177 s.width(12); 178 178 s << histogram.observation_value(i); -
trunk/yat/statistics/PearsonCorrelation.cc
r1145 r1271 42 42 { 43 43 return pearson_p_value(ap_.correlation(), 44 static_cast<u _int>(ap_.n()));44 static_cast<unsigned int>(ap_.n())); 45 45 } 46 46 -
trunk/yat/statistics/PearsonCorrelation.h
r1145 r1271 70 70 71 71 P-value is calculated using function pearson_p_value(double, 72 u _int) where degrees of freedom is calculated using n(void) in72 unsigned int) where degrees of freedom is calculated using n(void) in 73 73 AveragerPairWeighted. 74 74 -
trunk/yat/statistics/ROC.cc
r1120 r1271 103 103 } 104 104 105 u _int& ROC::minimum_size(void)105 unsigned int& ROC::minimum_size(void) 106 106 { 107 107 return minimum_size_; … … 109 109 110 110 111 const u _int& ROC::minimum_size(void) const111 const unsigned int& ROC::minimum_size(void) const 112 112 { 113 113 return minimum_size_; -
trunk/yat/statistics/ROC.h
r1260 r1271 32 32 #include <map> 33 33 #include <utility> 34 35 #include <sys/types.h>36 34 37 35 namespace theplu { … … 80 78 /// @return reference to minimum_size 81 79 /// 82 u _int& minimum_size(void);80 unsigned int& minimum_size(void); 83 81 84 82 /** … … 88 86 @return const reference to minimum_size 89 87 */ 90 const u _int& minimum_size(void) const;88 const unsigned int& minimum_size(void) const; 91 89 92 90 /// … … 144 142 145 143 double area_; 146 u _int minimum_size_;144 unsigned int minimum_size_; 147 145 double w_neg_; 148 146 double w_pos_; -
trunk/yat/statistics/utility.cc
r1145 r1271 37 37 namespace statistics { 38 38 39 double cdf_hypergeometric_P(u_int k, u_int n1, u_int n2, u_int t) 39 double cdf_hypergeometric_P(unsigned int k, unsigned int n1, 40 unsigned int n2, unsigned int t) 40 41 { 41 42 double p=0; 42 for ( u_int i=0; i<=k; i++)43 for (size_t i=0; i<=k; i++) 43 44 p+= gsl_ran_hypergeometric_pdf(i, n1, n2, t); 44 45 return p; … … 46 47 47 48 48 double pearson_p_value(double r, u _int n)49 double pearson_p_value(double r, unsigned int n) 49 50 { 50 51 assert(n>=2); 51 if (n< 2)52 if (n<=2) 52 53 return std::numeric_limits<double>::quiet_NaN(); 53 54 return gsl_cdf_tdist_Q(r*sqrt((n-2)/(1-r*r)), n-2); -
trunk/yat/statistics/utility.h
r1145 r1271 77 77 /// @return cumulative hypergeomtric distribution functions P(k). 78 78 /// 79 double cdf_hypergeometric_P(u_int k, u_int n1, u_int n2, u_int t); 79 double cdf_hypergeometric_P(unsigned int k, unsigned int n1, 80 unsigned int n2, unsigned int t); 80 81 81 82 … … 93 94 chance when having \a n samples. 94 95 */ 95 double pearson_p_value(double r, u _int n);96 double pearson_p_value(double r, unsigned int n); 96 97 97 98 /// -
trunk/yat/utility/Matrix.cc
r1260 r1271 37 37 #include <vector> 38 38 39 #include <sys/types.h>40 41 39 #include <gsl/gsl_blas.h> 42 40 … … 78 76 // expandable) 79 77 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; 82 80 std::string line; 83 81 while(getline(is, line, '\n')){ … … 140 138 // if gsl error handler disabled, out of bounds index will not 141 139 // 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++) 144 142 gsl_matrix_set( m_, i, j, data_matrix[i][j] ); 145 143 } -
trunk/yat/utility/NNI.cc
r1121 r1271 39 39 // documentation. 40 40 NNI::NNI(const utility::Matrix& matrix,const utility::Matrix& weight, 41 const u _int neighbours)41 const unsigned int neighbours) 42 42 : data_(matrix), imputed_data_(matrix), neighbours_(neighbours), 43 43 weight_(weight) … … 49 49 // {\sum_{k=l,C} w_{ik} w_{jk} } 50 50 // where C is the number of columns 51 std::vector<std::pair< u_int,double> >52 NNI::calculate_distances(const u_int row) const51 std::vector<std::pair<size_t,double> > 52 NNI::calculate_distances(const size_t row) const 53 53 { 54 std::vector<std::pair< u_int,double> > distance;54 std::vector<std::pair<size_t,double> > distance; 55 55 for (size_t i=0; i<data_.rows(); i++) 56 56 if (i!=row) { 57 57 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); 59 59 for (size_t j=0; j<data_.columns(); j++) 60 60 // 0 contribution for missing values … … 90 90 // number, and neighbours are disqualified if their element (column) 91 91 // 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) const92 std::vector<size_t> 93 NNI::nearest_neighbours(const size_t column, 94 const std::vector<std::pair<size_t,double> >& d) const 95 95 { 96 std::vector< u_int> index;96 std::vector<size_t> index; 97 97 double contribs=0; 98 for ( u_int i=0; ((i<d.size()) &&98 for (size_t i=0; ((i<d.size()) && 99 99 (contribs+=weight_(d[i].first,column))<=neighbours_); i++) 100 100 if (weight_(d[i].first,column)) -
trunk/yat/utility/NNI.h
r1260 r1271 33 33 #include <utility> 34 34 #include <vector> 35 36 #include <sys/types.h>37 35 38 36 namespace theplu { … … 92 90 /// 93 91 NNI(const utility::Matrix& matrix,const utility::Matrix& weight, 94 const u _int neighbours);92 const unsigned int neighbours); 95 93 96 94 virtual ~NNI(void) {}; … … 101 99 /// @return number of rows not imputed 102 100 /// 103 virtual u _int estimate(void)=0;101 virtual unsigned int estimate(void)=0; 104 102 105 103 /// … … 118 116 }{\sum_{k=l}^C w_{ik} w_{jk} } \f$ where C is the number of columns 119 117 */ 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; 121 120 /// Contributing nearest neighbours are added up to the user set 122 121 /// number, and neighbours are disqualified if their element 123 122 /// (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; 126 126 /// 127 127 /// original data matrix … … 137 137 /// number of neighbor to use 138 138 /// 139 u _int neighbours_;139 unsigned int neighbours_; 140 140 141 141 /// -
trunk/yat/utility/SmartPtr.h
r1260 r1271 26 26 27 27 #include "yat_assert.h" 28 29 // debug30 #include <iostream>31 32 #include <sys/types.h>33 28 34 29 namespace theplu { … … 74 69 { 75 70 if (owner) 76 ref_count_ = new u _int(1);71 ref_count_ = new unsigned int(1); 77 72 else 78 73 ref_count_ = NULL; … … 134 129 private: 135 130 T* pointee_; 136 u _int* ref_count_;131 unsigned int* ref_count_; 137 132 138 133 void detach(void) -
trunk/yat/utility/Vector.cc
r1268 r1271 27 27 #include "Vector.h" 28 28 #include "utility.h" 29 #include "yat/random/random.h"30 29 31 30 #include <algorithm> … … 80 79 // expandable) 81 80 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; 84 83 std::string line; 85 84 while(getline(is, line, '\n')) { -
trunk/yat/utility/WeNNI.cc
r1121 r1271 38 38 39 39 WeNNI::WeNNI(const utility::Matrix& matrix,const utility::Matrix& flag, 40 const u _int neighbours)40 const unsigned int neighbours) 41 41 : NNI(matrix,flag,neighbours), imputed_data_raw_(matrix) 42 42 { … … 50 50 // where N is defined in the paper cited in the NNI class definition 51 51 // documentation. 52 u _int WeNNI::estimate(void)52 unsigned int WeNNI::estimate(void) 53 53 { 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)); 56 56 std::sort(distance.begin(),distance.end(), 57 pair_value_compare< u_int,double>());57 pair_value_compare<size_t,double>()); 58 58 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); 61 61 double new_value=0.0; 62 62 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(); 64 64 ++k) { 65 65 // Avoid division with zero (perfect match vectors) -
trunk/yat/utility/WeNNI.h
r1121 r1271 55 55 /// 56 56 WeNNI(const utility::Matrix& matrix,const utility::Matrix& weight, 57 const u _int neighbours);57 const unsigned int neighbours); 58 58 59 59 /// … … 62 62 /// value. 63 63 /// 64 u _int estimate(void);64 unsigned int estimate(void); 65 65 66 66 /// -
trunk/yat/utility/kNNI.cc
r1121 r1271 37 37 38 38 kNNI::kNNI(const utility::Matrix& matrix,const utility::Matrix& flag, 39 const u _int neighbours)39 const unsigned int neighbours) 40 40 : NNI(matrix,flag,neighbours) 41 41 { … … 55 55 // where N is defined in the paper cited in the NNI class definition 56 56 // documentation. 57 u _int kNNI::estimate(void)57 unsigned int kNNI::estimate(void) 58 58 { 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> > 61 61 distance(calculate_distances(mv_rows_[i])); 62 62 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++) 65 65 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); 67 67 double new_value=0.0; 68 68 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(); 70 70 ++k) { 71 71 // Avoid division with zero (perfect match vectors) -
trunk/yat/utility/kNNI.h
r1121 r1271 56 56 /// 57 57 kNNI(const utility::Matrix& matrix,const utility::Matrix& weight, 58 const u _int neighbours);58 const unsigned int neighbours); 59 59 60 60 /// … … 63 63 /// value. 64 64 /// 65 u _int estimate(void);65 unsigned int estimate(void); 66 66 67 67 private: 68 std::vector< u_int> mv_rows_; // index to rows that have values to estimate68 std::vector<size_t> mv_rows_; // index to rows that have values to estimate 69 69 }; 70 70
Note: See TracChangeset
for help on using the changeset viewer.