Changeset 2283
- Timestamp:
- Jun 26, 2010, 4:14:39 AM (13 years ago)
- Location:
- trunk
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/test/normalization_test.cc
r2276 r2283 102 102 // compile test should not be run 103 103 if (false) { 104 boost::detail::dummy_constructor dummy_cons;105 104 c(boost::input_iterator_archetype<double>(), 106 105 boost::input_iterator_archetype<double>(), 107 boost::output_iterator_archetype<double>(dummy_cons)); 108 109 /* For ticket #631 106 boost::mutable_forward_iterator_archetype<double>()); 107 110 108 c(boost::input_iterator_archetype<double>(), 111 109 boost::input_iterator_archetype<double>(), 112 boost::output_iterator_archetype<utility::DataWeight>(dummy_cons)); 113 114 c(boost::input_iterator_archetype<utility::DataWeight>(), 115 boost::input_iterator_archetype<utility::DataWeight>(), 116 boost::output_iterator_archetype<double>(dummy_cons)); 117 118 c(boost::input_iterator_archetype<utility::DataWeight>(), 119 boost::input_iterator_archetype<utility::DataWeight>(), 120 boost::output_iterator_archetype<utility::DataWeight>(dummy_cons)); 121 */ 110 boost::mutable_forward_iterator_archetype<utility::DataWeight>()); 111 112 c(boost::input_iterator_archetype_no_proxy<utility::DataWeight>(), 113 boost::input_iterator_archetype_no_proxy<utility::DataWeight>(), 114 boost::mutable_forward_iterator_archetype<double>()); 115 116 c(boost::input_iterator_archetype_no_proxy<utility::DataWeight>(), 117 boost::input_iterator_archetype_no_proxy<utility::DataWeight>(), 118 boost::mutable_forward_iterator_archetype<utility::DataWeight>()); 122 119 } 123 120 } -
trunk/yat/normalizer/Centralizer.h
r2161 r2283 24 24 */ 25 25 26 #include "utility.h" 27 26 28 #include "yat/statistics/Average.h" 27 29 #include "yat/utility/DataIterator.h" … … 45 47 mean, but this can be changed by providing a suitable 46 48 UnaryFunction. 49 50 Type Requirements: 51 - InputIterator must be an \input_iterator 52 - ForwardIterator must be a mutable \forward_iterator 47 53 48 54 \since New in yat 0.5 … … 78 84 \see std::transform 79 85 */ 80 template<class InputIterator, class OutputIterator>86 template<class InputIterator, class ForwardIterator> 81 87 void operator()(InputIterator first, InputIterator last, 82 OutputIterator result) const88 ForwardIterator result) const 83 89 { 84 90 BOOST_CONCEPT_ASSERT((boost::InputIterator<InputIterator>)); 85 typename utility::weighted_iterator_traits<InputIterator>::type tag; 86 normalize(first, last, result, tag); 87 } 88 89 private: 90 UnaryFunction func_; 91 92 // unweighted version 93 template<class InputIterator, class OutputIterator> 94 void normalize(InputIterator first,InputIterator last,OutputIterator result, 95 utility::unweighted_iterator_tag tag) const 96 { 97 std::transform(first, last, result, 98 std::bind2nd(std::minus<double>(), func_(first, last))); 99 } 100 101 102 // weighted version 103 template<class InputIterator, class OutputIterator> 104 void normalize(InputIterator first,InputIterator last,OutputIterator result, 105 utility::weighted_iterator_tag tag) const 106 { 107 std::copy(utility::weight_iterator(first), 108 utility::weight_iterator(last), 109 utility::weight_iterator(result)); 91 BOOST_CONCEPT_ASSERT((boost::Mutable_ForwardIterator<ForwardIterator>)); 92 // copy weight if result is weighted 93 detail::copy_weight_if_weighted(first, last, result); 110 94 std::transform(utility::data_iterator(first), 111 95 utility::data_iterator(last), … … 114 98 } 115 99 100 private: 101 UnaryFunction func_; 116 102 }; 117 103
Note: See TracChangeset
for help on using the changeset viewer.