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 #include <cmath>
00045
00047 namespace quantity {
00048
00050
00051
00052
00053
00055
00057
00066 template<class UT, class UL>
00067 class UnitPointerBySymbol
00068 {
00069 public:
00071 static unit::Unit<UT> *result (const std::string &symbol)
00072 {if (UL::Head::Symbol () == symbol)
00073 return new typename UL::Head;
00074 else
00075 return UnitPointerBySymbol<UT, typename UL::Tail>::result
00076 (symbol);
00077 }
00078 };
00079
00081
00085 template<class UT>
00086 class UnitPointerBySymbol<UT, Loki::NullType>
00087 {
00088 public:
00090
00093 static unit::Unit<UT> *result (const std::string &)
00094 {throw UnitMismatch (); return 0;}
00095 };
00096
00098
00106 template<class UL>
00107 class UnitIndexBySymbol
00108 {
00109 public:
00110 static const int index (const std::string &symbol)
00111 {if (UL::Head::Symbol () == symbol)
00112 return 0;
00113 else
00114 return
00115 UnitIndexBySymbol<typename UL::Tail>::index (symbol) + 1;
00116 }
00117 };
00118
00120
00124 template<>
00125 class UnitIndexBySymbol<Loki::NullType>
00126 {
00127 public:
00129
00132 static int index (const std::string &)
00133 {throw UnitMismatch (); return -1;}
00134 };
00135
00137
00139 template<class UL>
00140 class ListUnitSymbols
00141 {
00142 public:
00144
00148 static std::vector<std::string> & result
00149 (std::vector<std::string> &stringvector)
00150 {
00151 stringvector.push_back (UL::Head::Symbol ());
00152 return ListUnitSymbols<typename UL::Tail>::result (stringvector);
00153 }
00154 };
00155
00157
00159 template<>
00160 class ListUnitSymbols<Loki::NullType>
00161 {
00162 public:
00164 static std::vector<std::string> & result
00165 (std::vector<std::string> &stringvector)
00166 {
00167 return stringvector;
00168 }
00169 };
00170
00177 template<class UT, class UL>
00178 class AllUnits
00179 {
00180 private:
00182
00184 typedef
00185 typename unit::CheckUnits<unit::Unit<UT>, UL>::Check Check;
00186
00187 public:
00189 typedef UL Units;
00190
00192
00200 static ::unit::Unit<UT> *unit (const std::string &unitstring)
00201 {return UnitPointerBySymbol<UT, UL>::result (unitstring);}
00202
00204
00207 static std::vector<std::string> allsymbols (void)
00208 {std::vector<std::string> stringvector;
00209 return ListUnitSymbols<UL>::result (stringvector);
00210 }
00211 };
00212
00214
00217 template<class UT, class U>
00218 class DefaultUnit
00219 {
00220 private:
00222
00224 typedef
00225 typename unit::CheckUnit<unit::Unit<UT>, U>::Check Check;
00226
00227 public:
00229 typedef U Unit;
00230 };
00231
00233 template<class U, class TL> struct CheckAgainstAllUnits;
00234
00236
00244 template<class U, class Head, class Tail>
00245 struct CheckAgainstAllUnits<U, Loki::Typelist<Head, Tail> >
00246 {
00247 typedef
00248 typename BSUtilities::IF<BSUtilities::SameType<U, Head>::sameType,
00249 U, typename CheckAgainstAllUnits<U, Tail>::RET >::RET RET;
00250 };
00251
00253
00260 template<class U>
00261 struct CheckAgainstAllUnits<U, Loki::NullType>
00262 {
00263 typedef unit::UnitError<true> RET;
00264 };
00265
00267
00268
00269
00271
00273
00275 template<bool>
00276 struct DimensionError;
00277
00279
00283 template<>
00284 struct DimensionError<false>
00285 {
00287
00289 static const bool RET = true;
00290 };
00291
00293
00297 template<class Q>
00298 struct CheckDimensionality
00299 {
00300 public:
00302
00304 static const bool RET =
00305 BSUtilities::IF<Q::Dim::IsDimensionless, DimensionError<false>,
00306 DimensionError<true> >::RET::RET;
00307 };
00308
00310
00311
00312
00314
00316
00318 template<bool P> class PrintName;
00320
00322 template<bool P> class PrintSymbol;
00323
00325 class PrintStatus
00326 {
00327 private:
00329 static bool _name;
00331 static bool _symbol;
00332
00333 public:
00335
00337 bool name (void) const {return _name;}
00339
00341 bool symbol (void) const {return _symbol;}
00342
00344 template<bool P> friend class PrintName;
00345
00347 template<bool P> friend class PrintSymbol;
00348 };
00349
00351 typedef Loki::SingletonHolder<PrintStatus> PrintStatusHolder;
00352
00353 #define PS PrintStatusHolder::Instance()
00354
00356
00359 template<bool P>
00360 class PrintName
00361 {
00363
00366 void set (bool name) const {PrintStatus::_name = name;}
00367
00369
00375 friend std::ostream & operator<<
00376 (std::ostream &os, const PrintName &print)
00377 {print.set (P); return os;}
00378 };
00379
00381
00384 template<bool P>
00385 class PrintSymbol
00386 {
00388
00391 void set (bool symbol) const {PrintStatus::_symbol = symbol;}
00392
00394
00400 friend std::ostream & operator<<
00401 (std::ostream &os, const PrintSymbol &print)
00402 {print.set (P); return os;}
00403
00404 };
00405
00407
00409 template<bool P> class ReadName;
00410
00412
00414 template<bool P> class ReadSymbol;
00415
00417
00419 template<bool P> class ReadEqual;
00420
00422 class ReadStatus
00423 {
00424 private:
00426 static bool _name;
00427
00429 static bool _symbol;
00430
00432 static bool _equal;
00433
00435
00438 static std::string _unit;
00439
00440 public:
00442
00444 bool name (void) const {return _name;}
00445
00447
00449 bool symbol (void) const {return _symbol;}
00450
00452
00454 bool equal (void) const {return _equal;}
00455
00457
00459 std::string unit (void) const {return _unit;}
00460
00462 template<bool P> friend class ReadName;
00463
00465 template<bool P> friend class ReadSymbol;
00466
00468 template<bool P> friend class ReadEqual;
00469
00471 template<class U> friend class ReadUnit;
00472 };
00473
00475 typedef Loki::SingletonHolder<ReadStatus> ReadStatusHolder;
00476
00477 #define RS ReadStatusHolder::Instance()
00478
00480
00483 template<bool P>
00484 class ReadName
00485 {
00487
00490 void set (bool name) const {ReadStatus::_name = name;}
00491
00493
00499 friend std::istream & operator>>
00500 (std::istream &is, const ReadName &read)
00501 {read.set (P); return is;}
00502 };
00503
00505
00508 template<bool P>
00509 class ReadSymbol
00510 {
00512
00515 void set (bool symbol) const {ReadStatus::_symbol = symbol;}
00516
00518
00524 friend std::istream & operator>>
00525 (std::istream &is, const ReadSymbol &read)
00526 {read.set (P); return is;}
00527
00528 };
00529
00531
00534 template<bool P>
00535 class ReadEqual
00536 {
00538
00541 void set (bool equal) const {ReadStatus::_equal = equal;}
00542
00544
00550 friend std::istream & operator>>
00551 (std::istream &is, const ReadEqual &read)
00552 {read.set (P); return is;}
00553
00554 };
00555
00557
00559 template<class U>
00560 class ReadUnit
00561 {
00563
00566 void set (std::string unit) const {ReadStatus::_unit = unit;}
00567
00569
00576 friend std::istream & operator>>
00577 (std::istream &is, const ReadUnit<U> &unit)
00578 {unit.set (U::Symbol ()); return is;}
00579
00580 };
00581
00582 typedef Loki::NullType NoUnit;
00583
00585
00587 template<>
00588 class ReadUnit<NoUnit>
00589 {
00591
00594 void set (std::string unit) const {ReadStatus::_unit = unit;}
00595
00597
00603 friend std::istream & operator>>
00604 (std::istream &is, const ReadUnit<NoUnit> &unit)
00605 {unit.set (""); return is;}
00606
00607 };
00608
00609
00611
00612
00613
00615
00617
00619 class Quantities
00620 {
00621 public:
00623
00626 static const std::string Version (void)
00627 {static const
00628 std::string v_string ("Quantities version 1.2.1 with ");
00629 return v_string + ::unit::Units::Version () + ", "
00630 + ::dimension::Dimensions::Version () +
00631 " and " + ::BSUtilities::version ();}
00632
00634
00637 static const std::string version (void) {return Version ();}
00638
00640
00642 virtual const std::string unitsymbol (void) const = 0;
00643
00645
00647 virtual const std::string unitname (void) const = 0;
00648
00650
00652 virtual const bool isDimensionless (void) const = 0;
00653
00655
00658 virtual ~Quantities (void) {}
00659
00661
00663 static const std::string TAG;
00664
00666
00668 static const std::string MODETAG;
00669
00671
00673 static const std::string BASENAMETAG;
00674
00676
00678 static const std::string VALUETAG;
00679
00681
00683 static const std::string UNITTAG;
00684
00685 };
00686
00688
00689
00690
00692
00694
00698 template<class D, class UT, class UL, class DU, class ST = double>
00699 class Quantity;
00700
00702 template <class Q> struct Name;
00703
00705 template<class DIM, class UT, class UL, class DU, class ST>
00706 struct Name<Quantity<DIM, UT, UL, DU, ST> >
00707 {
00709
00711 static const std::string String;
00712 };
00713
00715 template <class Q> struct Symbol;
00716
00718 template<class DIM, class UT, class UL, class DU, class ST>
00719 struct Symbol<Quantity<DIM, UT, UL, DU, ST> >
00720 {
00722
00724 static const std::string String;
00725 };
00726
00728
00730 template<class U, class ST = double> struct Standard;
00731
00733
00737 template<class UT, class U, class ST>
00738 struct Standard<unit::NonPrefixable<UT, U>, ST>
00739 {
00740 static const ST ratio;
00741 static const bool exact;
00742 };
00743
00745
00749 template<class UT, class U, class ST>
00750 struct Standard<unit::Prefixable<UT, U>, ST>
00751 {
00752 static const ST ratio;
00753 static const bool exact;
00754 };
00755
00757
00761 template<class UT, class CUL, class ST>
00762 struct Standard<unit::ComposeBase<UT, CUL>, ST>
00763 {
00764 static const ST ratio;
00765 static const bool exact;
00766 };
00767
00769
00774 template<class UL, class PL, class ST = double> class CompStd;
00775
00777
00780 template<class UT, class U, class CULTail, long N, long D,
00781 class PTail, class ST>
00782 class CompStd<Loki::Typelist<unit::NonPrefixable<UT, U>, CULTail>,
00783 Loki::Typelist<BSUtilities::Rational<N, D>, PTail>, ST>
00784 {
00785 public:
00786 static ST ratio (void)
00787 {return std::pow (Standard<unit::NonPrefixable<UT, U> >::ratio,
00788 static_cast<double>(N)/static_cast<double>(D))
00789 * CompStd<CULTail, PTail, ST>::ratio ();}
00790
00791 static bool exact (void)
00792 {return (Standard<unit::NonPrefixable<UT, U> >::exact
00793 && CompStd<CULTail, PTail, ST>::exact ());}
00794 };
00795
00797
00800 template<class UT, class U, class P, class CULTail, long N, long D,
00801 class PTail, class ST>
00802 class CompStd<Loki::Typelist<unit::Prefixed<
00803 unit::Prefixable<UT, U>, P>, CULTail>,
00804 Loki::Typelist<BSUtilities::Rational<N, D>, PTail>, ST>
00805 {
00806 public:
00807 static ST ratio (void)
00808 {return std::pow ((Standard<unit::Prefixable<UT, U> >::ratio
00809 * P::Factor), static_cast<double>(N)/static_cast<double>(D))
00810 * CompStd<CULTail, PTail, ST>::ratio ();}
00811
00812 static bool exact (void)
00813 {return (Standard<unit::Prefixable<UT, U> >::exact
00814 && CompStd<CULTail, PTail, ST>::exact ());}
00815 };
00816
00818
00821 template<class UT, class CEL, class UL, class CULTail, long N, long D,
00822 class PTail, class ST>
00823 class CompStd<Loki::Typelist<unit::Composed<
00824 unit::ComposeBase<UT, CEL>, UL>, CULTail>,
00825 Loki::Typelist<BSUtilities::Rational<N, D>, PTail>, ST>
00826 {
00827 public:
00828 static ST ratio (void)
00829 {return std::pow
00830 (Standard<unit::ComposeBase<UT, CEL> >::ratio,
00831 static_cast<double>(N)/static_cast<double>(D))
00832 * CompStd<CULTail, PTail, ST>::ratio ();}
00833 static bool exact (void)
00834 {return (Standard<unit::ComposeBase<UT, CEL> >::exact
00835 && CompStd<CULTail, PTail, ST>::exact ());}
00836 };
00837
00839
00842 template<class UT, class U, long N, long D, class ST>
00843 class CompStd<Loki::Typelist<unit::NonPrefixable<UT, U>,
00844 Loki::NullType>, Loki::Typelist<BSUtilities::Rational<N, D>,
00845 Loki::NullType>, ST>
00846 {
00847 public:
00848 static ST ratio (void) {return std::pow
00849 (Standard<unit::NonPrefixable<UT, U> >::ratio,
00850 static_cast<double>(N)/static_cast<double>(D));}
00851
00852 static bool exact (void)
00853 {return Standard<unit::NonPrefixable<UT, U> >::exact;}
00854 };
00855
00857
00860 template<class UT, class U, class P, long N, long D, class ST>
00861 class CompStd<Loki::Typelist<unit::Prefixed<
00862 unit::Prefixable<UT, U>, P>, Loki::NullType>,
00863 Loki::Typelist<BSUtilities::Rational<N, D>, Loki::NullType>, ST>
00864 {
00865 public:
00866 static ST ratio (void) {return std::pow
00867 ((Standard<unit::Prefixable<UT, U> >::ratio * P::Factor),
00868 static_cast<double>(N)/static_cast<double>(D));}
00869
00870 static bool exact (void)
00871 {return Standard<unit::Prefixable<UT, U> >::exact;}
00872 };
00873
00875
00878 template<class UT, class CEL, class UL, long N, long D, class ST>
00879 class CompStd<Loki::Typelist<unit::Composed<
00880 unit::ComposeBase<UT, CEL>, UL>, Loki::NullType>,
00881 Loki::Typelist<BSUtilities::Rational<N, D>, Loki::NullType>, ST>
00882 {
00883 public:
00884 static ST ratio (void) {return std::pow
00885 (Standard<unit::ComposeBase<UT, CEL> >::ratio,
00886 static_cast<double>(N)/static_cast<double>(D));}
00887
00888 static bool exact (void)
00889 {return Standard<unit::ComposeBase<UT, CEL> >::exact;}
00890 };
00891
00893
00895 template<class U, class ST = double> struct Standardize;
00896
00898
00903 template<class UT, class U, class ST>
00904 struct Standardize<unit::NonPrefixable<UT, U>, ST>
00905 {
00906 static ST VAL (const ST &value)
00907 {return value *
00908 Standard<unit::NonPrefixable<UT, U>, ST>::ratio;}
00909
00910 static bool Exact (void)
00911 {return Standard<unit::NonPrefixable<UT, U>, ST>::exact;}
00912 };
00913
00915
00920 template<class UT, class U, class P, class ST>
00921 struct Standardize<unit::Prefixed<unit::Prefixable<UT, U>, P>, ST>
00922 {
00923 static ST VAL (const ST &value)
00924 {return ST (value * P::Factor *
00925 Standard<unit::Prefixable<UT, U>, ST>::ratio);}
00926
00927 static bool Exact (void)
00928 {return Standard<unit::Prefixable<UT, U>, ST>::exact;}
00929 };
00930
00932
00937 template<class UT, class CUL, class CEL, class ST>
00938 struct Standardize<unit::Composed<unit::ComposeBase<UT, CEL>,
00939 CUL>, ST>
00940 {
00941 static ST VAL (const ST &value)
00942 {return ST (value * CompStd<CUL,
00943 typename unit::ComposeBase<UT, CEL>::Powers::Powers, ST>
00944 ::ratio () *
00945 Standard<unit::ComposeBase<UT, CEL>, ST>::ratio);}
00946
00947 static bool Exact (void)
00948 {return CompStd<CUL, typename
00949 unit::ComposeBase<UT, CEL>::Powers::Powers, ST>::exact ();}
00950 };
00951
00953
00955 template<class U, class ST = double> struct Reverse;
00956
00958
00963 template<class UT, class U, class ST>
00964 struct Reverse<unit::NonPrefixable<UT, U>, ST>
00965 {
00966 static ST VAL (const ST &value)
00967 {return value /
00968 Standard<unit::NonPrefixable<UT, U>, ST>::ratio;}
00969
00970 static bool Exact (void)
00971 {return Standard<unit::NonPrefixable<UT, U>, ST>::exact;}
00972 };
00973
00975
00980 template<class UT, class U, class P, class ST>
00981 struct Reverse<unit::Prefixed<unit::Prefixable<UT, U>, P>, ST>
00982 {
00983 static ST VAL (const ST &value)
00984 {return ST (value / (P::Factor *
00985 Standard<unit::Prefixable<UT, U>, ST>::ratio));}
00986
00987 static bool Exact (void)
00988 {return Standard<unit::Prefixable<UT, U>, ST>::exact;}
00989 };
00990
00992
00997 template<class UT, class CUL, class CEL, class ST>
00998 struct Reverse<unit::Composed<unit::ComposeBase<UT, CEL>, CUL>,
00999 ST>
01000 {
01001 static ST VAL (const ST &value)
01002 {return
01003 ST (value / (CompStd<CUL,
01004 typename unit::ComposeBase<UT, CEL>::Powers::Powers,
01005 ST>::ratio () *
01006 Standard<unit::ComposeBase<UT, CEL>, ST>::ratio));}
01007
01008 static bool Exact (void)
01009 {return CompStd<CUL, typename
01010 unit::ComposeBase<UT, CEL>::Powers::Powers, ST>::exact ();}
01011 };
01012
01014
01016 template<class UL> struct dynamic_standardize;
01017
01019
01026 template<class Head, class Tail>
01027 struct dynamic_standardize<Loki::Typelist<Head, Tail> >
01028 {
01029 template<class U, class ST>
01030 static ST VAL (const ST &value, const U &unit)
01031 {Head test = Head ();
01032 if (typeid(unit) == typeid(test))
01033 return Standardize<Head, ST>::VAL (value);
01034 else
01035 return dynamic_standardize<Tail>::VAL (value, unit);
01036 }
01037 };
01038
01040
01042 template<>
01043 struct dynamic_standardize<Loki::NullType>
01044 {
01045 template<class U, class ST>
01046 static ST VAL (const ST &, const U &)
01047 {throw UnitMismatch (); return ST (0);}
01048 };
01049
01051
01053 template<class UL> struct dynamic_reverse;
01054
01056
01063 template<class Head, class Tail>
01064 struct dynamic_reverse<Loki::Typelist<Head, Tail> >
01065 {
01066 template<class U, class ST>
01067 static ST VAL (const ST &value, const U &unit)
01068 {Head test = Head ();
01069 if (typeid(unit) == typeid (test))
01070 return Reverse<Head, ST>::VAL (value);
01071 else
01072 return dynamic_reverse<Tail>::VAL (value, unit);
01073 }
01074 };
01075
01077
01079 template<>
01080 struct dynamic_reverse<Loki::NullType>
01081 {
01082 template<class U, class ST>
01083 static ST VAL (const ST &, const U &)
01084 {throw UnitMismatch (); return ST (0);}
01085 };
01086
01088
01096 template<long RL_N, long RL_D, long RM_N, long RM_D,
01097 long RT_N, long RT_D, long RE_N, long RE_D, long RTE_N, long RTE_D,
01098 long RA_N, long RA_D, long RLU_N, long RLU_D, class UT,
01099 class Head, class Tail, class DU, class ST>
01100 class Quantity<
01101 dimension::Dimension<BSUtilities::Rational<RL_N, RL_D>,
01102 BSUtilities::Rational<RM_N, RM_D>,
01103 BSUtilities::Rational<RT_N, RT_D>,
01104 BSUtilities::Rational<RE_N, RE_D>,
01105 BSUtilities::Rational<RTE_N, RTE_D>,
01106 BSUtilities::Rational<RA_N, RA_D>,
01107 BSUtilities::Rational<RLU_N, RLU_D> >,
01108 UT, Loki::Typelist<Head, Tail>, DU, ST>
01109 : public Quantities
01110 {
01111 public:
01113
01115 typedef dimension::Dimension<BSUtilities::Rational<RL_N, RL_D>,
01116 BSUtilities::Rational<RM_N, RM_D>,
01117 BSUtilities::Rational<RT_N, RT_D>,
01118 BSUtilities::Rational<RE_N, RE_D>,
01119 BSUtilities::Rational<RTE_N, RTE_D>,
01120 BSUtilities::Rational<RA_N, RA_D>,
01121 BSUtilities::Rational<RLU_N, RLU_D> > Dim;
01122
01123 private:
01125 static const bool Dimensionless = Dim::IsDimensionless;
01126
01127 protected:
01129
01131 std::string namestring;
01133
01135 std::string symbolstring;
01136
01138
01140 unit::Unit<UT> * findBySymbol (const std::string &unitsymbol)
01141 {return UnitPointerBySymbol<UT, Loki::Typelist<Head, Tail> >
01142 ::result (unitsymbol);}
01143
01145
01150 template<class U>
01151 static ST standard (const ST value, const U&)
01152 {return Standardize<typename CheckAgainstAllUnits<U,
01153 Loki::Typelist<Head, Tail> >::RET, ST> (value);}
01154
01156
01161 template<class U>
01162 static ST reverse (const ST value, const U& unit)
01163 {return Reverse<typename CheckAgainstAllUnits<U,
01164 Loki::Typelist<Head, Tail> >::RET, ST> (value);}
01165
01166 public:
01168
01171 Quantity (void)
01172 : namestring (quantity::Name<Quantity<Dim, UT,
01173 Loki::Typelist<Head, Tail>, DU, ST> >::String),
01174 symbolstring (quantity::Symbol<Quantity<Dim, UT,
01175 Loki::Typelist<Head, Tail>, DU, ST> >::String) {}
01176
01178
01181 virtual ~Quantity (void) {}
01182
01184
01187 typedef AllUnits<UT, Loki::Typelist<Head, Tail> > AllUnits;
01188
01190
01193 typedef DefaultUnit<UT, DU> DefaultUnit;
01194
01196 std::string name (void) const {return namestring;}
01198 std::string symbol (void) const {return symbolstring;}
01199
01201
01202
01203 static const std::string Name (void)
01204 {return quantity::Name<Quantity<Dim, UT,
01205 Loki::Typelist<Head, Tail>, DU, ST> >::String;}
01206
01208
01209
01210 static const std::string Symbol (void)
01211 {return quantity::Symbol<Quantity<Dim, UT,
01212 Loki::Typelist<Head, Tail>, DU, ST> >::String;}
01213
01215 void name (const std::string &name) {namestring = name;}
01217 void symbol (const std::string &symbol) {symbolstring = symbol;}
01218
01220
01222 virtual ST standard_value (void) const = 0;
01223
01225
01227 virtual ST value (void) const = 0;
01228
01230
01232 static const bool IsDimensionless (void) {return Dimensionless;}
01233
01235
01237 const bool isDimensionless (void) const
01238 {return IsDimensionless ();}
01239
01241
01246 friend std::ostream & operator<<
01247 (std::ostream &os, const Quantity &quantity)
01248 {return quantity.print (os);}
01249
01251
01265 std::ostream & print (std::ostream &os) const
01266 {
01267 std::string name ("");
01268 std::string symbol ("");
01269 std::string equal ("");
01270
01271 if (PS.name ())
01272 name = namestring + " ";
01273
01274 if (PS.symbol ())
01275 symbol = symbolstring + " ";
01276
01277 if (PS.name () || PS.symbol ())
01278 equal = "= ";
01279
01280 os << name << symbol << equal;
01281
01282 return print_value (os);
01283 }
01284
01286
01289 virtual std::ostream & print_value (std::ostream &os) const = 0;
01290
01292 friend void operator<<
01293 (std::string &str, const Quantity &quantity) {quantity >> str;}
01294
01296 virtual void operator>> (std::string &str) const = 0;
01297
01299
01302 operator std::string () const
01303 {std::string string; *this >> string; return string;}
01304
01306
01309 virtual std::ostream & operator>> (std::ostream &os) const = 0;
01310
01312
01316 virtual void save (BSUtilities::xmlw::XmlStream &) const = 0;
01317
01319
01323 virtual void load (const TiXmlHandle) const = 0;
01324
01326
01330 typedef Loki::SingletonHolder
01331 <Loki::Factory<Quantity, std::string> > Factory;
01332
01333 };
01334
01336
01337
01338
01339
01341
01343
01345 struct Dummy;
01346
01348
01353 template<class UT, long RL_N, long RL_D, long RM_N, long RM_D,
01354 long RT_N, long RT_D, long RE_N, long RE_D, long RTE_N, long RTE_D,
01355 long RA_N, long RA_D, long RLU_N, long RLU_D,
01356 class UL, class DU, class ST>
01357 struct Exp {static ST exec (const Quantity<
01358 dimension::Dimension<BSUtilities::Rational<RL_N, RL_D>,
01359 BSUtilities::Rational<RM_N, RM_D>,
01360 BSUtilities::Rational<RT_N, RT_D>,
01361 BSUtilities::Rational<RE_N, RE_D>,
01362 BSUtilities::Rational<RTE_N, RTE_D>,
01363 BSUtilities::Rational<RA_N, RA_D>,
01364 BSUtilities::Rational<RLU_N, RLU_D> >,
01365 UT, UL, DU, ST> &quantity)
01366 {return ST(std::exp (quantity.value ()));}
01367 };
01368
01370
01375 template<class UT, long RL_N, long RL_D, long RM_N, long RM_D,
01376 long RT_N, long RT_D, long RE_N, long RE_D, long RTE_N, long RTE_D,
01377 long RA_N, long RA_D, long RLU_N, long RLU_D,
01378 class UL, class DU, class ST>
01379 inline ST exp (const Quantity<
01380 dimension::Dimension<BSUtilities::Rational<RL_N, RL_D>,
01381 BSUtilities::Rational<RM_N, RM_D>,
01382 BSUtilities::Rational<RT_N, RT_D>,
01383 BSUtilities::Rational<RE_N, RE_D>,
01384 BSUtilities::Rational<RTE_N, RTE_D>,
01385 BSUtilities::Rational<RA_N, RA_D>,
01386 BSUtilities::Rational<RLU_N, RLU_D> >,
01387 UT, UL, DU, ST> &quantity)
01388 {return ST(BSUtilities::IF<CheckDimensionality<Quantity<
01389 dimension::Dimension<BSUtilities::Rational<RL_N, RL_D>,
01390 BSUtilities::Rational<RM_N, RM_D>,
01391 BSUtilities::Rational<RT_N, RT_D>,
01392 BSUtilities::Rational<RE_N, RE_D>,
01393 BSUtilities::Rational<RTE_N, RTE_D>,
01394 BSUtilities::Rational<RA_N, RA_D>,
01395 BSUtilities::Rational<RLU_N, RLU_D> >,
01396 UT, UL, DU, ST> >::RET,
01397 typename
01398 Exp<UT, RL_N, RL_D, RM_N, RM_D, RT_N, RT_D, RE_N, RE_D,
01399 RTE_N, RTE_D, RA_N, RA_D, RLU_N, RLU_D, UL, DU, ST>::Exp,
01400 Dummy>::RET::exec (quantity));
01401 }
01402
01404
01409 template<class UT, long RL_N, long RL_D, long RM_N, long RM_D,
01410 long RT_N, long RT_D, long RE_N, long RE_D, long RTE_N, long RTE_D,
01411 long RA_N, long RA_D, long RLU_N, long RLU_D,
01412 class UL, class DU, class ST>
01413 struct Log {static ST exec (const Quantity<
01414 dimension::Dimension<BSUtilities::Rational<RL_N, RL_D>,
01415 BSUtilities::Rational<RM_N, RM_D>,
01416 BSUtilities::Rational<RT_N, RT_D>,
01417 BSUtilities::Rational<RE_N, RE_D>,
01418 BSUtilities::Rational<RTE_N, RTE_D>,
01419 BSUtilities::Rational<RA_N, RA_D>,
01420 BSUtilities::Rational<RLU_N, RLU_D> >,
01421 UT, UL, DU, ST> &quantity)
01422 {return ST(std::log (quantity.value ()));}
01423 };
01424
01426
01431 template<class UT, long RL_N, long RL_D, long RM_N, long RM_D,
01432 long RT_N, long RT_D, long RE_N, long RE_D, long RTE_N, long RTE_D,
01433 long RA_N, long RA_D, long RLU_N, long RLU_D,
01434 class UL, class DU, class ST>
01435 inline ST log (const Quantity<
01436 dimension::Dimension<BSUtilities::Rational<RL_N, RL_D>,
01437 BSUtilities::Rational<RM_N, RM_D>,
01438 BSUtilities::Rational<RT_N, RT_D>,
01439 BSUtilities::Rational<RE_N, RE_D>,
01440 BSUtilities::Rational<RTE_N, RTE_D>,
01441 BSUtilities::Rational<RA_N, RA_D>,
01442 BSUtilities::Rational<RLU_N, RLU_D> >,
01443 UT, UL, DU, ST> &quantity)
01444 {return ST(BSUtilities::IF<CheckDimensionality<Quantity<
01445 dimension::Dimension<BSUtilities::Rational<RL_N, RL_D>,
01446 BSUtilities::Rational<RM_N, RM_D>,
01447 BSUtilities::Rational<RT_N, RT_D>,
01448 BSUtilities::Rational<RE_N, RE_D>,
01449 BSUtilities::Rational<RTE_N, RTE_D>,
01450 BSUtilities::Rational<RA_N, RA_D>,
01451 BSUtilities::Rational<RLU_N, RLU_D> >,
01452 UT, UL, DU, ST> >::RET,
01453 typename
01454 Log<UT, RL_N, RL_D, RM_N, RM_D, RT_N, RT_D, RE_N, RE_D, RTE_N,
01455 RTE_D, RA_N, RA_D, RLU_N, RLU_D, UL, DU, ST>::Log,
01456 Dummy>::RET::exec (quantity));
01457 }
01458
01460
01465 template<class UT, long RL_N, long RL_D, long RM_N, long RM_D,
01466 long RT_N, long RT_D, long RE_N, long RE_D, long RTE_N, long RTE_D,
01467 long RA_N, long RA_D, long RLU_N, long RLU_D,
01468 class UL, class DU, class ST>
01469 struct Log10 {static ST exec (const Quantity<
01470 dimension::Dimension<BSUtilities::Rational<RL_N, RL_D>,
01471 BSUtilities::Rational<RM_N, RM_D>,
01472 BSUtilities::Rational<RT_N, RT_D>,
01473 BSUtilities::Rational<RE_N, RE_D>,
01474 BSUtilities::Rational<RTE_N, RTE_D>,
01475 BSUtilities::Rational<RA_N, RA_D>,
01476 BSUtilities::Rational<RLU_N, RLU_D> >,
01477 UT, UL, DU, ST> &quantity)
01478 {return ST(std::log10 (quantity.value ()));}
01479 };
01480
01482
01487 template<class UT, long RL_N, long RL_D, long RM_N, long RM_D,
01488 long RT_N, long RT_D, long RE_N, long RE_D, long RTE_N, long RTE_D,
01489 long RA_N, long RA_D, long RLU_N, long RLU_D,
01490 class UL, class DU, class ST>
01491 inline ST log10 (const Quantity<
01492 dimension::Dimension<BSUtilities::Rational<RL_N, RL_D>,
01493 BSUtilities::Rational<RM_N, RM_D>,
01494 BSUtilities::Rational<RT_N, RT_D>,
01495 BSUtilities::Rational<RE_N, RE_D>,
01496 BSUtilities::Rational<RTE_N, RTE_D>,
01497 BSUtilities::Rational<RA_N, RA_D>,
01498 BSUtilities::Rational<RLU_N, RLU_D> >,
01499 UT, UL, DU, ST> &quantity)
01500 {return ST(BSUtilities::IF<CheckDimensionality<Quantity<
01501 dimension::Dimension<BSUtilities::Rational<RL_N, RL_D>,
01502 BSUtilities::Rational<RM_N, RM_D>,
01503 BSUtilities::Rational<RT_N, RT_D>,
01504 BSUtilities::Rational<RE_N, RE_D>,
01505 BSUtilities::Rational<RTE_N, RTE_D>,
01506 BSUtilities::Rational<RA_N, RA_D>,
01507 BSUtilities::Rational<RLU_N, RLU_D> >,
01508 UT, UL, DU, ST> >::RET,
01509 typename
01510 Log10<UT, RL_N, RL_D, RM_N, RM_D, RT_N, RT_D, RE_N, RE_D, RTE_N,
01511 RTE_D, RA_N, RA_D, RLU_N, RLU_D, UL, DU, ST>::Log10,
01512 Dummy>::RET::exec (quantity));
01513 }
01514
01516
01521 template<class D, class UT, class UL, class DU, class ST>
01522 struct Sin
01523 {static ST exec (const Quantity<D, UT, UL, DU, ST> &quantity)
01524 {return ST(std::sin (quantity.value ()));}
01525 };
01526
01528
01533 template<class UT, long RL_N, long RL_D, long RM_N, long RM_D,
01534 long RT_N, long RT_D, long RE_N, long RE_D, long RTE_N, long RTE_D,
01535 long RA_N, long RA_D, long RLU_N, long RLU_D,
01536 class UL, class DU, class ST>
01537 inline ST sin (const Quantity<
01538 dimension::Dimension<BSUtilities::Rational<RL_N, RL_D>,
01539 BSUtilities::Rational<RM_N, RM_D>,
01540 BSUtilities::Rational<RT_N, RT_D>,
01541 BSUtilities::Rational<RE_N, RE_D>,
01542 BSUtilities::Rational<RTE_N, RTE_D>,
01543 BSUtilities::Rational<RA_N, RA_D>,
01544 BSUtilities::Rational<RLU_N, RLU_D> >,
01545 UT, UL, DU, ST> &quantity)
01546 {return ST(BSUtilities::IF<CheckDimensionality<Quantity<
01547 dimension::Dimension<BSUtilities::Rational<RL_N, RL_D>,
01548 BSUtilities::Rational<RM_N, RM_D>,
01549 BSUtilities::Rational<RT_N, RT_D>,
01550 BSUtilities::Rational<RE_N, RE_D>,
01551 BSUtilities::Rational<RTE_N, RTE_D>,
01552 BSUtilities::Rational<RA_N, RA_D>,
01553 BSUtilities::Rational<RLU_N, RLU_D> >,
01554 UT, UL, DU, ST> >::RET,
01555 typename
01556 Sin<dimension::Dimension<BSUtilities::Rational<RL_N, RL_D>,
01557 BSUtilities::Rational<RM_N, RM_D>,
01558 BSUtilities::Rational<RT_N, RT_D>,
01559 BSUtilities::Rational<RE_N, RE_D>,
01560 BSUtilities::Rational<RTE_N, RTE_D>,
01561 BSUtilities::Rational<RA_N, RA_D>,
01562 BSUtilities::Rational<RLU_N, RLU_D> >,
01563 UT, UL, DU, ST>::Sin, Dummy>::RET::exec (quantity));
01564 }
01565
01567
01572 template<class D, class UT, class UL, class DU, class ST>
01573 struct Cos
01574 {static ST exec (const Quantity<D, UT, UL, DU, ST> &quantity)
01575 {return ST(std::cos (quantity.value ()));}
01576 };
01577
01579
01584 template<class UT, long RL_N, long RL_D, long RM_N, long RM_D,
01585 long RT_N, long RT_D, long RE_N, long RE_D, long RTE_N, long RTE_D,
01586 long RA_N, long RA_D, long RLU_N, long RLU_D,
01587 class UL, class DU, class ST>
01588 inline ST cos (const Quantity<
01589 dimension::Dimension<BSUtilities::Rational<RL_N, RL_D>,
01590 BSUtilities::Rational<RM_N, RM_D>,
01591 BSUtilities::Rational<RT_N, RT_D>,
01592 BSUtilities::Rational<RE_N, RE_D>,
01593 BSUtilities::Rational<RTE_N, RTE_D>,
01594 BSUtilities::Rational<RA_N, RA_D>,
01595 BSUtilities::Rational<RLU_N, RLU_D> >,
01596 UT, UL, DU, ST> &quantity)
01597 {return ST(BSUtilities::IF<CheckDimensionality<Quantity<
01598 dimension::Dimension<BSUtilities::Rational<RL_N, RL_D>,
01599 BSUtilities::Rational<RM_N, RM_D>,
01600 BSUtilities::Rational<RT_N, RT_D>,
01601 BSUtilities::Rational<RE_N, RE_D>,
01602 BSUtilities::Rational<RTE_N, RTE_D>,
01603 BSUtilities::Rational<RA_N, RA_D>,
01604 BSUtilities::Rational<RLU_N, RLU_D> >,
01605 UT, UL, DU, ST> >::RET,
01606 typename
01607 Cos<dimension::Dimension<BSUtilities::Rational<RL_N, RL_D>,
01608 BSUtilities::Rational<RM_N, RM_D>,
01609 BSUtilities::Rational<RT_N, RT_D>,
01610 BSUtilities::Rational<RE_N, RE_D>,
01611 BSUtilities::Rational<RTE_N, RTE_D>,
01612 BSUtilities::Rational<RA_N, RA_D>,
01613 BSUtilities::Rational<RLU_N, RLU_D> >,
01614 UT, UL, DU, ST>::Cos, Dummy>::RET::exec (quantity));
01615 }
01616
01618
01623 template<class D, class UT, class UL, class DU, class ST>
01624 struct Tan
01625 {static ST exec (const Quantity<D, UT, UL, DU, ST> &quantity)
01626 {return ST(std::tan (quantity.value ()));}
01627 };
01628
01630
01635 template<class UT, long RL_N, long RL_D, long RM_N, long RM_D,
01636 long RT_N, long RT_D, long RE_N, long RE_D, long RTE_N, long RTE_D,
01637 long RA_N, long RA_D, long RLU_N, long RLU_D,
01638 class UL, class DU, class ST>
01639 inline ST tan (const Quantity<
01640 dimension::Dimension<BSUtilities::Rational<RL_N, RL_D>,
01641 BSUtilities::Rational<RM_N, RM_D>,
01642 BSUtilities::Rational<RT_N, RT_D>,
01643 BSUtilities::Rational<RE_N, RE_D>,
01644 BSUtilities::Rational<RTE_N, RTE_D>,
01645 BSUtilities::Rational<RA_N, RA_D>,
01646 BSUtilities::Rational<RLU_N, RLU_D> >,
01647 UT, UL, DU, ST> &quantity)
01648 {return ST(BSUtilities::IF<CheckDimensionality<Quantity<
01649 dimension::Dimension<BSUtilities::Rational<RL_N, RL_D>,
01650 BSUtilities::Rational<RM_N, RM_D>,
01651 BSUtilities::Rational<RT_N, RT_D>,
01652 BSUtilities::Rational<RE_N, RE_D>,
01653 BSUtilities::Rational<RTE_N, RTE_D>,
01654 BSUtilities::Rational<RA_N, RA_D>,
01655 BSUtilities::Rational<RLU_N, RLU_D> >,
01656 UT, UL, DU, ST> >::RET,
01657 typename
01658 Tan<dimension::Dimension<BSUtilities::Rational<RL_N, RL_D>,
01659 BSUtilities::Rational<RM_N, RM_D>,
01660 BSUtilities::Rational<RT_N, RT_D>,
01661 BSUtilities::Rational<RE_N, RE_D>,
01662 BSUtilities::Rational<RTE_N, RTE_D>,
01663 BSUtilities::Rational<RA_N, RA_D>,
01664 BSUtilities::Rational<RLU_N, RLU_D> >,
01665 UT, UL, DU, ST>::Tan, Dummy>::RET::exec (quantity));
01666 }
01667
01669
01674 template<class D, class UT, class UL, class DU, class ST>
01675 struct Sinh
01676 {static ST exec (const Quantity<D, UT, UL, DU, ST> &quantity)
01677 {return ST(std::sinh (quantity.value ()));}
01678 };
01679
01681
01686 template<class UT, long RL_N, long RL_D, long RM_N, long RM_D,
01687 long RT_N, long RT_D, long RE_N, long RE_D, long RTE_N, long RTE_D,
01688 long RA_N, long RA_D, long RLU_N, long RLU_D,
01689 class UL, class DU, class ST>
01690 inline ST sinh (const Quantity<
01691 dimension::Dimension<BSUtilities::Rational<RL_N, RL_D>,
01692 BSUtilities::Rational<RM_N, RM_D>,
01693 BSUtilities::Rational<RT_N, RT_D>,
01694 BSUtilities::Rational<RE_N, RE_D>,
01695 BSUtilities::Rational<RTE_N, RTE_D>,
01696 BSUtilities::Rational<RA_N, RA_D>,
01697 BSUtilities::Rational<RLU_N, RLU_D> >,
01698 UT, UL, DU, ST> &quantity)
01699 {return ST(BSUtilities::IF<CheckDimensionality<Quantity<
01700 dimension::Dimension<BSUtilities::Rational<RL_N, RL_D>,
01701 BSUtilities::Rational<RM_N, RM_D>,
01702 BSUtilities::Rational<RT_N, RT_D>,
01703 BSUtilities::Rational<RE_N, RE_D>,
01704 BSUtilities::Rational<RTE_N, RTE_D>,
01705 BSUtilities::Rational<RA_N, RA_D>,
01706 BSUtilities::Rational<RLU_N, RLU_D> >,
01707 UT, UL, DU, ST> >::RET,
01708 typename
01709 Sinh<dimension::Dimension<BSUtilities::Rational<RL_N, RL_D>,
01710 BSUtilities::Rational<RM_N, RM_D>,
01711 BSUtilities::Rational<RT_N, RT_D>,
01712 BSUtilities::Rational<RE_N, RE_D>,
01713 BSUtilities::Rational<RTE_N, RTE_D>,
01714 BSUtilities::Rational<RA_N, RA_D>,
01715 BSUtilities::Rational<RLU_N, RLU_D> >,
01716 UT, UL, DU, ST>::Sinh, Dummy>::RET::exec (quantity));
01717 }
01718
01720
01725 template<class D, class UT, class UL, class DU, class ST>
01726 struct Cosh
01727 {static ST exec (const Quantity<D, UT, UL, DU, ST> &quantity)
01728 {return ST(std::cosh (quantity.value ()));}
01729 };
01730
01732
01737 template<class UT, long RL_N, long RL_D, long RM_N, long RM_D,
01738 long RT_N, long RT_D, long RE_N, long RE_D, long RTE_N, long RTE_D,
01739 long RA_N, long RA_D, long RLU_N, long RLU_D,
01740 class UL, class DU, class ST>
01741 inline ST cosh (const Quantity<
01742 dimension::Dimension<BSUtilities::Rational<RL_N, RL_D>,
01743 BSUtilities::Rational<RM_N, RM_D>,
01744 BSUtilities::Rational<RT_N, RT_D>,
01745 BSUtilities::Rational<RE_N, RE_D>,
01746 BSUtilities::Rational<RTE_N, RTE_D>,
01747 BSUtilities::Rational<RA_N, RA_D>,
01748 BSUtilities::Rational<RLU_N, RLU_D> >,
01749 UT, UL, DU, ST> &quantity)
01750 {return ST(BSUtilities::IF<CheckDimensionality<Quantity<
01751 dimension::Dimension<BSUtilities::Rational<RL_N, RL_D>,
01752 BSUtilities::Rational<RM_N, RM_D>,
01753 BSUtilities::Rational<RT_N, RT_D>,
01754 BSUtilities::Rational<RE_N, RE_D>,
01755 BSUtilities::Rational<RTE_N, RTE_D>,
01756 BSUtilities::Rational<RA_N, RA_D>,
01757 BSUtilities::Rational<RLU_N, RLU_D> >,
01758 UT, UL, DU, ST> >::RET,
01759 typename
01760 Cosh<dimension::Dimension<BSUtilities::Rational<RL_N, RL_D>,
01761 BSUtilities::Rational<RM_N, RM_D>,
01762 BSUtilities::Rational<RT_N, RT_D>,
01763 BSUtilities::Rational<RE_N, RE_D>,
01764 BSUtilities::Rational<RTE_N, RTE_D>,
01765 BSUtilities::Rational<RA_N, RA_D>,
01766 BSUtilities::Rational<RLU_N, RLU_D> >,
01767 UT, UL, DU, ST>::Cosh, Dummy>::RET::exec (quantity));
01768 }
01769
01771
01776 template<class D, class UT, class UL, class DU, class ST>
01777 struct Tanh
01778 {static ST exec (const Quantity<D, UT, UL, DU, ST> &quantity)
01779 {return ST(std::tanh (quantity.value ()));}
01780 };
01781
01783
01788 template<class UT, long RL_N, long RL_D, long RM_N, long RM_D,
01789 long RT_N, long RT_D, long RE_N, long RE_D, long RTE_N, long RTE_D,
01790 long RA_N, long RA_D, long RLU_N, long RLU_D,
01791 class UL, class DU, class ST>
01792 inline ST tanh (const Quantity<
01793 dimension::Dimension<BSUtilities::Rational<RL_N, RL_D>,
01794 BSUtilities::Rational<RM_N, RM_D>,
01795 BSUtilities::Rational<RT_N, RT_D>,
01796 BSUtilities::Rational<RE_N, RE_D>,
01797 BSUtilities::Rational<RTE_N, RTE_D>,
01798 BSUtilities::Rational<RA_N, RA_D>,
01799 BSUtilities::Rational<RLU_N, RLU_D> >,
01800 UT, UL, DU, ST> &quantity)
01801 {return ST(BSUtilities::IF<CheckDimensionality<Quantity<
01802 dimension::Dimension<BSUtilities::Rational<RL_N, RL_D>,
01803 BSUtilities::Rational<RM_N, RM_D>,
01804 BSUtilities::Rational<RT_N, RT_D>,
01805 BSUtilities::Rational<RE_N, RE_D>,
01806 BSUtilities::Rational<RTE_N, RTE_D>,
01807 BSUtilities::Rational<RA_N, RA_D>,
01808 BSUtilities::Rational<RLU_N, RLU_D> >,
01809 UT, UL, DU, ST> >::RET,
01810 typename
01811 Tanh<dimension::Dimension<BSUtilities::Rational<RL_N, RL_D>,
01812 BSUtilities::Rational<RM_N, RM_D>,
01813 BSUtilities::Rational<RT_N, RT_D>,
01814 BSUtilities::Rational<RE_N, RE_D>,
01815 BSUtilities::Rational<RTE_N, RTE_D>,
01816 BSUtilities::Rational<RA_N, RA_D>,
01817 BSUtilities::Rational<RLU_N, RLU_D> >,
01818 UT, UL, DU, ST>::Tanh, Dummy>::RET::exec (quantity));
01819 }
01820
01822
01827 template<class D, class UT, class UL, class DU, class ST>
01828 struct Asin
01829 {static ST exec (const Quantity<D, UT, UL, DU, ST> &quantity)
01830 {return ST(std::asin (quantity.value ()));}
01831 };
01832
01834
01839 template<class UT, long RL_N, long RL_D, long RM_N, long RM_D,
01840 long RT_N, long RT_D, long RE_N, long RE_D, long RTE_N, long RTE_D,
01841 long RA_N, long RA_D, long RLU_N, long RLU_D,
01842 class UL, class DU, class ST>
01843 inline ST asin (const Quantity<
01844 dimension::Dimension<BSUtilities::Rational<RL_N, RL_D>,
01845 BSUtilities::Rational<RM_N, RM_D>,
01846 BSUtilities::Rational<RT_N, RT_D>,
01847 BSUtilities::Rational<RE_N, RE_D>,
01848 BSUtilities::Rational<RTE_N, RTE_D>,
01849 BSUtilities::Rational<RA_N, RA_D>,
01850 BSUtilities::Rational<RLU_N, RLU_D> >,
01851 UT, UL, DU, ST> &quantity)
01852 {return ST(BSUtilities::IF<CheckDimensionality<Quantity<
01853 dimension::Dimension<BSUtilities::Rational<RL_N, RL_D>,
01854 BSUtilities::Rational<RM_N, RM_D>,
01855 BSUtilities::Rational<RT_N, RT_D>,
01856 BSUtilities::Rational<RE_N, RE_D>,
01857 BSUtilities::Rational<RTE_N, RTE_D>,
01858 BSUtilities::Rational<RA_N, RA_D>,
01859 BSUtilities::Rational<RLU_N, RLU_D> >,
01860 UT, UL, DU, ST> >::RET,
01861 typename
01862 Asin<dimension::Dimension<BSUtilities::Rational<RL_N, RL_D>,
01863 BSUtilities::Rational<RM_N, RM_D>,
01864 BSUtilities::Rational<RT_N, RT_D>,
01865 BSUtilities::Rational<RE_N, RE_D>,
01866 BSUtilities::Rational<RTE_N, RTE_D>,
01867 BSUtilities::Rational<RA_N, RA_D>,
01868 BSUtilities::Rational<RLU_N, RLU_D> >,
01869 UT, UL, DU, ST>::Asin, Dummy>::RET::exec (quantity));
01870 }
01871
01873
01878 template<class D, class UT, class UL, class DU, class ST>
01879 struct Acos
01880 {static ST exec (const Quantity<D, UT, UL, DU, ST> &quantity)
01881 {return ST(std::acos (quantity.value ()));}
01882 };
01883
01885
01890 template<class UT, long RL_N, long RL_D, long RM_N, long RM_D,
01891 long RT_N, long RT_D, long RE_N, long RE_D, long RTE_N, long RTE_D,
01892 long RA_N, long RA_D, long RLU_N, long RLU_D,
01893 class UL, class DU, class ST>
01894 inline ST acos (const Quantity<
01895 dimension::Dimension<BSUtilities::Rational<RL_N, RL_D>,
01896 BSUtilities::Rational<RM_N, RM_D>,
01897 BSUtilities::Rational<RT_N, RT_D>,
01898 BSUtilities::Rational<RE_N, RE_D>,
01899 BSUtilities::Rational<RTE_N, RTE_D>,
01900 BSUtilities::Rational<RA_N, RA_D>,
01901 BSUtilities::Rational<RLU_N, RLU_D> >,
01902 UT, UL, DU, ST> &quantity)
01903 {return ST(BSUtilities::IF<CheckDimensionality<Quantity<
01904 dimension::Dimension<BSUtilities::Rational<RL_N, RL_D>,
01905 BSUtilities::Rational<RM_N, RM_D>,
01906 BSUtilities::Rational<RT_N, RT_D>,
01907 BSUtilities::Rational<RE_N, RE_D>,
01908 BSUtilities::Rational<RTE_N, RTE_D>,
01909 BSUtilities::Rational<RA_N, RA_D>,
01910 BSUtilities::Rational<RLU_N, RLU_D> >,
01911 UT, UL, DU, ST> >::RET,
01912 typename
01913 Acos<dimension::Dimension<BSUtilities::Rational<RL_N, RL_D>,
01914 BSUtilities::Rational<RM_N, RM_D>,
01915 BSUtilities::Rational<RT_N, RT_D>,
01916 BSUtilities::Rational<RE_N, RE_D>,
01917 BSUtilities::Rational<RTE_N, RTE_D>,
01918 BSUtilities::Rational<RA_N, RA_D>,
01919 BSUtilities::Rational<RLU_N, RLU_D> >,
01920 UT, UL, DU, ST>::Acos, Dummy>::RET::exec (quantity));
01921 }
01922
01924
01929 template<class D, class UT, class UL, class DU, class ST>
01930 struct Atan
01931 {static ST exec (const Quantity<D, UT, UL, DU, ST> &quantity)
01932 {return ST(std::atan (quantity.value ()));}
01933 };
01934
01936
01941 template<class UT, long RL_N, long RL_D, long RM_N, long RM_D,
01942 long RT_N, long RT_D, long RE_N, long RE_D, long RTE_N, long RTE_D,
01943 long RA_N, long RA_D, long RLU_N, long RLU_D,
01944 class UL, class DU, class ST>
01945 inline ST atan (const Quantity<
01946 dimension::Dimension<BSUtilities::Rational<RL_N, RL_D>,
01947 BSUtilities::Rational<RM_N, RM_D>,
01948 BSUtilities::Rational<RT_N, RT_D>,
01949 BSUtilities::Rational<RE_N, RE_D>,
01950 BSUtilities::Rational<RTE_N, RTE_D>,
01951 BSUtilities::Rational<RA_N, RA_D>,
01952 BSUtilities::Rational<RLU_N, RLU_D> >,
01953 UT, UL, DU, ST> &quantity)
01954 {return ST(BSUtilities::IF<CheckDimensionality<Quantity<
01955 dimension::Dimension<BSUtilities::Rational<RL_N, RL_D>,
01956 BSUtilities::Rational<RM_N, RM_D>,
01957 BSUtilities::Rational<RT_N, RT_D>,
01958 BSUtilities::Rational<RE_N, RE_D>,
01959 BSUtilities::Rational<RTE_N, RTE_D>,
01960 BSUtilities::Rational<RA_N, RA_D>,
01961 BSUtilities::Rational<RLU_N, RLU_D> >,
01962 UT, UL, DU, ST> >::RET,
01963 typename
01964 Atan<dimension::Dimension<BSUtilities::Rational<RL_N, RL_D>,
01965 BSUtilities::Rational<RM_N, RM_D>,
01966 BSUtilities::Rational<RT_N, RT_D>,
01967 BSUtilities::Rational<RE_N, RE_D>,
01968 BSUtilities::Rational<RTE_N, RTE_D>,
01969 BSUtilities::Rational<RA_N, RA_D>,
01970 BSUtilities::Rational<RLU_N, RLU_D> >,
01971 UT, UL, DU, ST>::Atan, Dummy>::RET::exec (quantity));
01972 }
01973
01975
01978 template<class UT,
01979 long RL_N, long RL_D, long RM_N, long RM_D,
01980 long RT_N, long RT_D, long RE_N, long RE_D,
01981 long RTE_N, long RTE_D, long RA_N, long RA_D,
01982 long RLU_N, long RLU_D,
01983 class UL1, class DU1, class ST1,
01984 class UL2, class DU2, class ST2>
01985 inline ST1 atan2 (const Quantity<
01986 dimension::Dimension<BSUtilities::Rational<RL_N, RL_D>,
01987 BSUtilities::Rational<RM_N, RM_D>,
01988 BSUtilities::Rational<RT_N, RT_D>,
01989 BSUtilities::Rational<RE_N, RE_D>,
01990 BSUtilities::Rational<RTE_N, RTE_D>,
01991 BSUtilities::Rational<RA_N, RA_D>,
01992 BSUtilities::Rational<RLU_N, RLU_D> >,
01993 UT, UL1, DU1, ST1> &quantity,
01994 const Quantity<
01995 dimension::Dimension<BSUtilities::Rational<RL_N, RL_D>,
01996 BSUtilities::Rational<RM_N, RM_D>,
01997 BSUtilities::Rational<RT_N, RT_D>,
01998 BSUtilities::Rational<RE_N, RE_D>,
01999 BSUtilities::Rational<RTE_N, RTE_D>,
02000 BSUtilities::Rational<RA_N, RA_D>,
02001 BSUtilities::Rational<RLU_N, RLU_D> >,
02002 UT, UL2, DU2, ST2> &quantity2)
02003 {return ST1(std::atan2 (quantity.standard_value (),
02004 quantity2.standard_value ()));}
02005
02006 }
02007
02008 #endif