|
From: Matthias S. <mat...@us...> - 2007-04-10 23:13:06
|
Update of /cvsroot/boost-sandbox/boost-sandbox/libs/units/example In directory sc8-pr-cvs3.sourceforge.net:/tmp/cvs-serv16800/example Modified Files: test_system.hpp unit_example_1.cpp unit_example_16.cpp unit_example_20.cpp unit_example_22.cpp Log Message: change base dimension syntax Index: unit_example_20.cpp =================================================================== RCS file: /cvsroot/boost-sandbox/boost-sandbox/libs/units/example/unit_example_20.cpp,v retrieving revision 1.6 retrieving revision 1.7 diff -u -d -r1.6 -r1.7 --- unit_example_20.cpp 4 Apr 2007 20:06:57 -0000 1.6 +++ unit_example_20.cpp 10 Apr 2007 23:13:05 -0000 1.7 @@ -63,7 +63,7 @@ } // fahrenheit -template<> struct base_unit_info<temperature_tag,fahrenheit::system_tag> +template<> struct base_unit_info<temperature_dim,fahrenheit::system_tag> { static std::string name() { return "Fahrenheit"; } static std::string symbol() { return "F"; } @@ -189,3 +189,4 @@ return(-1); } } + Index: unit_example_22.cpp =================================================================== RCS file: /cvsroot/boost-sandbox/boost-sandbox/libs/units/example/unit_example_22.cpp,v retrieving revision 1.13 retrieving revision 1.14 diff -u -d -r1.13 -r1.14 --- unit_example_22.cpp 5 Apr 2007 21:56:15 -0000 1.13 +++ unit_example_22.cpp 10 Apr 2007 23:13:05 -0000 1.14 @@ -203,8 +203,8 @@ template<int N> struct f { - typedef typename derived_dimension<length_tag, (1<<N) >::type dim1; - typedef typename derived_dimension<mass_tag, (1<<N) >::type dim2; + typedef typename derived_dimension<length_dim, (1<<N) >::type dim1; + typedef typename derived_dimension<mass_dim, (1<<N) >::type dim2; template<class T> static void apply(const T& t) { f<N - 1>::apply(t * unit<dim1, SI::system>()); @@ -413,10 +413,13 @@ return 0; } */ + #include <iostream> #include <boost/units/io.hpp> #include <boost/units/quantity.hpp> +#include <boost/units/systems/cgs/acceleration.hpp> +#include <boost/units/systems/si/acceleration.hpp> #include <boost/units/systems/si/force.hpp> #include <boost/units/systems/cgs/force.hpp> #include <boost/units/systems/si/mass.hpp> @@ -424,17 +427,21 @@ #include <boost/units/systems/si/momentum.hpp> #include <boost/units/systems/cgs/momentum.hpp> +#include <boost/units/systems/other/non_si_units.hpp> + int main() { using namespace boost; using namespace boost::units; std::cout << quantity<SI::dimensionless>(1.0*CGS::dyne/SI::newton) << std::endl; +// std::cout << exp(1.0*(SI::newtons*CGS::dynes)/(SI::newtons*CGS::dynes)) << std::endl; std::cout << exp(quantity<SI::dimensionless>(1.0*(SI::newtons*CGS::dynes)/(SI::newtons*CGS::dynes))) << std::endl; std::cout << conversion_factor<double>(CGS::dyne,SI::newton) << std::endl; std::cout << conversion_factor<double>(SI::newton/SI::kilogram,CGS::dyne/CGS::gram) << std::endl; std::cout << conversion_factor<double>(CGS::momentum(),SI::momentum()) << std::endl; std::cout << conversion_factor<double>(SI::momentum()/SI::mass(),CGS::momentum()/CGS::mass()) << std::endl; + std::cout << conversion_factor<double>(CGS::gal,SI::meter_per_second_squared) << std::endl; return 0; } Index: test_system.hpp =================================================================== RCS file: /cvsroot/boost-sandbox/boost-sandbox/libs/units/example/test_system.hpp,v retrieving revision 1.3 retrieving revision 1.4 diff -u -d -r1.3 -r1.4 --- test_system.hpp 4 Apr 2007 20:06:57 -0000 1.3 +++ test_system.hpp 10 Apr 2007 23:13:05 -0000 1.4 @@ -23,39 +23,39 @@ namespace units { //[test_system_snippet_1 -typedef base_dimension<1> length_tag; -typedef base_dimension<2> mass_tag; -typedef base_dimension<3> time_tag; +typedef base_dimension<1> length_dim; +typedef base_dimension<2> mass_dim; +typedef base_dimension<3> time_dim; //] #if 0 //[test_system_snippet_2 -typedef make_dimension_list< boost::mpl::list< dim< length_tag,static_rational<1> > > >::type length_type; -typedef make_dimension_list< boost::mpl::list< dim< mass_tag,static_rational<1> > > >::type mass_type; -typedef make_dimension_list< boost::mpl::list< dim< time_tag,static_rational<1> > > >::type time_type; +typedef make_dimension_list< boost::mpl::list< dim< length_dim,static_rational<1> > > >::type length_type; +typedef make_dimension_list< boost::mpl::list< dim< mass_dim,static_rational<1> > > >::type mass_type; +typedef make_dimension_list< boost::mpl::list< dim< time_dim,static_rational<1> > > >::type time_type; //] #endif //[test_system_snippet_3 -typedef length_tag::type length_type; -typedef mass_tag::type mass_type; -typedef time_tag::type time_type; +typedef length_dim::type length_type; +typedef mass_dim::type mass_type; +typedef time_dim::type time_type; //] #if 0 //[test_system_snippet_4 -typedef make_dimension_list< boost::mpl::list< dim< length_tag,static_rational<2> > > >::type area_type; -typedef make_dimension_list< boost::mpl::list< dim< mass_tag,static_rational<1> >, - dim< length_tag,static_rational<2> >, - dim< time_tag,static_rational<-2> > > >::type energy_type; +typedef make_dimension_list< boost::mpl::list< dim< length_dim,static_rational<2> > > >::type area_type; +typedef make_dimension_list< boost::mpl::list< dim< mass_dim,static_rational<1> >, + dim< length_dim,static_rational<2> >, + dim< time_dim,static_rational<-2> > > >::type energy_type; //] #endif //[test_system_snippet_5 -typedef derived_dimension<length_tag,2>::type area_type; -typedef derived_dimension<mass_tag,1, - length_tag,2, - time_tag,-2>::type energy_type; +typedef derived_dimension<length_dim,2>::type area_type; +typedef derived_dimension<mass_dim,1, + length_dim,2, + time_dim,-2>::type energy_type; //] namespace test { @@ -95,20 +95,20 @@ } // namespace test //[test_system_snippet_8 -template<> struct base_unit_info<length_tag,test::system_tag> +template<> struct base_unit_info<length_dim,test::system_tag> { static std::string name() { return "meter"; } static std::string symbol() { return "m"; } }; //] -template<> struct base_unit_info<mass_tag,test::system_tag> +template<> struct base_unit_info<mass_dim,test::system_tag> { static std::string name() { return "kilogram"; } static std::string symbol() { return "kg"; } }; -template<> struct base_unit_info<time_tag,test::system_tag> +template<> struct base_unit_info<time_dim,test::system_tag> { static std::string name() { return "second"; } static std::string symbol() { return "s"; } Index: unit_example_1.cpp =================================================================== RCS file: /cvsroot/boost-sandbox/boost-sandbox/libs/units/example/unit_example_1.cpp,v retrieving revision 1.3 retrieving revision 1.4 diff -u -d -r1.3 -r1.4 --- unit_example_1.cpp 4 Apr 2007 20:06:57 -0000 1.3 +++ unit_example_1.cpp 10 Apr 2007 23:13:05 -0000 1.4 @@ -20,13 +20,13 @@ @verbatim //[unit_example_1_output -length_type = l_item<long_<1L>, dim<length_tag, static_rational<1L, 1L> > > -mass_type = l_item<long_<1L>, dim<mass_tag, static_rational<1L, 1L> > > -time_type = l_item<long_<1L>, dim<time_tag, static_rational<1L, 1L> > > -energy_type = l_item<long_<3L>, dim<length_tag, static_rational<2L, 1L> >, l_item<long_<2L>, dim<mass_tag, static_rational<1L, 1L> >, l_item<long_<1L>, dim<time_tag, static_rational<-2L, 1L> > > > > -LM_type = l_item<long_<2L>, dim<length_tag, static_rational<1L, 1L> >, l_item<long_<1L>, dim<mass_tag, static_rational<1L, 1L> > > > -L_T_type = l_item<long_<2L>, dim<length_tag, static_rational<1L, 1L> >, l_item<long_<1L>, dim<time_tag, static_rational<-1L, 1L> > > > -V_type = l_item<long_<2L>, dim<length_tag, static_rational<1L, 1L> >, l_item<long_<1L>, dim<time_tag, static_rational<-1L, 1L> > > > +length_type = l_item<long_<1L>, dim<length_dim, static_rational<1L, 1L> > > +mass_type = l_item<long_<1L>, dim<mass_dim, static_rational<1L, 1L> > > +time_type = l_item<long_<1L>, dim<time_dim, static_rational<1L, 1L> > > +energy_type = l_item<long_<3L>, dim<length_dim, static_rational<2L, 1L> >, l_item<long_<2L>, dim<mass_dim, static_rational<1L, 1L> >, l_item<long_<1L>, dim<time_dim, static_rational<-2L, 1L> > > > > +LM_type = l_item<long_<2L>, dim<length_dim, static_rational<1L, 1L> >, l_item<long_<1L>, dim<mass_dim, static_rational<1L, 1L> > > > +L_T_type = l_item<long_<2L>, dim<length_dim, static_rational<1L, 1L> >, l_item<long_<1L>, dim<time_dim, static_rational<-1L, 1L> > > > +V_type = l_item<long_<2L>, dim<length_dim, static_rational<1L, 1L> >, l_item<long_<1L>, dim<time_dim, static_rational<-1L, 1L> > > > //] @endverbatim @@ -51,16 +51,16 @@ { using namespace boost::units; - BOOST_MPL_ASSERT((boost::is_same<length_type, mpl::push_front<dimensionless_type, dim<length_tag, static_rational<1L, 1L> > >::type>)); - BOOST_MPL_ASSERT((boost::is_same<mass_type, mpl::push_front<dimensionless_type, dim<mass_tag, static_rational<1L, 1L> > >::type>)); + BOOST_MPL_ASSERT((boost::is_same<length_type, mpl::push_front<dimensionless_type, dim<length_dim, static_rational<1L, 1L> > >::type>)); + BOOST_MPL_ASSERT((boost::is_same<mass_type, mpl::push_front<dimensionless_type, dim<mass_dim, static_rational<1L, 1L> > >::type>)); BOOST_MPL_ASSERT((boost::is_same<energy_type, mpl::push_front< mpl::push_front< mpl::push_front< dimensionless_type, - dim<time_tag, static_rational<-2L, 1L> > >::type, - dim<mass_tag, static_rational<1L, 1L> > >::type, - dim<length_tag, static_rational<2L, 1L> > >::type>)); + dim<time_dim, static_rational<-2L, 1L> > >::type, + dim<mass_dim, static_rational<1L, 1L> > >::type, + dim<length_dim, static_rational<2L, 1L> > >::type>)); std::cout << "length_type = " << simplify_typename(length_type()) << std::endl << "mass_type = " << simplify_typename(mass_type()) << std::endl @@ -77,22 +77,22 @@ mpl::push_front< mpl::push_front< dimensionless_type, - dim<mass_tag, static_rational<1L, 1L> > >::type, - dim<length_tag, static_rational<1L, 1L> > >::type>)); + dim<mass_dim, static_rational<1L, 1L> > >::type, + dim<length_dim, static_rational<1L, 1L> > >::type>)); BOOST_MPL_ASSERT((boost::is_same<L_T_type, mpl::push_front< mpl::push_front< dimensionless_type, - dim<time_tag, static_rational<-1L, 1L> > >::type, - dim<length_tag, static_rational<1L, 1L> > >::type>)); + dim<time_dim, static_rational<-1L, 1L> > >::type, + dim<length_dim, static_rational<1L, 1L> > >::type>)); BOOST_MPL_ASSERT((boost::is_same<V_type, mpl::push_front< mpl::push_front< dimensionless_type, - dim<time_tag, static_rational<-1L, 1L> > >::type, - dim<length_tag, static_rational<1L, 1L> > >::type>)); + dim<time_dim, static_rational<-1L, 1L> > >::type, + dim<length_dim, static_rational<1L, 1L> > >::type>)); std::cout << "LM_type = " << simplify_typename(LM_type()) << std::endl << "L_T_type = " << simplify_typename(L_T_type()) << std::endl Index: unit_example_16.cpp =================================================================== RCS file: /cvsroot/boost-sandbox/boost-sandbox/libs/units/example/unit_example_16.cpp,v retrieving revision 1.4 retrieving revision 1.5 diff -u -d -r1.4 -r1.5 --- unit_example_16.cpp 29 Mar 2007 22:41:06 -0000 1.4 +++ unit_example_16.cpp 10 Apr 2007 23:13:05 -0000 1.5 @@ -64,7 +64,7 @@ // IO helper class template<> -struct base_unit_info<length_tag,nautical::system_tag> +struct base_unit_info<length_dim,nautical::system_tag> { static std::string name() { return "nautical mile"; } static std::string symbol() { return "nmi"; } @@ -72,7 +72,7 @@ // helper for conversions between nautical length and SI length template<> -struct base_unit_converter<length_tag,nautical::system_tag,SI::system_tag> : +struct base_unit_converter<length_dim,nautical::system_tag,SI::system_tag> : public trivial_conversion, trivial_inverse_conversion { typedef double type; @@ -97,7 +97,7 @@ // IO helper class template<> -struct base_unit_info<length_tag,imperial::system_tag> +struct base_unit_info<length_dim,imperial::system_tag> { static std::string name() { return "foot"; } static std::string symbol() { return "ft"; } @@ -105,14 +105,14 @@ // helpers for conversions between imperial length and SI length template<> -struct base_unit_converter<length_tag,imperial::system_tag,SI::system_tag> +struct base_unit_converter<length_dim,imperial::system_tag,SI::system_tag> { typedef double type; static type value() { return 1.0/3.28083989501312; } }; template<> -struct base_unit_converter<length_tag,SI::system_tag,imperial::system_tag> +struct base_unit_converter<length_dim,SI::system_tag,imperial::system_tag> { typedef double type; static type value() { return 3.28083989501312; } |