Boost logo

Boost-Commit :

Subject: [Boost-commit] svn:boost r50526 - in branches/release: boost/units boost/units/detail libs/units/test
From: steven_at_[hidden]
Date: 2009-01-09 12:31:32


Author: steven_watanabe
Date: 2009-01-09 12:31:30 EST (Fri, 09 Jan 2009)
New Revision: 50526
URL: http://svn.boost.org/trac/boost/changeset/50526

Log:
merge [50447], [40486], and [50497] from trunk
Text files modified:
   branches/release/boost/units/detail/linear_algebra.hpp | 6 ++--
   branches/release/boost/units/operators.hpp | 14 +++++++---
   branches/release/boost/units/static_constant.hpp | 2
   branches/release/libs/units/test/test_complicated_system.cpp | 52 +++++++++++++++++++++++++++++++++------
   4 files changed, 57 insertions(+), 17 deletions(-)

Modified: branches/release/boost/units/detail/linear_algebra.hpp
==============================================================================
--- branches/release/boost/units/detail/linear_algebra.hpp (original)
+++ branches/release/boost/units/detail/linear_algebra.hpp 2009-01-09 12:31:30 EST (Fri, 09 Jan 2009)
@@ -194,9 +194,9 @@
 struct determine_extra_equations_skip_zeros_impl<true, false> {
     template<class RowsBegin, int RemainingRows, int CurrentColumn, int TotalColumns, class Result>
     struct apply {
- typedef typename RowsBegin::item current_row;
+ typedef typename RowsBegin::next::item next_row;
         typedef typename determine_extra_equations_skip_zeros_impl<
- current_row::item::Numerator == 0,
+ next_row::item::Numerator == 0,
             RemainingRows == 2 // the next one will be the last.
>::template apply<
             typename RowsBegin::next,
@@ -213,7 +213,7 @@
 // all the elements in this column are zero.
 template<>
 struct determine_extra_equations_skip_zeros_impl<true, true> {
- template<class RowsBegin, int RemainingRows, int CurrentColumn, int TotalColumns, class MatrixWithFirstColumnStripped, class Result>
+ template<class RowsBegin, int RemainingRows, int CurrentColumn, int TotalColumns, class Result>
     struct apply {
         typedef list<typename RowsBegin::item::next, dimensionless_type> next_equations;
         typedef list<typename create_row_of_identity<CurrentColumn, TotalColumns>::type, Result> type;

Modified: branches/release/boost/units/operators.hpp
==============================================================================
--- branches/release/boost/units/operators.hpp (original)
+++ branches/release/boost/units/operators.hpp 2009-01-09 12:31:30 EST (Fri, 09 Jan 2009)
@@ -120,11 +120,14 @@
 
 #ifdef BOOST_UNITS_DOXYGEN
 
-/// A helper for computing the result of
-/// raising a runtime object to a compile time
+/// A helper used by @c pow to raise
+/// a runtime object to a compile time
 /// known exponent. This template is intended to
 /// be specialized. All specializations must
 /// conform to the interface shown here.
+/// @c Exponent will be either the exponent
+/// passed to @c pow or @c static_rational<N>
+/// for and integer argument, N.
 template<typename BaseType, typename Exponent>
 struct power_typeof_helper
 {
@@ -134,18 +137,21 @@
     static type value(const BaseType& base);
 };
 
-/// A helper for computing taking a root
+/// A helper used by @c root to take a root
 /// of a runtime object using a compile time
 /// known index. This template is intended to
 /// be specialized. All specializations must
 /// conform to the interface shown here.
+/// @c Index will be either the type
+/// passed to @c pow or @c static_rational<N>
+/// for and integer argument, N.
 template<typename Radicand, typename Index>
 struct root_typeof_helper
 {
     /// specifies the result type
     typedef detail::unspecified type;
     /// Carries out the runtime calculation.
- static type value(const BaseType& base);
+ static type value(const Radicand& base);
 };
 
 #endif

Modified: branches/release/boost/units/static_constant.hpp
==============================================================================
--- branches/release/boost/units/static_constant.hpp (original)
+++ branches/release/boost/units/static_constant.hpp 2009-01-09 12:31:30 EST (Fri, 09 Jan 2009)
@@ -24,7 +24,7 @@
                                                             \
 namespace \
 { \
- const type& name = name##_instance_t<true>::instance; \
+ static const type& name = name##_instance_t<true>::instance; \
 } \
                                                             \
 template<bool b> \

Modified: branches/release/libs/units/test/test_complicated_system.cpp
==============================================================================
--- branches/release/libs/units/test/test_complicated_system.cpp (original)
+++ branches/release/libs/units/test/test_complicated_system.cpp 2009-01-09 12:31:30 EST (Fri, 09 Jan 2009)
@@ -8,11 +8,6 @@
 // accompanying file LICENSE_1_0.txt or copy at
 // http://www.boost.org/LICENSE_1_0.txt)
 
-template<class T>
-struct print {
- enum { value = false };
-};
-
 #include <boost/type_traits/is_same.hpp>
 #include <boost/mpl/assert.hpp>
 
@@ -28,16 +23,25 @@
 #include <boost/units/physical_dimensions/energy.hpp>
 #include <boost/units/physical_dimensions/force.hpp>
 #include <boost/units/physical_dimensions/length.hpp>
+#include <boost/units/physical_dimensions/mass.hpp>
 #include <boost/units/physical_dimensions/time.hpp>
 
+namespace test_system1 {
+
 // the base units in the system will be:
 //
-// volts = kg m^2 s^-2 C^-1
-// newtons = kg m s^-2
-// joules = kg m^2 s^-2
+// volts = m^2 kg s^-2 C^-1
+// newtons = m kg s^-2
+// joules = m^2 kg s^-2
 
 // we will find the representation of m^-1 C^-1 = V N J^-2 = m^-1 C^-1
 
+// reducing the system should generate the matrix equation
+// 2 1 2
+// 1 1 1 x = c
+// -2 -2 -2
+// -1 0 0
+
 struct volt : boost::units::base_unit<volt, boost::units::electric_potential_dimension, 1> {};
 struct newton : boost::units::base_unit<newton, boost::units::force_dimension, 2> {};
 struct joule : boost::units::base_unit<joule, boost::units::energy_dimension, 3> {};
@@ -57,6 +61,36 @@
     boost::units::power_typeof_helper<joule::unit_type, boost::units::static_rational<2> >::type
>::type expected;
 
-int main() {
+void test() {
     BOOST_MPL_ASSERT((boost::is_same<reduced, expected>));
 }
+
+}
+
+namespace test_system2 {
+
+// the base units in the system will be:
+//
+// kilograms = kg
+// meters = m
+
+// we will find the representation of m and kg
+
+// reducing the system should generate the matrix equation
+// 0 1
+// 1 0 x = c
+
+struct kilogram : boost::units::base_unit<kilogram, boost::units::mass_dimension, 4> {};
+struct meter : boost::units::base_unit<meter, boost::units::length_dimension, 5> {};
+
+typedef boost::units::make_system<meter, kilogram>::type mk_system;
+
+typedef boost::units::reduce_unit<boost::units::unit<boost::units::mass_dimension, mk_system> >::type mass_unit;
+typedef boost::units::reduce_unit<boost::units::unit<boost::units::length_dimension, mk_system> >::type length_unit;
+
+void test() {
+ BOOST_MPL_ASSERT((boost::is_same<mass_unit, kilogram::unit_type>));
+ BOOST_MPL_ASSERT((boost::is_same<length_unit, meter::unit_type>));
+}
+
+}


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