|
Boost : |
Subject: [boost] [math][distributions] superfluous checking of parameters?
From: Thijs (M.A.) van den Berg (thijs_at_[hidden])
Date: 2011-10-29 05:56:14
The boost math distributions check validity of distribution the same parameters multiple times.
E.g. in normal.hpp, class normal_distribution, the constructor,
normal_distribution(RealType mean = 0, RealType sd = 1)
: m_mean(mean), m_sd(sd)
{ // Default is a 'standard' normal distribution N01.
static const char* function = "boost::math::normal_distribution<%1%>::normal_distribution";
RealType result;
detail::check_scale(function, sd, &result, Policy());
detail::check_location(function, mean, &result, Policy());
}
however, those are *again* checked in e.g. the pdf() non member function
inline RealType pdf(const normal_distribution<RealType, Policy>& dist, const RealType& x)
{
...
if(false == detail::check_scale(function, sd, &result, Policy()))
{
return result;
}
...
}
Why is that? It's done in a consistent way across all distributions. Can we remove the check inside the non member functions that are already checked in the constructor?
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk