Changeset 1740
- Timestamp:
- Jan 21, 2009, 2:03:13 PM (14 years ago)
- Location:
- trunk
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/test/normalization_test.cc
r1738 r1740 153 153 // Enough iteration will make all columns to have the same values as 154 154 // the target. 155 suite.err() << "Testing that q=matrix rows gives QuantileNormaliz tion\n";155 suite.err() << "Testing that q=matrix rows gives QuantileNormalization\n"; 156 156 utility::Matrix m2(4,2); 157 157 m2(0,0) = 0; m2(0,1) = 10; -
trunk/yat/normalizer/qQuantileNormalizer.h
r1739 r1740 22 22 23 23 #include "yat/regression/CSplineInterpolation.h" 24 #include "yat/utility/DataIterator.h" 24 25 #include "yat/utility/DataWeight.h" 25 26 #include "yat/utility/iterator_traits.h" 26 27 #include "yat/utility/Vector.h" 28 #include "yat/utility/WeightIterator.h" 27 29 #include "yat/utility/yat_assert.h" 28 30 … … 158 160 159 161 Partitioner target_; 162 163 // unweighted version 164 template<typename RandomAccessIterator1, typename RandomAccessIterator2> 165 void normalize(const Partitioner& source,RandomAccessIterator1 first, 166 RandomAccessIterator1 last, RandomAccessIterator2 result, 167 utility::unweighted_iterator_tag tag) const; 168 169 // weighted version 170 // copy weights and apply unweighted version on data part 171 template<typename RandomAccessIterator1, typename RandomAccessIterator2> 172 void normalize(const Partitioner& source,RandomAccessIterator1 first, 173 RandomAccessIterator1 last, RandomAccessIterator2 result, 174 utility::weighted_iterator_tag tag) const; 160 175 }; 161 176 … … 179 194 RandomAccessIterator2 result) const 180 195 { 196 Partitioner source(first, last, target_.size()); 197 typename utility::weighted_iterator_traits<RandomAccessIterator2>::type tag; 198 normalize(source, first, last, result, tag); 199 } 200 201 202 template<typename RandomAccessIterator1, typename RandomAccessIterator2> 203 void 204 qQuantileNormalizer::normalize(const qQuantileNormalizer::Partitioner& source, 205 RandomAccessIterator1 first, 206 RandomAccessIterator1 last, 207 RandomAccessIterator2 result, 208 utility::unweighted_iterator_tag tag) const 209 { 181 210 size_t N = last-first; 182 211 utility::yat_assert<std::runtime_error> … … 186 215 utility::sort_index(first, last, sorted_index); 187 216 188 Partitioner source(first, last, target_.size());189 217 utility::Vector diff(source.averages()); 190 218 diff-=target_.averages(); … … 233 261 234 262 263 template<typename RandomAccessIterator1, typename RandomAccessIterator2> 264 void qQuantileNormalizer::normalize(const Partitioner& source, 265 RandomAccessIterator1 first, 266 RandomAccessIterator1 last, 267 RandomAccessIterator2 result, 268 utility::weighted_iterator_tag tag) const 269 { 270 // copy the weights 271 std::copy(utility::weight_iterator<RandomAccessIterator1>(first), 272 utility::weight_iterator<RandomAccessIterator1>(last), 273 utility::weight_iterator<RandomAccessIterator2>(result)); 274 // apply algorithm on data part of range 275 normalize(source, utility::data_iterator<RandomAccessIterator1>(first), 276 utility::data_iterator<RandomAccessIterator1>(last), 277 utility::data_iterator<RandomAccessIterator2>(result), 278 utility::unweighted_iterator_tag()); 279 } 280 281 235 282 template<typename BidirectionalIterator> 236 283 qQuantileNormalizer::Partitioner::Partitioner(BidirectionalIterator first,
Note: See TracChangeset
for help on using the changeset viewer.