result_type result(Args const &args) const { float_type threshold = sum_of_weights(args) * ( ( is_same<LeftRight, left>::value ) ? args[quantile_probability] : 1. - args[quantile_probability] ); std::size_t n = 0; Weight sum = Weight(0); while (sum < threshold) { if (n < static_cast<std::size_t>(tail_weights(args).size())) { sum += *(tail_weights(args).begin() + n); n++; } else { if (std::numeric_limits<float_type>::has_quiet_NaN) { std::fill( this->tail_means_.begin() , this->tail_means_.end() , std::numeric_limits<float_type>::quiet_NaN() ); } else { std::ostringstream msg; msg << "index n = " << n << " is not in valid range [0, " << tail(args).size() << ")"; boost::throw_exception(std::runtime_error(msg.str())); } } } std::size_t num_variates = tail_variate(args).begin()->size(); this->tail_means_.clear(); this->tail_means_.resize(num_variates, Sample(0)); this->tail_means_ = std::inner_product( tail_variate(args).begin() , tail_variate(args).begin() + n , tail_weights(args).begin() , this->tail_means_ , numeric::functional::plus<array_type const, array_type const>() , numeric::functional::multiply_and_promote_to_double<VariateType const, Weight const>() ); float_type factor = sum * ( (is_same<Impl, relative>::value) ? non_coherent_weighted_tail_mean(args) : 1. ); std::transform( this->tail_means_.begin() , this->tail_means_.end() , this->tail_means_.begin() , std::bind2nd(numeric::functional::divides<typename array_type::value_type const, float_type const>(), factor) ); return make_iterator_range(this->tail_means_); }
typename boost::disable_if< std::is_same<typename std::decay<Sink>::type::element_type, boost::container::basic_string<Element>>, typename error_type<Sink>::type>::type append(Sink &&out, boost::container::basic_string<Element> const &str) { return out.append( make_iterator_range(str.data(), str.data() + str.size())); }
typename std::enable_if< std::is_same<Element, typename std::decay<Sink>::type::element_type>::value, typename error_type<Sink>::type>::type append(Sink &&out, Element const *c_str) { return out.append(make_iterator_range( c_str, c_str + std::char_traits<Element>::length(c_str))); }
result_type result(Args const &args) const { std::size_t cnt = count(args); std::size_t n = static_cast<std::size_t>( std::ceil( cnt * ( ( is_same<LeftRight, left>::value ) ? args[quantile_probability] : 1. - args[quantile_probability] ) ) ); std::size_t num_variates = tail_variate(args).begin()->size(); this->tail_means_.clear(); this->tail_means_.resize(num_variates, Sample(0)); // If n is in a valid range, return result, otherwise return NaN or throw exception if (n < static_cast<std::size_t>(tail(args).size())) { this->tail_means_ = std::accumulate( tail_variate(args).begin() , tail_variate(args).begin() + n , this->tail_means_ , numeric::plus ); float_type factor = n * ( (is_same<Impl, relative>::value) ? non_coherent_tail_mean(args) : 1. ); std::transform( this->tail_means_.begin() , this->tail_means_.end() , this->tail_means_.begin() #ifdef BOOST_NO_CXX98_BINDERS , std::bind(std::divides<float_type>(), std::placeholders::_1, factor) #else , std::bind2nd(std::divides<float_type>(), factor) #endif ); } else { if (std::numeric_limits<float_type>::has_quiet_NaN) { std::fill( this->tail_means_.begin() , this->tail_means_.end() , std::numeric_limits<float_type>::quiet_NaN() ); } else { std::ostringstream msg; msg << "index n = " << n << " is not in valid range [0, " << tail(args).size() << ")"; boost::throw_exception(std::runtime_error(msg.str())); } } return make_iterator_range(this->tail_means_); }
find_iterator( RangeT& Col, FinderT Finder ) : detail::find_iterator_base<IteratorT>(Finder,0) { iterator_range<BOOST_STRING_TYPENAME range_iterator<RangeT>::type> lit_col(as_literal(Col)); m_Match=make_iterator_range(::boost::begin(lit_col), ::boost::begin(lit_col)); m_End=::boost::end(lit_col); increment(); }
split_iterator( RangeT& Col, FinderT Finder ) : detail::find_iterator_base<IteratorT>(Finder,0), m_bEof(false) { iterator_range<BOOST_STRING_TYPENAME range_iterator<RangeT>::type> lit_col(::boost::as_literal(Col)); m_Match=make_iterator_range(::boost::begin(lit_col), ::boost::begin(lit_col)); m_Next=::boost::begin(lit_col); m_End=::boost::end(lit_col); // force the correct behavior for empty sequences and yield at least one token if(m_Next!=m_End) { increment(); } }
result_type result(Args const &args) const { if (this->is_dirty) { this->is_dirty = false; // creates a vector of std::pair where each pair i holds // the values heights[i] (x-axis of histogram) and // actual_positions[i] / sum_of_weights (y-axis of histogram) for (std::size_t i = 0; i < this->histogram.size(); ++i) { this->histogram[i] = std::make_pair(this->heights[i], numeric::fdiv(this->actual_positions[i], sum_of_weights(args))); } } return make_iterator_range(this->histogram); }
result_type result(Args const &args) const { if (this->is_dirty) { this->is_dirty = false; // creates a vector of std::pair where each pair i holds // the values bin_positions[i] (x-axis of histogram) and // samples_in_bin[i] / cnt (y-axis of histogram). for (std::size_t i = 0; i < this->num_bins + 2; ++i) { this->histogram[i] = std::make_pair(this->bin_positions[i], numeric::average(this->samples_in_bin[i], count(args))); } } // returns a range of pairs return make_iterator_range(this->histogram); }
inline iterator_range< BOOST_DEDUCED_TYPENAME range_iterator<Range>::type > make_range_impl( Range& r, BOOST_DEDUCED_TYPENAME range_difference<Range>::type advance_begin, BOOST_DEDUCED_TYPENAME range_difference<Range>::type advance_end ) { // // Not worth the effort // //if( advance_begin == 0 && advance_end == 0 ) // return make_iterator_range( r ); // BOOST_DEDUCED_TYPENAME range_iterator<Range>::type new_begin = lslboost::begin( r ), new_end = lslboost::end( r ); std::advance( new_begin, advance_begin ); std::advance( new_end, advance_end ); return make_iterator_range( new_begin, new_end ); }
void GameStateManager::draw() { auto findStart = [&] { for (auto riter = std::rbegin(states), eriter = std::rend(states); riter != eriter; ++riter) { auto iter = next(riter).base(); auto halts = iter->haltsDraw(); if (halts) return iter; } return begin(states); }; auto start = findStart(); for (auto& state : make_iterator_range(start, end(states))) { state.draw(); } }
inline bool ends_with_iter_select( ForwardIterator1T Begin, ForwardIterator1T End, ForwardIterator2T SubBegin, ForwardIterator2T SubEnd, PredicateT Comp, std::forward_iterator_tag) { if ( SubBegin==SubEnd ) { // empty subsequence check return true; } iterator_range<ForwardIterator1T> Result =last_finder( make_iterator_range(SubBegin, SubEnd), Comp)(Begin, End); return !Result.empty() && Result.end()==End; }
iterator_range<value_type *> to_range() const { return make_iterator_range(begin(), end()); }
ArcRange arcs () const { return make_iterator_range( arcBegin (), arcEnd () ); }
IncEdgeRange incEdges( BaseNode const & n ) const { return make_iterator_range( incEdgeBegin( n ), incEdgeEnd( n ) ); }
bool dispatch_attribute_element(Component const& component, mpl::true_) const { return f(component, make_iterator_range(iter, end)); }
bool TrackList::Contains(const Track * t) const { return make_iterator_range( *this ).contains( t ); }
memory_source<Element> make_c_str_source(Element const *c_str) { return memory_source<Element>(make_iterator_range( c_str, c_str + std::char_traits<Element>::length(c_str))); }
memory_source<Element> make_container_source(std::basic_string<Element> const &container) { return memory_source<Element>(make_iterator_range( container.data(), container.data() + container.size())); }
InArcRange inArcs ( BaseNode const & n ) const { return make_iterator_range( inArcBegin ( n ), inArcEnd ( n ) ); }
iterator_range<typename range_access_iterator<Container>::type> range(Container& cont) { return make_iterator_range(cont); }
operator range_type () { return make_iterator_range(message_.headers().begin(), message_.headers().end()); }
operator range_type () { return make_iterator_range(headers_wrapper<Tag>::_message.headers().begin(), headers_wrapper<Tag>::_message.headers().end()); };
NodeRange nodes() const { return make_iterator_range( nodeBegin(), nodeEnd() ); }
bool dispatch_main(Component const& component, mpl::true_) const { return f(component, make_iterator_range(iter, end)); }
EdgeRange edges() const { return make_iterator_range( edgeBegin(), edgeEnd() ); }
mutable_memory_source<Element> make_container_source(std::array<Element, N> &&container) { return mutable_memory_source<Element>(make_iterator_range( container.data(), container.data() + container.size())); }
OutArcRange outArcs ( BaseNode const & n ) const { return make_iterator_range( outArcBegin ( n ), outArcEnd ( n ) ); }