Boost logo

Boost-Commit :

From: steven_at_[hidden]
Date: 2008-05-14 17:54:33


Author: steven_watanabe
Date: 2008-05-14 17:54:31 EDT (Wed, 14 May 2008)
New Revision: 45372
URL: http://svn.boost.org/trac/boost/changeset/45372

Log:
Moved pow into its own directory
Added:
   sandbox/units/boost/units/pow.hpp
      - copied, changed from r45358, /sandbox/units/boost/units/static_rational.hpp
Text files modified:
   sandbox/units/boost/units/absolute.hpp | 3
   sandbox/units/boost/units/cmath.hpp | 6
   sandbox/units/boost/units/pow.hpp | 186 ---------------------------------------
   sandbox/units/boost/units/static_rational.hpp | 72 ---------------
   sandbox/units/boost/units/systems/si/codata/physico-chemical_constants.hpp | 1
   sandbox/units/libs/units/example/complex.cpp | 1
   sandbox/units/libs/units/example/conversion.cpp | 1
   sandbox/units/libs/units/example/heterogeneous_unit.cpp | 1
   sandbox/units/libs/units/example/quantity.cpp | 1
   sandbox/units/libs/units/example/quaternion.cpp | 1
   sandbox/units/libs/units/example/radar_beam_height.cpp | 1
   sandbox/units/libs/units/example/unit.cpp | 2
   sandbox/units/libs/units/test/test_dimensionless_quantity.cpp | 2
   sandbox/units/libs/units/test/test_quantity.cpp | 2
   sandbox/units/libs/units/test/test_unit.cpp | 2
   15 files changed, 26 insertions(+), 256 deletions(-)

Modified: sandbox/units/boost/units/absolute.hpp
==============================================================================
--- sandbox/units/boost/units/absolute.hpp (original)
+++ sandbox/units/boost/units/absolute.hpp 2008-05-14 17:54:31 EDT (Wed, 14 May 2008)
@@ -11,7 +11,8 @@
 #ifndef BOOST_UNITS_ABSOLUTE_HPP
 #define BOOST_UNITS_ABSOLUTE_HPP
 
-#include <iosfwd>
+// necessary because the expression os << "absolute " is not dependent.
+#include <ostream>
 
 #include <boost/units/detail/absolute_impl.hpp>
 

Modified: sandbox/units/boost/units/cmath.hpp
==============================================================================
--- sandbox/units/boost/units/cmath.hpp (original)
+++ sandbox/units/boost/units/cmath.hpp 2008-05-14 17:54:31 EDT (Wed, 14 May 2008)
@@ -14,13 +14,15 @@
 #include <cmath>
 #include <cstdlib>
 
-#include <boost/units/quantity.hpp>
-#include <boost/units/detail/cmath_impl.hpp>
 #include <boost/math/special_functions/fpclassify.hpp>
 #include <boost/math/special_functions/sign.hpp>
 #include <boost/math/special_functions/hypot.hpp>
 #include <boost/math/special_functions/round.hpp>
 
+#include <boost/units/pow.hpp>
+#include <boost/units/quantity.hpp>
+#include <boost/units/detail/cmath_impl.hpp>
+
 /// \file
 /// \brief Overloads of functions in \<cmath\> for quantities
 ///

Copied: sandbox/units/boost/units/pow.hpp (from r45358, /sandbox/units/boost/units/static_rational.hpp)
==============================================================================
--- /sandbox/units/boost/units/static_rational.hpp (original)
+++ sandbox/units/boost/units/pow.hpp 2008-05-14 17:54:31 EDT (Wed, 14 May 2008)
@@ -8,124 +8,22 @@
 // accompanying file LICENSE_1_0.txt or copy at
 // http://www.boost.org/LICENSE_1_0.txt)
 
