|
Boost-Commit : |
Subject: [Boost-commit] svn:boost r50486 - in trunk: boost/units/detail libs/units/test
From: steven_at_[hidden]
Date: 2009-01-05 13:12:46
Author: steven_watanabe
Date: 2009-01-05 13:12:46 EST (Mon, 05 Jan 2009)
New Revision: 50486
URL: http://svn.boost.org/trac/boost/changeset/50486
Log:
Fix bug in handling of leading zeros.
Text files modified:
trunk/boost/units/detail/linear_algebra.hpp | 6 ++--
trunk/libs/units/test/test_complicated_system.cpp | 52 +++++++++++++++++++++++++++++++++------
2 files changed, 46 insertions(+), 12 deletions(-)
Modified: trunk/boost/units/detail/linear_algebra.hpp
==============================================================================
--- trunk/boost/units/detail/linear_algebra.hpp (original)
+++ trunk/boost/units/detail/linear_algebra.hpp 2009-01-05 13:12:46 EST (Mon, 05 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: trunk/libs/units/test/test_complicated_system.cpp
==============================================================================
--- trunk/libs/units/test/test_complicated_system.cpp (original)
+++ trunk/libs/units/test/test_complicated_system.cpp 2009-01-05 13:12:46 EST (Mon, 05 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