Back to home page

EIC code displayed by LXR

 
 

    


Warning, file /include/boost/units/cmath.hpp was not indexed or was modified since last indexation (in which case cross-reference links may be missing, inaccurate or erroneous).

0001 // Boost.Units - A C++ library for zero-overhead dimensional analysis and 
0002 // unit/quantity manipulation and conversion
0003 //
0004 // Copyright (C) 2003-2008 Matthias Christian Schabel
0005 // Copyright (C) 2007-2008 Steven Watanabe
0006 //
0007 // Distributed under the Boost Software License, Version 1.0. (See
0008 // accompanying file LICENSE_1_0.txt or copy at
0009 // http://www.boost.org/LICENSE_1_0.txt)
0010 
0011 #ifndef BOOST_UNITS_CMATH_HPP 
0012 #define BOOST_UNITS_CMATH_HPP
0013 
0014 #include <boost/config/no_tr1/cmath.hpp>
0015 #include <cstdlib>
0016 
0017 #include <boost/math/special_functions/fpclassify.hpp>
0018 #include <boost/math/special_functions/hypot.hpp>
0019 #include <boost/math/special_functions/next.hpp>
0020 #include <boost/math/special_functions/round.hpp>
0021 #include <boost/math/special_functions/sign.hpp>
0022 
0023 #include <boost/units/dimensionless_quantity.hpp>
0024 #include <boost/units/pow.hpp>
0025 #include <boost/units/quantity.hpp>
0026 #include <boost/units/detail/cmath_impl.hpp>
0027 #include <boost/units/detail/dimensionless_unit.hpp>
0028 
0029 #include <boost/units/systems/si/plane_angle.hpp>
0030 
0031 /// \file
0032 /// \brief Overloads of functions in \<cmath\> for quantities.
0033 /// \details Only functions for which a dimensionally-correct result type
0034 ///   can be determined are overloaded.
0035 ///   All functions work with dimensionless quantities.
0036 
0037 // BOOST_PREVENT_MACRO_SUBSTITUTION is needed on certain compilers that define 
0038 // some <cmath> functions as macros; it is used for all functions even though it
0039 // isn't necessary -- I didn't want to think :)
0040 //
0041 // the form using namespace detail; return(f(x)); is used
0042 // to enable ADL for UDTs.
0043 
0044 namespace boost {
0045 
0046 namespace units { 
0047 
0048 template<class Unit,class Y>
0049 inline 
0050 BOOST_CONSTEXPR
0051 bool 
0052 isfinite BOOST_PREVENT_MACRO_SUBSTITUTION (const quantity<Unit,Y>& q)
0053 { 
0054     using boost::math::isfinite;
0055     return isfinite BOOST_PREVENT_MACRO_SUBSTITUTION (q.value());
0056 }
0057 
0058 template<class Unit,class Y>
0059 inline 
0060 BOOST_CONSTEXPR
0061 bool 
0062 isinf BOOST_PREVENT_MACRO_SUBSTITUTION (const quantity<Unit,Y>& q)
0063 { 
0064     using boost::math::isinf;
0065     return isinf BOOST_PREVENT_MACRO_SUBSTITUTION (q.value());
0066 }
0067 
0068 template<class Unit,class Y>
0069 inline
0070 BOOST_CONSTEXPR
0071 bool 
0072 isnan BOOST_PREVENT_MACRO_SUBSTITUTION (const quantity<Unit,Y>& q)
0073 { 
0074     using boost::math::isnan;
0075     return isnan BOOST_PREVENT_MACRO_SUBSTITUTION (q.value());
0076 }
0077 
0078 template<class Unit,class Y>
0079 inline 
0080 BOOST_CONSTEXPR
0081 bool 
0082 isnormal BOOST_PREVENT_MACRO_SUBSTITUTION (const quantity<Unit,Y>& q)
0083 { 
0084     using boost::math::isnormal;
0085     return isnormal BOOST_PREVENT_MACRO_SUBSTITUTION (q.value());
0086 }
0087 
0088 template<class Unit,class Y>
0089 inline 
0090 BOOST_CONSTEXPR
0091 bool 
0092 isgreater BOOST_PREVENT_MACRO_SUBSTITUTION (const quantity<Unit,Y>& q1,
0093                                             const quantity<Unit,Y>& q2)
0094 { 
0095     using namespace detail;
0096     return isgreater BOOST_PREVENT_MACRO_SUBSTITUTION (q1.value(),q2.value());
0097 }
0098 
0099 template<class Unit,class Y>
0100 inline 
0101 BOOST_CONSTEXPR
0102 bool 
0103 isgreaterequal BOOST_PREVENT_MACRO_SUBSTITUTION (const quantity<Unit,Y>& q1,
0104                                                  const quantity<Unit,Y>& q2)
0105 { 
0106     using namespace detail;
0107     return isgreaterequal BOOST_PREVENT_MACRO_SUBSTITUTION (q1.value(),q2.value());
0108 }
0109 
0110 template<class Unit,class Y>
0111 inline 
0112 BOOST_CONSTEXPR
0113 bool 
0114 isless BOOST_PREVENT_MACRO_SUBSTITUTION (const quantity<Unit,Y>& q1,
0115                                          const quantity<Unit,Y>& q2)
0116 { 
0117     using namespace detail;
0118     return isless BOOST_PREVENT_MACRO_SUBSTITUTION (q1.value(),q2.value());
0119 }
0120 
0121 template<class Unit,class Y>
0122 inline 
0123 BOOST_CONSTEXPR
0124 bool 
0125 islessequal BOOST_PREVENT_MACRO_SUBSTITUTION (const quantity<Unit,Y>& q1,
0126                                               const quantity<Unit,Y>& q2)
0127 { 
0128     using namespace detail;
0129     return islessequal BOOST_PREVENT_MACRO_SUBSTITUTION (q1.value(),q2.value());
0130 }
0131 
0132 template<class Unit,class Y>
0133 inline 
0134 BOOST_CONSTEXPR
0135 bool 
0136 islessgreater BOOST_PREVENT_MACRO_SUBSTITUTION (const quantity<Unit,Y>& q1,
0137                                                 const quantity<Unit,Y>& q2)
0138 { 
0139     using namespace detail;
0140     return islessgreater BOOST_PREVENT_MACRO_SUBSTITUTION (q1.value(),q2.value());
0141 }
0142 
0143 template<class Unit,class Y>
0144 inline 
0145 BOOST_CONSTEXPR
0146 bool 
0147 isunordered BOOST_PREVENT_MACRO_SUBSTITUTION (const quantity<Unit,Y>& q1,
0148                                               const quantity<Unit,Y>& q2)
0149 { 
0150     using namespace detail;
0151     return isunordered BOOST_PREVENT_MACRO_SUBSTITUTION (q1.value(),q2.value());
0152 }
0153 
0154 template<class Unit,class Y>
0155 inline 
0156 BOOST_CONSTEXPR
0157 quantity<Unit,Y> 
0158 abs BOOST_PREVENT_MACRO_SUBSTITUTION (const quantity<Unit,Y>& q)
0159 {
0160     using std::abs;
0161 
0162     typedef quantity<Unit,Y>    quantity_type;
0163     
0164     return quantity_type::from_value(abs BOOST_PREVENT_MACRO_SUBSTITUTION (q.value()));
0165 }
0166 
0167 template<class Unit,class Y>
0168 inline 
0169 BOOST_CONSTEXPR
0170 quantity<Unit,Y> 
0171 ceil BOOST_PREVENT_MACRO_SUBSTITUTION (const quantity<Unit,Y>& q)
0172 {
0173     using std::ceil;
0174 
0175     typedef quantity<Unit,Y>    quantity_type;
0176     
0177     return quantity_type::from_value(ceil BOOST_PREVENT_MACRO_SUBSTITUTION (q.value()));
0178 }
0179 
0180 template<class Unit,class Y>
0181 inline 
0182 BOOST_CONSTEXPR
0183 quantity<Unit,Y> 
0184 copysign BOOST_PREVENT_MACRO_SUBSTITUTION (const quantity<Unit,Y>& q1,
0185          const quantity<Unit,Y>& q2)
0186 {
0187     using boost::math::copysign;
0188 
0189     typedef quantity<Unit,Y>    quantity_type;
0190     
0191     return quantity_type::from_value(copysign BOOST_PREVENT_MACRO_SUBSTITUTION (q1.value(),q2.value()));
0192 }
0193 
0194 template<class Unit,class Y>
0195 inline 
0196 BOOST_CONSTEXPR
0197 quantity<Unit,Y> 
0198 fabs BOOST_PREVENT_MACRO_SUBSTITUTION (const quantity<Unit,Y>& q)
0199 {
0200     using std::fabs;
0201 
0202     typedef quantity<Unit,Y>    quantity_type;
0203     
0204     return quantity_type::from_value(fabs BOOST_PREVENT_MACRO_SUBSTITUTION (q.value()));
0205 }
0206 
0207 template<class Unit,class Y>
0208 inline 
0209 BOOST_CONSTEXPR
0210 quantity<Unit,Y> 
0211 floor BOOST_PREVENT_MACRO_SUBSTITUTION (const quantity<Unit,Y>& q)
0212 {
0213     using std::floor;
0214 
0215     typedef quantity<Unit,Y>    quantity_type;
0216     
0217     return quantity_type::from_value(floor BOOST_PREVENT_MACRO_SUBSTITUTION (q.value()));
0218 }
0219 
0220 template<class Unit,class Y>
0221 inline 
0222 BOOST_CONSTEXPR
0223 quantity<Unit,Y> 
0224 fdim BOOST_PREVENT_MACRO_SUBSTITUTION (const quantity<Unit,Y>& q1,
0225                                        const quantity<Unit,Y>& q2)
0226 {
0227     using namespace detail;
0228 
0229     typedef quantity<Unit,Y>    quantity_type;
0230     
0231     return quantity_type::from_value(fdim BOOST_PREVENT_MACRO_SUBSTITUTION (q1.value(),q2.value()));
0232 }
0233 
0234 #if 0
0235 
0236 template<class Unit1,class Unit2,class Unit3,class Y>
0237 inline 
0238 BOOST_CONSTEXPR
0239 typename add_typeof_helper<
0240     typename multiply_typeof_helper<quantity<Unit1,Y>,
0241                                     quantity<Unit2,Y> >::type,
0242     quantity<Unit3,Y> >::type 
0243 fma BOOST_PREVENT_MACRO_SUBSTITUTION (const quantity<Unit1,Y>& q1,
0244                                       const quantity<Unit2,Y>& q2,
0245                                       const quantity<Unit3,Y>& q3)
0246 {
0247     using namespace detail;
0248 
0249     typedef quantity<Unit1,Y>   type1;
0250     typedef quantity<Unit2,Y>   type2;
0251     typedef quantity<Unit3,Y>   type3;
0252     
0253     typedef typename multiply_typeof_helper<type1,type2>::type  prod_type;
0254     typedef typename add_typeof_helper<prod_type,type3>::type   quantity_type;
0255     
0256     return quantity_type::from_value(fma BOOST_PREVENT_MACRO_SUBSTITUTION (q1.value(),q2.value(),q3.value()));
0257 }
0258 
0259 #endif
0260 
0261 template<class Unit,class Y>
0262 inline 
0263 BOOST_CONSTEXPR
0264 quantity<Unit,Y> 
0265 fmax BOOST_PREVENT_MACRO_SUBSTITUTION (const quantity<Unit,Y>& q1,
0266                                        const quantity<Unit,Y>& q2)
0267 {
0268     using namespace detail;
0269 
0270     typedef quantity<Unit,Y>    quantity_type;
0271     
0272     return quantity_type::from_value(fmax BOOST_PREVENT_MACRO_SUBSTITUTION (q1.value(),q2.value()));
0273 }
0274 
0275 template<class Unit,class Y>
0276 inline 
0277 BOOST_CONSTEXPR
0278 quantity<Unit,Y> 
0279 fmin BOOST_PREVENT_MACRO_SUBSTITUTION (const quantity<Unit,Y>& q1,
0280                                        const quantity<Unit,Y>& q2)
0281 {
0282     using namespace detail;
0283 
0284     typedef quantity<Unit,Y>    quantity_type;
0285     
0286     return quantity_type::from_value(fmin BOOST_PREVENT_MACRO_SUBSTITUTION (q1.value(),q2.value()));
0287 }
0288 
0289 template<class Unit,class Y>
0290 inline 
0291 BOOST_CONSTEXPR
0292 int 
0293 fpclassify BOOST_PREVENT_MACRO_SUBSTITUTION (const quantity<Unit,Y>& q)
0294 { 
0295     using boost::math::fpclassify;
0296 
0297     return fpclassify BOOST_PREVENT_MACRO_SUBSTITUTION (q.value());
0298 }
0299 
0300 template<class Unit,class Y>
0301 inline 
0302 BOOST_CONSTEXPR
0303 typename root_typeof_helper<
0304     typename add_typeof_helper<
0305         typename power_typeof_helper<quantity<Unit,Y>,
0306                                      static_rational<2> >::type,
0307         typename power_typeof_helper<quantity<Unit,Y>,
0308                                      static_rational<2> >::type>::type,
0309         static_rational<2> >::type
0310 hypot BOOST_PREVENT_MACRO_SUBSTITUTION (const quantity<Unit,Y>& q1,const quantity<Unit,Y>& q2)
0311 {
0312     using boost::math::hypot;
0313 
0314     typedef quantity<Unit,Y>    type1;
0315     
0316     typedef typename power_typeof_helper<type1,static_rational<2> >::type   pow_type;
0317     typedef typename add_typeof_helper<pow_type,pow_type>::type             add_type;
0318     typedef typename root_typeof_helper<add_type,static_rational<2> >::type quantity_type;
0319         
0320     return quantity_type::from_value(hypot BOOST_PREVENT_MACRO_SUBSTITUTION (q1.value(),q2.value()));
0321 }
0322 
0323 // does ISO C++ support long long? g++ claims not
0324 //template<class Unit,class Y>
0325 //inline 
0326 //BOOST_CONSTEXPR
0327 //quantity<Unit,long long> 
0328 //llrint BOOST_PREVENT_MACRO_SUBSTITUTION (const quantity<Unit,Y>& q)
0329 //{
0330 //    using namespace detail;
0331 //
0332 //    typedef quantity<Unit,long long>    quantity_type;
0333 //    
0334 //    return quantity_type::from_value(llrint BOOST_PREVENT_MACRO_SUBSTITUTION (q.value()));
0335 //}
0336 
0337 // does ISO C++ support long long? g++ claims not
0338 //template<class Unit,class Y>
0339 //inline 
0340 //BOOST_CONSTEXPR
0341 //quantity<Unit,long long> 
0342 //llround BOOST_PREVENT_MACRO_SUBSTITUTION (const quantity<Unit,Y>& q)
0343 //{
0344 //    using namespace detail;
0345 //
0346 //    typedef quantity<Unit,long long>    quantity_type;
0347 //    
0348 //    return quantity_type::from_value(llround BOOST_PREVENT_MACRO_SUBSTITUTION (q.value()));
0349 //}
0350 
0351 #if 0
0352 
0353 template<class Unit,class Y>
0354 inline 
0355 BOOST_CONSTEXPR
0356 quantity<Unit,Y> 
0357 nearbyint BOOST_PREVENT_MACRO_SUBSTITUTION (const quantity<Unit,Y>& q)
0358 {
0359     using namespace detail;
0360 
0361     typedef quantity<Unit,Y>    quantity_type;
0362     
0363     return quantity_type::from_value(nearbyint BOOST_PREVENT_MACRO_SUBSTITUTION (q.value()));
0364 }
0365 
0366 #endif
0367 
0368 template<class Unit,class Y>
0369 inline 
0370 BOOST_CONSTEXPR
0371 quantity<Unit,Y> nextafter BOOST_PREVENT_MACRO_SUBSTITUTION (const quantity<Unit,Y>& q1,
0372                                                              const quantity<Unit,Y>& q2)
0373 {
0374     using boost::math::nextafter;
0375 
0376     typedef quantity<Unit,Y>    quantity_type;
0377     
0378     return quantity_type::from_value(nextafter BOOST_PREVENT_MACRO_SUBSTITUTION (q1.value(),q2.value()));
0379 }
0380 template<class Unit,class Y>
0381 inline 
0382 BOOST_CONSTEXPR
0383 quantity<Unit,Y> nexttoward BOOST_PREVENT_MACRO_SUBSTITUTION (const quantity<Unit,Y>& q1,
0384                                                               const quantity<Unit,Y>& q2)
0385 {
0386     // the only difference between nextafter and nexttowards is
0387     // in the argument types.  Since we are requiring identical
0388     // argument types, there is no difference.
0389     using boost::math::nextafter;
0390 
0391     typedef quantity<Unit,Y>    quantity_type;
0392     
0393     return quantity_type::from_value(nextafter BOOST_PREVENT_MACRO_SUBSTITUTION (q1.value(),q2.value()));
0394 }
0395 
0396 #if 0
0397 
0398 template<class Unit,class Y>
0399 inline 
0400 BOOST_CONSTEXPR
0401 quantity<Unit,Y> 
0402 rint BOOST_PREVENT_MACRO_SUBSTITUTION (const quantity<Unit,Y>& q)
0403 {
0404     using namespace detail;
0405 
0406     typedef quantity<Unit,Y>    quantity_type;
0407     
0408     return quantity_type::from_value(rint BOOST_PREVENT_MACRO_SUBSTITUTION (q.value()));
0409 }
0410 
0411 #endif
0412 
0413 template<class Unit,class Y>
0414 inline 
0415 BOOST_CONSTEXPR
0416 quantity<Unit,Y> 
0417 round BOOST_PREVENT_MACRO_SUBSTITUTION (const quantity<Unit,Y>& q)
0418 {
0419     using boost::math::round;
0420 
0421     typedef quantity<Unit,Y>    quantity_type;
0422     
0423     return quantity_type::from_value(round BOOST_PREVENT_MACRO_SUBSTITUTION (q.value()));
0424 }
0425 
0426 template<class Unit,class Y>
0427 inline 
0428 BOOST_CONSTEXPR
0429 int 
0430 signbit BOOST_PREVENT_MACRO_SUBSTITUTION (const quantity<Unit,Y>& q)
0431 { 
0432     using boost::math::signbit;
0433 
0434     return signbit BOOST_PREVENT_MACRO_SUBSTITUTION (q.value());
0435 }
0436 
0437 template<class Unit,class Y>
0438 inline 
0439 BOOST_CONSTEXPR
0440 quantity<Unit,Y> 
0441 trunc BOOST_PREVENT_MACRO_SUBSTITUTION (const quantity<Unit,Y>& q)
0442 {
0443     using namespace detail;
0444 
0445     typedef quantity<Unit,Y>    quantity_type;
0446     
0447     return quantity_type::from_value(trunc BOOST_PREVENT_MACRO_SUBSTITUTION (q.value()));
0448 }
0449 
0450 template<class Unit,class Y>
0451 inline
0452 BOOST_CONSTEXPR
0453 quantity<Unit, Y>
0454 fmod(const quantity<Unit,Y>& q1, const quantity<Unit,Y>& q2)
0455 {
0456     using std::fmod;
0457     
0458     typedef quantity<Unit,Y> quantity_type;
0459 
0460     return quantity_type::from_value(fmod(q1.value(), q2.value()));
0461 }
0462 
0463 template<class Unit, class Y>
0464 inline
0465 BOOST_CONSTEXPR
0466 quantity<Unit, Y>
0467 modf(const quantity<Unit, Y>& q1, quantity<Unit, Y>* q2)
0468 {
0469     using std::modf;
0470 
0471     typedef quantity<Unit,Y> quantity_type;
0472 
0473     return quantity_type::from_value(modf(q1.value(), &quantity_cast<Y&>(*q2)));
0474 }
0475 
0476 template<class Unit, class Y, class Int>
0477 inline
0478 BOOST_CONSTEXPR
0479 quantity<Unit, Y>
0480 frexp(const quantity<Unit, Y>& q,Int* ex)
0481 {
0482     using std::frexp;
0483 
0484     typedef quantity<Unit,Y> quantity_type;
0485 
0486     return quantity_type::from_value(frexp(q.value(),ex));
0487 }
0488 
0489 /// For non-dimensionless quantities, integral and rational powers 
0490 /// and roots can be computed by @c pow<Ex> and @c root<Rt> respectively.
0491 template<class S, class Y>
0492 inline
0493 BOOST_CONSTEXPR
0494 quantity<BOOST_UNITS_DIMENSIONLESS_UNIT(S), Y>
0495 pow(const quantity<BOOST_UNITS_DIMENSIONLESS_UNIT(S), Y>& q1,
0496     const quantity<BOOST_UNITS_DIMENSIONLESS_UNIT(S), Y>& q2)
0497 {
0498     using std::pow;
0499 
0500     typedef quantity<BOOST_UNITS_DIMENSIONLESS_UNIT(S),Y> quantity_type;
0501 
0502     return quantity_type::from_value(pow(q1.value(), q2.value()));
0503 }
0504 
0505 template<class S, class Y>
0506 inline
0507 BOOST_CONSTEXPR
0508 quantity<BOOST_UNITS_DIMENSIONLESS_UNIT(S), Y>
0509 exp(const quantity<BOOST_UNITS_DIMENSIONLESS_UNIT(S), Y>& q)
0510 {
0511     using std::exp;
0512 
0513     typedef quantity<BOOST_UNITS_DIMENSIONLESS_UNIT(S), Y> quantity_type;
0514 
0515     return quantity_type::from_value(exp(q.value()));
0516 }
0517 
0518 template<class Unit, class Y, class Int>
0519 inline
0520 BOOST_CONSTEXPR
0521 quantity<Unit, Y>
0522 ldexp(const quantity<Unit, Y>& q,const Int& ex)
0523 {
0524     using std::ldexp;
0525 
0526     typedef quantity<Unit,Y> quantity_type;
0527 
0528     return quantity_type::from_value(ldexp(q.value(), ex));
0529 }
0530 
0531 template<class S, class Y>
0532 inline
0533 BOOST_CONSTEXPR
0534 quantity<BOOST_UNITS_DIMENSIONLESS_UNIT(S), Y>
0535 log(const quantity<BOOST_UNITS_DIMENSIONLESS_UNIT(S), Y>& q)
0536 {
0537     using std::log;
0538 
0539     typedef quantity<BOOST_UNITS_DIMENSIONLESS_UNIT(S), Y> quantity_type;
0540 
0541     return quantity_type::from_value(log(q.value()));
0542 }
0543 
0544 template<class S, class Y>
0545 inline
0546 BOOST_CONSTEXPR
0547 quantity<BOOST_UNITS_DIMENSIONLESS_UNIT(S), Y>
0548 log10(const quantity<BOOST_UNITS_DIMENSIONLESS_UNIT(S), Y>& q)
0549 {
0550     using std::log10;
0551 
0552     typedef quantity<BOOST_UNITS_DIMENSIONLESS_UNIT(S), Y> quantity_type;
0553 
0554     return quantity_type::from_value(log10(q.value()));
0555 }
0556 
0557 template<class Unit,class Y>
0558 inline 
0559 BOOST_CONSTEXPR
0560 typename root_typeof_helper<
0561                             quantity<Unit,Y>,
0562                             static_rational<2>
0563                            >::type
0564 sqrt(const quantity<Unit,Y>& q)
0565 {
0566     using std::sqrt;
0567 
0568     typedef typename root_typeof_helper<
0569                                         quantity<Unit,Y>,
0570                                         static_rational<2>
0571                                        >::type quantity_type;
0572 
0573     return quantity_type::from_value(sqrt(q.value()));
0574 }
0575 
0576 } // namespace units
0577 
0578 } // namespace boost
0579 
0580 namespace boost {
0581 
0582 namespace units {
0583 
0584 // trig functions with si argument/return types
0585 
0586 /// cos of theta in radians
0587 template<class Y>
0588 BOOST_CONSTEXPR
0589 typename dimensionless_quantity<si::system,Y>::type 
0590 cos(const quantity<si::plane_angle,Y>& theta)
0591 {
0592     using std::cos;
0593     return cos(theta.value());
0594 }
0595 
0596 /// sin of theta in radians
0597 template<class Y>
0598 BOOST_CONSTEXPR
0599 typename dimensionless_quantity<si::system,Y>::type 
0600 sin(const quantity<si::plane_angle,Y>& theta)
0601 {
0602     using std::sin;
0603     return sin(theta.value());
0604 }
0605 
0606 /// tan of theta in radians
0607 template<class Y>
0608 BOOST_CONSTEXPR
0609 typename dimensionless_quantity<si::system,Y>::type 
0610 tan(const quantity<si::plane_angle,Y>& theta)
0611 {
0612     using std::tan;
0613     return tan(theta.value());
0614 }
0615 
0616 /// cos of theta in other angular units 
0617 template<class System,class Y>
0618 BOOST_CONSTEXPR
0619 typename dimensionless_quantity<System,Y>::type 
0620 cos(const quantity<unit<plane_angle_dimension,System>,Y>& theta)
0621 {
0622     return cos(quantity<si::plane_angle,Y>(theta));
0623 }
0624 
0625 /// sin of theta in other angular units 
0626 template<class System,class Y>
0627 BOOST_CONSTEXPR
0628 typename dimensionless_quantity<System,Y>::type 
0629 sin(const quantity<unit<plane_angle_dimension,System>,Y>& theta)
0630 {
0631     return sin(quantity<si::plane_angle,Y>(theta));
0632 }
0633 
0634 /// tan of theta in other angular units 
0635 template<class System,class Y>
0636 BOOST_CONSTEXPR
0637 typename dimensionless_quantity<System,Y>::type 
0638 tan(const quantity<unit<plane_angle_dimension,System>,Y>& theta)
0639 {
0640     return tan(quantity<si::plane_angle,Y>(theta));
0641 }
0642 
0643 /// acos of dimensionless quantity returning angle in same system
0644 template<class Y,class System>
0645 BOOST_CONSTEXPR
0646 quantity<unit<plane_angle_dimension, homogeneous_system<System> >,Y>
0647 acos(const quantity<unit<dimensionless_type, homogeneous_system<System> >,Y>& val)
0648 {
0649     using std::acos;
0650     return quantity<unit<plane_angle_dimension, homogeneous_system<System> >,Y>(acos(val.value())*si::radians);
0651 }
0652 
0653 /// acos of dimensionless quantity returning angle in radians
0654 template<class Y>
0655 BOOST_CONSTEXPR
0656 quantity<angle::radian_base_unit::unit_type,Y>
0657 acos(const quantity<unit<dimensionless_type, heterogeneous_dimensionless_system>,Y>& val)
0658 {
0659     using std::acos;
0660     return quantity<angle::radian_base_unit::unit_type,Y>::from_value(acos(val.value()));
0661 }
0662 
0663 /// asin of dimensionless quantity returning angle in same system
0664 template<class Y,class System>
0665 BOOST_CONSTEXPR
0666 quantity<unit<plane_angle_dimension, homogeneous_system<System> >,Y>
0667 asin(const quantity<unit<dimensionless_type, homogeneous_system<System> >,Y>& val)
0668 {
0669     using std::asin;
0670     return quantity<unit<plane_angle_dimension, homogeneous_system<System> >,Y>(asin(val.value())*si::radians);
0671 }
0672 
0673 /// asin of dimensionless quantity returning angle in radians
0674 template<class Y>
0675 BOOST_CONSTEXPR
0676 quantity<angle::radian_base_unit::unit_type,Y>
0677 asin(const quantity<unit<dimensionless_type, heterogeneous_dimensionless_system>,Y>& val)
0678 {
0679     using std::asin;
0680     return quantity<angle::radian_base_unit::unit_type,Y>::from_value(asin(val.value()));
0681 }
0682 
0683 /// atan of dimensionless quantity returning angle in same system
0684 template<class Y,class System>
0685 BOOST_CONSTEXPR
0686 quantity<unit<plane_angle_dimension, homogeneous_system<System> >,Y>
0687 atan(const quantity<unit<dimensionless_type, homogeneous_system<System> >, Y>& val)
0688 {
0689     using std::atan;
0690     return quantity<unit<plane_angle_dimension, homogeneous_system<System> >,Y>(atan(val.value())*si::radians);
0691 }
0692 
0693 /// atan of dimensionless quantity returning angle in radians
0694 template<class Y>
0695 BOOST_CONSTEXPR
0696 quantity<angle::radian_base_unit::unit_type,Y>
0697 atan(const quantity<unit<dimensionless_type, heterogeneous_dimensionless_system>, Y>& val)
0698 {
0699     using std::atan;
0700     return quantity<angle::radian_base_unit::unit_type,Y>::from_value(atan(val.value()));
0701 }
0702 
0703 /// atan2 of @c value_type returning angle in radians
0704 template<class Y, class Dimension, class System>
0705 BOOST_CONSTEXPR
0706 quantity<unit<plane_angle_dimension, homogeneous_system<System> >, Y>
0707 atan2(const quantity<unit<Dimension, homogeneous_system<System> >, Y>& y,
0708       const quantity<unit<Dimension, homogeneous_system<System> >, Y>& x)
0709 {
0710     using std::atan2;
0711     return quantity<unit<plane_angle_dimension, homogeneous_system<System> >, Y>(atan2(y.value(),x.value())*si::radians);
0712 }
0713 
0714 /// atan2 of @c value_type returning angle in radians
0715 template<class Y, class Dimension, class System>
0716 BOOST_CONSTEXPR
0717 quantity<angle::radian_base_unit::unit_type,Y>
0718 atan2(const quantity<unit<Dimension, heterogeneous_system<System> >, Y>& y,
0719       const quantity<unit<Dimension, heterogeneous_system<System> >, Y>& x)
0720 {
0721     using std::atan2;
0722     return quantity<angle::radian_base_unit::unit_type,Y>::from_value(atan2(y.value(),x.value()));
0723 }
0724 
0725 } // namespace units
0726 
0727 } // namespace boost
0728 
0729 #endif // BOOST_UNITS_CMATH_HPP