-#ifndef BOOST_UNITS_STATIC_RATIONAL_HPP
-#define BOOST_UNITS_STATIC_RATIONAL_HPP
-
-#include <cmath>
-#include <complex>
+#ifndef BOOST_UNITS_POW_HPP
+#define BOOST_UNITS_POW_HPP
 
 #include <boost/type_traits/is_integral.hpp>
-#include <boost/math/common_factor_ct.hpp>
-#include <boost/mpl/less.hpp>
-#include <boost/mpl/arithmetic.hpp>
-#include <boost/mpl/less.hpp>
-#include <boost/mpl/if.hpp>
 
 #include <boost/units/operators.hpp>
+#include <boost/units/static_rational.hpp>
 #include <boost/units/detail/static_rational_power.hpp>
 
 /// \file
-/// \brief Compile-time rational numbers and operators.
-
-namespace boost {
-
-namespace units {
-
-namespace detail {
-
-struct static_rational_tag {};
-
-}
-
-typedef long integer_type;
-
-/// Compile time absolute value.
-template<integer_type Value>
-struct static_abs
-{
- BOOST_STATIC_CONSTANT(integer_type,value) = Value < 0 ? -Value : Value;
-};
-
-/// Compile time rational number.
-/**
-This is an implementation of a compile time rational number, where @c static_rational<N,D> represents
-a rational number with numerator @c N and denominator @c D. Because of the potential for ambiguity arising
-from multiple equivalent values of @c static_rational (e.g. @c static_rational<6,2>==static_rational<3>),
-static rationals should always be accessed through @c static_rational<N,D>::type. Template specialization
-prevents instantiation of zero denominators (i.e. @c static_rational<N,0>). The following compile-time
-arithmetic operators are provided for static_rational variables only (no operators are defined between
-long and static_rational):
- - @c mpl::negate
- - @c mpl::plus
- - @c mpl::minus
- - @c mpl::times
- - @c mpl::divides
-
-Neither @c static_power nor @c static_root are defined for @c static_rational. This is because template types
-may not be floating point values, while powers and roots of rational numbers can produce floating point
-values.
-*/
-template<integer_type N,integer_type D = 1>
-class static_rational
-{
- private:
- static const integer_type nabs = static_abs<N>::value,
- dabs = static_abs<D>::value;
-
- /// greatest common divisor of N and D
- // need cast to signed because static_gcd returns unsigned long
- static const integer_type den =
- static_cast<integer_type>(boost::math::static_gcd<nabs,dabs>::value) * ((D < 0) ? -1 : 1);
-
- public:
- // for mpl arithmetic support
- typedef detail::static_rational_tag tag;
-
- static const integer_type Numerator = N/den,
- Denominator = D/den;
-
- /// INTERNAL ONLY
- typedef static_rational<N,D> this_type;
-
- /// static_rational<N,D> reduced by GCD
- typedef static_rational<Numerator,Denominator> type;
-
- static integer_type numerator() { return Numerator; }
- static integer_type denominator() { return Denominator; }
-
- // INTERNAL ONLY
- static_rational() { }
- //~static_rational() { }
-
-};
-
-}
-
-}
-
-#if BOOST_UNITS_HAS_BOOST_TYPEOF
-
-#include BOOST_TYPEOF_INCREMENT_REGISTRATION_GROUP()
-
-BOOST_TYPEOF_REGISTER_TEMPLATE(boost::units::static_rational, (long)(long))
-
-#endif
+/// \brief Raise values to exponents known as compile-time
 
 namespace boost {
 
 namespace units {
 
-// prohibit zero denominator
-template<integer_type N> class static_rational<N,0>;
-
-/// get decimal value of @c static_rational
-template<class T,integer_type N,integer_type D>
-inline typename divide_typeof_helper<T,T>::type
-value(const static_rational<N,D>&)
-{
- return T(N)/T(D);
-}
-
 /// raise a value to a @c static_rational power
 template<class Rat,class Y>
 inline typename power_dimof_helper<Y,Rat>::type
@@ -192,82 +90,6 @@
 
 } // namespace units
 
-#ifndef BOOST_UNITS_DOXYGEN
-
-namespace mpl {
-
-template<>
-struct plus_impl<boost::units::detail::static_rational_tag, boost::units::detail::static_rational_tag>
-{
- template<class T0, class T1>
- struct apply {
- typedef typename boost::units::static_rational<
- T0::Numerator*T1::Denominator+T1::Numerator*T0::Denominator,
- T0::Denominator*T1::Denominator
- >::type type;
- };
-};
-
-template<>
-struct minus_impl<boost::units::detail::static_rational_tag, boost::units::detail::static_rational_tag>
-{
- template<class T0, class T1>
- struct apply {
- typedef typename boost::units::static_rational<
- T0::Numerator*T1::Denominator-T1::Numerator*T0::Denominator,
- T0::Denominator*T1::Denominator
- >::type type;
- };
-};
-
-template<>
-struct times_impl<boost::units::detail::static_rational_tag, boost::units::detail::static_rational_tag>
-{
- template<class T0, class T1>
- struct apply {
- typedef typename boost::units::static_rational<
- T0::Numerator*T1::Numerator,
- T0::Denominator*T1::Denominator
- >::type type;
- };
-};
-
-template<>
-struct divides_impl<boost::units::detail::static_rational_tag, boost::units::detail::static_rational_tag>
-{
- template<class T0, class T1>
- struct apply {
- typedef typename boost::units::static_rational<
- T0::Numerator*T1::Denominator,
- T0::Denominator*T1::Numerator
- >::type type;
- };
-};
-
-template<>
-struct negate_impl<boost::units::detail::static_rational_tag>
-{
- template<class T0>
- struct apply {
- typedef typename boost::units::static_rational<-T0::Numerator,T0::Denominator>::type type;
- };
-};
-
-template<>
-struct less_impl<boost::units::detail::static_rational_tag, boost::units::detail::static_rational_tag>
-{
- template<class T0, class T1>
- struct apply
- {
- typedef mpl::bool_<((mpl::minus<T0, T1>::type::Numerator) < 0)> type;
- };
-};
-
-
-}
-
-#endif
-
 } // namespace boost
 
 #endif // BOOST_UNITS_STATIC_RATIONAL_HPP

