Boost logo

Boost-Commit :

From: boost_at_[hidden]
Date: 2008-05-18 21:10:08


Author: matthiasschabel
Date: 2008-05-18 21:10:08 EDT (Sun, 18 May 2008)
New Revision: 45516
URL: http://svn.boost.org/trac/boost/changeset/45516

Log:
move SI trig functions into cmath.hpp
Removed:
   sandbox/units/boost/units/systems/trig.hpp
Text files modified:
   sandbox/units/boost/units/cmath.hpp | 108 ++++++++++++++++++++++++++++++++++++++++
   sandbox/units/libs/units/example/kitchen_sink.cpp | 2
   2 files changed, 109 insertions(+), 1 deletions(-)

Modified: sandbox/units/boost/units/cmath.hpp
==============================================================================
--- sandbox/units/boost/units/cmath.hpp (original)
+++ sandbox/units/boost/units/cmath.hpp 2008-05-18 21:10:08 EDT (Sun, 18 May 2008)
@@ -19,10 +19,13 @@
 #include <boost/math/special_functions/hypot.hpp>
 #include <boost/math/special_functions/round.hpp>
 
+#include <boost/units/dimensionless_quantity.hpp>
 #include <boost/units/pow.hpp>
 #include <boost/units/quantity.hpp>
 #include <boost/units/detail/cmath_impl.hpp>
 
+#include <boost/units/systems/si/plane_angle.hpp>
+
 /// \file
 /// \brief Overloads of functions in \<cmath\> for quantities
 ///
@@ -516,6 +519,111 @@
     return quantity_type::from_value(sqrt(q.value()));
 }
 
+// trig functions with si argument/return types
+/// cos of theta in radians
+template<class Y>
+typename dimensionless_quantity<si::system,Y>::type
+cos(const quantity<si::plane_angle,Y>& theta)
+{
+ return std::cos(theta.value());
+}
+
+/// sin of theta in radians
+template<class Y>
+typename dimensionless_quantity<si::system,Y>::type
+sin(const quantity<si::plane_angle,Y>& theta)
+{
+ return std::sin(theta.value());
+}
+
+/// tan of theta in radians
+template<class Y>
+typename dimensionless_quantity<si::system,Y>::type
+tan(const quantity<si::plane_angle,Y>& theta)
+{
+ return std::tan(theta.value());
+}
+
+/// cos of theta in other angular units
+template<class System,class Y>
+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>
+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>
+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 @c value_type returning angle in radians
+template<class Y>
+quantity<si::plane_angle,Y>
+acos(const Y& val)
+{
+ return quantity<si::plane_angle,Y>(std::acos(val)*si::radians);
+}
+
+/// acos of dimensionless quantity returning angle in same system
+template<class Y,class System>
+quantity<unit<plane_angle_dimension,System>,Y>
+acos(const quantity<unit<dimensionless_type,System>,Y>& val)
+{
+ return quantity<unit<plane_angle_dimension,System>,Y>(std::acos(val)*si::radians);
+}
+
+/// asin of @c value_type returning angle in radians
+template<class Y>
+quantity<si::plane_angle,Y>
+asin(const Y& val)
+{
+ return quantity<si::plane_angle,Y>(std::asin(val)*si::radians);
+}
+
+/// asin of dimensionless quantity returning angle in same system
+template<class Y,class System>
+quantity<unit<plane_angle_dimension,System>,Y>
+asin(const quantity<unit<dimensionless_type,System>,Y>& val)
+{
+ return quantity<unit<plane_angle_dimension,System>,Y>(std::asin(val)*si::radians);
+}
+
+/// atan of @c value_type returning angle in radians
+template<class Y>
+quantity<si::plane_angle,Y>
+atan(const Y& val)
+{
+ return quantity<si::plane_angle,Y>(std::atan(val)*si::radians);
+}
+
+/// atan of dimensionless quantity returning angle in same system
+template<class Y,class System>
+quantity<unit<plane_angle_dimension,System>,Y>
+atan(const quantity<unit<dimensionless_type,System>,Y>& val)
+{
+ return quantity<unit<plane_angle_dimension,System>,Y>(std::atan(val)*si::radians);
+}
+
+/// atan2 of @c value_type returning angle in radians
+template<class Y>
+quantity<si::plane_angle,Y>
+atan2(const Y& y,const Y& x)
+{
+ return quantity<si::plane_angle,Y>(std::atan2(y,x)*si::radians);
+}
+
 } // namespace units
 
 } // namespace boost

