mirror of
https://github.com/boostorg/histogram.git
synced 2025-05-11 13:14:06 +00:00
Merge branch 'cleanup' into doc
This commit is contained in:
commit
98c6fbc575
@ -99,12 +99,13 @@ BOOST_PP_REPEAT_FROM_TO(1, BOOST_HISTOGRAM_AXIS_LIMIT, BOOST_HISTOGRAM_BASE_CTOR
|
||||
return lin.k;
|
||||
}
|
||||
|
||||
template<typename Range>
|
||||
inline
|
||||
size_type linearize(const int* idx) const {
|
||||
size_type linearize(const Range &r) const {
|
||||
detail::linearize lin(false);
|
||||
int i = axes_.size();
|
||||
while (i--) {
|
||||
lin.j = idx[i];
|
||||
lin.j = r[i];
|
||||
apply_visitor(lin, axes_[i]);
|
||||
}
|
||||
return lin.k;
|
||||
|
@ -169,13 +169,12 @@ BOOST_PP_REPEAT_FROM_TO(1, BOOST_HISTOGRAM_AXIS_LIMIT, BOOST_HISTOGRAM_WFILL, ni
|
||||
void fill(double x0, ...);
|
||||
#endif
|
||||
// C-style call
|
||||
inline
|
||||
double value_c(unsigned n, const int* idx)
|
||||
const
|
||||
template<typename Iterator>
|
||||
inline double value(boost::iterator_range<Iterator> range) const
|
||||
{
|
||||
if (n != dim())
|
||||
if (range.size() != dim())
|
||||
throw std::range_error("wrong number of arguments");
|
||||
return data_.value(linearize(idx));
|
||||
return data_.value(linearize(range));
|
||||
}
|
||||
|
||||
#define BOOST_HISTOGRAM_VALUE(z, n, unused) \
|
||||
@ -184,20 +183,20 @@ BOOST_PP_REPEAT_FROM_TO(1, BOOST_HISTOGRAM_AXIS_LIMIT, BOOST_HISTOGRAM_WFILL, ni
|
||||
const \
|
||||
{ \
|
||||
const int idx[n] = { BOOST_PP_ENUM_PARAMS_Z(z, n, i) }; \
|
||||
return value_c(n, idx); /* size is checked here */ \
|
||||
return value(boost::make_iterator_range( \
|
||||
boost::begin(idx), boost::end(idx) \
|
||||
)); /* size is checked here */ \
|
||||
}
|
||||
|
||||
// generates value functions taking 1 to AXIS_LIMT arguments
|
||||
BOOST_PP_REPEAT_FROM_TO(1, BOOST_HISTOGRAM_AXIS_LIMIT, BOOST_HISTOGRAM_VALUE, nil)
|
||||
|
||||
// C-style call
|
||||
inline
|
||||
double variance_c(unsigned n, const int* idx)
|
||||
const
|
||||
template<typename Iterator>
|
||||
inline double variance(boost::iterator_range<Iterator> range) const
|
||||
{
|
||||
if (n != dim())
|
||||
if (range.size() != dim())
|
||||
throw std::runtime_error("wrong number of arguments");
|
||||
return data_.variance(linearize(idx));
|
||||
return data_.variance(linearize(range));
|
||||
}
|
||||
|
||||
#define BOOST_HISTOGRAM_VARIANCE(z, n, unused) \
|
||||
@ -206,7 +205,9 @@ BOOST_PP_REPEAT_FROM_TO(1, BOOST_HISTOGRAM_AXIS_LIMIT, BOOST_HISTOGRAM_VALUE, ni
|
||||
const \
|
||||
{ \
|
||||
const int idx[n] = { BOOST_PP_ENUM_PARAMS_Z(z, n, i) }; \
|
||||
return variance_c(n, idx); /* size is checked here */ \
|
||||
return variance(boost::make_iterator_range( \
|
||||
boost::begin(idx), boost::end(idx) \
|
||||
)); /* size is checked here */ \
|
||||
}
|
||||
|
||||
// generates variance functions taking 1 to AXIS_LIMT arguments
|
||||
|
@ -184,7 +184,7 @@ histogram_value(python::tuple args, python::dict kwargs) {
|
||||
for (unsigned i = 0; i < self.dim(); ++i)
|
||||
idx[i] = extract<int>(args[1 + i]);
|
||||
|
||||
return object(self.value_c(self.dim(), idx));
|
||||
return object(self.value(boost::make_iterator_range(idx, idx + self.dim())));
|
||||
}
|
||||
|
||||
python::object
|
||||
@ -206,7 +206,7 @@ histogram_variance(python::tuple args, python::dict kwargs) {
|
||||
for (unsigned i = 0; i < self.dim(); ++i)
|
||||
idx[i] = extract<int>(args[1 + i]);
|
||||
|
||||
return object(self.variance_c(self.dim(), idx));
|
||||
return object(self.variance(boost::make_iterator_range(idx, idx + self.dim())));
|
||||
}
|
||||
|
||||
class histogram_access {
|
||||
|
Loading…
x
Reference in New Issue
Block a user