Modified: sandbox/units/boost/units/static_rational.hpp
==============================================================================
--- sandbox/units/boost/units/static_rational.hpp (original)
+++ sandbox/units/boost/units/static_rational.hpp 2008-05-14 17:54:31 EDT (Wed, 14 May 2008)
@@ -11,18 +11,12 @@
 #ifndef BOOST_UNITS_STATIC_RATIONAL_HPP
 #define BOOST_UNITS_STATIC_RATIONAL_HPP
 
-#include <cmath>
-#include <complex>
-
-#include <boost/type_traits/is_integral.hpp>
 #include <boost/math/common_factor_ct.hpp>
 #include <boost/mpl/less.hpp>
 #include <boost/mpl/arithmetic.hpp>
-#include <boost/mpl/less.hpp>
-#include <boost/mpl/if.hpp>
 
+#include <boost/units/config.hpp>
 #include <boost/units/operators.hpp>
-#include <boost/units/detail/static_rational_power.hpp>
 
 /// \file
 /// \brief Compile-time rational numbers and operators.
@@ -126,70 +120,6 @@
     return T(N)/T(D);
 }
 
-/// raise a value to a @c static_rational power
-template<class Rat,class Y>
-inline typename power_dimof_helper<Y,Rat>::type
-pow(const Y& x)
-{
- return power_dimof_helper<Y,Rat>::value(x);
-}
-
-/// raise a value to an integer power
-template<long N,class Y>
-inline typename power_dimof_helper<Y,static_rational<N> >::type
-pow(const Y& x)
-{
- return power_dimof_helper<Y,static_rational<N> >::value(x);
-}
-
-#ifndef BOOST_UNITS_DOXYGEN
-
-/// raise @c T to a @c static_rational power
-template<class T, long N,long D>
-struct power_dimof_helper<T, static_rational<N,D> >
-{
- typedef typename mpl::if_<boost::is_integral<T>, double, T>::type internal_type;
- typedef detail::static_rational_power_impl<static_rational<N, D>, internal_type> impl;
- typedef typename impl::type type;
-
- static type value(const T& x)
- {
- return impl::call(x);
- }
-};
-
-/// raise @c float to a @c static_rational power
-template<long N,long D>
-struct power_dimof_helper<float, static_rational<N,D> >
- : power_dimof_helper<double, static_rational<N,D> > {};
-
-#endif
-
-/// take the @c static_rational root of a value
-template<class Rat,class Y>
-typename root_typeof_helper<Y,Rat>::type
-root(const Y& x)
-{
- return root_typeof_helper<Y,Rat>::value(x);
-}
-
-/// take the integer root of a value
-template<long N,class Y>
-typename root_typeof_helper<Y,static_rational<N> >::type
-root(const Y& x)
-{
- return root_typeof_helper<Y,static_rational<N> >::value(x);
-}
-
-#ifndef BOOST_UNITS_DOXYGEN
-
-/// take @c static_rational root of an @c T
-template<class T, long N,long D>
-struct root_typeof_helper<T,static_rational<N,D> >
- : power_dimof_helper<T, static_rational<D,N> > {};
-
-#endif
-
 } // namespace units
 
 #ifndef BOOST_UNITS_DOXYGEN

