Files

730 lines
21 KiB
C++

// Boost.Units - A C++ library for zero-overhead dimensional analysis and
// unit/quantity manipulation and conversion
//
// Copyright (C) 2003-2008 Matthias Christian Schabel
// Copyright (C) 2007-2008 Steven Watanabe
//
// 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)
#ifndef ACTIV_BOOST_UNITS_CMATH_HPP
#define ACTIV_BOOST_UNITS_CMATH_HPP
#include <ActivBoost/config/no_tr1/cmath.hpp>
#include <cstdlib>
#include <ActivBoost/math/special_functions/fpclassify.hpp>
#include <ActivBoost/math/special_functions/hypot.hpp>
#include <ActivBoost/math/special_functions/next.hpp>
#include <ActivBoost/math/special_functions/round.hpp>
#include <ActivBoost/math/special_functions/sign.hpp>
#include <ActivBoost/units/dimensionless_quantity.hpp>
#include <ActivBoost/units/pow.hpp>
#include <ActivBoost/units/quantity.hpp>
#include <ActivBoost/units/detail/cmath_impl.hpp>
#include <ActivBoost/units/detail/dimensionless_unit.hpp>
#include <ActivBoost/units/systems/si/plane_angle.hpp>
/// \file
/// \brief Overloads of functions in \<cmath\> for quantities.
/// \details Only functions for which a dimensionally-correct result type
/// can be determined are overloaded.
/// All functions work with dimensionless quantities.
// ACTIV_BOOST_PREVENT_MACRO_SUBSTITUTION is needed on certain compilers that define
// some <cmath> functions as macros; it is used for all functions even though it
// isn't necessary -- I didn't want to think :)
//
// the form using namespace detail; return(f(x)); is used
// to enable ADL for UDTs.
namespace Boost {
namespace units {
template<class Unit,class Y>
inline
ACTIV_BOOST_CONSTEXPR
bool
isfinite ACTIV_BOOST_PREVENT_MACRO_SUBSTITUTION (const quantity<Unit,Y>& q)
{
using Boost::math::isfinite;
return isfinite ACTIV_BOOST_PREVENT_MACRO_SUBSTITUTION (q.value());
}
template<class Unit,class Y>
inline
ACTIV_BOOST_CONSTEXPR
bool
isinf ACTIV_BOOST_PREVENT_MACRO_SUBSTITUTION (const quantity<Unit,Y>& q)
{
using Boost::math::isinf;
return isinf ACTIV_BOOST_PREVENT_MACRO_SUBSTITUTION (q.value());
}
template<class Unit,class Y>
inline
ACTIV_BOOST_CONSTEXPR
bool
isnan ACTIV_BOOST_PREVENT_MACRO_SUBSTITUTION (const quantity<Unit,Y>& q)
{
using Boost::math::isnan;
return isnan ACTIV_BOOST_PREVENT_MACRO_SUBSTITUTION (q.value());
}
template<class Unit,class Y>
inline
ACTIV_BOOST_CONSTEXPR
bool
isnormal ACTIV_BOOST_PREVENT_MACRO_SUBSTITUTION (const quantity<Unit,Y>& q)
{
using Boost::math::isnormal;
return isnormal ACTIV_BOOST_PREVENT_MACRO_SUBSTITUTION (q.value());
}
template<class Unit,class Y>
inline
ACTIV_BOOST_CONSTEXPR
bool
isgreater ACTIV_BOOST_PREVENT_MACRO_SUBSTITUTION (const quantity<Unit,Y>& q1,
const quantity<Unit,Y>& q2)
{
using namespace detail;
return isgreater ACTIV_BOOST_PREVENT_MACRO_SUBSTITUTION (q1.value(),q2.value());
}
template<class Unit,class Y>
inline
ACTIV_BOOST_CONSTEXPR
bool
isgreaterequal ACTIV_BOOST_PREVENT_MACRO_SUBSTITUTION (const quantity<Unit,Y>& q1,
const quantity<Unit,Y>& q2)
{
using namespace detail;
return isgreaterequal ACTIV_BOOST_PREVENT_MACRO_SUBSTITUTION (q1.value(),q2.value());
}
template<class Unit,class Y>
inline
ACTIV_BOOST_CONSTEXPR
bool
isless ACTIV_BOOST_PREVENT_MACRO_SUBSTITUTION (const quantity<Unit,Y>& q1,
const quantity<Unit,Y>& q2)
{
using namespace detail;
return isless ACTIV_BOOST_PREVENT_MACRO_SUBSTITUTION (q1.value(),q2.value());
}
template<class Unit,class Y>
inline
ACTIV_BOOST_CONSTEXPR
bool
islessequal ACTIV_BOOST_PREVENT_MACRO_SUBSTITUTION (const quantity<Unit,Y>& q1,
const quantity<Unit,Y>& q2)
{
using namespace detail;
return islessequal ACTIV_BOOST_PREVENT_MACRO_SUBSTITUTION (q1.value(),q2.value());
}
template<class Unit,class Y>
inline
ACTIV_BOOST_CONSTEXPR
bool
islessgreater ACTIV_BOOST_PREVENT_MACRO_SUBSTITUTION (const quantity<Unit,Y>& q1,
const quantity<Unit,Y>& q2)
{
using namespace detail;
return islessgreater ACTIV_BOOST_PREVENT_MACRO_SUBSTITUTION (q1.value(),q2.value());
}
template<class Unit,class Y>
inline
ACTIV_BOOST_CONSTEXPR
bool
isunordered ACTIV_BOOST_PREVENT_MACRO_SUBSTITUTION (const quantity<Unit,Y>& q1,
const quantity<Unit,Y>& q2)
{
using namespace detail;
return isunordered ACTIV_BOOST_PREVENT_MACRO_SUBSTITUTION (q1.value(),q2.value());
}
template<class Unit,class Y>
inline
ACTIV_BOOST_CONSTEXPR
quantity<Unit,Y>
abs ACTIV_BOOST_PREVENT_MACRO_SUBSTITUTION (const quantity<Unit,Y>& q)
{
using std::abs;
typedef quantity<Unit,Y> quantity_type;
return quantity_type::from_value(abs ACTIV_BOOST_PREVENT_MACRO_SUBSTITUTION (q.value()));
}
template<class Unit,class Y>
inline
ACTIV_BOOST_CONSTEXPR
quantity<Unit,Y>
ceil ACTIV_BOOST_PREVENT_MACRO_SUBSTITUTION (const quantity<Unit,Y>& q)
{
using std::ceil;
typedef quantity<Unit,Y> quantity_type;
return quantity_type::from_value(ceil ACTIV_BOOST_PREVENT_MACRO_SUBSTITUTION (q.value()));
}
template<class Unit,class Y>
inline
ACTIV_BOOST_CONSTEXPR
quantity<Unit,Y>
copysign ACTIV_BOOST_PREVENT_MACRO_SUBSTITUTION (const quantity<Unit,Y>& q1,
const quantity<Unit,Y>& q2)
{
using Boost::math::copysign;
typedef quantity<Unit,Y> quantity_type;
return quantity_type::from_value(copysign ACTIV_BOOST_PREVENT_MACRO_SUBSTITUTION (q1.value(),q2.value()));
}
template<class Unit,class Y>
inline
ACTIV_BOOST_CONSTEXPR
quantity<Unit,Y>
fabs ACTIV_BOOST_PREVENT_MACRO_SUBSTITUTION (const quantity<Unit,Y>& q)
{
using std::fabs;
typedef quantity<Unit,Y> quantity_type;
return quantity_type::from_value(fabs ACTIV_BOOST_PREVENT_MACRO_SUBSTITUTION (q.value()));
}
template<class Unit,class Y>
inline
ACTIV_BOOST_CONSTEXPR
quantity<Unit,Y>
floor ACTIV_BOOST_PREVENT_MACRO_SUBSTITUTION (const quantity<Unit,Y>& q)
{
using std::floor;
typedef quantity<Unit,Y> quantity_type;
return quantity_type::from_value(floor ACTIV_BOOST_PREVENT_MACRO_SUBSTITUTION (q.value()));
}
template<class Unit,class Y>
inline
ACTIV_BOOST_CONSTEXPR
quantity<Unit,Y>
fdim ACTIV_BOOST_PREVENT_MACRO_SUBSTITUTION (const quantity<Unit,Y>& q1,
const quantity<Unit,Y>& q2)
{
using namespace detail;
typedef quantity<Unit,Y> quantity_type;
return quantity_type::from_value(fdim ACTIV_BOOST_PREVENT_MACRO_SUBSTITUTION (q1.value(),q2.value()));
}
#if 0
template<class Unit1,class Unit2,class Unit3,class Y>
inline
ACTIV_BOOST_CONSTEXPR
typename add_typeof_helper<
typename multiply_typeof_helper<quantity<Unit1,Y>,
quantity<Unit2,Y> >::type,
quantity<Unit3,Y> >::type
fma ACTIV_BOOST_PREVENT_MACRO_SUBSTITUTION (const quantity<Unit1,Y>& q1,
const quantity<Unit2,Y>& q2,
const quantity<Unit3,Y>& q3)
{
using namespace detail;
typedef quantity<Unit1,Y> type1;
typedef quantity<Unit2,Y> type2;
typedef quantity<Unit3,Y> type3;
typedef typename multiply_typeof_helper<type1,type2>::type prod_type;
typedef typename add_typeof_helper<prod_type,type3>::type quantity_type;
return quantity_type::from_value(fma ACTIV_BOOST_PREVENT_MACRO_SUBSTITUTION (q1.value(),q2.value(),q3.value()));
}
#endif
template<class Unit,class Y>
inline
ACTIV_BOOST_CONSTEXPR
quantity<Unit,Y>
fmax ACTIV_BOOST_PREVENT_MACRO_SUBSTITUTION (const quantity<Unit,Y>& q1,
const quantity<Unit,Y>& q2)
{
using namespace detail;
typedef quantity<Unit,Y> quantity_type;
return quantity_type::from_value(fmax ACTIV_BOOST_PREVENT_MACRO_SUBSTITUTION (q1.value(),q2.value()));
}
template<class Unit,class Y>
inline
ACTIV_BOOST_CONSTEXPR
quantity<Unit,Y>
fmin ACTIV_BOOST_PREVENT_MACRO_SUBSTITUTION (const quantity<Unit,Y>& q1,
const quantity<Unit,Y>& q2)
{
using namespace detail;
typedef quantity<Unit,Y> quantity_type;
return quantity_type::from_value(fmin ACTIV_BOOST_PREVENT_MACRO_SUBSTITUTION (q1.value(),q2.value()));
}
template<class Unit,class Y>
inline
ACTIV_BOOST_CONSTEXPR
int
fpclassify ACTIV_BOOST_PREVENT_MACRO_SUBSTITUTION (const quantity<Unit,Y>& q)
{
using Boost::math::fpclassify;
return fpclassify ACTIV_BOOST_PREVENT_MACRO_SUBSTITUTION (q.value());
}
template<class Unit,class Y>
inline
ACTIV_BOOST_CONSTEXPR
typename root_typeof_helper<
typename add_typeof_helper<
typename power_typeof_helper<quantity<Unit,Y>,
static_rational<2> >::type,
typename power_typeof_helper<quantity<Unit,Y>,
static_rational<2> >::type>::type,
static_rational<2> >::type
hypot ACTIV_BOOST_PREVENT_MACRO_SUBSTITUTION (const quantity<Unit,Y>& q1,const quantity<Unit,Y>& q2)
{
using Boost::math::hypot;
typedef quantity<Unit,Y> type1;
typedef typename power_typeof_helper<type1,static_rational<2> >::type pow_type;
typedef typename add_typeof_helper<pow_type,pow_type>::type add_type;
typedef typename root_typeof_helper<add_type,static_rational<2> >::type quantity_type;
return quantity_type::from_value(hypot ACTIV_BOOST_PREVENT_MACRO_SUBSTITUTION (q1.value(),q2.value()));
}
// does ISO C++ support long long? g++ claims not
//template<class Unit,class Y>
//inline
//ACTIV_BOOST_CONSTEXPR
//quantity<Unit,long long>
//llrint ACTIV_BOOST_PREVENT_MACRO_SUBSTITUTION (const quantity<Unit,Y>& q)
//{
// using namespace detail;
//
// typedef quantity<Unit,long long> quantity_type;
//
// return quantity_type::from_value(llrint ACTIV_BOOST_PREVENT_MACRO_SUBSTITUTION (q.value()));
//}
// does ISO C++ support long long? g++ claims not
//template<class Unit,class Y>
//inline
//ACTIV_BOOST_CONSTEXPR
//quantity<Unit,long long>
//llround ACTIV_BOOST_PREVENT_MACRO_SUBSTITUTION (const quantity<Unit,Y>& q)
//{
// using namespace detail;
//
// typedef quantity<Unit,long long> quantity_type;
//
// return quantity_type::from_value(llround ACTIV_BOOST_PREVENT_MACRO_SUBSTITUTION (q.value()));
//}
#if 0
template<class Unit,class Y>
inline
ACTIV_BOOST_CONSTEXPR
quantity<Unit,Y>
nearbyint ACTIV_BOOST_PREVENT_MACRO_SUBSTITUTION (const quantity<Unit,Y>& q)
{
using namespace detail;
typedef quantity<Unit,Y> quantity_type;
return quantity_type::from_value(nearbyint ACTIV_BOOST_PREVENT_MACRO_SUBSTITUTION (q.value()));
}
#endif
template<class Unit,class Y>
inline
ACTIV_BOOST_CONSTEXPR
quantity<Unit,Y> nextafter ACTIV_BOOST_PREVENT_MACRO_SUBSTITUTION (const quantity<Unit,Y>& q1,
const quantity<Unit,Y>& q2)
{
using Boost::math::nextafter;
typedef quantity<Unit,Y> quantity_type;
return quantity_type::from_value(nextafter ACTIV_BOOST_PREVENT_MACRO_SUBSTITUTION (q1.value(),q2.value()));
}
template<class Unit,class Y>
inline
ACTIV_BOOST_CONSTEXPR
quantity<Unit,Y> nexttoward ACTIV_BOOST_PREVENT_MACRO_SUBSTITUTION (const quantity<Unit,Y>& q1,
const quantity<Unit,Y>& q2)
{
// the only difference between nextafter and nexttowards is
// in the argument types. Since we are requiring identical
// argument types, there is no difference.
using Boost::math::nextafter;
typedef quantity<Unit,Y> quantity_type;
return quantity_type::from_value(nextafter ACTIV_BOOST_PREVENT_MACRO_SUBSTITUTION (q1.value(),q2.value()));
}
#if 0
template<class Unit,class Y>
inline
ACTIV_BOOST_CONSTEXPR
quantity<Unit,Y>
rint ACTIV_BOOST_PREVENT_MACRO_SUBSTITUTION (const quantity<Unit,Y>& q)
{
using namespace detail;
typedef quantity<Unit,Y> quantity_type;
return quantity_type::from_value(rint ACTIV_BOOST_PREVENT_MACRO_SUBSTITUTION (q.value()));
}
#endif
template<class Unit,class Y>
inline
ACTIV_BOOST_CONSTEXPR
quantity<Unit,Y>
round ACTIV_BOOST_PREVENT_MACRO_SUBSTITUTION (const quantity<Unit,Y>& q)
{
using Boost::math::round;
typedef quantity<Unit,Y> quantity_type;
return quantity_type::from_value(round ACTIV_BOOST_PREVENT_MACRO_SUBSTITUTION (q.value()));
}
template<class Unit,class Y>
inline
ACTIV_BOOST_CONSTEXPR
int
signbit ACTIV_BOOST_PREVENT_MACRO_SUBSTITUTION (const quantity<Unit,Y>& q)
{
using Boost::math::signbit;
return signbit ACTIV_BOOST_PREVENT_MACRO_SUBSTITUTION (q.value());
}
template<class Unit,class Y>
inline
ACTIV_BOOST_CONSTEXPR
quantity<Unit,Y>
trunc ACTIV_BOOST_PREVENT_MACRO_SUBSTITUTION (const quantity<Unit,Y>& q)
{
using namespace detail;
typedef quantity<Unit,Y> quantity_type;
return quantity_type::from_value(trunc ACTIV_BOOST_PREVENT_MACRO_SUBSTITUTION (q.value()));
}
template<class Unit,class Y>
inline
ACTIV_BOOST_CONSTEXPR
quantity<Unit, Y>
fmod(const quantity<Unit,Y>& q1, const quantity<Unit,Y>& q2)
{
using std::fmod;
typedef quantity<Unit,Y> quantity_type;
return quantity_type::from_value(fmod(q1.value(), q2.value()));
}
template<class Unit, class Y>
inline
ACTIV_BOOST_CONSTEXPR
quantity<Unit, Y>
modf(const quantity<Unit, Y>& q1, quantity<Unit, Y>* q2)
{
using std::modf;
typedef quantity<Unit,Y> quantity_type;
return quantity_type::from_value(modf(q1.value(), &quantity_cast<Y&>(*q2)));
}
template<class Unit, class Y, class Int>
inline
ACTIV_BOOST_CONSTEXPR
quantity<Unit, Y>
frexp(const quantity<Unit, Y>& q,Int* ex)
{
using std::frexp;
typedef quantity<Unit,Y> quantity_type;
return quantity_type::from_value(frexp(q.value(),ex));
}
/// For non-dimensionless quantities, integral and rational powers
/// and roots can be computed by @c pow<Ex> and @c root<Rt> respectively.
template<class S, class Y>
inline
ACTIV_BOOST_CONSTEXPR
quantity<ACTIV_BOOST_UNITS_DIMENSIONLESS_UNIT(S), Y>
pow(const quantity<ACTIV_BOOST_UNITS_DIMENSIONLESS_UNIT(S), Y>& q1,
const quantity<ACTIV_BOOST_UNITS_DIMENSIONLESS_UNIT(S), Y>& q2)
{
using std::pow;
typedef quantity<ACTIV_BOOST_UNITS_DIMENSIONLESS_UNIT(S),Y> quantity_type;
return quantity_type::from_value(pow(q1.value(), q2.value()));
}
template<class S, class Y>
inline
ACTIV_BOOST_CONSTEXPR
quantity<ACTIV_BOOST_UNITS_DIMENSIONLESS_UNIT(S), Y>
exp(const quantity<ACTIV_BOOST_UNITS_DIMENSIONLESS_UNIT(S), Y>& q)
{
using std::exp;
typedef quantity<ACTIV_BOOST_UNITS_DIMENSIONLESS_UNIT(S), Y> quantity_type;
return quantity_type::from_value(exp(q.value()));
}
template<class Unit, class Y, class Int>
inline
ACTIV_BOOST_CONSTEXPR
quantity<Unit, Y>
ldexp(const quantity<Unit, Y>& q,const Int& ex)
{
using std::ldexp;
typedef quantity<Unit,Y> quantity_type;
return quantity_type::from_value(ldexp(q.value(), ex));
}
template<class S, class Y>
inline
ACTIV_BOOST_CONSTEXPR
quantity<ACTIV_BOOST_UNITS_DIMENSIONLESS_UNIT(S), Y>
log(const quantity<ACTIV_BOOST_UNITS_DIMENSIONLESS_UNIT(S), Y>& q)
{
using std::log;
typedef quantity<ACTIV_BOOST_UNITS_DIMENSIONLESS_UNIT(S), Y> quantity_type;
return quantity_type::from_value(log(q.value()));
}
template<class S, class Y>
inline
ACTIV_BOOST_CONSTEXPR
quantity<ACTIV_BOOST_UNITS_DIMENSIONLESS_UNIT(S), Y>
log10(const quantity<ACTIV_BOOST_UNITS_DIMENSIONLESS_UNIT(S), Y>& q)
{
using std::log10;
typedef quantity<ACTIV_BOOST_UNITS_DIMENSIONLESS_UNIT(S), Y> quantity_type;
return quantity_type::from_value(log10(q.value()));
}
template<class Unit,class Y>
inline
ACTIV_BOOST_CONSTEXPR
typename root_typeof_helper<
quantity<Unit,Y>,
static_rational<2>
>::type
sqrt(const quantity<Unit,Y>& q)
{
using std::sqrt;
typedef typename root_typeof_helper<
quantity<Unit,Y>,
static_rational<2>
>::type quantity_type;
return quantity_type::from_value(sqrt(q.value()));
}
} // namespace units
} // namespace Boost
namespace Boost {
namespace units {
// trig functions with si argument/return types
/// cos of theta in radians
template<class Y>
ACTIV_BOOST_CONSTEXPR
typename dimensionless_quantity<si::system,Y>::type
cos(const quantity<si::plane_angle,Y>& theta)
{
using std::cos;
return cos(theta.value());
}
/// sin of theta in radians
template<class Y>
ACTIV_BOOST_CONSTEXPR
typename dimensionless_quantity<si::system,Y>::type
sin(const quantity<si::plane_angle,Y>& theta)
{
using std::sin;
return sin(theta.value());
}
/// tan of theta in radians
template<class Y>
ACTIV_BOOST_CONSTEXPR
typename dimensionless_quantity<si::system,Y>::type
tan(const quantity<si::plane_angle,Y>& theta)
{
using std::tan;
return tan(theta.value());
}
/// cos of theta in other angular units
template<class System,class Y>
ACTIV_BOOST_CONSTEXPR
typename dimensionless_quantity<System,Y>::type
cos(const quantity<unit<plane_angle_dimension,System>,Y>& theta)
{
return cos(quantity<si::plane_angle,Y>(theta));
}
/// sin of theta in other angular units
template<class System,class Y>
ACTIV_BOOST_CONSTEXPR
typename dimensionless_quantity<System,Y>::type
sin(const quantity<unit<plane_angle_dimension,System>,Y>& theta)
{
return sin(quantity<si::plane_angle,Y>(theta));
}
/// tan of theta in other angular units
template<class System,class Y>
ACTIV_BOOST_CONSTEXPR
typename dimensionless_quantity<System,Y>::type
tan(const quantity<unit<plane_angle_dimension,System>,Y>& theta)
{
return tan(quantity<si::plane_angle,Y>(theta));
}
/// acos of dimensionless quantity returning angle in same system
template<class Y,class System>
ACTIV_BOOST_CONSTEXPR
quantity<unit<plane_angle_dimension, homogeneous_system<System> >,Y>
acos(const quantity<unit<dimensionless_type, homogeneous_system<System> >,Y>& val)
{
using std::acos;
return quantity<unit<plane_angle_dimension, homogeneous_system<System> >,Y>(acos(val.value())*si::radians);
}
/// acos of dimensionless quantity returning angle in radians
template<class Y>
ACTIV_BOOST_CONSTEXPR
quantity<angle::radian_base_unit::unit_type,Y>
acos(const quantity<unit<dimensionless_type, heterogeneous_dimensionless_system>,Y>& val)
{
using std::acos;
return quantity<angle::radian_base_unit::unit_type,Y>::from_value(acos(val.value()));
}
/// asin of dimensionless quantity returning angle in same system
template<class Y,class System>
ACTIV_BOOST_CONSTEXPR
quantity<unit<plane_angle_dimension, homogeneous_system<System> >,Y>
asin(const quantity<unit<dimensionless_type, homogeneous_system<System> >,Y>& val)
{
using std::asin;
return quantity<unit<plane_angle_dimension, homogeneous_system<System> >,Y>(asin(val.value())*si::radians);
}
/// asin of dimensionless quantity returning angle in radians
template<class Y>
ACTIV_BOOST_CONSTEXPR
quantity<angle::radian_base_unit::unit_type,Y>
asin(const quantity<unit<dimensionless_type, heterogeneous_dimensionless_system>,Y>& val)
{
using std::asin;
return quantity<angle::radian_base_unit::unit_type,Y>::from_value(asin(val.value()));
}
/// atan of dimensionless quantity returning angle in same system
template<class Y,class System>
ACTIV_BOOST_CONSTEXPR
quantity<unit<plane_angle_dimension, homogeneous_system<System> >,Y>
atan(const quantity<unit<dimensionless_type, homogeneous_system<System> >, Y>& val)
{
using std::atan;
return quantity<unit<plane_angle_dimension, homogeneous_system<System> >,Y>(atan(val.value())*si::radians);
}
/// atan of dimensionless quantity returning angle in radians
template<class Y>
ACTIV_BOOST_CONSTEXPR
quantity<angle::radian_base_unit::unit_type,Y>
atan(const quantity<unit<dimensionless_type, heterogeneous_dimensionless_system>, Y>& val)
{
using std::atan;
return quantity<angle::radian_base_unit::unit_type,Y>::from_value(atan(val.value()));
}
/// atan2 of @c value_type returning angle in radians
template<class Y, class Dimension, class System>
ACTIV_BOOST_CONSTEXPR
quantity<unit<plane_angle_dimension, homogeneous_system<System> >, Y>
atan2(const quantity<unit<Dimension, homogeneous_system<System> >, Y>& y,
const quantity<unit<Dimension, homogeneous_system<System> >, Y>& x)
{
using std::atan2;
return quantity<unit<plane_angle_dimension, homogeneous_system<System> >, Y>(atan2(y.value(),x.value())*si::radians);
}
/// atan2 of @c value_type returning angle in radians
template<class Y, class Dimension, class System>
ACTIV_BOOST_CONSTEXPR
quantity<angle::radian_base_unit::unit_type,Y>
atan2(const quantity<unit<Dimension, heterogeneous_system<System> >, Y>& y,
const quantity<unit<Dimension, heterogeneous_system<System> >, Y>& x)
{
using std::atan2;
return quantity<angle::radian_base_unit::unit_type,Y>::from_value(atan2(y.value(),x.value()));
}
} // namespace units
} // namespace Boost
#endif // ACTIV_BOOST_UNITS_CMATH_HPP