view release on metacpan or search on metacpan
src/boost/config/auto_link.hpp view on Meta::CPAN
the compiler name and version, or the Boost version. Just the build options.
These macros will be undef'ed at the end of the header, further this header
has no include guards - so be sure to include it only once from your library!
Algorithm:
~~~~~~~~~~
Libraries for Borland and Microsoft compilers are automatically
selected here, the name of the lib is selected according to the following
formula:
BOOST_LIB_PREFIX
+ BOOST_LIB_NAME
+ "_"
+ BOOST_LIB_TOOLSET
+ BOOST_LIB_THREAD_OPT
+ BOOST_LIB_RT_OPT
"-"
+ BOOST_LIB_VERSION
src/boost/detail/utf8_codecvt_facet.ipp view on Meta::CPAN
// Check for invalid UCS-4 character
if (*from > max_wchar) {
from_next = from;
to_next = to;
return std::codecvt_base::error;
}
int cont_octet_count = get_cont_octet_out_count(*from);
// RG - comment this formula better
int shift_exponent = (cont_octet_count) * 6;
// Process the first character
*to++ = static_cast<char>(octet1_modifier_table[cont_octet_count] +
(unsigned char)(*from / (1 << shift_exponent)));
// Process the continuation characters
// Invariants: At the start of the loop:
// 1) 'i' continuing octets have been generated
// 2) '*to' points to the next location to place an octet
src/boost/geometry/strategies/cartesian/area_surveyor.hpp view on Meta::CPAN
namespace boost { namespace geometry
{
namespace strategy { namespace area
{
/*!
\brief Area calculation for cartesian points
\ingroup strategies
\details Calculates area using the Surveyor's formula, a well-known
triangulation algorithm
\tparam PointOfSegment \tparam_segment_point
\tparam CalculationType \tparam_calculation
\qbk{
[heading See also]
[link geometry.reference.algorithms.area.area_2_with_strategy area (with strategy)]
}
*/
src/boost/geometry/strategies/spherical/area_huiller.hpp view on Meta::CPAN
namespace boost { namespace geometry
{
namespace strategy { namespace area
{
/*!
\brief Area calculation by spherical excess / Huiller's formula
\ingroup strategies
\tparam PointOfSegment point type of segments of rings/polygons
\tparam CalculationType \tparam_calculation
\author Barend Gehrels. Adapted from:
- http://www.soe.ucsc.edu/~pang/160/f98/Gems/GemsIV/sph_poly.c
- http://williams.best.vwh.net/avform.htm
\note The version in Gems didn't account for polygons crossing the 180 meridian.
\note This version works for convex and non-convex polygons, for 180 meridian
crossing polygons and for polygons with holes. However, some cases (especially
180 meridian cases) must still be checked.
src/boost/geometry/strategies/spherical/area_huiller.hpp view on Meta::CPAN
// Distance p1 p2
calculation_type a = state.distance_over_unit_sphere.apply(p1, p2);
// Sides on unit sphere to south pole
calculation_type b = half_pi - geometry::get_as_radian<1>(p2);
calculation_type c = half_pi - geometry::get_as_radian<1>(p1);
// Semi parameter
calculation_type s = half * (a + b + c);
// E: spherical excess, using l'Huiller's formula
// [tg(e / 4)]2 = tg[s / 2] tg[(s-a) / 2] tg[(s-b) / 2] tg[(s-c) / 2]
calculation_type E = four * atan(sqrt(geometry::math::abs(tan(s / two)
* tan((s - a) / two)
* tan((s - b) / two)
* tan((s - c) / two))));
E = geometry::math::abs(E);
// In right direction: positive, add area. In left direction: negative, subtract area.
// Longitude comparisons are not so obvious. If one is negative, other is positive,
src/boost/geometry/strategies/spherical/distance_cross_track.hpp view on Meta::CPAN
(
(geometry::concept::PointDistanceStrategy<Strategy >)
);
return_type m_radius;
// Point-point distances are calculated in radians, on the unit sphere
Strategy m_strategy;
/// Calculate course (bearing) between two points. Might be moved to a "course formula" ...
inline return_type course(Point const& p1, Point const& p2) const
{
// http://williams.best.vwh.net/avform.htm#Crs
return_type dlon = get_as_radian<0>(p2) - get_as_radian<0>(p1);
return_type cos_p2lat = cos(get_as_radian<1>(p2));
// "An alternative formula, not requiring the pre-computation of d"
return atan2(sin(dlon) * cos_p2lat,
cos(get_as_radian<1>(p1)) * sin(get_as_radian<1>(p2))
- sin(get_as_radian<1>(p1)) * cos_p2lat * cos(dlon));
}
};
#ifndef DOXYGEN_NO_STRATEGY_SPECIALIZATIONS
src/boost/geometry/strategies/spherical/distance_haversine.hpp view on Meta::CPAN
on a perfect sphere using haversine
\ingroup strategies
\tparam Point1 \tparam_first_point
\tparam Point2 \tparam_second_point
\tparam CalculationType \tparam_calculation
\author Adapted from: http://williams.best.vwh.net/avform.htm
\see http://en.wikipedia.org/wiki/Great-circle_distance
\note It says: <em>The great circle distance d between two
points with coordinates {lat1,lon1} and {lat2,lon2} is given by:
d=acos(sin(lat1)*sin(lat2)+cos(lat1)*cos(lat2)*cos(lon1-lon2))
A mathematically equivalent formula, which is less subject
to rounding error for short distances is:
d=2*asin(sqrt((sin((lat1-lat2)/2))^2
+ cos(lat1)*cos(lat2)*(sin((lon1-lon2)/2))^2))
</em>
\qbk{
[heading See also]
[link geometry.reference.algorithms.distance.distance_3_with_strategy distance (with strategy)]
}
src/boost/geometry/strategies/spherical/side_by_cross_track.hpp view on Meta::CPAN
{
namespace strategy { namespace side
{
#ifndef DOXYGEN_NO_DETAIL
namespace detail
{
/// Calculate course (bearing) between two points. Might be moved to a "course formula" ...
template <typename Point>
static inline double course(Point const& p1, Point const& p2)
{
// http://williams.best.vwh.net/avform.htm#Crs
double dlon = get_as_radian<0>(p2) - get_as_radian<0>(p1);
double cos_p2lat = cos(get_as_radian<1>(p2));
// "An alternative formula, not requiring the pre-computation of d"
return atan2(sin(dlon) * cos_p2lat,
cos(get_as_radian<1>(p1)) * sin(get_as_radian<1>(p2))
- sin(get_as_radian<1>(p1)) * cos_p2lat * cos(dlon));
}
}
#endif // DOXYGEN_NO_DETAIL
src/boost/geometry/strategies/spherical/ssf.hpp view on Meta::CPAN
{
/*!
\brief Check at which side of a Great Circle segment a point lies
left of segment (> 0), right of segment (< 0), on segment (0)
\ingroup strategies
\tparam CalculationType \tparam_calculation
*/
template <typename CalculationType = void>
class spherical_side_formula
{
public :
template <typename P1, typename P2, typename P>
static inline int apply(P1 const& p1, P2 const& p2, P const& p)
{
typedef typename boost::mpl::if_c
<
boost::is_void<CalculationType>::type::value,
src/boost/geometry/strategies/spherical/ssf.hpp view on Meta::CPAN
};
#ifndef DOXYGEN_NO_STRATEGY_SPECIALIZATIONS
namespace services
{
/*template <typename CalculationType>
struct default_strategy<spherical_polar_tag, CalculationType>
{
typedef spherical_side_formula<CalculationType> type;
};*/
template <typename CalculationType>
struct default_strategy<spherical_equatorial_tag, CalculationType>
{
typedef spherical_side_formula<CalculationType> type;
};
template <typename CalculationType>
struct default_strategy<geographic_tag, CalculationType>
{
typedef spherical_side_formula<CalculationType> type;
};
}
#endif
}} // namespace strategy::side
}} // namespace boost::geometry
src/boost/geometry/util/math.hpp view on Meta::CPAN
}
double const d2r = geometry::math::pi<double>() / 180.0;
double const r2d = 1.0 / d2r;
/*!
\brief Calculates the haversine of an angle
\ingroup utility
\note See http://en.wikipedia.org/wiki/Haversine_formula
haversin(alpha) = sin2(alpha/2)
*/
template <typename T>
inline T hav(T const& theta)
{
T const half = T(0.5);
T const sn = sin(half * theta);
return sn * sn;
}
src/boost/graph/distributed/eager_dijkstra_shortest_paths.hpp view on Meta::CPAN
m_combine(combine), m_compare(compare), m_zero(zero) { }
template <class Vertex, class Graph>
void initialize_vertex(Vertex u, Graph& g)
{ m_vis.initialize_vertex(u, g); }
template <class Vertex, class Graph>
void discover_vertex(Vertex u, Graph& g) { m_vis.discover_vertex(u, g); }
template <class Vertex, class Graph>
void examine_vertex(Vertex u, Graph& g) { m_vis.examine_vertex(u, g); }
/* Since the eager formulation of Parallel Dijkstra's algorithm can
loop, we may relax on *any* edge, not just those associated with
white and gray targets. */
template <class Edge, class Graph>
void examine_edge(Edge e, Graph& g) {
if (m_compare(get(m_weight, e), m_zero))
boost::throw_exception(negative_edge());
m_vis.examine_edge(e, g);
boost::parallel::caching_property_map<PredecessorMap> c_pred(m_predecessor);
src/boost/math/special_functions/beta.hpp view on Meta::CPAN
{
prefix = 1;
}
fract = ibeta_a_step(bbar, a, y, x, n, pol, normalised, static_cast<T*>(0));
fract = beta_small_b_large_a_series(a, bbar, x, y, fract, T(1), pol, normalised);
fract /= prefix;
BOOST_MATH_INSTRUMENT_VARIABLE(fract);
}
else if(normalised)
{
// the formula here for the non-normalised case is tricky to figure
// out (for me!!), and requires two pochhammer calculations rather
// than one, so leave it for now....
int n = itrunc(T(floor(b)), pol);
T bbar = b - n;
if(bbar <= 0)
{
--n;
bbar += 1;
}
fract = ibeta_a_step(bbar, a, y, x, n, pol, normalised, static_cast<T*>(0));
src/boost/math/special_functions/detail/bessel_ik.hpp view on Meta::CPAN
else
{
Kv = std::numeric_limits<T>::quiet_NaN(); // any value will do
}
if(reflect && (kind & need_i))
{
T z = (u + n % 2);
Iv = boost::math::sin_pi(z, pol) == 0 ?
Iv :
policies::raise_overflow_error<T>(function, 0, pol); // reflection formula
}
*I = Iv;
*K = Kv;
return 0;
}
// x is positive until reflection
W = 1 / x; // Wronskian
if (x <= 2) // x in (0, 2]
src/boost/math/special_functions/detail/bessel_ik.hpp view on Meta::CPAN
if (reflect)
{
T z = (u + n % 2);
T fact = (2 / pi<T>()) * (boost::math::sin_pi(z) * Kv);
if(fact == 0)
*I = Iv;
else if(tools::max_value<T>() * scale < fact)
*I = (org_kind & need_i) ? T(sign(fact) * sign(scale) * policies::raise_overflow_error<T>(function, 0, pol)) : T(0);
else
*I = Iv + fact / scale; // reflection formula
}
else
{
*I = Iv;
}
if(tools::max_value<T>() * scale < Kv)
*K = (org_kind & need_k) ? T(sign(Kv) * sign(scale) * policies::raise_overflow_error<T>(function, 0, pol)) : T(0);
else
*K = Kv / scale;
BOOST_MATH_INSTRUMENT_VARIABLE(*I);
src/boost/math/special_functions/detail/bessel_j0.hpp view on Meta::CPAN
BOOST_ASSERT(sizeof(PS) == sizeof(QS));
rc = evaluate_rational(PC, QC, y2);
rs = evaluate_rational(PS, QS, y2);
factor = sqrt(2 / (x * pi<T>()));
//
// What follows is really just:
//
// T z = x - pi/4;
// value = factor * (rc * cos(z) - y * rs * sin(z));
//
// But using the addition formulae for sin and cos, plus
// the special values for sin/cos of pi/4.
//
T sx = sin(x);
T cx = cos(x);
value = factor * (rc * (cx * constants::one_div_root_two<T>() + sx * constants::half_root_two<T>())
- y * rs * (sx * constants::one_div_root_two<T>() - cx * constants::half_root_two<T>()));
}
return value;
}
src/boost/math/special_functions/detail/bessel_jy.hpp view on Meta::CPAN
static const char* function = "boost::math::bessel_jy<%1%>(%1%,%1%)";
BOOST_MATH_STD_USING
using namespace boost::math::tools;
using namespace boost::math::constants;
if (v < 0)
{
reflect = true;
v = -v; // v is non-negative from here
kind = need_j|need_y; // need both for reflection formula
}
n = iround(v, pol);
u = v - n; // -1/2 <= u < 1/2
if(reflect)
{
T z = (u + n % 2);
cp = boost::math::cos_pi(z, pol);
sp = boost::math::sin_pi(z, pol);
}
src/boost/math/special_functions/detail/bessel_jy.hpp view on Meta::CPAN
// This is particularly important for x << v as in this
// area temme_jy may be slow to converge, if it converges at all.
// Requires x is not an integer.
if(kind&need_j)
Jv = bessel_j_small_z_series(v, x, pol);
else
Jv = std::numeric_limits<T>::quiet_NaN();
if((org_kind&need_y && (!reflect || (cp != 0)))
|| (org_kind & need_j && (reflect && (sp != 0))))
{
// Only calculate if we need it, and if the reflection formula will actually use it:
Yv = bessel_y_small_z_series(v, x, &Yv_scale, pol);
}
else
Yv = std::numeric_limits<T>::quiet_NaN();
}
else if((u == 0) && (x < policies::get_epsilon<T, Policy>()))
{
// Truncated series evaluation for small x and v an integer,
// much quicker in this area than temme_jy below.
if(kind&need_j)
Jv = bessel_j_small_z_series(v, x, pol);
else
Jv = std::numeric_limits<T>::quiet_NaN();
if((org_kind&need_y && (!reflect || (cp != 0)))
|| (org_kind & need_j && (reflect && (sp != 0))))
{
// Only calculate if we need it, and if the reflection formula will actually use it:
Yv = bessel_yn_small_z(n, x, &Yv_scale, pol);
}
else
Yv = std::numeric_limits<T>::quiet_NaN();
}
else if (x <= 2) // x in (0, 2]
{
if(temme_jy(u, x, &Yu, &Yu1, pol)) // Temme series
{
// domain error:
src/boost/math/special_functions/detail/bessel_jy.hpp view on Meta::CPAN
}
else
Yv = std::numeric_limits<T>::quiet_NaN(); // any value will do, we're not using it.
}
if (reflect)
{
if((sp != 0) && (tools::max_value<T>() * fabs(Yv_scale) < fabs(sp * Yv)))
*J = org_kind & need_j ? T(-sign(sp) * sign(Yv) * sign(Yv_scale) * policies::raise_overflow_error<T>(function, 0, pol)) : T(0);
else
*J = cp * Jv - (sp == 0 ? T(0) : T((sp * Yv) / Yv_scale)); // reflection formula
if((cp != 0) && (tools::max_value<T>() * fabs(Yv_scale) < fabs(cp * Yv)))
*Y = org_kind & need_y ? T(-sign(cp) * sign(Yv) * sign(Yv_scale) * policies::raise_overflow_error<T>(function, 0, pol)) : T(0);
else
*Y = sp * Jv + (cp == 0 ? T(0) : T((cp * Yv) / Yv_scale));
}
else
{
*J = Jv;
if(tools::max_value<T>() * fabs(Yv_scale) < fabs(Yv))
*Y = org_kind & need_y ? T(sign(Yv) * sign(Yv_scale) * policies::raise_overflow_error<T>(function, 0, pol)) : T(0);
src/boost/math/special_functions/detail/bessel_y0.hpp view on Meta::CPAN
T y2 = y * y;
rc = evaluate_rational(PC, QC, y2);
rs = evaluate_rational(PS, QS, y2);
factor = sqrt(2 / (x * pi<T>()));
//
// The following code is really just:
//
// T z = x - 0.25f * pi<T>();
// value = factor * (rc * sin(z) + y * rs * cos(z));
//
// But using the sin/cos addition formulae and constant values for
// sin/cos of PI/4:
//
T sx = sin(x);
T cx = cos(x);
value = factor * (rc * (sx * constants::one_div_root_two<T>() - cx * constants::half_root_two<T>())
+ y * rs * (cx * constants::one_div_root_two<T>() + sx * constants::half_root_two<T>()));
}
return value;
}
src/boost/math/special_functions/detail/erf_inv.hpp view on Meta::CPAN
static const char* function = "boost::math::erfc_inv<%1%>(%1%, %1%)";
if((z < 0) || (z > 2))
policies::raise_domain_error<result_type>(function, "Argument outside range [0,2] in inverse erfc function (got p=%1%).", z, pol);
if(z == 0)
return policies::raise_overflow_error<result_type>(function, 0, pol);
if(z == 2)
return -policies::raise_overflow_error<result_type>(function, 0, pol);
//
// Normalise the input, so it's in the range [0,1], we will
// negate the result if z is outside that range. This is a simple
// application of the erfc reflection formula: erfc(-z) = 2 - erfc(z)
//
result_type p, q, s;
if(z > 1)
{
q = 2 - z;
p = 1 - q;
s = -1;
}
else
{
src/boost/math/special_functions/detail/erf_inv.hpp view on Meta::CPAN
policies::raise_domain_error<result_type>(function, "Argument outside range [-1, 1] in inverse erf function (got p=%1%).", z, pol);
if(z == 1)
return policies::raise_overflow_error<result_type>(function, 0, pol);
if(z == -1)
return -policies::raise_overflow_error<result_type>(function, 0, pol);
if(z == 0)
return 0;
//
// Normalise the input, so it's in the range [0,1], we will
// negate the result if z is outside that range. This is a simple
// application of the erf reflection formula: erf(-z) = -erf(z)
//
result_type p, q, s;
if(z < 0)
{
p = -z;
q = 1 - p;
s = -1;
}
else
{
src/boost/math/special_functions/ellint_1.hpp view on Meta::CPAN
if(phi >= tools::max_value<T>())
{
// Need to handle infinity as a special case:
result = policies::raise_overflow_error<T>(function, 0, pol);
BOOST_MATH_INSTRUMENT_VARIABLE(result);
}
else if(phi > 1 / tools::epsilon<T>())
{
// Phi is so large that phi%pi is necessarily zero (or garbage),
// just return the second part of the duplication formula:
result = 2 * phi * ellint_k_imp(k, pol) / constants::pi<T>();
BOOST_MATH_INSTRUMENT_VARIABLE(result);
}
else
{
// Carlson's algorithm works only for |phi| <= pi/2,
// use the integrand's periodicity to normalize phi
//
// Xiaogang's original code used a cast to long long here
// but that fails if T has more digits than a long long,
src/boost/math/special_functions/ellint_2.hpp view on Meta::CPAN
T result;
if(phi >= tools::max_value<T>())
{
// Need to handle infinity as a special case:
result = policies::raise_overflow_error<T>("boost::math::ellint_e<%1%>(%1%,%1%)", 0, pol);
}
else if(phi > 1 / tools::epsilon<T>())
{
// Phi is so large that phi%pi is necessarily zero (or garbage),
// just return the second part of the duplication formula:
result = 2 * phi * ellint_e_imp(k, pol) / constants::pi<T>();
}
else
{
// Carlson's algorithm works only for |phi| <= pi/2,
// use the integrand's periodicity to normalize phi
//
// Xiaogang's original code used a cast to long long here
// but that fails if T has more digits than a long long,
// so rewritten to use fmod instead:
src/boost/math/special_functions/ellint_3.hpp view on Meta::CPAN
}
#if 0 // disabled but retained for future reference: see below.
if(v > 1)
{
//
// If v > 1 we can use the identity in A&S 17.7.7/8
// to shift to 0 <= v <= 1. Unfortunately this
// identity appears only to function correctly when
// 0 <= phi <= pi/2, but it's when phi is outside that
// range that we really need it: That's when
// Carlson's formula fails, and what's more the periodicity
// reduction used below on phi doesn't work when v > 1.
//
// So we're stuck... the code is archived here in case
// some bright spart can figure out the fix.
//
T k2 = k * k;
T N = k2 / v;
T Nm1 = (v - k2) / v;
T p1 = sqrt((-vc) * (1 - k2 / v));
T delta = sqrt(1 - k2 * sphi * sphi);
src/boost/math/special_functions/ellint_3.hpp view on Meta::CPAN
// so rewritten to use fmod instead:
//
if(fabs(phi) > 1 / tools::epsilon<T>())
{
if(v > 1)
return policies::raise_domain_error<T>(
function,
"Got v = %1%, but this is only supported for 0 <= phi <= pi/2", v, pol);
//
// Phi is so large that phi%pi is necessarily zero (or garbage),
// just return the second part of the duplication formula:
//
value = 2 * fabs(phi) * ellint_pi_imp(v, k, vc, pol) / constants::pi<T>();
}
else
{
T rphi = boost::math::tools::fmod_workaround(T(fabs(phi)), T(constants::pi<T>() / 2));
T m = floor((2 * fabs(phi)) / constants::pi<T>());
int sign = 1;
if(boost::math::tools::fmod_workaround(m, T(2)) > 0.5)
{
src/boost/math/special_functions/gamma.hpp view on Meta::CPAN
#endif
BOOST_MATH_STD_USING
static const char* function = "boost::math::lgamma<%1%>(%1%)";
T result = 0;
int sresult = 1;
if(z <= 0)
{
// reflection formula:
if(floor(z) == z)
return policies::raise_pole_error<T>(function, "Evaluation of lgamma at a negative integer %1%.", z, pol);
T t = sinpx(z);
z = -z;
if(t < 0)
{
t = -t;
}
else
src/boost/math/special_functions/next.hpp view on Meta::CPAN
// b > a and both postive for the following logic:
//
if(a < 0)
return float_distance(static_cast<T>(-b), static_cast<T>(-a), pol);
BOOST_ASSERT(a >= 0);
BOOST_ASSERT(b >= a);
int expon;
//
// Note that if a is a denorm then the usual formula fails
// because we actually have fewer than tools::digits<T>()
// significant bits in the representation:
//
frexp(((boost::math::fpclassify)(a) == FP_SUBNORMAL) ? tools::min_value<T>() : a, &expon);
T upper = ldexp(T(1), expon);
T result = 0;
expon = tools::digits<T>() - expon;
//
// If b is greater than upper, then we *must* split the calculation
// as the size of the ULP changes with each order of magnitude change:
src/boost/polygon/detail/voronoi_robust_fpt.hpp view on Meta::CPAN
// used at the first step. In case of the undefined result high-precision
// arithmetic is used to produce required robustness. This approach
// requires exact computation of epsilon intervals within which epsilon
// robust predicates have undefined value.
// There are two ways to measure an error of floating-point calculations:
// relative error and ULPs (units in the last place).
// Let EPS be machine epsilon, then next inequalities have place:
// 1 EPS <= 1 ULP <= 2 EPS (1), 0.5 ULP <= 1 EPS <= 1 ULP (2).
// ULPs are good for measuring rounding errors and comparing values.
// Relative errors are good for computation of general relative
// error of formulas or expressions. So to calculate epsilon
// interval within which epsilon robust predicates have undefined result
// next schema is used:
// 1) Compute rounding errors of initial variables using ULPs;
// 2) Transform ULPs to epsilons using upper bound of the (1);
// 3) Compute relative error of the formula using epsilon arithmetic;
// 4) Transform epsilon to ULPs using upper bound of the (2);
// In case two values are inside undefined ULP range use high-precision
// arithmetic to produce the correct result, else output the result.
// Look at almost_equal function to see how two floating-point variables
// are checked to fit in the ULP range.
// If A has relative error of r(A) and B has relative error of r(B) then:
// 1) r(A + B) <= max(r(A), r(B)), for A * B >= 0;
// 2) r(A - B) <= B*r(A)+A*r(B)/(A-B), for A * B >= 0;
// 2) r(A * B) <= r(A) + r(B);
// 3) r(A / B) <= r(A) + r(B);
// In addition rounding error should be added, that is always equal to
// 0.5 ULP or at most 1 epsilon. As you might see from the above formulas
// subtraction relative error may be extremely large, that's why
// epsilon robust comparator class is used to store floating point values
// and compute subtraction as the final step of the evaluation.
// For further information about relative errors and ULPs try this link:
// http://docs.sun.com/source/806-3568/ncg_goldberg.html
namespace boost {
namespace polygon {
namespace detail {
src/boost/python/with_custodian_and_ward.hpp view on Meta::CPAN
BOOST_STATIC_ASSERT(custodian != ward);
template <class ArgumentPackage>
static PyObject* postcall(ArgumentPackage const& args_, PyObject* result)
{
std::size_t arity_ = detail::arity(args_);
#if BOOST_WORKAROUND(BOOST_MSVC, < 1300)
if ( custodian > arity_ || ward > arity_ )
#else
// check if either custodian or ward exceeds the arity
// (this weird formulation avoids "always false" warnings
// for arity_ = 0)
if ( (std::max)(custodian, ward) > arity_ )
#endif
{
PyErr_SetString(
PyExc_IndexError
, "boost::python::with_custodian_and_ward_postcall: argument index out of range"
);
return 0;
}
src/boost/random/uniform_smallint.hpp view on Meta::CPAN
* numbers of the base distribution, the rest has only \f$\displaystyle
* \left\lfloor\frac{r_{\mathtt{base}}}{r_{\mathtt{out}}}\right\rfloor\f$.
* Therefore,
* \f$\displaystyle p_{\mathtt{out\_s}}(i) =
* \left(\left\lfloor\frac{r_{\mathtt{base}}}
* {r_{\mathtt{out}}}\right\rfloor+1\right) /
* r_{\mathtt{base}}\f$ for i < r and \f$\displaystyle p_{\mathtt{out\_s}}(i) =
* \left\lfloor\frac{r_{\mathtt{base}}}
* {r_{\mathtt{out}}}\right\rfloor/r_{\mathtt{base}}\f$ otherwise.
* Substituting this in the
* above sum formula leads to the desired result.
* @endxmlnote
*
* Note: The upper bound for
* \f$(r_{\mathtt{base}} \mbox{ mod } r_{\mathtt{out}})
* (r_{\mathtt{out}} - r_{\mathtt{base}} \mbox{ mod } r_{\mathtt{out}})\f$ is
* \f$\displaystyle \frac{r_{\mathtt{out}}^2}{4}\f$. Regarding the upper bound
* for the square sum of the relative quantization error of
* \f$\displaystyle \frac{r_\mathtt{out}^3}{4r_{\mathtt{base}}^2}\f$, it
* seems wise to either choose \f$r_{\mathtt{base}}\f$ so that
* \f$r_{\mathtt{base}} > 10r_{\mathtt{out}}^2\f$ or ensure that
src/boost/smart_ptr/detail/sp_counted_base_aix.hpp view on Meta::CPAN
// Copyright 2006 Michael van der Westhuizen
//
// Distributed under the Boost Software License, Version 1.0. (See
// accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt)
//
//
// Lock-free algorithm by Alexander Terekhov
//
// Thanks to Ben Hitchings for the #weak + (#shared != 0)
// formulation
//
#include <boost/detail/sp_typeinfo.hpp>
#include <builtins.h>
#include <sys/atomic_op.h>
namespace boost
{
namespace detail
src/boost/smart_ptr/detail/sp_counted_base_cw_ppc.hpp view on Meta::CPAN
// Copyright 2004-2005 Peter Dimov
//
// Distributed under the Boost Software License, Version 1.0. (See
// accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt)
//
//
// Lock-free algorithm by Alexander Terekhov
//
// Thanks to Ben Hitchings for the #weak + (#shared != 0)
// formulation
//
#include <boost/detail/sp_typeinfo.hpp>
namespace boost
{
namespace detail
{
src/boost/smart_ptr/detail/sp_counted_base_gcc_ppc.hpp view on Meta::CPAN
// Copyright 2004-2005 Peter Dimov
//
// Distributed under the Boost Software License, Version 1.0. (See
// accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt)
//
//
// Lock-free algorithm by Alexander Terekhov
//
// Thanks to Ben Hitchings for the #weak + (#shared != 0)
// formulation
//
#include <boost/detail/sp_typeinfo.hpp>
namespace boost
{
namespace detail
{
src/boost/smart_ptr/detail/sp_counted_base_gcc_x86.hpp view on Meta::CPAN
// Copyright 2004-2005 Peter Dimov
//
// Distributed under the Boost Software License, Version 1.0. (See
// accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt)
//
//
// Lock-free algorithm by Alexander Terekhov
//
// Thanks to Ben Hitchings for the #weak + (#shared != 0)
// formulation
//
#include <boost/detail/sp_typeinfo.hpp>
namespace boost
{
namespace detail
{
src/boost/smart_ptr/detail/sp_counted_base_vacpp_ppc.hpp view on Meta::CPAN
// Copyright 2012 IBM Corp.
//
// Distributed under the Boost Software License, Version 1.0. (See
// accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt)
//
//
// Lock-free algorithm by Alexander Terekhov
//
// Thanks to Ben Hitchings for the #weak + (#shared != 0)
// formulation
//
#include <boost/detail/sp_typeinfo.hpp>
extern "builtin" void __lwsync(void);
extern "builtin" void __isync(void);
extern "builtin" int __fetch_and_add(volatile int* addr, int val);
extern "builtin" int __compare_and_swap(volatile int*, int*, int);
namespace boost
src/boost/smart_ptr/detail/sp_counted_base_w32.hpp view on Meta::CPAN
// Copyright 2004-2005 Peter Dimov
//
// Distributed under the Boost Software License, Version 1.0. (See
// accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt)
//
//
// Lock-free algorithm by Alexander Terekhov
//
// Thanks to Ben Hitchings for the #weak + (#shared != 0)
// formulation
//
#include <boost/detail/interlocked.hpp>
#include <boost/detail/workaround.hpp>
#include <boost/detail/sp_typeinfo.hpp>
namespace boost
{
namespace detail