Deleted: sandbox/units/boost/units/systems/trig.hpp
==============================================================================
--- sandbox/units/boost/units/systems/trig.hpp 2008-05-18 21:10:08 EDT (Sun, 18 May 2008)
+++ (empty file)
@@ -1,132 +0,0 @@
-// 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) 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 BOOST_UNITS_TRIG_HPP
-#define BOOST_UNITS_TRIG_HPP
-
-#include <cmath>
-
-#include <boost/units/dimensionless_quantity.hpp>
-#include <boost/units/quantity.hpp>
-#include <boost/units/systems/si/plane_angle.hpp>
-
-namespace boost {
-
-namespace units {
-
-/// cos of theta in radians
-template<class Y>
-typename dimensionless_quantity<si::system,Y>::type
-cos(const quantity<si::plane_angle,Y>& theta)
-{
- return std::cos(theta.value());
-}
-
-/// sin of theta in radians
-template<class Y>
-typename dimensionless_quantity<si::system,Y>::type
-sin(const quantity<si::plane_angle,Y>& theta)
-{
- return std::sin(theta.value());
-}
-
-/// tan of theta in radians
-template<class Y>
-typename dimensionless_quantity<si::system,Y>::type
-tan(const quantity<si::plane_angle,Y>& theta)
-{
- return std::tan(theta.value());
-}
-
-/// cos of theta in other angular units
-template<class System,class Y>
-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>
-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>
-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 @c value_type returning angle in radians
-template<class Y>
-quantity<si::plane_angle,Y>
-acos(const Y& val)
-{
- return quantity<si::plane_angle,Y>(std::acos(val)*si::radians);
-}
-
-/// acos of dimensionless quantity returning angle in same system
-template<class Y,class System>
-quantity<unit<plane_angle_dimension,System>,Y>
-acos(const quantity<unit<dimensionless_type,System>,Y>& val)
-{
- return quantity<unit<plane_angle_dimension,System>,Y>(std::acos(val)*si::radians);
-}
-
-/// asin of @c value_type returning angle in radians
-template<class Y>
-quantity<si::plane_angle,Y>
-asin(const Y& val)
-{
- return quantity<si::plane_angle,Y>(std::asin(val)*si::radians);
-}
-
-/// asin of dimensionless quantity returning angle in same system
-template<class Y,class System>
-quantity<unit<plane_angle_dimension,System>,Y>
-asin(const quantity<unit<dimensionless_type,System>,Y>& val)
-{
- return quantity<unit<plane_angle_dimension,System>,Y>(std::asin(val)*si::radians);
-}
-
-/// atan of @c value_type returning angle in radians
-template<class Y>
-quantity<si::plane_angle,Y>
-atan(const Y& val)
-{
- return quantity<si::plane_angle,Y>(std::atan(val)*si::radians);
-}
-
-/// atan of dimensionless quantity returning angle in same system
-template<class Y,class System>
-quantity<unit<plane_angle_dimension,System>,Y>
-atan(const quantity<unit<dimensionless_type,System>,Y>& val)
-{
- return quantity<unit<plane_angle_dimension,System>,Y>(std::atan(val)*si::radians);
-}
-
-/// atan2 of @c value_type returning angle in radians
-template<class Y>
-quantity<si::plane_angle,Y>
-atan2(const Y& y,const Y& x)
-{
- return quantity<si::plane_angle,Y>(std::atan2(y,x)*si::radians);
-}
-
-} // namespace units
-
-} // namespace boost
-
-#endif // BOOST_UNITS_TRIG_HPP

Modified: sandbox/units/libs/units/example/kitchen_sink.cpp
==============================================================================
--- sandbox/units/libs/units/example/kitchen_sink.cpp (original)
+++ sandbox/units/libs/units/example/kitchen_sink.cpp 2008-05-18 21:10:08 EDT (Sun, 18 May 2008)
@@ -143,9 +143,9 @@
 
 #include <boost/typeof/std/complex.hpp>
 
+#include <boost/units/cmath.hpp>
 #include <boost/units/io.hpp>
 #include <boost/units/systems/si.hpp>
-#include <boost/units/systems/trig.hpp>
 #include <boost/units/systems/si/codata/physico-chemical_constants.hpp>
 
 #include "measurement.hpp"


Boost-Commit list run by bdawes at acm.org, david.abrahams at rcn.com, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk