Boost logo

Boost-Commit :

From: steven_at_[hidden]
Date: 2008-05-13 16:11:43


Author: steven_watanabe
Date: 2008-05-13 16:11:42 EDT (Tue, 13 May 2008)
New Revision: 45340
URL: http://svn.boost.org/trac/boost/changeset/45340

Log:
Tweaks to absolute
Text files modified:
   sandbox/units/boost/units/absolute.hpp | 15 +++++++------
   sandbox/units/boost/units/systems/base_units.hpp | 42 ++++++++++++++++++++--------------------
   2 files changed, 29 insertions(+), 28 deletions(-)

Modified: sandbox/units/boost/units/absolute.hpp
==============================================================================
--- sandbox/units/boost/units/absolute.hpp (original)
+++ sandbox/units/boost/units/absolute.hpp 2008-05-13 16:11:42 EDT (Tue, 13 May 2008)
@@ -67,22 +67,21 @@
     return absolute<Y>(aval.value()-rval);
 }
 
-/// subtracting two absolutes gives a difference (Like pointers)
+/// subtracting two absolutes gives a difference
 template<class Y>
 Y operator-(const absolute<Y>& aval1,const absolute<Y>& aval2)
 {
     return Y(aval1.value()-aval2.value());
 }
 
-/// multiplying an absolute unit by a scalar gives a quantity
-/// just like an ordinary unit
+/// creates a quantity from an absolute unit and a raw value
 template<class D, class S, class T>
 quantity<absolute<unit<D, S> >, T> operator*(const T& t, const absolute<unit<D, S> >&)
 {
     return(quantity<absolute<unit<D, S> >, T>::from_value(t));
 }
