Changeset 936
- Timestamp:
- Oct 6, 2007, 1:02:08 AM (16 years ago)
- Location:
- trunk/yat
- Files:
-
- 8 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/yat/classifier/IGP.h
r925 r936 34 34 #include <cmath> 35 35 #include <limits> 36 #include <stdexcept> 36 37 37 38 namespace theplu { … … 82 83 : matrix_(data), target_(target) 83 84 { 84 yat_assert(target_.size()==matrix_.columns());85 utility::yat_assert<std::runtime_error>(target_.size()==matrix_.columns()); 85 86 86 87 // Calculate IGP for each class -
trunk/yat/classifier/KNN.h
r931 r936 14 14 #include <cmath> 15 15 #include <map> 16 #include <stdexcept> 16 17 17 18 namespace theplu { … … 129 130 for(size_t j=0; j<input.columns(); j++) { 130 131 classifier::DataLookupWeighted1D test(*weighted_input,j,false); 131 yat_assert(training.size()==test.size()); 132 (*distances)(i,j)=statistics::vector_distance(training.begin(),training.end(),test.begin(),typename statistics::vector_distance_traits<Distance>::distance()); 133 yat_assert(!std::isnan((*distances)(i,j))); 132 utility::yat_assert<std::runtime_error>(training.size()==test.size()); 133 (*distances)(i,j) = 134 statistics::vector_distance(training.begin(),training.end(), 135 test.begin(), typename statistics::vector_distance_traits<Distance>::distance()); 136 utility::yat_assert<std::runtime_error>(!std::isnan((*distances)(i,j))); 134 137 } 135 138 } -
trunk/yat/classifier/NCC.h
r931 r936 50 50 #include <map> 51 51 #include <cmath> 52 52 #include <stdexcept> 53 53 54 54 namespace theplu { … … 234 234 for(size_t k=0; k<centroids_->columns();k++) { 235 235 DataLookup1D centroid(unweighted_centroids,k,false); 236 yat_assert(in.size()==centroid.size());236 utility::yat_assert<std::runtime_error>(in.size()==centroid.size()); 237 237 prediction(k,j)=statistics:: 238 238 vector_distance(in.begin(),in.end(),centroid.begin(), … … 252 252 for(size_t k=0; k<centroids_->columns();k++) { 253 253 DataLookupWeighted1D centroid(weighted_centroids,k,false); 254 yat_assert(in.size()==centroid.size());254 utility::yat_assert<std::runtime_error>(in.size()==centroid.size()); 255 255 prediction(k,j)=statistics:: 256 256 vector_distance(in.begin(),in.end(),centroid.begin(), … … 267 267 for(size_t k=0; k<centroids_->columns();k++) { 268 268 DataLookupWeighted1D centroid(weighted_centroids,k,false); 269 yat_assert(in.size()==centroid.size());269 utility::yat_assert<std::runtime_error>(in.size()==centroid.size()); 270 270 prediction(k,j)=statistics:: 271 271 vector_distance(in.begin(),in.end(),centroid.begin(), -
trunk/yat/statistics/AveragerPairWeighted.h
r916 r936 33 33 34 34 #include <cmath> 35 #include <stdexcept> 35 36 36 37 namespace theplu{ … … 200 201 { 201 202 for (size_t i=0; i<x.size(); ++i){ 202 yat_assert(!std::isnan(x[i]));203 utility::yat_assert<std::runtime_error>(!std::isnan(x[i])); 203 204 add(x[i],y[i],wx[i],wy[i]); 204 205 } -
trunk/yat/statistics/utility.h
r934 r936 35 35 #include <algorithm> 36 36 #include <cmath> 37 #include <stdexcept> 37 38 #include <vector> 38 39 … … 161 162 double percentile(T first, T last, double p, bool sorted=false) 162 163 { 163 yat_assert(first<last && "range is invalid"); 164 yat_assert(p>=0); 165 yat_assert(p<=100); 164 utility::yat_assert<std::range_error>(first<last); 165 utility::yat_assert<std::runtime_error>(p>=0, "percentage is negative"); 166 utility::yat_assert<std::runtime_error>(p<=100, 167 "percentage is larger than 100"); 166 168 if (sorted){ 167 169 if (p>=100) -
trunk/yat/utility/Iterator.h
r932 r936 29 29 #include <iterator> 30 30 #include <stddef.h> 31 #include <stdexcept> 31 32 32 33 namespace theplu { … … 65 66 */ 66 67 return_type operator*(void) const 67 { yat_assert (index_<container_->size());68 { yat_assert<std::out_of_range>(index_<container_->size()); 68 69 return container_->operator()(index_); } 69 70 … … 72 73 */ 73 74 return_type operator[](difference_type n) const 74 { yat_assert (index_+n < container_->size());75 { yat_assert<std::out_of_range>(index_+n < container_->size()); 75 76 return container_->operator()(index_+n); } 76 77 -
trunk/yat/utility/IteratorWeighted.h
r916 r936 8 8 #include <iterator> 9 9 #include <stddef.h> 10 #include <stdexcept> 10 11 11 12 namespace theplu { … … 45 46 return_type operator*(void) const 46 47 { 47 yat_assert (index_<container_->size());48 yat_assert<std::out_of_range>(index_<container_->size()); 48 49 return container_->operator()(index_); 49 50 } … … 53 54 */ 54 55 return_type data(void) const 55 { yat_assert(index_<container_->size()); return container_->data(index_); } 56 { yat_assert<std::out_of_range>(index_<container_->size()); 57 return container_->data(index_); } 56 58 57 59 /** … … 59 61 */ 60 62 return_type weight(void) const 61 { yat_assert(index_<container_->size());return container_->weight(index_); } 63 { yat_assert<std::out_of_range>(index_<container_->size()); 64 return container_->weight(index_); } 62 65 63 66 -
trunk/yat/utility/yat_assert.h
r921 r936 24 24 */ 25 25 26 #include <cassert> 26 #include <string> 27 28 namespace theplu { 29 namespace yat { 30 namespace utility { 31 32 template<class X> inline void yat_assert(bool assertion, std::string msg="") 27 33 #ifdef YAT_DEBUG 28 # define yat_assert(expr) (assert(expr)) 34 { if (YAT_DEBUG && !assertion) throw X(msg); } 29 35 #else 30 # define yat_assert(expr) 36 { } 31 37 #endif 32 38 39 }}} 40 /* 41 */ 33 42 #endif
Note: See TracChangeset
for help on using the changeset viewer.