00001
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024 #ifndef _Quantity_h
00025 #define _Quantity_h
00026
00027 #include "Quantity/Unit.h"
00028 #include "Quantity/Dimension.h"
00029 #include "Quantity/QuantityError.h"
00030
00031 #include "BSUtilities.h"
00032 #include "Conversion.h"
00033
00034 #include "Factory.h"
00035 #include "Singleton.h"
00036 #include "NullType.h"
00037
00038 #include "xmlwriter.h"
00039
00040 #include <tinyxml/tinyxml.h>
00041
00042 #include <iostream>
00043 #include <string>
00044
00046 namespace quantity {
00047
00049
00050
00051
00052
00054
00056
00065 template<class UT, class UL>
00066 class UnitPointerBySymbol
00067 {
00068 public:
00070 static unit::Unit<UT> *result (const std::string &symbol)
00071 {if (UL::Head::Symbol () == symbol)
00072 return new typename UL::Head;
00073 else
00074 return UnitPointerBySymbol<UT, typename UL::Tail>::result
00075 (symbol);
00076 }
00077 };
00078
00080
00084 template<class UT>
00085 class UnitPointerBySymbol<UT, Loki::NullType>
00086 {
00087 public:
00089
00092 static unit::Unit<UT> *result (const std::string &)
00093 {throw UnitMismatch (); return 0;}
00094 };
00095
00097
00105 template<class UL>
00106 class UnitIndexBySymbol
00107 {
00108 public:
00109 static const int index (const std::string &symbol)
00110 {if (UL::Head::Symbol () == symbol)
00111 return 0;
00112 else
00113 return
00114 UnitIndexBySymbol<typename UL::Tail>::index (symbol) + 1;
00115 }
00116 };
00117
00119
00123 template<>
00124 class UnitIndexBySymbol<Loki::NullType>
00125 {
00126 public:
00128
00131 static int index (const std::string &)
00132 {throw UnitMismatch (); return -1;}
00133 };
00134
00136
00138 template<class UL>
00139 class ListUnitSymbols
00140 {
00141 public:
00143
00147 static std::vector<std::string> & result
00148 (std::vector<std::string> &stringvector)
00149 {
00150 stringvector.push_back (UL::Head::Symbol ());
00151 return ListUnitSymbols<typename UL::Tail>::result (stringvector);
00152 }
00153 };
00154
00156
00158 template<>
00159 class ListUnitSymbols<Loki::NullType>
00160 {
00161 public:
00163 static std::vector<std::string> & result
00164 (std::vector<std::string> &stringvector)
00165 {
00166 return stringvector;
00167 }
00168 };
00169
00176 template<class UT, class UL>
00177 class AllUnits
00178 {
00179 private:
00181
00183 typedef
00184 typename unit::CheckUnits<unit::Unit<UT>, UL>::Check Check;
00185
00186 public:
00188 typedef UL Units;
00189
00191
00199 static ::unit::Unit<UT> *unit (const std::string &unitstring)
00200 {return UnitPointerBySymbol<UT, UL>::result (unitstring);}
00201
00203
00206 static std::vector<std::string> allsymbols (void)
00207 {std::vector<std::string> stringvector;
00208 return ListUnitSymbols<UL>::result (stringvector);
00209 }
00210 };
00211
00213
00216 template<class UT, class U>
00217 class DefaultUnit
00218 {
00219 private:
00221
00223 typedef
00224 typename unit::CheckUnit<unit::Unit<UT>, U>::Check Check;
00225
00226 public:
00228 typedef U Unit;
00229 };
00230
00232 template<class U, class TL> struct CheckAgainstAllUnits;
00233
00235
00243 template<class U, class Head, class Tail>
00244 struct CheckAgainstAllUnits<U, Loki::Typelist<Head, Tail> >
00245 {
00246 typedef
00247 typename BSUtilities::IF<BSUtilities::SameType<U, Head>::sameType,
00248 U, typename CheckAgainstAllUnits<U, Tail>::RET >::RET RET;
00249 };
00250
00252
00259 template<class U>
00260 struct CheckAgainstAllUnits<U, Loki::NullType>
00261 {
00262 typedef unit::UnitError<true> RET;
00263 };
00264
00266
00267
00268
00270
00272
00274 template<bool>
00275 struct DimensionError;
00276
00278
00282 template<>
00283 struct DimensionError<false>
00284 {
00286
00288 static const bool RET = true;
00289 };
00290
00292
00296 template<class Q>
00297 struct CheckDimensionality
00298 {
00299 public:
00301
00303 static const bool RET =
00304 BSUtilities::IF<Q::Dim::IsDimensionless, DimensionError<false>,
00305 DimensionError<true> >::RET::RET;
00306 };
00307
00309
00310
00311
00313
00315
00317 template<bool P> class PrintName;
00319
00321 template<bool P> class PrintSymbol;
00322
00324 class PrintStatus
00325 {
00326 private:
00328 static bool _name;
00330 static bool _symbol;
00331
00332 public:
00334
00336 bool name (void) const {return _name;}
00338
00340 bool symbol (void) const {return _symbol;}
00341
00343 template<bool P> friend class PrintName;
00344
00346 template<bool P> friend class PrintSymbol;
00347 };
00348
00350 typedef Loki::SingletonHolder<PrintStatus> PrintStatusHolder;
00351
00352 #define PS PrintStatusHolder::Instance()
00353
00355
00358 template<bool P>
00359 class PrintName
00360 {
00362
00365 void set (bool name) const {PrintStatus::_name = name;}
00366
00368
00374 friend std::ostream & operator<<
00375 (std::ostream &os, const PrintName &print)
00376 {print.set (P); return os;}
00377 };
00378
00380
00383 template<bool P>
00384 class PrintSymbol
00385 {
00387
00390 void set (bool symbol) const {PrintStatus::_symbol = symbol;}
00391
00393
00399 friend std::ostream & operator<<
00400 (std::ostream &os, const PrintSymbol &print)
00401 {print.set (P); return os;}
00402
00403 };
00404
00406
00408 template<bool P> class ReadName;
00409
00411
00413 template<bool P> class ReadSymbol;
00414
00416
00418 template<bool P> class ReadEqual;
00419
00421 class ReadStatus
00422 {
00423 private:
00425 static bool _name;
00426
00428 static bool _symbol;
00429
00431 static bool _equal;
00432
00434
00437 static std::string _unit;
00438
00439 public:
00441
00443 bool name (void) const {return _name;}
00444
00446
00448 bool symbol (void) const {return _symbol;}
00449
00451
00453 bool equal (void) const {return _equal;}
00454
00456
00458 std::string unit (void) const {return _unit;}
00459
00461 template<bool P> friend class ReadName;
00462
00464 template<bool P> friend class ReadSymbol;
00465
00467 template<bool P> friend class ReadEqual;
00468
00470 template<class U> friend class ReadUnit;
00471 };
00472
00474 typedef Loki::SingletonHolder<ReadStatus> ReadStatusHolder;
00475
00476 #define RS ReadStatusHolder::Instance()
00477
00479
00482 template<bool P>
00483 class ReadName
00484 {
00486
00489 void set (bool name) const {ReadStatus::_name = name;}
00490
00492
00498 friend std::istream & operator>>
00499 (std::istream &is, const ReadName &read)
00500 {read.set (P); return is;}
00501 };
00502
00504
00507 template<bool P>
00508 class ReadSymbol
00509 {
00511
00514 void set (bool symbol) const {ReadStatus::_symbol = symbol;}
00515
00517
00523 friend std::istream & operator>>
00524 (std::istream &is, const ReadSymbol &read)
00525 {read.set (P); return is;}
00526
00527 };
00528
00530
00533 template<bool P>
00534 class ReadEqual
00535 {
00537
00540 void set (bool equal) const {ReadStatus::_equal = equal;}
00541
00543
00549 friend std::istream & operator>>
00550 (std::istream &is, const ReadEqual &read)
00551 {read.set (P); return is;}
00552
00553 };
00554
00556
00558 template<class U>
00559 class ReadUnit
00560 {
00562
00565 void set (std::string unit) const {ReadStatus::_unit = unit;}
00566
00568
00575 friend std::istream & operator>>
00576 (std::istream &is, const ReadUnit<U> &unit)
00577 {unit.set (U::Symbol ()); return is;}
00578
00579 };
00580
00581 typedef Loki::NullType NoUnit;
00582
00584
00586 template<>
00587 class ReadUnit<NoUnit>
00588 {
00590
00593 void set (std::string unit) const {ReadStatus::_unit = unit;}
00594
00596
00602 friend std::istream & operator>>
00603 (std::istream &is, const ReadUnit<NoUnit> &unit)
00604 {unit.set (""); return is;}
00605
00606 };
00607
00608
00610
00611
00612
00614
00616
00618 class Quantities
00619 {
00620 public:
00622
00625 static const std::string Version (void)
00626 {static const
00627 std::string v_string ("Quantities version 1.2 with ");
00628 return v_string + ::unit::Units::Version () + ", "
00629 + ::dimension::Dimensions::Version () +
00630 " and " + ::BSUtilities::version ();}
00631
00633
00636 static const std::string version (void) {return Version ();}
00637
00639
00641 virtual const std::string unitsymbol (void) const = 0;
00642
00644
00646 virtual const std::string unitname (void) const = 0;
00647
00649
00651 virtual const bool isDimensionless (void) const = 0;
00652
00654
00657 virtual ~Quantities (void) {}
00658
00660
00662 static const std::string TAG;
00663
00665
00667 static const std::string MODETAG;
00668
00670
00672 static const std::string BASENAMETAG;
00673
00675
00677 static const std::string VALUETAG;
00678
00680
00682 static const std::string UNITTAG;
00683
00684 };
00685
00687
00688
00689
00691
00693
00697 template<class D, class UT, class UL, class DU, class ST = double>
00698 class Quantity;
00699
00701 template <class Q> struct Name;
00702
00704 template<class DIM, class UT, class UL, class DU, class ST>
00705 struct Name<Quantity<DIM, UT, UL, DU, ST> >
00706 {
00708
00710 static const std::string String;
00711 };
00712
00714 template <class Q> struct Symbol;
00715
00717 template<class DIM, class UT, class UL, class DU, class ST>
00718 struct Symbol<Quantity<DIM, UT, UL, DU, ST> >
00719 {
00721
00723 static const std::string String;
00724 };
00725
00727
00729 template<class U, class ST = double> struct Standard;
00730
00732
00736 template<class UT, class U, class ST>
00737 struct Standard<unit::NonPrefixable<UT, U>, ST>
00738 {
00739 static const ST ratio;
00740 static const bool exact;
00741 };
00742
00744
00748 template<class UT, class U, class ST>
00749 struct Standard<unit::Prefixable<UT, U>, ST>
00750 {
00751 static const ST ratio;
00752 static const bool exact;
00753 };
00754
00756
00760 template<class UT, class CUL, class ST>
00761 struct Standard<unit::ComposeBase<UT, CUL>, ST>
00762 {
00763 static const ST ratio;
00764 static const bool exact;
00765 };
00766
00768
00773 template<class UL, class PL, class ST = double> class CompStd;
00774
00776
00779 template<class UT, class U, class CULTail, long N, long D,
00780 class PTail, class ST>
00781 class CompStd<Loki::Typelist<unit::NonPrefixable<UT, U>, CULTail>,
00782 Loki::Typelist<BSUtilities::Rational<N, D>, PTail>, ST>
00783 {
00784 public:
00785 static ST ratio (void)
00786 {return std::pow (Standard<unit::NonPrefixable<UT, U> >::ratio,
00787 static_cast<double>(N)/static_cast<double>(D))
00788 * CompStd<CULTail, PTail, ST>::ratio ();}
00789
00790 static bool exact (void)
00791 {return (Standard<unit::NonPrefixable<UT, U> >::exact
00792 && CompStd<CULTail, PTail, ST>::exact ());}
00793 };
00794
00796
00799 template<class UT, class U, class P, class CULTail, long N, long D,
00800 class PTail, class ST>
00801 class CompStd<Loki::Typelist<unit::Prefixed<
00802 unit::Prefixable<UT, U>, P>, CULTail>,
00803 Loki::Typelist<BSUtilities::Rational<N, D>, PTail>, ST>
00804 {
00805 public:
00806 static ST ratio (void)
00807 {return std::pow ((Standard<unit::Prefixable<UT, U> >::ratio
00808 * P::Factor), static_cast<double>(N)/static_cast<double>(D))
00809 * CompStd<CULTail, PTail, ST>::ratio ();}
00810
00811 static bool exact (void)
00812 {return (Standard<unit::Prefixable<UT, U> >::exact
00813 && CompStd<CULTail, PTail, ST>::exact ());}
00814 };
00815
00817
00820 template<class UT, class CEL, class UL, class CULTail, long N, long D,
00821 class PTail, class ST>
00822 class CompStd<Loki::Typelist<unit::Composed<
00823 unit::ComposeBase<UT, CEL>, UL>, CULTail>,
00824 Loki::Typelist<BSUtilities::Rational<N, D>, PTail>, ST>
00825 {
00826 public:
00827 static ST ratio (void)
00828 {return std::pow
00829 (Standard<unit::ComposeBase<UT, CEL> >::ratio,
00830 static_cast<double>(N)/static_cast<double>(D))
00831 * CompStd<CULTail, PTail, ST>::ratio ();}
00832 static bool exact (void)
00833 {return (Standard<unit::ComposeBase<UT, CEL> >::exact
00834 && CompStd<CULTail, PTail, ST>::exact ());}
00835 };
00836
00838
00841 template<class UT, class U, long N, long D, class ST>
00842 class CompStd<Loki::Typelist<unit::NonPrefixable<UT, U>,
00843 Loki::NullType>, Loki::Typelist<BSUtilities::Rational<N, D>,
00844 Loki::NullType>, ST>
00845 {
00846 public:
00847 static ST ratio (void) {return std::pow
00848 (Standard<unit::NonPrefixable<UT, U> >::ratio,
00849 static_cast<double>(N)/static_cast<double>(D));}
00850
00851 static bool exact (void)
00852 {return Standard<unit::NonPrefixable<UT, U> >::exact;}
00853 };
00854
00856
00859 template<class UT, class U, class P, long N, long D, class ST>
00860 class CompStd<Loki::Typelist<unit::Prefixed<
00861 unit::Prefixable<UT, U>, P>, Loki::NullType>,
00862 Loki::Typelist<BSUtilities::Rational<N, D>, Loki::NullType>, ST>
00863 {
00864 public:
00865 static ST ratio (void) {return std::pow
00866 ((Standard<unit::Prefixable<UT, U> >::ratio * P::Factor),
00867 static_cast<double>(N)/static_cast<double>(D));}
00868
00869 static bool exact (void)
00870 {return Standard<unit::Prefixable<UT, U> >::exact;}
00871 };
00872
00874
00877 template<class UT, class CEL, class UL, long N, long D, class ST>
00878 class CompStd<Loki::Typelist<unit::Composed<
00879 unit::ComposeBase<UT, CEL>, UL>, Loki::NullType>,
00880 Loki::Typelist<BSUtilities::Rational<N, D>, Loki::NullType>, ST>
00881 {
00882 public:
00883 static ST ratio (void) {return std::pow
00884 (Standard<unit::ComposeBase<UT, CEL> >::ratio,
00885 static_cast<double>(N)/static_cast<double>(D));}
00886
00887 static bool exact (void)
00888 {return Standard<unit::ComposeBase<UT, CEL> >::exact;}
00889 };
00890
00892
00894 template<class U, class ST = double> struct Standardize;
00895
00897
00902 template<class UT, class U, class ST>
00903 struct Standardize<unit::NonPrefixable<UT, U>, ST>
00904 {
00905 static ST VAL (const ST &value)
00906 {return value *
00907 Standard<unit::NonPrefixable<UT, U>, ST>::ratio;}
00908
00909 static bool Exact (void)
00910 {return Standard<unit::NonPrefixable<UT, U>, ST>::exact;}
00911 };
00912
00914
00919 template<class UT, class U, class P, class ST>
00920 struct Standardize<unit::Prefixed<unit::Prefixable<UT, U>, P>, ST>
00921 {
00922 static ST VAL (const ST &value)
00923 {return ST (value * P::Factor *
00924 Standard<unit::Prefixable<UT, U>, ST>::ratio);}
00925
00926 static bool Exact (void)
00927 {return Standard<unit::Prefixable<UT, U>, ST>::exact;}
00928 };
00929
00931
00936 template<class UT, class CUL, class CEL, class ST>
00937 struct Standardize<unit::Composed<unit::ComposeBase<UT, CEL>,
00938 CUL>, ST>
00939 {
00940 static ST VAL (const ST &value)
00941 {return ST (value * CompStd<CUL,
00942 typename unit::ComposeBase<UT, CEL>::Powers::Powers, ST>
00943 ::ratio () *
00944 Standard<unit::ComposeBase<UT, CEL>, ST>::ratio);}
00945
00946 static bool Exact (void)
00947 {return CompStd<CUL, typename
00948 unit::ComposeBase<UT, CEL>::Powers::Powers, ST>::exact ();}
00949 };
00950
00952
00954 template<class U, class ST = double> struct Reverse;
00955
00957
00962 template<class UT, class U, class ST>
00963 struct Reverse<unit::NonPrefixable<UT, U>, ST>
00964 {
00965 static ST VAL (const ST &value)
00966 {return value /
00967 Standard<unit::NonPrefixable<UT, U>, ST>::ratio;}
00968
00969 static bool Exact (void)
00970 {return Standard<unit::NonPrefixable<UT, U>, ST>::exact;}
00971 };
00972
00974
00979 template<class UT, class U, class P, class ST>
00980 struct Reverse<unit::Prefixed<unit::Prefixable<UT, U>, P>, ST>
00981 {
00982 static ST VAL (const ST &value)
00983 {return ST (value / (P::Factor *
00984 Standard<unit::Prefixable<UT, U>, ST>::ratio));}
00985
00986 static bool Exact (void)
00987 {return Standard<unit::Prefixable<UT, U>, ST>::exact;}
00988 };
00989
00991
00996 template<class UT, class CUL, class CEL, class ST>
00997 struct Reverse<unit::Composed<unit::ComposeBase<UT, CEL>, CUL>,
00998 ST>
00999 {
01000 static ST VAL (const ST &value)
01001 {return
01002 ST (value / (CompStd<CUL,
01003 typename unit::ComposeBase<UT, CEL>::Powers::Powers,
01004 ST>::ratio () *
01005 Standard<unit::ComposeBase<UT, CEL>, ST>::ratio));}
01006
01007 static bool Exact (void)
01008 {return CompStd<CUL, typename
01009 unit::ComposeBase<UT, CEL>::Powers::Powers, ST>::exact ();}
01010 };
01011
01013
01015 template<class UL> struct dynamic_standardize;
01016
01018
01025 template<class Head, class Tail>
01026 struct dynamic_standardize<Loki::Typelist<Head, Tail> >
01027 {
01028 template<class U, class ST>
01029 static ST VAL (const ST &value, const U &unit)
01030 {Head test = Head ();
01031 if (typeid(unit) == typeid(test))
01032 return Standardize<Head, ST>::VAL (value);
01033 else
01034 return dynamic_standardize<Tail>::VAL (value, unit);
01035 }
01036 };
01037
01039
01041 template<>
01042 struct dynamic_standardize<Loki::NullType>
01043 {
01044 template<class U, class ST>
01045 static ST VAL (const ST &, const U &)
01046 {throw UnitMismatch (); return ST (0);}
01047 };
01048
01050
01052 template<class UL> struct dynamic_reverse;
01053
01055
01062 template<class Head, class Tail>
01063 struct dynamic_reverse<Loki::Typelist<Head, Tail> >
01064 {
01065 template<class U, class ST>
01066 static ST VAL (const ST &value, const U &unit)
01067 {Head test = Head ();
01068 if (typeid(unit) == typeid (test))
01069 return Reverse<Head, ST>::VAL (value);
01070 else
01071 return dynamic_reverse<Tail>::VAL (value, unit);
01072 }
01073 };
01074
01076
01078 template<>
01079 struct dynamic_reverse<Loki::NullType>
01080 {
01081 template<class U, class ST>
01082 static ST VAL (const ST &, const U &)
01083 {throw UnitMismatch (); return ST (0);}
01084 };
01085
01087
01095 template<long RL_N, long RL_D, long RM_N, long RM_D,
01096 long RT_N, long RT_D, long RE_N, long RE_D, long RTE_N, long RTE_D,
01097 long RA_N, long RA_D, long RLU_N, long RLU_D, class UT,
01098 class Head, class Tail, class DU, class ST>
01099 class Quantity<
01100 dimension::Dimension<BSUtilities::Rational<RL_N, RL_D>,
01101 BSUtilities::Rational<RM_N, RM_D>,
01102 BSUtilities::Rational<RT_N, RT_D>,
01103 BSUtilities::Rational<RE_N, RE_D>,
01104 BSUtilities::Rational<RTE_N, RTE_D>,
01105 BSUtilities::Rational<RA_N, RA_D>,
01106 BSUtilities::Rational<RLU_N, RLU_D> >,
01107 UT, Loki::Typelist<Head, Tail>, DU, ST>
01108 : public Quantities
01109 {
01110 public:
01112
01114 typedef dimension::Dimension<BSUtilities::Rational<RL_N, RL_D>,
01115 BSUtilities::Rational<RM_N, RM_D>,
01116 BSUtilities::Rational<RT_N, RT_D>,
01117 BSUtilities::Rational<RE_N, RE_D>,
01118 BSUtilities::Rational<RTE_N, RTE_D>,
01119 BSUtilities::Rational<RA_N, RA_D>,
01120 BSUtilities::Rational<RLU_N, RLU_D> > Dim;
01121
01122 private:
01124 static const bool Dimensionless = Dim::IsDimensionless;
01125
01126 protected:
01128
01130 std::string namestring;
01132
01134 std::string symbolstring;
01135
01137
01139 unit::Unit<UT> * findBySymbol (const std::string &unitsymbol)
01140 {return UnitPointerBySymbol<UT, Loki::Typelist<Head, Tail> >
01141 ::result (unitsymbol);}
01142
01144
01149 template<class U>
01150 static ST standard (const ST value, const U&)
01151 {return Standardize<typename CheckAgainstAllUnits<U,
01152 Loki::Typelist<Head, Tail> >::RET, ST> (value);}
01153
01155
01160 template<class U>
01161 static ST reverse (const ST value, const U& unit)
01162 {return Reverse<typename CheckAgainstAllUnits<U,
01163 Loki::Typelist<Head, Tail> >::RET, ST> (value);}
01164
01165 public:
01167
01170 Quantity (void)
01171 : namestring (quantity::Name<Quantity<Dim, UT,
01172 Loki::Typelist<Head, Tail>, DU, ST> >::String),
01173 symbolstring (quantity::Symbol<Quantity<Dim, UT,
01174 Loki::Typelist<Head, Tail>, DU, ST> >::String) {}
01175
01177
01180 virtual ~Quantity (void) {}
01181
01183
01186 typedef AllUnits<UT, Loki::Typelist<Head, Tail> > AllUnits;
01187
01189
01192 typedef DefaultUnit<UT, DU> DefaultUnit;
01193
01195 std::string name (void) const {return namestring;}
01197 std::string symbol (void) const {return symbolstring;}
01198
01200
01201
01202 static const std::string Name (void)
01203 {return quantity::Name<Quantity<Dim, UT,
01204 Loki::Typelist<Head, Tail>, DU, ST> >::String;}
01205
01207
01208
01209 static const std::string Symbol (void)
01210 {return quantity::Symbol<Quantity<Dim, UT,
01211 Loki::Typelist<Head, Tail>, DU, ST> >::String;}
01212
01214 void name (const std::string &name) {namestring = name;}
01216 void symbol (const std::string &symbol) {symbolstring = symbol;}
01217
01219
01221 virtual ST standard_value (void) const = 0;
01222
01224
01226 virtual ST value (void) const = 0;
01227
01229
01231 static const bool IsDimensionless (void) {return Dimensionless;}
01232
01234
01236 const bool isDimensionless (void) const
01237 {return IsDimensionless ();}
01238
01240
01245 friend std::ostream & operator<<
01246 (std::ostream &os, const Quantity &quantity)
01247 {return quantity.print (os);}
01248
01250
01264 std::ostream & print (std::ostream &os) const
01265 {
01266 std::string name ("");
01267 std::string symbol ("");
01268 std::string equal ("");
01269
01270 if (PS.name ())
01271 name = namestring + " ";
01272
01273 if (PS.symbol ())
01274 symbol = symbolstring + " ";
01275
01276 if (PS.name () || PS.symbol ())
01277 equal = "= ";
01278
01279 os << name << symbol << equal;
01280
01281 return print_value (os);
01282 }
01283
01285
01288 virtual std::ostream & print_value (std::ostream &os) const = 0;
01289
01291 friend void operator<<
01292 (std::string &str, const Quantity &quantity) {quantity >> str;}
01293
01295 virtual void operator>> (std::string &str) const = 0;
01296
01298
01301 operator std::string () const
01302 {std::string string; *this >> string; return string;}
01303
01305
01308 virtual std::ostream & operator>> (std::ostream &os) const = 0;
01309
01311
01315 virtual void save (BSUtilities::xmlw::XmlStream &) const = 0;
01316
01318
01322 virtual void load (const TiXmlHandle) const = 0;
01323
01325
01329 typedef Loki::SingletonHolder
01330 <Loki::Factory<Quantity, std::string> > Factory;
01331
01332 };
01333
01335
01336
01337
01338
01340
01342
01344 struct Dummy;
01345
01347
01352 template<class UT, long RL_N, long RL_D, long RM_N, long RM_D,
01353 long RT_N, long RT_D, long RE_N, long RE_D, long RTE_N, long RTE_D,
01354 long RA_N, long RA_D, long RLU_N, long RLU_D,
01355 class UL, class DU, class ST>
01356 struct Exp {static ST exec (const Quantity<
01357 dimension::Dimension<BSUtilities::Rational<RL_N, RL_D>,
01358 BSUtilities::Rational<RM_N, RM_D>,
01359 BSUtilities::Rational<RT_N, RT_D>,
01360 BSUtilities::Rational<RE_N, RE_D>,
01361 BSUtilities::Rational<RTE_N, RTE_D>,
01362 BSUtilities::Rational<RA_N, RA_D>,
01363 BSUtilities::Rational<RLU_N, RLU_D> >,
01364 UT, UL, DU, ST> &quantity)
01365 {return ST(std::exp (quantity.value ()));}
01366 };
01367
01369
01374 template<class UT, long RL_N, long RL_D, long RM_N, long RM_D,
01375 long RT_N, long RT_D, long RE_N, long RE_D, long RTE_N, long RTE_D,
01376 long RA_N, long RA_D, long RLU_N, long RLU_D,
01377 class UL, class DU, class ST>
01378 inline ST exp (const Quantity<
01379 dimension::Dimension<BSUtilities::Rational<RL_N, RL_D>,
01380 BSUtilities::Rational<RM_N, RM_D>,
01381 BSUtilities::Rational<RT_N, RT_D>,
01382 BSUtilities::Rational<RE_N, RE_D>,
01383 BSUtilities::Rational<RTE_N, RTE_D>,
01384 BSUtilities::Rational<RA_N, RA_D>,
01385 BSUtilities::Rational<RLU_N, RLU_D> >,
01386 UT, UL, DU, ST> &quantity)
01387 {return ST(BSUtilities::IF<CheckDimensionality<Quantity<
01388 dimension::Dimension<BSUtilities::Rational<RL_N, RL_D>,
01389 BSUtilities::Rational<RM_N, RM_D>,
01390 BSUtilities::Rational<RT_N, RT_D>,
01391 BSUtilities::Rational<RE_N, RE_D>,
01392 BSUtilities::Rational<RTE_N, RTE_D>,
01393 BSUtilities::Rational<RA_N, RA_D>,
01394 BSUtilities::Rational<RLU_N, RLU_D> >,
01395 UT, UL, DU, ST> >::RET,
01396 typename
01397 Exp<UT, RL_N, RL_D, RM_N, RM_D, RT_N, RT_D, RE_N, RE_D,
01398 RTE_N, RTE_D, RA_N, RA_D, RLU_N, RLU_D, UL, DU, ST>::Exp,
01399 Dummy>::RET::exec (quantity));
01400 }
01401
01403
01408 template<class UT, long RL_N, long RL_D, long RM_N, long RM_D,
01409 long RT_N, long RT_D, long RE_N, long RE_D, long RTE_N, long RTE_D,
01410 long RA_N, long RA_D, long RLU_N, long RLU_D,
01411 class UL, class DU, class ST>
01412 struct Log {static ST exec (const Quantity<
01413 dimension::Dimension<BSUtilities::Rational<RL_N, RL_D>,
01414 BSUtilities::Rational<RM_N, RM_D>,
01415 BSUtilities::Rational<RT_N, RT_D>,
01416 BSUtilities::Rational<RE_N, RE_D>,
01417 BSUtilities::Rational<RTE_N, RTE_D>,
01418 BSUtilities::Rational<RA_N, RA_D>,
01419 BSUtilities::Rational<RLU_N, RLU_D> >,
01420 UT, UL, DU, ST> &quantity)
01421 {return ST(std::log (quantity.value ()));}
01422 };
01423
01425
01430 template<class UT, long RL_N, long RL_D, long RM_N, long RM_D,
01431 long RT_N, long RT_D, long RE_N, long RE_D, long RTE_N, long RTE_D,
01432 long RA_N, long RA_D, long RLU_N, long RLU_D,
01433 class UL, class DU, class ST>
01434 inline ST log (const Quantity<
01435 dimension::Dimension<BSUtilities::Rational<RL_N, RL_D>,
01436 BSUtilities::Rational<RM_N, RM_D>,
01437 BSUtilities::Rational<RT_N, RT_D>,
01438 BSUtilities::Rational<RE_N, RE_D>,
01439 BSUtilities::Rational<RTE_N, RTE_D>,
01440 BSUtilities::Rational<RA_N, RA_D>,
01441 BSUtilities::Rational<RLU_N, RLU_D> >,
01442 UT, UL, DU, ST> &quantity)
01443 {return ST(BSUtilities::IF<CheckDimensionality<Quantity<
01444 dimension::Dimension<BSUtilities::Rational<RL_N, RL_D>,
01445 BSUtilities::Rational<RM_N, RM_D>,
01446 BSUtilities::Rational<RT_N, RT_D>,
01447 BSUtilities::Rational<RE_N, RE_D>,
01448 BSUtilities::Rational<RTE_N, RTE_D>,
01449 BSUtilities::Rational<RA_N, RA_D>,
01450 BSUtilities::Rational<RLU_N, RLU_D> >,
01451 UT, UL, DU, ST> >::RET,
01452 typename
01453 Log<UT, RL_N, RL_D, RM_N, RM_D, RT_N, RT_D, RE_N, RE_D, RTE_N,
01454 RTE_D, RA_N, RA_D, RLU_N, RLU_D, UL, DU, ST>::Log,
01455 Dummy>::RET::exec (quantity));
01456 }
01457
01459
01464 template<class UT, long RL_N, long RL_D, long RM_N, long RM_D,
01465 long RT_N, long RT_D, long RE_N, long RE_D, long RTE_N, long RTE_D,
01466 long RA_N, long RA_D, long RLU_N, long RLU_D,
01467 class UL, class DU, class ST>
01468 struct Log10 {static ST exec (const Quantity<
01469 dimension::Dimension<BSUtilities::Rational<RL_N, RL_D>,
01470 BSUtilities::Rational<RM_N, RM_D>,
01471 BSUtilities::Rational<RT_N, RT_D>,
01472 BSUtilities::Rational<RE_N, RE_D>,
01473 BSUtilities::Rational<RTE_N, RTE_D>,
01474 BSUtilities::Rational<RA_N, RA_D>,
01475 BSUtilities::Rational<RLU_N, RLU_D> >,
01476 UT, UL, DU, ST> &quantity)
01477 {return ST(std::log10 (quantity.value ()));}
01478 };
01479
01481
01486 template<class UT, long RL_N, long RL_D, long RM_N, long RM_D,
01487 long RT_N, long RT_D, long RE_N, long RE_D, long RTE_N, long RTE_D,
01488 long RA_N, long RA_D, long RLU_N, long RLU_D,
01489 class UL, class DU, class ST>
01490 inline ST log10 (const Quantity<
01491 dimension::Dimension<BSUtilities::Rational<RL_N, RL_D>,
01492 BSUtilities::Rational<RM_N, RM_D>,
01493 BSUtilities::Rational<RT_N, RT_D>,
01494 BSUtilities::Rational<RE_N, RE_D>,
01495 BSUtilities::Rational<RTE_N, RTE_D>,
01496 BSUtilities::Rational<RA_N, RA_D>,
01497 BSUtilities::Rational<RLU_N, RLU_D> >,
01498 UT, UL, DU, ST> &quantity)
01499 {return ST(BSUtilities::IF<CheckDimensionality<Quantity<
01500 dimension::Dimension<BSUtilities::Rational<RL_N, RL_D>,
01501 BSUtilities::Rational<RM_N, RM_D>,
01502 BSUtilities::Rational<RT_N, RT_D>,
01503 BSUtilities::Rational<RE_N, RE_D>,
01504 BSUtilities::Rational<RTE_N, RTE_D>,
01505 BSUtilities::Rational<RA_N, RA_D>,
01506 BSUtilities::Rational<RLU_N, RLU_D> >,
01507 UT, UL, DU, ST> >::RET,
01508 typename
01509 Log10<UT, RL_N, RL_D, RM_N, RM_D, RT_N, RT_D, RE_N, RE_D, RTE_N,
01510 RTE_D, RA_N, RA_D, RLU_N, RLU_D, UL, DU, ST>::Log10,
01511 Dummy>::RET::exec (quantity));
01512 }
01513
01515
01520 template<class D, class UT, class UL, class DU, class ST>
01521 struct Sin
01522 {static ST exec (const Quantity<D, UT, UL, DU, ST> &quantity)
01523 {return ST(std::sin (quantity.value ()));}
01524 };
01525
01527
01532 template<class UT, long RL_N, long RL_D, long RM_N, long RM_D,
01533 long RT_N, long RT_D, long RE_N, long RE_D, long RTE_N, long RTE_D,
01534 long RA_N, long RA_D, long RLU_N, long RLU_D,
01535 class UL, class DU, class ST>
01536 inline ST sin (const Quantity<
01537 dimension::Dimension<BSUtilities::Rational<RL_N, RL_D>,
01538 BSUtilities::Rational<RM_N, RM_D>,
01539 BSUtilities::Rational<RT_N, RT_D>,
01540 BSUtilities::Rational<RE_N, RE_D>,
01541 BSUtilities::Rational<RTE_N, RTE_D>,
01542 BSUtilities::Rational<RA_N, RA_D>,
01543 BSUtilities::Rational<RLU_N, RLU_D> >,
01544 UT, UL, DU, ST> &quantity)
01545 {return ST(BSUtilities::IF<CheckDimensionality<Quantity<
01546 dimension::Dimension<BSUtilities::Rational<RL_N, RL_D>,
01547 BSUtilities::Rational<RM_N, RM_D>,
01548 BSUtilities::Rational<RT_N, RT_D>,
01549 BSUtilities::Rational<RE_N, RE_D>,
01550 BSUtilities::Rational<RTE_N, RTE_D>,
01551 BSUtilities::Rational<RA_N, RA_D>,
01552 BSUtilities::Rational<RLU_N, RLU_D> >,
01553 UT, UL, DU, ST> >::RET,
01554 typename
01555 Sin<dimension::Dimension<BSUtilities::Rational<RL_N, RL_D>,
01556 BSUtilities::Rational<RM_N, RM_D>,
01557 BSUtilities::Rational<RT_N, RT_D>,
01558 BSUtilities::Rational<RE_N, RE_D>,
01559 BSUtilities::Rational<RTE_N, RTE_D>,
01560 BSUtilities::Rational<RA_N, RA_D>,
01561 BSUtilities::Rational<RLU_N, RLU_D> >,
01562 UT, UL, DU, ST>::Sin, Dummy>::RET::exec (quantity));
01563 }
01564
01566
01571 template<class D, class UT, class UL, class DU, class ST>
01572 struct Cos
01573 {static ST exec (const Quantity<D, UT, UL, DU, ST> &quantity)
01574 {return ST(std::cos (quantity.value ()));}
01575 };
01576
01578
01583 template<class UT, long RL_N, long RL_D, long RM_N, long RM_D,
01584 long RT_N, long RT_D, long RE_N, long RE_D, long RTE_N, long RTE_D,
01585 long RA_N, long RA_D, long RLU_N, long RLU_D,
01586 class UL, class DU, class ST>
01587 inline ST cos (const Quantity<
01588 dimension::Dimension<BSUtilities::Rational<RL_N, RL_D>,
01589 BSUtilities::Rational<RM_N, RM_D>,
01590 BSUtilities::Rational<RT_N, RT_D>,
01591 BSUtilities::Rational<RE_N, RE_D>,
01592 BSUtilities::Rational<RTE_N, RTE_D>,
01593 BSUtilities::Rational<RA_N, RA_D>,
01594 BSUtilities::Rational<RLU_N, RLU_D> >,
01595 UT, UL, DU, ST> &quantity)
01596 {return ST(BSUtilities::IF<CheckDimensionality<Quantity<
01597 dimension::Dimension<BSUtilities::Rational<RL_N, RL_D>,
01598 BSUtilities::Rational<RM_N, RM_D>,
01599 BSUtilities::Rational<RT_N, RT_D>,
01600 BSUtilities::Rational<RE_N, RE_D>,
01601 BSUtilities::Rational<RTE_N, RTE_D>,
01602 BSUtilities::Rational<RA_N, RA_D>,
01603 BSUtilities::Rational<RLU_N, RLU_D> >,
01604 UT, UL, DU, ST> >::RET,
01605 typename
01606 Cos<dimension::Dimension<BSUtilities::Rational<RL_N, RL_D>,
01607 BSUtilities::Rational<RM_N, RM_D>,
01608 BSUtilities::Rational<RT_N, RT_D>,
01609 BSUtilities::Rational<RE_N, RE_D>,
01610 BSUtilities::Rational<RTE_N, RTE_D>,
01611 BSUtilities::Rational<RA_N, RA_D>,
01612 BSUtilities::Rational<RLU_N, RLU_D> >,
01613 UT, UL, DU, ST>::Cos, Dummy>::RET::exec (quantity));
01614 }
01615
01617
01622 template<class D, class UT, class UL, class DU, class ST>
01623 struct Tan
01624 {static ST exec (const Quantity<D, UT, UL, DU, ST> &quantity)
01625 {return ST(std::tan (quantity.value ()));}
01626 };
01627
01629
01634 template<class UT, long RL_N, long RL_D, long RM_N, long RM_D,
01635 long RT_N, long RT_D, long RE_N, long RE_D, long RTE_N, long RTE_D,
01636 long RA_N, long RA_D, long RLU_N, long RLU_D,
01637 class UL, class DU, class ST>
01638 inline ST tan (const Quantity<
01639 dimension::Dimension<BSUtilities::Rational<RL_N, RL_D>,
01640 BSUtilities::Rational<RM_N, RM_D>,
01641 BSUtilities::Rational<RT_N, RT_D>,
01642 BSUtilities::Rational<RE_N, RE_D>,
01643 BSUtilities::Rational<RTE_N, RTE_D>,
01644 BSUtilities::Rational<RA_N, RA_D>,
01645 BSUtilities::Rational<RLU_N, RLU_D> >,
01646 UT, UL, DU, ST> &quantity)
01647 {return ST(BSUtilities::IF<CheckDimensionality<Quantity<
01648 dimension::Dimension<BSUtilities::Rational<RL_N, RL_D>,
01649 BSUtilities::Rational<RM_N, RM_D>,
01650 BSUtilities::Rational<RT_N, RT_D>,
01651 BSUtilities::Rational<RE_N, RE_D>,
01652 BSUtilities::Rational<RTE_N, RTE_D>,
01653 BSUtilities::Rational<RA_N, RA_D>,
01654 BSUtilities::Rational<RLU_N, RLU_D> >,
01655 UT, UL, DU, ST> >::RET,
01656 typename
01657 Tan<dimension::Dimension<BSUtilities::Rational<RL_N, RL_D>,
01658 BSUtilities::Rational<RM_N, RM_D>,
01659 BSUtilities::Rational<RT_N, RT_D>,
01660 BSUtilities::Rational<RE_N, RE_D>,
01661 BSUtilities::Rational<RTE_N, RTE_D>,
01662 BSUtilities::Rational<RA_N, RA_D>,
01663 BSUtilities::Rational<RLU_N, RLU_D> >,
01664 UT, UL, DU, ST>::Tan, Dummy>::RET::exec (quantity));
01665 }
01666
01668
01673 template<class D, class UT, class UL, class DU, class ST>
01674 struct Sinh
01675 {static ST exec (const Quantity<D, UT, UL, DU, ST> &quantity)
01676 {return ST(std::sinh (quantity.value ()));}
01677 };
01678
01680
01685 template<class UT, long RL_N, long RL_D, long RM_N, long RM_D,
01686 long RT_N, long RT_D, long RE_N, long RE_D, long RTE_N, long RTE_D,
01687 long RA_N, long RA_D, long RLU_N, long RLU_D,
01688 class UL, class DU, class ST>
01689 inline ST sinh (const Quantity<
01690 dimension::Dimension<BSUtilities::Rational<RL_N, RL_D>,
01691 BSUtilities::Rational<RM_N, RM_D>,
01692 BSUtilities::Rational<RT_N, RT_D>,
01693 BSUtilities::Rational<RE_N, RE_D>,
01694 BSUtilities::Rational<RTE_N, RTE_D>,
01695 BSUtilities::Rational<RA_N, RA_D>,
01696 BSUtilities::Rational<RLU_N, RLU_D> >,
01697 UT, UL, DU, ST> &quantity)
01698 {return ST(BSUtilities::IF<CheckDimensionality<Quantity<
01699 dimension::Dimension<BSUtilities::Rational<RL_N, RL_D>,
01700 BSUtilities::Rational<RM_N, RM_D>,
01701 BSUtilities::Rational<RT_N, RT_D>,
01702 BSUtilities::Rational<RE_N, RE_D>,
01703 BSUtilities::Rational<RTE_N, RTE_D>,
01704 BSUtilities::Rational<RA_N, RA_D>,
01705 BSUtilities::Rational<RLU_N, RLU_D> >,
01706 UT, UL, DU, ST> >::RET,
01707 typename
01708 Sinh<dimension::Dimension<BSUtilities::Rational<RL_N, RL_D>,
01709 BSUtilities::Rational<RM_N, RM_D>,
01710 BSUtilities::Rational<RT_N, RT_D>,
01711 BSUtilities::Rational<RE_N, RE_D>,
01712 BSUtilities::Rational<RTE_N, RTE_D>,
01713 BSUtilities::Rational<RA_N, RA_D>,
01714 BSUtilities::Rational<RLU_N, RLU_D> >,
01715 UT, UL, DU, ST>::Sinh, Dummy>::RET::exec (quantity));
01716 }
01717
01719
01724 template<class D, class UT, class UL, class DU, class ST>
01725 struct Cosh
01726 {static ST exec (const Quantity<D, UT, UL, DU, ST> &quantity)
01727 {return ST(std::cosh (quantity.value ()));}
01728 };
01729
01731
01736 template<class UT, long RL_N, long RL_D, long RM_N, long RM_D,
01737 long RT_N, long RT_D, long RE_N, long RE_D, long RTE_N, long RTE_D,
01738 long RA_N, long RA_D, long RLU_N, long RLU_D,
01739 class UL, class DU, class ST>
01740 inline ST cosh (const Quantity<
01741 dimension::Dimension<BSUtilities::Rational<RL_N, RL_D>,
01742 BSUtilities::Rational<RM_N, RM_D>,
01743 BSUtilities::Rational<RT_N, RT_D>,
01744 BSUtilities::Rational<RE_N, RE_D>,
01745 BSUtilities::Rational<RTE_N, RTE_D>,
01746 BSUtilities::Rational<RA_N, RA_D>,
01747 BSUtilities::Rational<RLU_N, RLU_D> >,
01748 UT, UL, DU, ST> &quantity)
01749 {return ST(BSUtilities::IF<CheckDimensionality<Quantity<
01750 dimension::Dimension<BSUtilities::Rational<RL_N, RL_D>,
01751 BSUtilities::Rational<RM_N, RM_D>,
01752 BSUtilities::Rational<RT_N, RT_D>,
01753 BSUtilities::Rational<RE_N, RE_D>,
01754 BSUtilities::Rational<RTE_N, RTE_D>,
01755 BSUtilities::Rational<RA_N, RA_D>,
01756 BSUtilities::Rational<RLU_N, RLU_D> >,
01757 UT, UL, DU, ST> >::RET,
01758 typename
01759 Cosh<dimension::Dimension<BSUtilities::Rational<RL_N, RL_D>,
01760 BSUtilities::Rational<RM_N, RM_D>,
01761 BSUtilities::Rational<RT_N, RT_D>,
01762 BSUtilities::Rational<RE_N, RE_D>,
01763 BSUtilities::Rational<RTE_N, RTE_D>,
01764 BSUtilities::Rational<RA_N, RA_D>,
01765 BSUtilities::Rational<RLU_N, RLU_D> >,
01766 UT, UL, DU, ST>::Cosh, Dummy>::RET::exec (quantity));
01767 }
01768
01770
01775 template<class D, class UT, class UL, class DU, class ST>
01776 struct Tanh
01777 {static ST exec (const Quantity<D, UT, UL, DU, ST> &quantity)
01778 {return ST(std::tanh (quantity.value ()));}
01779 };
01780
01782
01787 template<class UT, long RL_N, long RL_D, long RM_N, long RM_D,
01788 long RT_N, long RT_D, long RE_N, long RE_D, long RTE_N, long RTE_D,
01789 long RA_N, long RA_D, long RLU_N, long RLU_D,
01790 class UL, class DU, class ST>
01791 inline ST tanh (const Quantity<
01792 dimension::Dimension<BSUtilities::Rational<RL_N, RL_D>,
01793 BSUtilities::Rational<RM_N, RM_D>,
01794 BSUtilities::Rational<RT_N, RT_D>,
01795 BSUtilities::Rational<RE_N, RE_D>,
01796 BSUtilities::Rational<RTE_N, RTE_D>,
01797 BSUtilities::Rational<RA_N, RA_D>,
01798 BSUtilities::Rational<RLU_N, RLU_D> >,
01799 UT, UL, DU, ST> &quantity)
01800 {return ST(BSUtilities::IF<CheckDimensionality<Quantity<
01801 dimension::Dimension<BSUtilities::Rational<RL_N, RL_D>,
01802 BSUtilities::Rational<RM_N, RM_D>,
01803 BSUtilities::Rational<RT_N, RT_D>,
01804 BSUtilities::Rational<RE_N, RE_D>,
01805 BSUtilities::Rational<RTE_N, RTE_D>,
01806 BSUtilities::Rational<RA_N, RA_D>,
01807 BSUtilities::Rational<RLU_N, RLU_D> >,
01808 UT, UL, DU, ST> >::RET,
01809 typename
01810 Tanh<dimension::Dimension<BSUtilities::Rational<RL_N, RL_D>,
01811 BSUtilities::Rational<RM_N, RM_D>,
01812 BSUtilities::Rational<RT_N, RT_D>,
01813 BSUtilities::Rational<RE_N, RE_D>,
01814 BSUtilities::Rational<RTE_N, RTE_D>,
01815 BSUtilities::Rational<RA_N, RA_D>,
01816 BSUtilities::Rational<RLU_N, RLU_D> >,
01817 UT, UL, DU, ST>::Tanh, Dummy>::RET::exec (quantity));
01818 }
01819
01821
01826 template<class D, class UT, class UL, class DU, class ST>
01827 struct Asin
01828 {static ST exec (const Quantity<D, UT, UL, DU, ST> &quantity)
01829 {return ST(std::asin (quantity.value ()));}
01830 };
01831
01833
01838 template<class UT, long RL_N, long RL_D, long RM_N, long RM_D,
01839 long RT_N, long RT_D, long RE_N, long RE_D, long RTE_N, long RTE_D,
01840 long RA_N, long RA_D, long RLU_N, long RLU_D,
01841 class UL, class DU, class ST>
01842 inline ST asin (const Quantity<
01843 dimension::Dimension<BSUtilities::Rational<RL_N, RL_D>,
01844 BSUtilities::Rational<RM_N, RM_D>,
01845 BSUtilities::Rational<RT_N, RT_D>,
01846 BSUtilities::Rational<RE_N, RE_D>,
01847 BSUtilities::Rational<RTE_N, RTE_D>,
01848 BSUtilities::Rational<RA_N, RA_D>,
01849 BSUtilities::Rational<RLU_N, RLU_D> >,
01850 UT, UL, DU, ST> &quantity)
01851 {return ST(BSUtilities::IF<CheckDimensionality<Quantity<
01852 dimension::Dimension<BSUtilities::Rational<RL_N, RL_D>,
01853 BSUtilities::Rational<RM_N, RM_D>,
01854 BSUtilities::Rational<RT_N, RT_D>,
01855 BSUtilities::Rational<RE_N, RE_D>,
01856 BSUtilities::Rational<RTE_N, RTE_D>,
01857 BSUtilities::Rational<RA_N, RA_D>,
01858 BSUtilities::Rational<RLU_N, RLU_D> >,
01859 UT, UL, DU, ST> >::RET,
01860 typename
01861 Asin<dimension::Dimension<BSUtilities::Rational<RL_N, RL_D>,
01862 BSUtilities::Rational<RM_N, RM_D>,
01863 BSUtilities::Rational<RT_N, RT_D>,
01864 BSUtilities::Rational<RE_N, RE_D>,
01865 BSUtilities::Rational<RTE_N, RTE_D>,
01866 BSUtilities::Rational<RA_N, RA_D>,
01867 BSUtilities::Rational<RLU_N, RLU_D> >,
01868 UT, UL, DU, ST>::Asin, Dummy>::RET::exec (quantity));
01869 }
01870
01872
01877 template<class D, class UT, class UL, class DU, class ST>
01878 struct Acos
01879 {static ST exec (const Quantity<D, UT, UL, DU, ST> &quantity)
01880 {return ST(std::acos (quantity.value ()));}
01881 };
01882
01884
01889 template<class UT, long RL_N, long RL_D, long RM_N, long RM_D,
01890 long RT_N, long RT_D, long RE_N, long RE_D, long RTE_N, long RTE_D,
01891 long RA_N, long RA_D, long RLU_N, long RLU_D,
01892 class UL, class DU, class ST>
01893 inline ST acos (const Quantity<
01894 dimension::Dimension<BSUtilities::Rational<RL_N, RL_D>,
01895 BSUtilities::Rational<RM_N, RM_D>,
01896 BSUtilities::Rational<RT_N, RT_D>,
01897 BSUtilities::Rational<RE_N, RE_D>,
01898 BSUtilities::Rational<RTE_N, RTE_D>,
01899 BSUtilities::Rational<RA_N, RA_D>,
01900 BSUtilities::Rational<RLU_N, RLU_D> >,
01901 UT, UL, DU, ST> &quantity)
01902 {return ST(BSUtilities::IF<CheckDimensionality<Quantity<
01903 dimension::Dimension<BSUtilities::Rational<RL_N, RL_D>,
01904 BSUtilities::Rational<RM_N, RM_D>,
01905 BSUtilities::Rational<RT_N, RT_D>,
01906 BSUtilities::Rational<RE_N, RE_D>,
01907 BSUtilities::Rational<RTE_N, RTE_D>,
01908 BSUtilities::Rational<RA_N, RA_D>,
01909 BSUtilities::Rational<RLU_N, RLU_D> >,
01910 UT, UL, DU, ST> >::RET,
01911 typename
01912 Acos<dimension::Dimension<BSUtilities::Rational<RL_N, RL_D>,
01913 BSUtilities::Rational<RM_N, RM_D>,
01914 BSUtilities::Rational<RT_N, RT_D>,
01915 BSUtilities::Rational<RE_N, RE_D>,
01916 BSUtilities::Rational<RTE_N, RTE_D>,
01917 BSUtilities::Rational<RA_N, RA_D>,
01918 BSUtilities::Rational<RLU_N, RLU_D> >,
01919 UT, UL, DU, ST>::Acos, Dummy>::RET::exec (quantity));
01920 }
01921
01923
01928 template<class D, class UT, class UL, class DU, class ST>
01929 struct Atan
01930 {static ST exec (const Quantity<D, UT, UL, DU, ST> &quantity)
01931 {return ST(std::atan (quantity.value ()));}
01932 };
01933
01935
01940 template<class UT, long RL_N, long RL_D, long RM_N, long RM_D,
01941 long RT_N, long RT_D, long RE_N, long RE_D, long RTE_N, long RTE_D,
01942 long RA_N, long RA_D, long RLU_N, long RLU_D,
01943 class UL, class DU, class ST>
01944 inline ST atan (const Quantity<
01945 dimension::Dimension<BSUtilities::Rational<RL_N, RL_D>,
01946 BSUtilities::Rational<RM_N, RM_D>,
01947 BSUtilities::Rational<RT_N, RT_D>,
01948 BSUtilities::Rational<RE_N, RE_D>,
01949 BSUtilities::Rational<RTE_N, RTE_D>,
01950 BSUtilities::Rational<RA_N, RA_D>,
01951 BSUtilities::Rational<RLU_N, RLU_D> >,
01952 UT, UL, DU, ST> &quantity)
01953 {return ST(BSUtilities::IF<CheckDimensionality<Quantity<
01954 dimension::Dimension<BSUtilities::Rational<RL_N, RL_D>,
01955 BSUtilities::Rational<RM_N, RM_D>,
01956 BSUtilities::Rational<RT_N, RT_D>,
01957 BSUtilities::Rational<RE_N, RE_D>,
01958 BSUtilities::Rational<RTE_N, RTE_D>,
01959 BSUtilities::Rational<RA_N, RA_D>,
01960 BSUtilities::Rational<RLU_N, RLU_D> >,
01961 UT, UL, DU, ST> >::RET,
01962 typename
01963 Atan<dimension::Dimension<BSUtilities::Rational<RL_N, RL_D>,
01964 BSUtilities::Rational<RM_N, RM_D>,
01965 BSUtilities::Rational<RT_N, RT_D>,
01966 BSUtilities::Rational<RE_N, RE_D>,
01967 BSUtilities::Rational<RTE_N, RTE_D>,
01968 BSUtilities::Rational<RA_N, RA_D>,
01969 BSUtilities::Rational<RLU_N, RLU_D> >,
01970 UT, UL, DU, ST>::Atan, Dummy>::RET::exec (quantity));
01971 }
01972
01974
01977 template<class UT,
01978 long RL_N, long RL_D, long RM_N, long RM_D,
01979 long RT_N, long RT_D, long RE_N, long RE_D,
01980 long RTE_N, long RTE_D, long RA_N, long RA_D,
01981 long RLU_N, long RLU_D,
01982 class UL1, class DU1, class ST1,
01983 class UL2, class DU2, class ST2>
01984 inline ST1 atan2 (const Quantity<
01985 dimension::Dimension<BSUtilities::Rational<RL_N, RL_D>,
01986 BSUtilities::Rational<RM_N, RM_D>,
01987 BSUtilities::Rational<RT_N, RT_D>,
01988 BSUtilities::Rational<RE_N, RE_D>,
01989 BSUtilities::Rational<RTE_N, RTE_D>,
01990 BSUtilities::Rational<RA_N, RA_D>,
01991 BSUtilities::Rational<RLU_N, RLU_D> >,
01992 UT, UL1, DU1, ST1> &quantity,
01993 const Quantity<
01994 dimension::Dimension<BSUtilities::Rational<RL_N, RL_D>,
01995 BSUtilities::Rational<RM_N, RM_D>,
01996 BSUtilities::Rational<RT_N, RT_D>,
01997 BSUtilities::Rational<RE_N, RE_D>,
01998 BSUtilities::Rational<RTE_N, RTE_D>,
01999 BSUtilities::Rational<RA_N, RA_D>,
02000 BSUtilities::Rational<RLU_N, RLU_D> >,
02001 UT, UL2, DU2, ST2> &quantity2)
02002 {return ST1(std::atan2 (quantity.standard_value (),
02003 quantity2.standard_value ()));}
02004
02005 }
02006
02007 #endif