-/// multiplying an absolute unit by a scalar gives a quantity
-/// just like an ordinary unit
+
+/// creates a quantity from an absolute unit and a raw value
 template<class D, class S, class T>
 quantity<absolute<unit<D, S> >, T> operator*(const absolute<unit<D, S> >&, const T& t)
 {
@@ -118,7 +117,7 @@
 /// Macro to define the offset between two absolute units.
 /// Requires the value to be in the destination units e.g
 /// @code
-/// BOOST_UNITS_DEFINE_CONVERSION_OFFSET(celsius_base_unit, fahrenheit_base_unit::unit_type, double, 32.0);
+/// BOOST_UNITS_DEFINE_CONVERSION_OFFSET(celsius_base_unit, fahrenheit_base_unit, double, 32.0);
 /// @endcode
 /// @c BOOST_UNITS_DEFINE_CONVERSION_FACTOR is also necessary to
 /// specify the conversion factor. Like @c BOOST_UNITS_DEFINE_CONVERSION_FACTOR
@@ -129,7 +128,9 @@
     namespace boost { \
     namespace units { \
     template<> \
- struct affine_conversion_helper<From, To> \
+ struct affine_conversion_helper< \
+ reduce_unit<From::unit_type>::type, \
+ reduce_unit<To::unit_type>::type> \
     { \
         typedef type_ type; \
         static type value() { return(value_); } \

Modified: sandbox/units/boost/units/systems/base_units.hpp
==============================================================================
--- sandbox/units/boost/units/systems/base_units.hpp (original)
+++ sandbox/units/boost/units/systems/base_units.hpp 2008-05-13 16:11:42 EDT (Tue, 13 May 2008)
@@ -41,38 +41,38 @@
 #include <boost/units/systems/base_units/steradian.hpp>
 #include <boost/units/systems/base_units/yard.hpp>
 
-BOOST_UNITS_DEFINE_CONVERSION_FACTOR(boost::units::foot_base_unit, boost::units::meter_base_unit::unit_type, double, 0.3048);
-BOOST_UNITS_DEFINE_CONVERSION_FACTOR(boost::units::inch_base_unit, boost::units::meter_base_unit::unit_type, double, 25.4e-3);
-BOOST_UNITS_DEFINE_CONVERSION_FACTOR(boost::units::yard_base_unit, boost::units::meter_base_unit::unit_type, double, 0.9144);
-BOOST_UNITS_DEFINE_CONVERSION_FACTOR(boost::units::mile_base_unit, boost::units::meter_base_unit::unit_type, double, 1609.344);
+BOOST_UNITS_DEFINE_CONVERSION_FACTOR(boost::units::foot_base_unit, boost::units::meter_base_unit, double, 0.3048);
+BOOST_UNITS_DEFINE_CONVERSION_FACTOR(boost::units::inch_base_unit, boost::units::meter_base_unit, double, 25.4e-3);
+BOOST_UNITS_DEFINE_CONVERSION_FACTOR(boost::units::yard_base_unit, boost::units::meter_base_unit, double, 0.9144);
+BOOST_UNITS_DEFINE_CONVERSION_FACTOR(boost::units::mile_base_unit, boost::units::meter_base_unit, double, 1609.344);
 
 BOOST_UNITS_DEFINE_CONVERSION_FACTOR(boost::units::mile_base_unit, boost::units::yard_base_unit::unit_type, double, 1760.0);
 BOOST_UNITS_DEFINE_CONVERSION_FACTOR(boost::units::mile_base_unit, boost::units::foot_base_unit::unit_type, double, 5280.0);
 BOOST_UNITS_DEFINE_CONVERSION_FACTOR(boost::units::mile_base_unit, boost::units::inch_base_unit::unit_type, double, 63360.0);
 
-BOOST_UNITS_DEFINE_CONVERSION_FACTOR(boost::units::yard_base_unit, boost::units::foot_base_unit::unit_type, double, 3.0);
-BOOST_UNITS_DEFINE_CONVERSION_FACTOR(boost::units::yard_base_unit, boost::units::inch_base_unit::unit_type, double, 36.0);
+BOOST_UNITS_DEFINE_CONVERSION_FACTOR(boost::units::yard_base_unit, boost::units::foot_base_unit, double, 3.0);
+BOOST_UNITS_DEFINE_CONVERSION_FACTOR(boost::units::yard_base_unit, boost::units::inch_base_unit, double, 36.0);
 
-BOOST_UNITS_DEFINE_CONVERSION_FACTOR(boost::units::foot_base_unit, boost::units::inch_base_unit::unit_type, double, 12.0);
+BOOST_UNITS_DEFINE_CONVERSION_FACTOR(boost::units::foot_base_unit, boost::units::inch_base_unit, double, 12.0);
 
-BOOST_UNITS_DEFINE_CONVERSION_FACTOR(boost::units::hour_base_unit, boost::units::minute_base_unit::unit_type, double, 60.0);
-BOOST_UNITS_DEFINE_CONVERSION_FACTOR(boost::units::hour_base_unit, boost::units::second_base_unit::unit_type, double, 3600.0);
-BOOST_UNITS_DEFINE_CONVERSION_FACTOR(boost::units::minute_base_unit, boost::units::second_base_unit::unit_type, double, 60.0);
+BOOST_UNITS_DEFINE_CONVERSION_FACTOR(boost::units::hour_base_unit, boost::units::minute_base_unit, double, 60.0);
+BOOST_UNITS_DEFINE_CONVERSION_FACTOR(boost::units::hour_base_unit, boost::units::second_base_unit, double, 3600.0);
+BOOST_UNITS_DEFINE_CONVERSION_FACTOR(boost::units::minute_base_unit, boost::units::second_base_unit, double, 60.0);
 
 BOOST_UNITS_DEFINE_CONVERSION_FACTOR(boost::units::kelvin_base_unit, boost::units::celsius_base_unit::unit_type, one, one());
-BOOST_UNITS_DEFINE_CONVERSION_OFFSET(boost::units::kelvin_base_unit::unit_type, boost::units::celsius_base_unit::unit_type, double, -273.15);
+BOOST_UNITS_DEFINE_CONVERSION_OFFSET(boost::units::kelvin_base_unit, boost::units::celsius_base_unit, double, -273.15);
 
-BOOST_UNITS_DEFINE_CONVERSION_FACTOR(boost::units::kelvin_base_unit, boost::units::fahrenheit_base_unit::unit_type, double, 9.0/5.0);
-BOOST_UNITS_DEFINE_CONVERSION_OFFSET(boost::units::kelvin_base_unit::unit_type, boost::units::fahrenheit_base_unit::unit_type, double, -273.15 * 9.0 / 5.0 + 32.0);
+BOOST_UNITS_DEFINE_CONVERSION_FACTOR(boost::units::kelvin_base_unit, boost::units::fahrenheit_base_unit, double, 9.0/5.0);
+BOOST_UNITS_DEFINE_CONVERSION_OFFSET(boost::units::kelvin_base_unit, boost::units::fahrenheit_base_unit, double, -273.15 * 9.0 / 5.0 + 32.0);
 
-BOOST_UNITS_DEFINE_CONVERSION_FACTOR(boost::units::celsius_base_unit, boost::units::fahrenheit_base_unit::unit_type, double, 9.0/5.0);
-BOOST_UNITS_DEFINE_CONVERSION_OFFSET(boost::units::celsius_base_unit::unit_type, boost::units::fahrenheit_base_unit::unit_type, double, 32.0);
+BOOST_UNITS_DEFINE_CONVERSION_FACTOR(boost::units::celsius_base_unit, boost::units::fahrenheit_base_unit, double, 9.0/5.0);
+BOOST_UNITS_DEFINE_CONVERSION_OFFSET(boost::units::celsius_base_unit, boost::units::fahrenheit_base_unit, double, 32.0);
 
-BOOST_UNITS_DEFINE_CONVERSION_FACTOR(boost::units::radian_base_unit, boost::units::degree_base_unit::unit_type, double, 180/3.14159265358979323846);
-BOOST_UNITS_DEFINE_CONVERSION_FACTOR(boost::units::radian_base_unit, boost::units::gradian_base_unit::unit_type, double, 200/3.14159265358979323846);
-BOOST_UNITS_DEFINE_CONVERSION_FACTOR(boost::units::radian_base_unit, boost::units::revolution_base_unit::unit_type, double, 0.5/3.14159265358979323846);
-BOOST_UNITS_DEFINE_CONVERSION_FACTOR(boost::units::degree_base_unit, boost::units::gradian_base_unit::unit_type, double, 10/9.);
-BOOST_UNITS_DEFINE_CONVERSION_FACTOR(boost::units::degree_base_unit, boost::units::revolution_base_unit::unit_type, double, 1/360.);
-BOOST_UNITS_DEFINE_CONVERSION_FACTOR(boost::units::gradian_base_unit, boost::units::revolution_base_unit::unit_type, double, 1/400.);
+BOOST_UNITS_DEFINE_CONVERSION_FACTOR(boost::units::radian_base_unit, boost::units::degree_base_unit, double, 180/3.14159265358979323846);
+BOOST_UNITS_DEFINE_CONVERSION_FACTOR(boost::units::radian_base_unit, boost::units::gradian_base_unit, double, 200/3.14159265358979323846);
+BOOST_UNITS_DEFINE_CONVERSION_FACTOR(boost::units::radian_base_unit, boost::units::revolution_base_unit, double, 0.5/3.14159265358979323846);
+BOOST_UNITS_DEFINE_CONVERSION_FACTOR(boost::units::degree_base_unit, boost::units::gradian_base_unit, double, 10/9.);
+BOOST_UNITS_DEFINE_CONVERSION_FACTOR(boost::units::degree_base_unit, boost::units::revolution_base_unit, double, 1/360.);
+BOOST_UNITS_DEFINE_CONVERSION_FACTOR(boost::units::gradian_base_unit, boost::units::revolution_base_unit, double, 1/400.);
 
 #endif // BOOST_UNITS_OTHER_UNITS_HPP_INCLUDED


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