Changeset 3545
 Timestamp:
 Dec 23, 2016, 8:53:15 AM (5 years ago)
 File:

 1 edited
Legend:
 Unmodified
 Added
 Removed

trunk/yat/normalizer/qQuantileNormalizer.h
r2263 r3545 138 138  \c RandomAccessIterator1's value type is convertible to 139 139 \c RandomAccessIterator2's value type 140  \c RandomAccessIterator2 is a model of \random_access_iterator 140  \c RandomAccessIterator2 is a model of \random_access_iterator 141 141  \c RandomAccessIterator2 is mutable. 142 142 … … 155 155 weight in a part is approximately W/Q where W is the total weight 156 156 (over all parts). The class calculates the average value in each 157 part and also the "quantile". 157 part and also the "quantile". 158 158 */ 159 159 class Partitioner … … 164 164 */ 165 165 template<typename ForwardIterator> 166 Partitioner(ForwardIterator first, ForwardIterator last, 166 Partitioner(ForwardIterator first, ForwardIterator last, 167 167 unsigned int N); 168 168 … … 179 179 smallest element in the part, and w_upper is the total weight 180 180 of elements smaller (or equal) than the largest value in the 181 part. 181 part. 182 182 183 183 In the unweighted case all weights are 1.0, which implies q_0 = … … 197 197 // unweighted "constructor" 198 198 template<typename ForwardIterator> 199 void build(ForwardIterator first, ForwardIterator last, unsigned int N, 199 void build(ForwardIterator first, ForwardIterator last, unsigned int N, 200 200 utility::unweighted_iterator_tag); 201 201 // weighted "constructor" 202 202 template<typename ForwardIterator> 203 void build(ForwardIterator first, ForwardIterator last, unsigned int N, 203 void build(ForwardIterator first, ForwardIterator last, unsigned int N, 204 204 utility::weighted_iterator_tag); 205 205 void init(const utility::VectorBase&, unsigned int N); … … 214 214 // unweighted version 215 215 template<typename RandomAccessIterator1, typename RandomAccessIterator2> 216 void normalize(const Partitioner& source,RandomAccessIterator1 first, 216 void normalize(const Partitioner& source,RandomAccessIterator1 first, 217 217 RandomAccessIterator1 last, RandomAccessIterator2 result, 218 218 utility::unweighted_iterator_tag tag) const; … … 220 220 // weighted version 221 221 template<typename RandomAccessIterator1, typename RandomAccessIterator2> 222 void normalize(const Partitioner& source,RandomAccessIterator1 first, 222 void normalize(const Partitioner& source,RandomAccessIterator1 first, 223 223 RandomAccessIterator1 last, RandomAccessIterator2 result, 224 224 utility::weighted_iterator_tag tag) const; … … 229 229 230 230 template<typename ForwardIterator> 231 qQuantileNormalizer::qQuantileNormalizer(ForwardIterator first, 231 qQuantileNormalizer::qQuantileNormalizer(ForwardIterator first, 232 232 ForwardIterator last, 233 233 unsigned int Q) … … 239 239 240 240 template<typename RandomAccessIterator1, typename RandomAccessIterator2> 241 void qQuantileNormalizer::operator()(RandomAccessIterator1 first, 241 void qQuantileNormalizer::operator()(RandomAccessIterator1 first, 242 242 RandomAccessIterator1 last, 243 243 RandomAccessIterator2 result) const … … 250 250 251 251 template<typename RandomAccessIterator1, typename RandomAccessIterator2> 252 void 252 void 253 253 qQuantileNormalizer::normalize(const qQuantileNormalizer::Partitioner& source, 254 RandomAccessIterator1 first, 255 RandomAccessIterator1 last, 254 RandomAccessIterator1 first, 255 RandomAccessIterator1 last, 256 256 RandomAccessIterator2 result, 257 257 utility::unweighted_iterator_tag tag) const … … 288 288 289 289 using utility::yat_assert; 290 290 291 291 // cspline interpolation for all data between the mid points of 292 292 // the first and last part … … 297 297 for ( size_t i=start; i<end; ++i) { 298 298 size_t si = sorted_index[i]; 299 299 300 300 YAT_ASSERT((i+0.5)/N>idx(0)); 301 301 result[si] = first[si]  cspline.evaluate((i+0.5)/N); 302 302 } 303 303 304 304 // linear extrapolation for last part, i.e., use last diff for 305 305 // all points in the last part. … … 313 313 template<typename RandomAccessIterator1, typename RandomAccessIterator2> 314 314 void qQuantileNormalizer::normalize(const Partitioner& source, 315 RandomAccessIterator1 first, 316 RandomAccessIterator1 last, 315 RandomAccessIterator1 first, 316 RandomAccessIterator1 last, 317 317 RandomAccessIterator2 result, 318 318 utility::weighted_iterator_tag tag) const … … 337 337 std::vector<double> vec; 338 338 vec.reserve(std::distance(first, last)); 339 std::copy(utility::data_iterator(first), utility::data_iterator(last), 339 std::copy(utility::data_iterator(first), utility::data_iterator(last), 340 340 std::back_inserter(vec)); 341 341 for (std::vector<double>::iterator i(vec.begin()); i!=vec.end(); ++i) … … 380 380 381 381 template<typename ForwardIterator> 382 qQuantileNormalizer::Partitioner::Partitioner(ForwardIterator first, 383 ForwardIterator last, 382 qQuantileNormalizer::Partitioner::Partitioner(ForwardIterator first, 383 ForwardIterator last, 384 384 unsigned int N) 385 385 : average_(utility::Vector(N)), quantiles_(utility::Vector(N)) … … 387 387 BOOST_CONCEPT_ASSERT((boost::ForwardIterator<ForwardIterator>)); 388 388 BOOST_CONCEPT_ASSERT((utility::DataIterator<ForwardIterator>)); 389 build(first, last, N, 389 build(first, last, N, 390 390 typename utility::weighted_iterator_traits<ForwardIterator>::type()); 391 391 } … … 393 393 394 394 template<typename ForwardIterator> 395 void qQuantileNormalizer::Partitioner::build(ForwardIterator first, 396 ForwardIterator last, 397 unsigned int N, 395 void qQuantileNormalizer::Partitioner::build(ForwardIterator first, 396 ForwardIterator last, 397 unsigned int N, 398 398 utility::unweighted_iterator_tag) 399 399 { … … 406 406 407 407 template<typename ForwardIterator> 408 void qQuantileNormalizer::Partitioner::build(ForwardIterator first, 409 ForwardIterator last, 410 unsigned int N, 408 void qQuantileNormalizer::Partitioner::build(ForwardIterator first, 409 ForwardIterator last, 410 unsigned int N, 411 411 utility::weighted_iterator_tag) 412 412 {
Note: See TracChangeset
for help on using the changeset viewer.