Modified: sandbox/units/boost/units/systems/si/codata/physico-chemical_constants.hpp
==============================================================================
--- sandbox/units/boost/units/systems/si/codata/physico-chemical_constants.hpp (original)
+++ sandbox/units/boost/units/systems/si/codata/physico-chemical_constants.hpp 2008-05-14 17:54:31 EDT (Wed, 14 May 2008)
@@ -11,6 +11,7 @@
 #ifndef BOOST_UNITS_CODATA_PHYSICO_CHEMICAL_CONSTANTS_HPP
 #define BOOST_UNITS_CODATA_PHYSICO_CHEMICAL_CONSTANTS_HPP
 
+#include <boost/units/pow.hpp>
 #include <boost/units/static_constant.hpp>
 
 #include <boost/units/systems/detail/constants.hpp>

Modified: sandbox/units/libs/units/example/complex.cpp
==============================================================================
--- sandbox/units/libs/units/example/complex.cpp (original)
+++ sandbox/units/libs/units/example/complex.cpp 2008-05-14 17:54:31 EDT (Wed, 14 May 2008)
@@ -57,6 +57,7 @@
 #include <boost/mpl/list.hpp>
 
 #include <boost/units/io.hpp>
+#include <boost/units/pow.hpp>
 #include <boost/units/quantity.hpp>
 
 #include "test_system.hpp"

Modified: sandbox/units/libs/units/example/conversion.cpp
==============================================================================
--- sandbox/units/libs/units/example/conversion.cpp (original)
+++ sandbox/units/libs/units/example/conversion.cpp 2008-05-14 17:54:31 EDT (Wed, 14 May 2008)
@@ -64,6 +64,7 @@
 #include <algorithm>
 
 #include <boost/units/io.hpp>
+#include <boost/units/pow.hpp>
 #include <boost/units/systems/cgs.hpp>
 #include <boost/units/systems/si.hpp>
 

Modified: sandbox/units/libs/units/example/heterogeneous_unit.cpp
==============================================================================
--- sandbox/units/libs/units/example/heterogeneous_unit.cpp (original)
+++ sandbox/units/libs/units/example/heterogeneous_unit.cpp 2008-05-14 17:54:31 EDT (Wed, 14 May 2008)
@@ -47,6 +47,7 @@
 #include <algorithm>
 
 #include <boost/units/io.hpp>
+#include <boost/units/pow.hpp>
 #include <boost/units/detail/utility.hpp>
 #include <boost/units/systems/cgs.hpp>
 #include <boost/units/systems/si.hpp>

Modified: sandbox/units/libs/units/example/quantity.cpp
==============================================================================
--- sandbox/units/libs/units/example/quantity.cpp (original)
+++ sandbox/units/libs/units/example/quantity.cpp 2008-05-14 17:54:31 EDT (Wed, 14 May 2008)
@@ -61,6 +61,7 @@
 
 #include <boost/typeof/std/complex.hpp>
 
+#include <boost/units/pow.hpp>
 #include <boost/units/quantity.hpp>
 #include <boost/units/io.hpp>
 

Modified: sandbox/units/libs/units/example/quaternion.cpp
==============================================================================
--- sandbox/units/libs/units/example/quaternion.cpp (original)
+++ sandbox/units/libs/units/example/quaternion.cpp 2008-05-14 17:54:31 EDT (Wed, 14 May 2008)
@@ -47,6 +47,7 @@
 #include <boost/math/quaternion.hpp>
 #include <boost/mpl/list.hpp>
 
+#include <boost/units/pow.hpp>
 #include <boost/units/quantity.hpp>
 #include <boost/units/io.hpp>
 

Modified: sandbox/units/libs/units/example/radar_beam_height.cpp
==============================================================================
--- sandbox/units/libs/units/example/radar_beam_height.cpp (original)
+++ sandbox/units/libs/units/example/radar_beam_height.cpp 2008-05-14 17:54:31 EDT (Wed, 14 May 2008)
@@ -39,6 +39,7 @@
 
 #include <boost/units/conversion.hpp>
 #include <boost/units/io.hpp>
+#include <boost/units/pow.hpp>
 #include <boost/units/systems/si.hpp>
 #include <boost/units/systems/si/prefixes.hpp>
 

Modified: sandbox/units/libs/units/example/unit.cpp
==============================================================================
--- sandbox/units/libs/units/example/unit.cpp (original)
+++ sandbox/units/libs/units/example/unit.cpp 2008-05-14 17:54:31 EDT (Wed, 14 May 2008)
@@ -42,6 +42,8 @@
 
 #include "test_system.hpp"
 
+#include <boost/units/pow.hpp>
+
 int main()
 {
     using namespace boost::units;

Modified: sandbox/units/libs/units/test/test_dimensionless_quantity.cpp
==============================================================================
--- sandbox/units/libs/units/test/test_dimensionless_quantity.cpp (original)
+++ sandbox/units/libs/units/test/test_dimensionless_quantity.cpp 2008-05-14 17:54:31 EDT (Wed, 14 May 2008)
@@ -23,6 +23,8 @@
 
 #include "test_header.hpp"
 
+#include <boost/units/pow.hpp>
+
 namespace bu = boost::units;
 
 static const double E_ = 2.718281828459045235360287471352662497757;

Modified: sandbox/units/libs/units/test/test_quantity.cpp
==============================================================================
--- sandbox/units/libs/units/test/test_quantity.cpp (original)
+++ sandbox/units/libs/units/test/test_quantity.cpp 2008-05-14 17:54:31 EDT (Wed, 14 May 2008)
@@ -23,6 +23,8 @@
 
 #include "test_header.hpp"
 
+#include <boost/units/pow.hpp>
+
 namespace bu = boost::units;
 
 static const double E_ = 2.718281828459045235360287471352662497757;

Modified: sandbox/units/libs/units/test/test_unit.cpp
==============================================================================
--- sandbox/units/libs/units/test/test_unit.cpp (original)
+++ sandbox/units/libs/units/test/test_unit.cpp 2008-05-14 17:54:31 EDT (Wed, 14 May 2008)
@@ -23,6 +23,8 @@
 
 #include "test_header.hpp"
 
+#include <boost/units/pow.hpp>
+
 namespace bu = boost::units;
 
 int test_main(int,char *[])


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