Main Page | Namespace List | Class Hierarchy | Class List | File List | Namespace Members | Class Members | File Members | Related Pages

Variable.h

Go to the documentation of this file.
00001 
00005 /* Copyright (C) 2002 - 2006, Bernd Speiser */
00006 /* This file is part of Quantity.
00007 
00008 Quantity is free software; you can redistribute it and/or
00009 modify it under the terms of the GNU General Public License
00010 as published by the Free Software Foundation; either version 2
00011 of the License, or (at your option) any later version.
00012 
00013 Quantity is distributed in the hope that it will be useful,
00014 but WITHOUT ANY WARRANTY; without even the implied warranty of
00015 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00016 GNU General Public License for more details.
00017   
00018 You should have received a copy of the GNU General Public License
00019 along with this program; if not, write to the Free Software
00020 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
00021 02111-1307, USA.
00022 */
00023 
00024 #ifndef _Variable_h
00025 #define _Variable_h
00026 
00027 #include "Quantity/Quantity.h"
00028 #include "Quantity/QuantityError.h"
00029 #include "Quantity/Generic.h"
00030 #include "Quantity/Dynamic.h"
00031 #include "Quantity/Dedimensionalization.h"
00032 
00033 #include "Typelist.h"
00034 #include "NullType.h"
00035 #include "Functor.h"
00036 #include "HierarchyGenerators.h"
00037 
00038 namespace quantity {
00039 
00041 //
00042 //  Helper classes and structs for compiling error messages
00043 //
00045 
00047 
00050 template<bool> 
00051   struct VariableError;
00052 
00054 
00058 template<bool> 
00059   struct ReturnError;
00060 
00062 
00066 template<bool>
00067   struct AssignmentError;
00068 
00070 
00074 template<>
00075   struct AssignmentError<false>
00076     {
00078 
00080        static const bool RET = true;
00081     };
00082 
00084 
00088 template<bool>
00089   struct OperationError;
00090 
00092 
00096 template<>
00097   struct OperationError<false>
00098     {
00100 
00102        static const bool RET = true;
00103     };
00104 
00106 //
00107 //  helper classes and structs for checking features of quantities
00108 //
00110 
00112 
00114 template<class Q1, class Q2> struct SameDimensioned;
00115 
00117 
00125 template<template<class, class, class> class Q1, class UT1,
00126   long RL1_N, long RL1_D, long RM1_N, long RM1_D,
00127     long RT1_N, long RT1_D, long RE1_N, long RE1_D,
00128       long RTE1_N, long RTE1_D, long RA1_N, long RA1_D,
00129         long RLU1_N, long RLU1_D, 
00130           class UL1, class DU1, class U1, class ST1,
00131          template<class, class, class> class Q2, class UT2, 
00132            long RL2_N, long RL2_D, long RM2_N, long RM2_D,  
00133              long RT2_N, long RT2_D, long RE2_N, long RE2_D,  
00134                long RTE2_N, long RTE2_D, long RA2_N, long RA2_D,  
00135                  long RLU2_N, long RLU2_D, 
00136            class UL2, class DU2, class U2, class ST2, 
00137                                                      class N1, class N2>
00138   struct SameDimensioned
00139     <Q1<Quantity<
00140       dimension::Dimension<BSUtilities::Rational<RL1_N, RL1_D>, 
00141         BSUtilities::Rational<RM1_N, RM1_D>, 
00142           BSUtilities::Rational<RT1_N, RT1_D>, 
00143             BSUtilities::Rational<RE1_N, RE1_D>, 
00144               BSUtilities::Rational<RTE1_N, RTE1_D>,
00145                 BSUtilities::Rational<RA1_N, RA1_D>, 
00146                   BSUtilities::Rational<RLU1_N, RLU1_D> >, 
00147                                           UT1, UL1, DU1, ST1>, U1, N1>,
00148     Q2<Quantity<
00149       dimension::Dimension<BSUtilities::Rational<RL2_N, RL2_D>, 
00150         BSUtilities::Rational<RM2_N, RM2_D>, 
00151           BSUtilities::Rational<RT2_N, RT2_D>, 
00152             BSUtilities::Rational<RE2_N, RE2_D>, 
00153               BSUtilities::Rational<RTE2_N, RTE2_D>,
00154                 BSUtilities::Rational<RA2_N, RA2_D>, 
00155                   BSUtilities::Rational<RLU2_N, RLU2_D> >, 
00156                                          UT2, UL2, DU2, ST2>, U2, N2> >
00157   {
00158     enum {RET = dimension::Equal<
00159       dimension::Dimension<BSUtilities::Rational<RL1_N, RL1_D>, 
00160         BSUtilities::Rational<RM1_N, RM1_D>, 
00161           BSUtilities::Rational<RT1_N, RT1_D>, 
00162             BSUtilities::Rational<RE1_N, RE1_D>, 
00163               BSUtilities::Rational<RTE1_N, RTE1_D>,
00164                 BSUtilities::Rational<RA1_N, RA1_D>, 
00165                   BSUtilities::Rational<RLU1_N, RLU1_D> >, 
00166       dimension::Dimension<BSUtilities::Rational<RL2_N, RL2_D>, 
00167         BSUtilities::Rational<RM2_N, RM2_D>, 
00168           BSUtilities::Rational<RT2_N, RT2_D>, 
00169             BSUtilities::Rational<RE2_N, RE2_D>, 
00170               BSUtilities::Rational<RTE2_N, RTE2_D>,
00171                 BSUtilities::Rational<RA2_N, RA2_D>, 
00172                   BSUtilities::Rational<RLU2_N, RLU2_D> > >::EQ}; 
00173   };
00174 
00175 
00177 
00182 template<class Q1, class Q2> struct CheckSecondDimension;
00183 
00184 template<template<class, class, class> class Q1, class UT1, class D1, 
00185            class UL1, class DU1, class U1, class ST1, class N1,
00186          template<class, class, class> class Q2, class UT2, class D2, 
00187            class UL2, class DU2, class U2, class ST2, class N2>
00188   struct CheckSecondDimension
00189     <Q1<Quantity<D1, UT1, UL1, DU1, ST1>, U1, N1>, 
00190          Q2<Quantity<D2, UT2, UL2, DU2, ST2>, U2, N2> >
00191   {
00192     private:
00193       typedef Q1<Quantity<D1, UT1, UL1, DU1, ST1>, U1, N1> Quant1; 
00194       typedef Q2<Quantity<D2, UT2, UL2, DU2, ST2>, U2, N2> Quant2; 
00195 
00196     public: 
00197       typedef 
00198         typename BSUtilities::IF<SameDimensioned<Quant1, Quant2>::RET, 
00199                                 Quant2, DimensionError<true> >::RET RET;
00200   };
00201 
00203 //
00204 //  forward declaration
00205 //
00207 
00209 
00212 template<class Q1, class Q2> struct GenerateVariable;
00213 
00215 //
00216 //  the Variable classes
00217 //
00219 
00221 
00228 template<class PQ, class SU = typename PQ::DefaultUnit::Unit,
00229   class DD = typename DefaultDedimensionalizer<PQ, SU>::F> 
00230                                                          class Variable;
00231 
00233 
00236 template<long RL_N, long RL_D, long RM_N, long RM_D, 
00237   long RT_N, long RT_D, long RE_N, long RE_D, long RTE_N, long RTE_D,
00238     long RA_N, long RA_D, long RLU_N, long RLU_D, 
00239              class BT, class UL, class DU, class SU, class ST, class R,
00240                                                    class DDH, class DDT>
00241   class Variable<Quantity<dimension::Dimension<
00242             BSUtilities::Rational<RL_N, RL_D>,
00243       BSUtilities::Rational<RM_N, RM_D>,  
00244         BSUtilities::Rational<RT_N, RT_D>,
00245           BSUtilities::Rational<RE_N, RE_D>,
00246             BSUtilities::Rational<RTE_N, RTE_D>, 
00247               BSUtilities::Rational<RA_N, RA_D>,
00248                 BSUtilities::Rational<RLU_N, RLU_D> >, BT, UL, DU, ST>,
00249                   SU, Loki::Functor<R, Loki::Typelist<DDH, DDT> > > 
00250       : public 
00251       Quantity<dimension::Dimension<BSUtilities::Rational<RL_N, RL_D>,
00252         BSUtilities::Rational<RM_N, RM_D>,  
00253           BSUtilities::Rational<RT_N, RT_D>,
00254             BSUtilities::Rational<RE_N, RE_D>,
00255               BSUtilities::Rational<RTE_N, RTE_D>, 
00256                 BSUtilities::Rational<RA_N, RA_D>,
00257                   BSUtilities::Rational<RLU_N, RLU_D> >, BT, UL, DU, ST>
00258     {
00259       public:
00261 
00263         typedef dimension::Dimension<BSUtilities::Rational<RL_N, RL_D>,
00264             BSUtilities::Rational<RM_N, RM_D>,  
00265               BSUtilities::Rational<RT_N, RT_D>,
00266                 BSUtilities::Rational<RE_N, RE_D>,
00267                   BSUtilities::Rational<RTE_N, RTE_D>, 
00268                     BSUtilities::Rational<RA_N, RA_D>,
00269                               BSUtilities::Rational<RLU_N, RLU_D> > DIM;
00270 
00272         typedef typename Loki::Typelist<DDH, DDT> DDL;
00273  
00275 
00282         typedef typename Loki::TL::TypeAt<DDL, 0>::Result DDP;
00283 
00285         typedef typename Loki::Functor<R, DDL> DD;
00286 
00288 
00291         typedef Quantity<DIM, BT, UL, DU, ST> ABQ;
00292 
00294 
00296         typedef Variable<ABQ, SU, DD> V;
00297 
00299 
00304         typedef ABQ PQ;
00305 
00307         typedef typename BSUtilities::IF<BSUtilities::SameType
00308           <DD, typename DefaultDedimensionalizer<PQ, SU>::F>::sameType,
00309                                        DedimReturn<PQ, SU>, V>::RET DDR;
00310 
00311       private:
00313 
00317         static DDR defaultDedimensionalizer (DDP) {return DDR(ST(1.));}
00318 
00320 
00322         static const DD _defaultDD;
00323 
00325 
00333         DD _dedimensionalizer;
00334 
00336 
00339         ST _value;
00340 
00341       public:
00343 
00348         typedef 
00349                typename unit::CheckUnit<unit::Unit<BT>, SU>::Check Unit;
00350 
00352 
00355         Variable (void) : ABQ (), _dedimensionalizer (_defaultDD), 
00356                                                        _value (ST(0)) {}
00357 
00359 
00361         Variable (const DD &dedimensionalizer)
00362           : ABQ (), _dedimensionalizer (dedimensionalizer), 
00363                                                        _value (ST(0)) {}
00364 
00366 
00369         Variable (const ST value) 
00370              : ABQ (), _dedimensionalizer (_defaultDD), _value (value) {}
00371 
00373 
00376         Variable (const ST value, const DD &dedimensionalizer) 
00377           : ABQ (), _dedimensionalizer (dedimensionalizer), 
00378                                                        _value (value) {}
00379 
00381 
00384         Variable (const ST value, const SU &) 
00385              : ABQ (), _dedimensionalizer (_defaultDD), _value (value) {}
00386             
00388 
00391         Variable 
00392           (const ST value, const SU &, const DD &dedimensionalizer) 
00393             : ABQ (), _dedimensionalizer (dedimensionalizer), 
00394                                                        _value (value) {}
00395             
00397 
00403         template<class NU>
00404           Variable (const ST value, const NU &) 
00405             : ABQ (), _value (Reverse<SU, ST>::VAL
00406               (Standardize<typename CheckAgainstAllUnits<NU, UL>::RET, 
00407                                                    ST>::VAL (value))) {}
00408 
00410 
00419         Variable (const ST value, const std::string &symbol) 
00420           : ABQ ()
00421             {::unit::Unit<BT> *unitp = PQ::findBySymbol (symbol);
00422 
00423              _value = Reverse<SU, ST>::VAL 
00424                          (dynamic_standardize<UL>::VAL (value, *unitp));
00425 
00426              delete (unitp);
00427             }
00428 
00430 
00437         Variable (const ST value, const char * symbol) 
00438           : ABQ ()
00439             {::unit::Unit<BT> *unitp 
00440                               = PQ::findBySymbol (std::string (symbol));
00441              _value = Reverse<SU, ST>::VAL 
00442                          (dynamic_standardize<UL>::VAL (value, *unitp));
00443 
00444              delete (unitp);
00445             }
00446 
00448 
00451         template<template<class, class, class> class Q1>
00452           Variable (const Q1<PQ, SU, DD> &quantity) 
00453             : ABQ (), _value (quantity.value ())
00454               {namestring = quantity.name ();
00455                symbolstring = quantity.symbol ();
00456               }
00457  
00459 
00472         template<template<class, class, class> class Q1, 
00473                                                    class SU1, class DD1>
00474           Variable (const Q1<PQ, SU1, DD1> &quantity)
00475             : ABQ (), _value (Reverse<SU, ST>::VAL 
00476                         (Standardize<SU1, ST>::VAL (quantity.value ())))
00477               {namestring = quantity.name ();
00478                symbolstring = quantity.symbol ();
00479               }
00480 
00482 
00491         template<template<class, class, class> class Q1, 
00492                  class BT1, class DIM1, class DU1, class SU1, class DD1>
00493           Variable (const Q1<Quantity<DIM1, BT1,
00494             Loki::Typelist<unit::NonPrefixable<BT1, unit::GenericUnit>,
00495                          Loki::NullType>, DU1, ST>, SU1, DD1> &quantity)
00496             : ABQ (), _value (Reverse<Unit, ST>::VAL
00497               (Standardize<typename
00498                  CheckSecondDimension<Variable<PQ, SU, DD>, 
00499                    Q1<Quantity<DIM1, BT1,
00500                      Loki::Typelist<unit::NonPrefixable<BT1, 
00501                        unit::GenericUnit>, Loki::NullType>, 
00502                          DU1, ST>, SU1, DD1> >::RET::Unit, ST>::VAL
00503                                                    (quantity.value ())))
00504               {namestring = quantity.name ();
00505                symbolstring = quantity.symbol ();
00506               }
00507 
00509 
00516         template<template<class, class, class> class Q1, 
00517           class PQ1, class SU1, class DD1> 
00518                                    Variable (const Q1<PQ1, SU1, DD1> &);
00519 
00521 
00526         Variable (const Dynamic<ST> &dynamic)
00527           {if (dynamic._rl_n == RL_N/BSUtilities::Gcd<RL_N, RL_D>::RET
00528              && dynamic._rl_d == RL_D/BSUtilities::Gcd<RL_N, RL_D>::RET
00529              && dynamic._rm_n == RM_N/BSUtilities::Gcd<RM_N, RM_D>::RET
00530              && dynamic._rm_d == RM_D/BSUtilities::Gcd<RM_N, RM_D>::RET
00531              && dynamic._rt_n == RT_N/BSUtilities::Gcd<RT_N, RT_D>::RET
00532              && dynamic._rt_d == RT_D/BSUtilities::Gcd<RT_N, RT_D>::RET
00533              && dynamic._re_n == RE_N/BSUtilities::Gcd<RE_N, RE_D>::RET
00534              && dynamic._re_d == RE_D/BSUtilities::Gcd<RE_N, RE_D>::RET
00535              && dynamic._rte_n 
00536                             == RTE_N/BSUtilities::Gcd<RTE_N, RTE_D>::RET
00537              && dynamic._rte_d 
00538                             == RTE_D/BSUtilities::Gcd<RTE_N, RTE_D>::RET
00539              && dynamic._ra_n == RA_N/BSUtilities::Gcd<RA_N, RA_D>::RET
00540              && dynamic._ra_d == RA_D/BSUtilities::Gcd<RA_N, RA_D>::RET
00541              && dynamic._rlu_n 
00542                             == RLU_N/BSUtilities::Gcd<RLU_N, RLU_D>::RET
00543              && dynamic._rlu_d 
00544                            == RLU_D/BSUtilities::Gcd<RLU_N, RLU_D>::RET)
00545 
00546                _value = Reverse<SU, ST>::VAL (dynamic.value ());
00547 
00548             else
00549                {throw DimensionMismatch ();}
00550 
00551           }
00552 
00554 
00561         Variable & operator= (const Variable &new_variable)
00562           {if (this != &new_variable)
00563              {_value = new_variable.value ();}
00564 
00565            return *this;
00566           }
00567 
00569 
00588         template<template<class, class, class> class Q1, 
00589                                                    class SU1, class DD1>
00590           Variable & operator= (const Q1<PQ, SU1, DD1> &quantity)
00591           {
00592             void *this_pointer = this;
00593             const void *new_pointer = &quantity;
00594 
00595             if (this_pointer != new_pointer)
00596             {_value = Reverse<SU, ST>::VAL
00597                         (Standardize<SU1, ST>::VAL (quantity.value ()));
00598             }
00599 
00600             return *this;
00601           }
00602 
00604 
00613         template<template<class, class, class> class Q1, 
00614           class PQ1, class SU1, class DD1>
00615           Variable & operator= (const Q1<PQ1, SU1, DD1> &quantity)
00616           {
00617             static const bool RET = 
00618               BSUtilities::IF<BSUtilities::SameType<PQ, PQ1>::sameType, 
00619                 DimensionError<false>, DimensionError<true> >::RET::RET;
00620             return *this;
00621           }
00622 
00624 
00645         template<template<class, class, class> class Q1, 
00646                  class BT1, class DIM1, class DU1, class SU1, class DD1>
00647           Variable & operator= (const Q1<Quantity<DIM1, BT1,
00648             Loki::Typelist<unit::NonPrefixable<BT1, unit::GenericUnit>,
00649                          Loki::NullType>, DU1, ST>, SU1, DD1> &quantity)
00650             {void *this_pointer = this;
00651              const void *new_pointer = &quantity;
00652 
00653              if (this_pointer != new_pointer)
00654              {_value = Reverse<SU, ST>::VAL
00655                (Standardize<typename
00656                  CheckSecondDimension<Variable<PQ, SU, DD>, 
00657                    Q1<Quantity<DIM1, BT1,
00658                      Loki::Typelist<unit::NonPrefixable<BT1,
00659                        unit::GenericUnit>, Loki::NullType>, 
00660                          DU1, ST>, SU1, DD1> >::RET::Unit, ST>::VAL
00661                                                    (quantity.value ()));
00662              }
00663              return *this;
00664             }
00665 
00667 
00670           Variable & operator= (const Dynamic<ST> &dynamic)
00671             {if (dynamic._rl_n == RL_N && dynamic._rl_d == RL_D &&
00672                  dynamic._rm_n == RM_N && dynamic._rm_d == RM_D &&
00673                  dynamic._rt_n == RT_N && dynamic._rt_d == RT_D &&
00674                  dynamic._re_n == RE_N && dynamic._re_d == RE_D &&
00675                  dynamic._rte_n == RTE_N && dynamic._rte_d == RTE_D &&
00676                  dynamic._ra_n == RA_N && dynamic._ra_d == RA_D &&
00677                  dynamic._rlu_n == RLU_N && dynamic._rlu_d == RLU_D)
00678                _value = Reverse<SU, ST>::VAL (dynamic.value ());
00679 
00680              else
00681                {throw DimensionMismatch ();}
00682 
00683              return *this;
00684             }
00685 
00687 
00689         ST value (void) const {return _value;}
00690 
00692 
00695         ST standard_value (void) const 
00696                      {return Standardize<SU, ST>::VAL (_value);}
00697 
00699 
00704         template<class NU>
00705           ST value (const unit::NonPrefixable<BT, NU> &) const 
00706             {return Reverse<typename CheckAgainstAllUnits<
00707               unit::NonPrefixable<BT, NU>, UL>::RET, ST>::VAL
00708                            (Standardize<SU, ST>::VAL (_value));}
00709 
00711 
00716         template<class NU, class P>
00717           ST value 
00718             (const unit::Prefixed<unit::Prefixable<BT, NU>, P> &) const
00719             {return Reverse<typename CheckAgainstAllUnits<
00720               unit::Prefixed<unit::Prefixable<BT, NU>, P>, UL>::RET, 
00721                   ST>::VAL (Standardize<SU, ST>::VAL (_value));}
00722 
00724 
00729         template<class CUL, class EL>
00730           ST value 
00731             (const unit::Composed<unit::ComposeBase<BT, CUL>, EL> &)
00732                                                                    const
00733             {return Reverse<typename CheckAgainstAllUnits<
00734               unit::Composed<unit::ComposeBase<BT, CUL>, EL>, UL>::RET,
00735                   ST>::VAL (Standardize<SU, ST>::VAL (_value));}
00736 
00738 
00747         ST value (const std::string &symbol)
00748           {ST value;
00749            ::unit::Unit<BT> *unitp = PQ::findBySymbol (symbol);
00750 
00751            value = dynamic_reverse<UL>::VAL
00752                     (Standardize<SU, ST>::VAL (_value), *unitp);
00753 
00754            delete (unitp);
00755 
00756            return value;
00757           }
00758 
00760 
00766         template<class NU>
00767           Variable<PQ, NU> operator () (const NU &) const 
00768                                {return Variable<PQ, NU> (_value, SU());}
00769 
00771 
00773         const std::string unitsymbol (void) const 
00774                                                  {return SU::Symbol ();}
00775 
00777 
00779         static std::string Unitsymbol (void) {return SU::Symbol ();}
00780 
00782 
00784         const std::string unitname (void) const {return SU::Name ();}
00785 
00787 
00789         static std::string Unitname (void) {return SU::Name ();}
00790 
00792 
00808         Variable & operator+= (const Variable &variable)
00809           {if(BSUtilities::IF<BSUtilities::SameType<UL, 
00810             Loki::Typelist<unit::NonPrefixable<BT, unit::GenericUnit>, 
00811               Loki::NullType> >::sameType, AssignmentError<true>, 
00812                                      AssignmentError<false> >::RET::RET)
00813            _value += variable.value (); 
00814            return *this;
00815           }
00816 
00818 
00827         template <template<class, class, class> class Q1, 
00828                                                    class SU1, class DD1>
00829           Variable & operator+= (const Q1<PQ, SU1, DD1> &quantity)
00830             {_value = Reverse<SU, ST>::VAL 
00831               (Standardize<Unit, ST>::VAL (_value) + 
00832                          Standardize<SU1, ST>::VAL (quantity.value ()));
00833               return *this;
00834             }
00835 
00837 
00845         template <template<class, class, class> class Q1, class BT1,
00846                             class DIM1, class DU1, class SU1, class DD1>
00847           Variable & operator+= (const Q1<Quantity<DIM1, BT1, 
00848             Loki::Typelist<unit::NonPrefixable<BT1, unit::GenericUnit>,
00849                          Loki::NullType>, DU1, ST>, SU1, DD1> &quantity)
00850             {_value = Reverse<SU, ST>::VAL 
00851               (Standardize<Unit, ST>::VAL (_value) + 
00852                 Standardize<typename CheckSecondDimension<
00853                   Variable<PQ, SU, DD>, Q1<Quantity<DIM1, BT1, 
00854                     Loki::Typelist<unit::NonPrefixable<BT1, 
00855                       unit::GenericUnit>, Loki::NullType>, DU1, ST>,
00856                         SU1, DD1> >::RET::Unit, ST>::VAL 
00857                                                    (quantity.value ()));
00858               return *this;
00859             }
00860 
00862 
00868         template<template<class, class, class> class Q1, class PQ1, 
00869           class SU1, class DD1>
00870           Variable & operator+= (const Q1<PQ1, SU1, DD1> &quantity)
00871           {
00872             static const bool RET = 
00873               BSUtilities::IF<BSUtilities::SameType<PQ, PQ1>::sameType, 
00874                 DimensionError<false>, DimensionError<true> >::RET::RET;
00875             return *this;
00876           }
00877 
00879 
00893         Variable & operator-= (const Variable &new_variable)
00894           {if(BSUtilities::IF<BSUtilities::SameType<UL, 
00895             Loki::Typelist<unit::NonPrefixable<BT, unit::GenericUnit>, 
00896               Loki::NullType> >::sameType, AssignmentError<true>, 
00897                                      AssignmentError<false> >::RET::RET)
00898            _value -= new_variable.value (); 
00899            return *this;
00900           }
00901 
00903 
00911         template <template<class, class> class Q1, class SU1>
00912           Variable & operator-= (const Q1<PQ, SU1> &quantity)
00913             {_value = Reverse<SU, ST>::VAL 
00914               (Standardize<Unit, ST>::VAL (_value) - 
00915                          Standardize<SU1, ST>::VAL (quantity.value ()));
00916               return *this;
00917             }
00918 
00920 
00926         template <template<class, class> class Q1, class BT1,
00927                                        class DIM1, class DU1, class SU1>
00928           Variable & operator-= (const Q1<Quantity<DIM1, BT1, 
00929             Loki::Typelist<unit::NonPrefixable<BT1, unit::GenericUnit>,
00930                               Loki::NullType>, DU1, ST>, SU1> &quantity)
00931             {_value = Reverse<SU, ST>::VAL 
00932               (Standardize<Unit, ST>::VAL (_value) - 
00933                 Standardize<typename CheckSecondDimension<
00934                   Variable<PQ, SU>, Q1<Quantity<DIM1, BT1, 
00935                     Loki::Typelist<unit::NonPrefixable<BT1, 
00936                       unit::GenericUnit>, Loki::NullType>, DU1, ST>,
00937                         SU1> >::RET::Unit, ST>::VAL 
00938                                                    (quantity.value ()));
00939               return *this;
00940             }
00941 
00943 
00947         template<template<class, class> class Q1, class PQ1, class SU1>
00948           Variable & operator-= (const Q1<PQ1, SU1> &quantity)
00949           {
00950             static const bool RET = 
00951               BSUtilities::IF<BSUtilities::SameType<PQ, PQ1>::sameType, 
00952                 DimensionError<false>, DimensionError<true> >::RET::RET;
00953             return *this;
00954           }
00955 
00957 
00960         Variable & operator*= (const ST factor)
00961            {_value *= factor;
00962              return *this;
00963            }
00964 
00966 
00970         Variable & operator/= (const ST divisor)
00971            {_value /= divisor;
00972              return *this;
00973            }
00974   
00976 
00978         Variable operator+ (void) const
00979           {return Variable (*this);}
00980 
00982 
00984         Variable operator- (void) const
00985           {return Variable (*this) *= ST(-1.0);}
00986 
00988 
00991         template<class Q>
00992           struct Plus
00993             {static Variable<PQ,SU> exec 
00994                    (const Variable<PQ, SU> &variable, const Q &quantity)
00995               {Variable<PQ, SU> new_object (variable);
00996                 return new_object += quantity;
00997               }
00998             };
00999 
01001 
01004       template<template<class, class> class Q1, class DIM1, class BT1, 
01005         class UL1, class DU1, class SU1>
01006       struct PlusGenerated
01007         {static Variable<PQ,SU> exec 
01008           (const Variable<PQ,SU> &variable, 
01009              const Q1<Quantity<DIM1, BT1, UL1, DU1, ST>, SU1> &quantity)
01010             {return Variable<PQ, SU> (Reverse<SU, ST>::VAL 
01011               (Standardize<SU, ST>::VAL (variable.value ()) 
01012                 + Standardize<typename CheckSecondDimension<
01013                   Variable<PQ, SU>, Q1<Quantity<DIM1, BT1, UL1, DU1, 
01014                     ST>, SU1> >::RET::Unit, ST>::VAL 
01015                                                   (quantity.value ())));
01016             }
01017         };
01018         
01020 
01026         template <template<class, class> class Q1, class DIM1,
01027                              class BT1, class UL1, class DU1, class SU1>
01028           Variable operator+ (const Q1<Quantity<DIM1, BT1, UL1, DU1, 
01029                                               ST>, SU1> &quantity) const
01030             {return BSUtilities::IF<BSUtilities::SameType<UL, 
01031               Loki::Typelist<unit::NonPrefixable<BT, 
01032                 unit::GenericUnit>, Loki::NullType> >::sameType, 
01033                   typename PlusGenerated<Q1, DIM1, BT1, UL1, 
01034                     DU1, SU1>::PlusGenerated, 
01035                   typename Plus<Q1<Quantity<DIM1, BT1, UL1, DU1, ST>, 
01036                              SU1> >::Plus>::RET::exec (*this, quantity);
01037             }
01038 
01040 
01047         Variable operator+ (const Dynamic<ST> &quantity) const
01048           {Variable new_variable (quantity);
01049            return *this + new_variable;
01050           }
01051 
01053 
01060         template<template<class, class> class Q>
01061           friend Variable operator+ 
01062             (const Dynamic<ST> &quantity1, 
01063                   const Q<Quantity<DIM, BT, UL, DU, ST>, SU> &quantity2)
01064           {Variable new_variable (quantity1);
01065            return new_variable + quantity2;
01066           }
01067 
01069 
01072         template<class Q>
01073           struct Minus
01074             {static Variable<PQ,SU> exec 
01075                    (const Variable<PQ, SU> &variable, const Q &quantity)
01076               {Variable<PQ, SU> new_object (variable);
01077                 return new_object -= quantity;
01078               }
01079             };
01080 
01082 
01085       template<template<class, class> class Q1, class DIM1, class BT1, 
01086         class UL1, class DU1, class SU1>
01087       struct MinusGenerated
01088         {static Variable<PQ,SU> exec 
01089           (const Variable<PQ,SU> &variable, 
01090              const Q1<Quantity<DIM1, BT1, UL1, DU1, ST>, SU1> &quantity)
01091             {return Variable<PQ, SU> (Reverse<SU, ST>::VAL 
01092               (Standardize<SU, ST>::VAL (variable.value ()) 
01093                 - Standardize<typename CheckSecondDimension<
01094                   Variable<PQ, SU>, Q1<Quantity<DIM1, BT1, UL1, DU1, 
01095                     ST>, SU1> >::RET::Unit, ST>::VAL 
01096                                                   (quantity.value ())));
01097             }
01098         };
01099         
01101 
01107         template <template<class, class> class Q1, class DIM1,
01108                              class BT1, class UL1, class DU1, class SU1>
01109           Variable operator- (const Q1<Quantity<DIM1, BT1, UL1, DU1, 
01110                                               ST>, SU1> &quantity) const
01111             {return BSUtilities::IF<BSUtilities::SameType<UL, 
01112               Loki::Typelist<unit::NonPrefixable<BT, 
01113                 unit::GenericUnit>, Loki::NullType> >::sameType, 
01114                   typename MinusGenerated<Q1, DIM1, BT1, UL1, 
01115                     DU1, SU1>::MinusGenerated, 
01116                   typename Minus<Q1<Quantity<DIM1, BT1, UL1, DU1, ST>, 
01117                             SU1> >::Minus>::RET::exec (*this, quantity);
01118             }
01119 
01121 
01127         Variable operator- (const Dynamic<ST> &quantity) const
01128           {Variable new_variable (quantity);
01129            return *this - new_variable;
01130           }
01131 
01133 
01140         template<template<class, class> class Q>
01141           friend Variable operator- 
01142             (const Dynamic<ST> &quantity1, 
01143                   const Q<Quantity<DIM, BT, UL, DU, ST>, SU> &quantity2)
01144           {Variable new_variable (quantity1);
01145            return new_variable - quantity2;
01146           }
01147 
01149 
01151         Variable operator* (const ST factor) const
01152           {Variable<PQ, SU> new_object (*this);
01153             return new_object *= factor;
01154           }
01155 
01157 
01159         Variable operator/ (const ST divisor) const
01160           {Variable<PQ, SU> new_object (*this);
01161             return new_object /= divisor;
01162           }
01163 
01165 
01175         template <template<class, class> class Q1>
01176           friend Variable operator* 
01177             (const ST factor, const Q1<PQ, SU> &variable)
01178                          {return Variable<PQ, SU> (variable) *= factor;}
01179 
01181 
01185         bool operator== (const Variable &rhs_variable) const
01186                        {return _value == rhs_variable.value ();}
01187 
01189 
01194         template <template<class, class> class Q1, class SU1>
01195           bool operator== (const Q1<PQ, SU1> &rhs_variable) const
01196             {return standard_value () == rhs_variable.standard_value ();
01197             }
01198 
01200 
01205         template <template<class, class> class Q1, 
01206                  class DIM1, class BT1, class UL1, class DU1, class SU1>
01207           bool operator== 
01208             (const Q1<Quantity<DIM1, BT1, UL1, DU1, ST>, SU1> 
01209                                                     &rhs_variable) const
01210             {
01211              return standard_value () == Standardize<typename 
01212                CheckSecondDimension<Variable<PQ, SU>, 
01213                  Q1<Quantity<DIM1, BT1, UL1, DU1, ST>, SU1> 
01214                          >::RET::Unit, ST>::VAL (rhs_variable.value ());
01215             }
01216 
01218 
01222         bool operator!= (const Variable &rhs_variable) const
01223                        {return _value != rhs_variable.value ();}
01224 
01226 
01231         template <template<class, class> class Q1, class SU1>
01232           bool operator!= (const Q1<PQ, SU1> &rhs_variable) const
01233             {return standard_value () != rhs_variable.standard_value ();
01234             }
01235 
01237 
01242         template <template<class, class> class Q1, 
01243                  class DIM1, class BT1, class UL1, class DU1, class SU1>
01244           bool operator!= 
01245             (const Q1<Quantity<DIM1, BT1, UL1, DU1, ST>, SU1> 
01246                                                     &rhs_variable) const
01247             {
01248              return standard_value () != Standardize<typename 
01249                CheckSecondDimension<Variable<PQ, SU>, 
01250                  Q1<Quantity<DIM1, BT1, UL1, DU1, ST>, SU1> 
01251                          >::RET::Unit, ST>::VAL (rhs_variable.value ());
01252             }
01253 
01255 
01259         bool operator> (const Variable &rhs_variable) const
01260                        {return _value > rhs_variable.value ();}
01261 
01263 
01268         template <template<class, class> class Q1, class SU1>
01269           bool operator> (const Q1<PQ, SU1> &rhs_variable) const
01270             {return standard_value () > rhs_variable.standard_value ();
01271             }
01272 
01274 
01279         template <template<class, class> class Q1, 
01280                  class DIM1, class BT1, class UL1, class DU1, class SU1>
01281           bool operator> 
01282             (const Q1<Quantity<DIM1, BT1, UL1, DU1, ST>, SU1> 
01283                                                     &rhs_variable) const
01284             {
01285              return standard_value () > Standardize<typename 
01286                CheckSecondDimension<Variable<PQ, SU>, 
01287                  Q1<Quantity<DIM1, BT1, UL1, DU1, ST>, SU1> 
01288                          >::RET::Unit, ST>::VAL (rhs_variable.value ());
01289             }
01290 
01292 
01296         bool operator< (const Variable &rhs_variable) const
01297                        {return _value < rhs_variable.value ();}
01298 
01300 
01305         template <template<class, class> class Q1, class SU1>
01306           bool operator< (const Q1<PQ, SU1> &rhs_variable) const
01307             {return standard_value () < rhs_variable.standard_value ();
01308             }
01309 
01311 
01316         template <template<class, class> class Q1, 
01317                  class DIM1, class BT1, class UL1, class DU1, class SU1>
01318           bool operator< 
01319             (const Q1<Quantity<DIM1, BT1, UL1, DU1, ST>, SU1> 
01320                                                     &rhs_variable) const
01321             {
01322              return standard_value () < Standardize<typename 
01323                CheckSecondDimension<Variable<PQ, SU>, 
01324                  Q1<Quantity<DIM1, BT1, UL1, DU1, ST>, SU1> 
01325                          >::RET::Unit, ST>::VAL (rhs_variable.value ());
01326             }
01327 
01329 
01333         bool operator>= (const Variable &rhs_variable) const
01334                       {return _value >= rhs_variable.value ();}
01335 
01337 
01342         template <template<class, class> class Q1, class SU1>
01343           bool operator>= (const Q1<PQ, SU1> &rhs_variable) const
01344             {return standard_value () >= rhs_variable.standard_value ();
01345             }
01346 
01348 
01353         template <template<class, class> class Q1, 
01354                  class DIM1, class BT1, class UL1, class DU1, class SU1>
01355           bool operator>= 
01356             (const Q1<Quantity<DIM1, BT1, UL1, DU1, ST>, SU1> 
01357                                                     &rhs_variable) const
01358             {
01359              return standard_value () >= Standardize<typename 
01360                CheckSecondDimension<Variable<PQ, SU>, 
01361                  Q1<Quantity<DIM1, BT1, UL1, DU1, ST>, SU1> 
01362                          >::RET::Unit, ST>::VAL (rhs_variable.value ());
01363             }
01364 
01366 
01370         bool operator<= (const Variable &rhs_variable) const
01371                        {return _value <= rhs_variable.value ();}
01372 
01374 
01379         template <template<class, class> class Q1, class SU1>
01380           bool operator<= (const Q1<PQ, SU1> &rhs_variable) const
01381             {return standard_value () <= rhs_variable.standard_value ();
01382             }
01383 
01385 
01390         template <template<class, class> class Q1, 
01391                  class DIM1, class BT1, class UL1, class DU1, class SU1>
01392           bool operator<= 
01393             (const Q1<Quantity<DIM1, BT1, UL1, DU1, ST>, SU1> 
01394                                                     &rhs_variable) const
01395             {
01396              return standard_value () <= Standardize<typename 
01397                CheckSecondDimension<Variable<PQ, SU>, 
01398                  Q1<Quantity<DIM1, BT1, UL1, DU1, ST>, SU1> 
01399                          >::RET::Unit, ST>::VAL (rhs_variable.value ());
01400             }
01401 
01403 
01408         template<class Q>
01409           typename GenerateVariable<Variable, Q>::Add operator* 
01410                                                 (const Q &factor) const
01411             {
01412               return typename GenerateVariable<Variable, Q>::Add 
01413                          (standard_value () * factor.standard_value ());
01414             }
01415 
01417 
01422         template<class Q>
01423           typename GenerateVariable<Variable, Q>::Sub operator/ 
01424                                                 (const Q &factor) const
01425             {
01426               return typename GenerateVariable<Variable, Q>::Sub 
01427                          (standard_value () / factor.standard_value ());
01428             }
01429 
01431 
01434         friend
01435           typename GenerateVariable<Variable, Loki::NullType>::Inv 
01436             operator/ (const ST numerator, const Variable &factor)
01437           {
01438             return typename 
01439               GenerateVariable<Variable, Loki::NullType>::Inv 
01440                                  (numerator / factor.standard_value ());
01441           }
01442 
01444 
01450         template<long N, long D>
01451           typename GenerateVariable<Variable, 
01452                                      BSUtilities::Rational<N, D> >::Mult
01453                                pow (const BSUtilities::Rational<N, D> &)
01454           {return ::quantity::pow 
01455                                (*this, BSUtilities::Rational<N, D> ());}
01456 
01458 
01464         template<int I>
01465           typename GenerateVariable<Variable, 
01466               BSUtilities::Rational<I, long(1)> >::Mult 
01467                                         pow (typename Loki::Int2Type<I>)
01468           {return ::quantity::pow (*this, Loki::Int2Type<I> ());}
01469 
01471 
01477     template<class T>
01478       Dynamic<ST> pow (const T &exp) const
01479                                 {return ::quantity::pow (*this, exp);}
01480 
01482 
01484         friend typename 
01485           GenerateVariable<Variable, BSUtilities::Rational<1, 2> 
01486                                  >::Mult sqrt (const Variable &variable)
01487           {
01488             return typename 
01489               GenerateVariable<Variable, BSUtilities::Rational<1, 2> 
01490                         >::Mult (std::sqrt(variable.standard_value ()));
01491           }
01492 
01494 
01496         typename 
01497           GenerateVariable<Variable, BSUtilities::Rational<1, 2> 
01498                                                >::Mult sqrt (void) const
01499           {
01500             return typename 
01501               GenerateVariable<Variable, BSUtilities::Rational<1, 2> 
01502                                  >::Mult (std::sqrt(standard_value ()));
01503           }
01504 
01506 
01509       std::ostream & print_value (std::ostream &os) const
01510         {return os << _value << " " << SU::Symbol ();}
01511 
01513 
01515       void operator>> (std::string &str) const
01516           {str = BSUtilities::Conversion<Variable>::to_string (*this);}
01517 
01519 
01523       std::ostream & operator>> (std::ostream &os) const
01524                    {return this->print (os);}
01525 
01527 
01529       void read_value (const std::string &str);
01530 
01532 
01534       friend void operator>> 
01535         (const std::string &str, Variable &variable) 
01536                                             {variable.read_value (str);}
01537 
01539       void operator<< (const std::string &str) {read_value (str);}
01540 
01542       void operator= (const std::string &str) {this->read_value (str);}
01543 
01545 
01549       std::istream & operator<< (std::istream &is) 
01550         {std::string string; getline (is, string); 
01551                                   this->read_value (string); return is;}
01552 
01554 
01557       friend std::istream & operator>> 
01558         (std::istream &is, Variable &variable) {return variable << is;}
01559 
01561 
01566     void save (BSUtilities::xmlw::XmlStream &os) const 
01567     {
01568       os << BSUtilities::xmlw::tag(TAG)
01569          << BSUtilities::xmlw::attr (MODETAG) << MODE
01570          << BSUtilities::xmlw::attr (BASENAMETAG) << Name<ABQ>::String
01571          << BSUtilities::xmlw::attr (VALUETAG) << _value
01572          << BSUtilities::xmlw::attr (UNITTAG) << SU::Name ()
01573          << BSUtilities::xmlw::endtag(TAG);
01574 // to be added ... dedimensionalizer?
01575     }
01576 
01578 
01581     void load (const TiXmlHandle node) const
01582     {
01583         TiXmlElement *element = node.Element();
01584 
01585         if (element
01586           && (element->ValueStr () == Quantities::TAG)
01587             && (element->Attribute(MODETAG) == MODE))
01588         {
01589 // to be added ...
01590         }
01591         else
01592           throw LoadError
01593                  ("error loading variable quantity: incorrect element");
01594     }
01595 
01597 
01601 //    PQ (???) * create (void) {return new Variable;}
01602 // to be implemented
01603 
01605 
01607       static const std::string MODE;
01608 
01609     };
01610 
01612 template<long RL_N, long RL_D, long RM_N, long RM_D, 
01613   long RT_N, long RT_D, long RE_N, long RE_D, long RTE_N, long RTE_D,
01614     long RA_N, long RA_D, long RLU_N, long RLU_D,  
01615       class BT, class UL, class DU, class SU, class ST, class R,
01616                                                    class DDH, class DDT>
01617   const std::string Variable<Quantity<dimension::Dimension<
01618     BSUtilities::Rational<RL_N, RL_D>,
01619       BSUtilities::Rational<RM_N, RM_D>,
01620         BSUtilities::Rational<RT_N, RT_D>,
01621           BSUtilities::Rational<RE_N, RE_D>,
01622             BSUtilities::Rational<RTE_N, RTE_D>,
01623               BSUtilities::Rational<RA_N, RA_D>,
01624                 BSUtilities::Rational<RLU_N, RLU_D> >, BT, UL, DU, ST>,
01625                           SU, Loki::Functor<R, Loki::Typelist<DDH, DDT>
01626                                                  > >::MODE = "variable";
01627 
01628 template<long RL_N, long RL_D, long RM_N, long RM_D, 
01629   long RT_N, long RT_D, long RE_N, long RE_D, long RTE_N, long RTE_D,
01630     long RA_N, long RA_D, long RLU_N, long RLU_D,  
01631       class BT, class UL, class DU, class SU, class ST, class R,
01632                                                    class DDH, class DDT>
01633 const typename Loki::Functor<R, typename Loki::Typelist<DDH, DDT> > 
01634   Variable<Quantity<dimension::Dimension<
01635     BSUtilities::Rational<RL_N, RL_D>,
01636       BSUtilities::Rational<RM_N, RM_D>,
01637         BSUtilities::Rational<RT_N, RT_D>,
01638           BSUtilities::Rational<RE_N, RE_D>,
01639             BSUtilities::Rational<RTE_N, RTE_D>,
01640               BSUtilities::Rational<RA_N, RA_D>,
01641                 BSUtilities::Rational<RLU_N, RLU_D> >, BT, UL, DU, ST>,
01642                           SU, Loki::Functor<R, Loki::Typelist<DDH, DDT>
01643                                                  > >::_defaultDD = 
01644        typename Loki::Functor<R, typename Loki::Typelist<DDH, DDT> > 
01645                                              (defaultDedimensionalizer);
01646 
01651 template<long RL_N, long RL_D, long RM_N, long RM_D, 
01652   long RT_N, long RT_D, long RE_N, long RE_D, long RTE_N, long RTE_D,
01653     long RA_N, long RA_D, long RLU_N, long RLU_D,  
01654       class BT, class UL, class DU, class SU, class ST, class R,
01655                                                    class DDH, class DDT>
01656   void 
01657     Variable<Quantity<dimension::Dimension<
01658     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> >, BT, UL, DU, ST>,
01665                   SU, Loki::Functor<R, Loki::Typelist<DDH, DDT> > >
01666                                    ::read_value (const std::string &str)
01667     {
01668       std::string value;
01669       std::string unit;
01670 
01671       std::string::size_type start;
01672       std::string::size_type end;
01673 
01674       start = str.find_first_not_of (" \0");
01675       end = start;
01676 
01677       if (RS.name ())
01678       {
01679         if (start == std::string::npos)
01680           throw InputError ();
01681 
01682         else
01683         {
01684           end = str.find_first_of (" \0", start);
01685 
01686           if (end == std::string::npos)
01687             namestring = str.substr (start);
01688 
01689           else
01690             namestring = (str.substr (start, end - start));
01691         }
01692       }
01693 
01694       start = str.find_first_not_of (" \0", end);
01695       end = start;
01696  
01697       if (RS.symbol ())
01698       {
01699         if (start == std::string::npos)
01700           throw InputError ();
01701 
01702         else
01703         {
01704           end = str.find_first_of (" \0", start);
01705 
01706           if (end == std::string::npos)
01707             symbolstring = str.substr (start);
01708 
01709           else
01710             symbolstring = (str.substr (start, end - start));
01711         }
01712       }
01713 
01714       start = str.find_first_not_of (" \0", end);
01715       end = start;
01716 
01717       if (RS.equal () && (RS.name () || RS.symbol ()))
01718       {
01719         if (start == std::string::npos)
01720           throw InputError ();
01721 
01722         else
01723         {
01724           end = str.find_first_of (" \0", start);
01725 
01726           if (end == std::string::npos)
01727             throw InputError ();
01728 
01729           else if (str.substr (start, end - start) != "=")
01730             throw InputError ();
01731         }
01732       }
01733 
01734       start = str.find_first_not_of (" \0", end);
01735       end = start;
01736  
01737       if (start == std::string::npos)
01738         throw InputError ();
01739 
01740       else
01741       {
01742         end = str.find_first_of (" \0", start);
01743 
01744         if (end == std::string::npos)
01745           value = str.substr (start);
01746 
01747         else
01748           value = str.substr (start, end - start);
01749 
01750         start = str.find_first_not_of (" \0", end);
01751 
01752         if (start == std::string::npos)
01753           unit = "";
01754 
01755         else
01756         {
01757           end = str.find_first_of (" \0\n", start);
01758 
01759           if (end = std::string::npos)
01760             unit = str.substr (start);
01761 
01762           else
01763             unit = str.substr (start, end - start);
01764         }
01765       }
01766    
01767       ST intermediate;
01768 
01769       try {
01770         intermediate = BSUtilities::Conversion<ST>::string_to (value);
01771           }
01772 
01773       catch (BSUtilities::ConversionFailure) {throw InputError ();}
01774 
01775       start = unit.find_first_not_of (" \0");
01776       end = start;
01777  
01778 /* if no unit symbol string is present in input, assume one or use
01779    storage unit
01780 */
01781       if (start == std::string::npos)
01782       {
01783         std::string assume_unit;
01784 
01785 /* if a unit has been set, use this for conversion of intermediate
01786    (value); else do nothing, since we assume that the value is in 
01787    the storage unit and can be stored directly. 
01788 */
01789         if ((assume_unit = RS.unit ()) != "")
01790         {
01791           try {
01792             ::unit::Unit<BT> *unitp = PQ::findBySymbol (assume_unit);
01793             intermediate 
01794               = Reverse<SU, ST>::VAL 
01795                   (dynamic_standardize<UL>::VAL (intermediate, *unitp));
01796 
01797             delete (unitp);
01798               }
01799 
01800           catch (UnitMismatch) {throw InputError ();}
01801 
01802         }
01803       }
01804 
01805 /* if unit symbol string is present in input, use it for conversion
01806    of intermediate (value)
01807 */
01808       else
01809       {
01810         end = unit.find_first_of (" \0", start);
01811         try {
01812           ::unit::Unit<BT> *unitp 
01813                   = PQ::findBySymbol (unit.substr (start, end - start));
01814 
01815           intermediate 
01816             = Reverse<SU, ST>::VAL 
01817                   (dynamic_standardize<UL>::VAL (intermediate, *unitp));
01818 
01819           delete (unitp);
01820             }
01821         catch (UnitMismatch) {throw InputError ();}
01822       }
01823       
01824 
01825       _value = intermediate;
01826 
01827     }
01828 
01830 
01835 template<template<class, class, class> class Q1, class BT1, 
01836   long RL1_N, long RL1_D, long RM1_N, long RM1_D,
01837     long RT1_N, long RT1_D, long RE1_N, long RE1_D,
01838       long RTE1_N, long RTE1_D, long RA1_N, long RA1_D,
01839         long RLU1_N, long RLU1_D, class UL1, class DU1, class SU1, 
01840                                                               class DD1,
01841          template<class, class, class> class Q2, class BT2, 
01842           long RL2_N, long RL2_D, long RM2_N, long RM2_D,
01843              long RT2_N, long RT2_D, long RE2_N, long RE2_D,
01844                long RTE2_N, long RTE2_D, long RA2_N, long RA2_D,
01845                  long RLU2_N, long RLU2_D,
01846                    class UL2, class DU2, class SU2, class DD2, class ST>
01847   struct GenerateVariable
01848     <Q1<Quantity<
01849       dimension::Dimension<BSUtilities::Rational<RL1_N, RL1_D>,
01850         BSUtilities::Rational<RM1_N, RM1_D>,
01851           BSUtilities::Rational<RT1_N, RT1_D>,
01852             BSUtilities::Rational<RE1_N, RE1_D>,
01853               BSUtilities::Rational<RTE1_N, RTE1_D>,
01854                 BSUtilities::Rational<RA1_N, RA1_D>,
01855                   BSUtilities::Rational<RLU1_N, RLU1_D> >,
01856                                           BT1, UL1, DU1, ST>, SU1, DD1>,
01857      Q2<Quantity<
01858       dimension::Dimension<BSUtilities::Rational<RL2_N, RL2_D>,
01859         BSUtilities::Rational<RM2_N, RM2_D>,
01860           BSUtilities::Rational<RT2_N, RT2_D>,
01861             BSUtilities::Rational<RE2_N, RE2_D>,
01862               BSUtilities::Rational<RTE2_N, RTE2_D>,
01863                 BSUtilities::Rational<RA2_N, RA2_D>,
01864                   BSUtilities::Rational<RLU2_N, RLU2_D> >,
01865                                          BT2, UL2, DU2, ST>, SU2, DD2> >
01866   {
01867      private:
01869        typedef typename 
01870          dimension::Dimension<BSUtilities::Rational<RL1_N, RL1_D>,
01871            BSUtilities::Rational<RM1_N, RM1_D>,
01872              BSUtilities::Rational<RT1_N, RT1_D>,
01873                BSUtilities::Rational<RE1_N, RE1_D>,
01874                  BSUtilities::Rational<RTE1_N, RTE1_D>,
01875                    BSUtilities::Rational<RA1_N, RA1_D>,
01876                      BSUtilities::Rational<RLU1_N, RLU1_D> >
01877          ::template Add<dimension::Dimension<
01878            BSUtilities::Rational<RL2_N, RL2_D>,
01879              BSUtilities::Rational<RM2_N, RM2_D>,
01880                BSUtilities::Rational<RT2_N, RT2_D>,
01881                  BSUtilities::Rational<RE2_N, RE2_D>,
01882                    BSUtilities::Rational<RTE2_N, RTE2_D>,
01883                      BSUtilities::Rational<RA2_N, RA2_D>,
01884                          BSUtilities::Rational<RLU2_N, RLU2_D> > > AddT;
01885 
01886        typedef unit::NonPrefixable<GenericClass<typename AddT::Res>, 
01887                                                unit::GenericUnit> AddU;
01888        typedef Loki::Typelist<AddU, Loki::NullType> AddUnits;
01889        typedef Quantity<typename AddT::Res, 
01890           GenericClass<typename AddT::Res>, AddUnits, AddU, ST> AddNewQ;
01891 
01893        typedef typename 
01894          dimension::Dimension<BSUtilities::Rational<RL1_N, RL1_D>,
01895            BSUtilities::Rational<RM1_N, RM1_D>,
01896              BSUtilities::Rational<RT1_N, RT1_D>,
01897                BSUtilities::Rational<RE1_N, RE1_D>,
01898                  BSUtilities::Rational<RTE1_N, RTE1_D>,
01899                    BSUtilities::Rational<RA1_N, RA1_D>,
01900                      BSUtilities::Rational<RLU1_N, RLU1_D> >
01901          ::template Sub<dimension::Dimension<
01902            BSUtilities::Rational<RL2_N, RL2_D>,
01903              BSUtilities::Rational<RM2_N, RM2_D>,
01904                BSUtilities::Rational<RT2_N, RT2_D>,
01905                  BSUtilities::Rational<RE2_N, RE2_D>,
01906                    BSUtilities::Rational<RTE2_N, RTE2_D>,
01907                      BSUtilities::Rational<RA2_N, RA2_D>,
01908                          BSUtilities::Rational<RLU2_N, RLU2_D> > > SubT;
01909 
01910        typedef unit::NonPrefixable<GenericClass<typename SubT::Res>,
01911                                                unit::GenericUnit> SubU;
01912        typedef Loki::Typelist<SubU, Loki::NullType> SubUnits;
01913        typedef Quantity<typename SubT::Res, 
01914           GenericClass<typename SubT::Res>, SubUnits, SubU, ST> SubNewQ;
01915 
01916      public:
01917        typedef Variable<AddNewQ, AddU> Add;
01918        typedef Variable<SubNewQ, SubU> Sub;
01919   };
01920 
01922 
01927 template<template<class, class, class> class Q1, class BT1, 
01928   long RL1_N, long RL1_D, long RM1_N, long RM1_D,
01929     long RT1_N, long RT1_D, long RE1_N, long RE1_D,
01930       long RTE1_N, long RTE1_D, long RA1_N, long RA1_D,
01931         long RLU1_N, long RLU1_D, 
01932                   class UL1, class DU1, class SU1, class DD1, class ST1>
01933   struct GenerateVariable
01934     <Q1<Quantity<
01935       dimension::Dimension<BSUtilities::Rational<RL1_N, RL1_D>,
01936         BSUtilities::Rational<RM1_N, RM1_D>,
01937           BSUtilities::Rational<RT1_N, RT1_D>,
01938             BSUtilities::Rational<RE1_N, RE1_D>,
01939               BSUtilities::Rational<RTE1_N, RTE1_D>,
01940                 BSUtilities::Rational<RA1_N, RA1_D>,
01941                   BSUtilities::Rational<RLU1_N, RLU1_D> >,
01942                          BT1, UL1, DU1, ST1>, SU1, DD1>, Loki::NullType>
01943   {
01944      private:
01946        typedef typename 
01947          dimension::Dimension<BSUtilities::Rational<RL1_N, RL1_D>,
01948            BSUtilities::Rational<RM1_N, RM1_D>,
01949              BSUtilities::Rational<RT1_N, RT1_D>,
01950                BSUtilities::Rational<RE1_N, RE1_D>,
01951                  BSUtilities::Rational<RTE1_N, RTE1_D>,
01952                    BSUtilities::Rational<RA1_N, RA1_D>,
01953                       BSUtilities::Rational<RLU1_N, RLU1_D> >::Inv InvT;
01954 
01955        typedef unit::NonPrefixable<GenericClass<typename InvT::Res>, 
01956                                                unit::GenericUnit> InvU;
01957        typedef Loki::Typelist<InvU, Loki::NullType> InvUnits;
01958        typedef Quantity< typename InvT::Res, 
01959          GenericClass<typename InvT::Res>, InvUnits, InvU, ST1> InvNewQ;
01960 
01961      public:
01962        typedef Variable<InvNewQ, InvU> Inv;
01963   };
01964 
01966 
01971 template<template<class, class, class> class Q1, class BT1, 
01972   long RL1_N, long RL1_D, long RM1_N, long RM1_D,
01973     long RT1_N, long RT1_D, long RE1_N, long RE1_D,
01974       long RTE1_N, long RTE1_D, long RA1_N, long RA1_D,
01975         long RLU1_N, long RLU1_D, class UL1, class DU1, class DD1, 
01976                                    class ST1, class SU1, long N, long D>
01977   struct GenerateVariable
01978     <Q1<Quantity<
01979       dimension::Dimension<BSUtilities::Rational<RL1_N, RL1_D>,
01980         BSUtilities::Rational<RM1_N, RM1_D>,
01981           BSUtilities::Rational<RT1_N, RT1_D>,
01982             BSUtilities::Rational<RE1_N, RE1_D>,
01983               BSUtilities::Rational<RTE1_N, RTE1_D>,
01984                 BSUtilities::Rational<RA1_N, RA1_D>,
01985                   BSUtilities::Rational<RLU1_N, RLU1_D> >,
01986                     BT1, UL1, DU1, ST1>, SU1, DD1>, 
01987                                            BSUtilities::Rational<N, D> >
01988   {
01989      private:
01991        typedef typename 
01992          dimension::Dimension<BSUtilities::Rational<RL1_N, RL1_D>,
01993            BSUtilities::Rational<RM1_N, RM1_D>,
01994              BSUtilities::Rational<RT1_N, RT1_D>,
01995                BSUtilities::Rational<RE1_N, RE1_D>,
01996                  BSUtilities::Rational<RTE1_N, RTE1_D>,
01997                    BSUtilities::Rational<RA1_N, RA1_D>,
01998                      BSUtilities::Rational<RLU1_N, RLU1_D> >::template 
01999                                                        Mult<N, D> MultT;
02000 
02001        typedef unit::NonPrefixable<GenericClass<typename MultT::Res>,
02002                                               unit::GenericUnit> MultU;
02003        typedef Loki::Typelist<MultU, Loki::NullType> MultUnits;
02004        typedef Quantity<typename MultT::Res, 
02005          GenericClass<typename MultT::Res>, MultUnits, MultU, ST1> 
02006                                                                MultNewQ;
02007 
02008      public:
02009        typedef Variable<MultNewQ, MultU> Mult;
02010   };
02011 
02013 
02016 template<template<class, class, class> class Q1, class BT1, 
02017   long RL1_N, long RL1_D, long RM1_N, long RM1_D,
02018     long RT1_N, long RT1_D, long RE1_N, long RE1_D,
02019       long RTE1_N, long RTE1_D, long RA1_N, long RA1_D,
02020         long RLU1_N, long RLU1_D, 
02021            class UL1, class DU1, class ST1, class SU1, class DD1, int I>
02022   inline typename GenerateVariable
02023     <Q1<Quantity<
02024       dimension::Dimension<BSUtilities::Rational<RL1_N, RL1_D>,
02025         BSUtilities::Rational<RM1_N, RM1_D>,
02026           BSUtilities::Rational<RT1_N, RT1_D>,
02027             BSUtilities::Rational<RE1_N, RE1_D>,
02028               BSUtilities::Rational<RTE1_N, RTE1_D>,
02029                 BSUtilities::Rational<RA1_N, RA1_D>,
02030                   BSUtilities::Rational<RLU1_N, RLU1_D> >,
02031                     BT1, UL1, DU1, ST1>, SU1, DD1>, 
02032               BSUtilities::Rational<I, long(1)> >::Mult 
02033                 pow (const 
02034     Q1<Quantity<
02035       dimension::Dimension<BSUtilities::Rational<RL1_N, RL1_D>,
02036         BSUtilities::Rational<RM1_N, RM1_D>,
02037           BSUtilities::Rational<RT1_N, RT1_D>,
02038             BSUtilities::Rational<RE1_N, RE1_D>,
02039               BSUtilities::Rational<RTE1_N, RTE1_D>,
02040                 BSUtilities::Rational<RA1_N, RA1_D>,
02041                   BSUtilities::Rational<RLU1_N, RLU1_D> >,
02042                     BT1, UL1, DU1, ST1>, SU1, DD1> &quantity, 
02043                                              typename Loki::Int2Type<I>)
02044           {
02045             return typename 
02046               GenerateVariable<
02047     Q1<Quantity<
02048       dimension::Dimension<BSUtilities::Rational<RL1_N, RL1_D>,
02049         BSUtilities::Rational<RM1_N, RM1_D>,
02050           BSUtilities::Rational<RT1_N, RT1_D>,
02051             BSUtilities::Rational<RE1_N, RE1_D>,
02052               BSUtilities::Rational<RTE1_N, RTE1_D>,
02053                 BSUtilities::Rational<RA1_N, RA1_D>,
02054                   BSUtilities::Rational<RLU1_N, RLU1_D> >,
02055                     BT1, UL1, DU1, ST1>, SU1, DD1>, 
02056                          BSUtilities::Rational<long(I), long(1)> >::Mult
02057                               (std::pow(quantity.standard_value (), I));
02058           }
02059 
02061 
02065 template<template<class, class, class> class Q1, class BT1, 
02066   long RL1_N, long RL1_D, long RM1_N, long RM1_D,
02067     long RT1_N, long RT1_D, long RE1_N, long RE1_D,
02068       long RTE1_N, long RTE1_D, long RA1_N, long RA1_D,
02069         long RLU1_N, long RLU1_D, 
02070           class UL1, class DU1, class ST1, class SU1, class DD1, 
02071                                                          long N, long D>
02072   inline typename GenerateVariable
02073     <Q1<Quantity<
02074       dimension::Dimension<BSUtilities::Rational<RL1_N, RL1_D>,
02075         BSUtilities::Rational<RM1_N, RM1_D>,
02076           BSUtilities::Rational<RT1_N, RT1_D>,
02077             BSUtilities::Rational<RE1_N, RE1_D>,
02078               BSUtilities::Rational<RTE1_N, RTE1_D>,
02079                 BSUtilities::Rational<RA1_N, RA1_D>,
02080                   BSUtilities::Rational<RLU1_N, RLU1_D> >,
02081                     BT1, UL1, DU1, ST1>, SU1, DD1>, 
02082               BSUtilities::Rational<N, D> >::Mult 
02083                 pow (const 
02084     Q1<Quantity<
02085       dimension::Dimension<BSUtilities::Rational<RL1_N, RL1_D>,
02086         BSUtilities::Rational<RM1_N, RM1_D>,
02087           BSUtilities::Rational<RT1_N, RT1_D>,
02088             BSUtilities::Rational<RE1_N, RE1_D>,
02089               BSUtilities::Rational<RTE1_N, RTE1_D>,
02090                 BSUtilities::Rational<RA1_N, RA1_D>,
02091                   BSUtilities::Rational<RLU1_N, RLU1_D> >,
02092                     BT1, UL1, DU1, ST1>, SU1, DD1> &quantity, 
02093                                     const BSUtilities::Rational<N, D> &)
02094           { return typename 
02095               GenerateVariable
02096     <Q1<Quantity<
02097       dimension::Dimension<BSUtilities::Rational<RL1_N, RL1_D>,
02098         BSUtilities::Rational<RM1_N, RM1_D>,
02099           BSUtilities::Rational<RT1_N, RT1_D>,
02100             BSUtilities::Rational<RE1_N, RE1_D>,
02101               BSUtilities::Rational<RTE1_N, RTE1_D>,
02102                 BSUtilities::Rational<RA1_N, RA1_D>,
02103                   BSUtilities::Rational<RLU1_N, RLU1_D> >,
02104                     BT1, UL1, DU1, ST1>, SU1, DD1>, 
02105                                      BSUtilities::Rational<N, D> >::Mult
02106                (std::pow(quantity.standard_value (), 
02107                         static_cast<double>(N)/static_cast<double>(D)));
02108           }
02109 
02111 
02113 template<template<class, class, class> class Q, class BT, 
02114   long RL_N, long RL_D, long RM_N, long RM_D,
02115     long RT_N, long RT_D, long RE_N, long RE_D,
02116       long RTE_N, long RTE_D, long RA_N, long RA_D,
02117         long RLU_N, long RLU_D, 
02118                        class UL, class DU, class ST, class SU, class DD>
02119   inline Variable<Quantity<
02120     dimension::Dimension<BSUtilities::Rational<RL_N, RL_D>,
02121       BSUtilities::Rational<RM_N, RM_D>,
02122         BSUtilities::Rational<RT_N, RT_D>,
02123           BSUtilities::Rational<RE_N, RE_D>,
02124             BSUtilities::Rational<RTE_N, RTE_D>,
02125               BSUtilities::Rational<RA_N, RA_D>,
02126                 BSUtilities::Rational<RLU_N, RLU_D> >,
02127                                                 BT, UL, DU, ST>, SU, DD>
02128   abs (const Q<Quantity<
02129     dimension::Dimension<BSUtilities::Rational<RL_N, RL_D>,
02130       BSUtilities::Rational<RM_N, RM_D>,
02131         BSUtilities::Rational<RT_N, RT_D>,
02132           BSUtilities::Rational<RE_N, RE_D>,
02133             BSUtilities::Rational<RTE_N, RTE_D>,
02134               BSUtilities::Rational<RA_N, RA_D>,
02135                 BSUtilities::Rational<RLU_N, RLU_D> >,
02136                                      BT, UL, DU, ST>, SU, DD> &variable)
02137   {return Variable<Quantity<
02138     dimension::Dimension<BSUtilities::Rational<RL_N, RL_D>,
02139       BSUtilities::Rational<RM_N, RM_D>,
02140         BSUtilities::Rational<RT_N, RT_D>,
02141           BSUtilities::Rational<RE_N, RE_D>,
02142             BSUtilities::Rational<RTE_N, RTE_D>,
02143               BSUtilities::Rational<RA_N, RA_D>,
02144                 BSUtilities::Rational<RLU_N, RLU_D> >,
02145                                                 BT, UL, DU, ST>, SU, DD>
02146                                         (std::abs (variable.value ()));}
02147 
02149 
02151 template<template<class, class, class> class Q, class BT, 
02152   long RL_N, long RL_D, long RM_N, long RM_D,
02153     long RT_N, long RT_D, long RE_N, long RE_D,
02154       long RTE_N, long RTE_D, long RA_N, long RA_D,
02155         long RLU_N, long RLU_D, 
02156                        class UL, class DU, class ST, class SU, class DD>
02157   inline Variable<Quantity<
02158     dimension::Dimension<BSUtilities::Rational<RL_N, RL_D>,
02159       BSUtilities::Rational<RM_N, RM_D>,
02160         BSUtilities::Rational<RT_N, RT_D>,
02161           BSUtilities::Rational<RE_N, RE_D>,
02162             BSUtilities::Rational<RTE_N, RTE_D>,
02163               BSUtilities::Rational<RA_N, RA_D>,
02164                 BSUtilities::Rational<RLU_N, RLU_D> >,
02165                                                 BT, UL, DU, ST>, SU, DD>
02166   ceil (const Q<Quantity<
02167     dimension::Dimension<BSUtilities::Rational<RL_N, RL_D>,
02168       BSUtilities::Rational<RM_N, RM_D>,
02169         BSUtilities::Rational<RT_N, RT_D>,
02170           BSUtilities::Rational<RE_N, RE_D>,
02171             BSUtilities::Rational<RTE_N, RTE_D>,
02172               BSUtilities::Rational<RA_N, RA_D>,
02173                 BSUtilities::Rational<RLU_N, RLU_D> >,
02174                                      BT, UL, DU, ST>, SU, DD> &variable)
02175   {return Variable<Quantity<
02176     dimension::Dimension<BSUtilities::Rational<RL_N, RL_D>,
02177       BSUtilities::Rational<RM_N, RM_D>,
02178         BSUtilities::Rational<RT_N, RT_D>,
02179           BSUtilities::Rational<RE_N, RE_D>,
02180             BSUtilities::Rational<RTE_N, RTE_D>,
02181               BSUtilities::Rational<RA_N, RA_D>,
02182                 BSUtilities::Rational<RLU_N, RLU_D> >,
02183                                                 BT, UL, DU, ST>, SU, DD>
02184                                        (std::ceil (variable.value ()));}
02185 
02187 
02189 template<template<class, class, class> class Q, class BT, 
02190   long RL_N, long RL_D, long RM_N, long RM_D,
02191     long RT_N, long RT_D, long RE_N, long RE_D,
02192       long RTE_N, long RTE_D, long RA_N, long RA_D,
02193         long RLU_N, long RLU_D, 
02194                        class UL, class DU, class ST, class SU, class DD>
02195   inline Variable<Quantity<
02196     dimension::Dimension<BSUtilities::Rational<RL_N, RL_D>,
02197       BSUtilities::Rational<RM_N, RM_D>,
02198         BSUtilities::Rational<RT_N, RT_D>,
02199           BSUtilities::Rational<RE_N, RE_D>,
02200             BSUtilities::Rational<RTE_N, RTE_D>,
02201               BSUtilities::Rational<RA_N, RA_D>,
02202                 BSUtilities::Rational<RLU_N, RLU_D> >,
02203                                                 BT, UL, DU, ST>, SU, DD>
02204   floor (const Q<Quantity<
02205     dimension::Dimension<BSUtilities::Rational<RL_N, RL_D>,
02206       BSUtilities::Rational<RM_N, RM_D>,
02207         BSUtilities::Rational<RT_N, RT_D>,
02208           BSUtilities::Rational<RE_N, RE_D>,
02209             BSUtilities::Rational<RTE_N, RTE_D>,
02210               BSUtilities::Rational<RA_N, RA_D>,
02211                 BSUtilities::Rational<RLU_N, RLU_D> >,
02212                                      BT, UL, DU, ST>, SU, DD> &variable)
02213   {return Variable<Quantity<
02214     dimension::Dimension<BSUtilities::Rational<RL_N, RL_D>,
02215       BSUtilities::Rational<RM_N, RM_D>,
02216         BSUtilities::Rational<RT_N, RT_D>,
02217           BSUtilities::Rational<RE_N, RE_D>,
02218             BSUtilities::Rational<RTE_N, RTE_D>,
02219               BSUtilities::Rational<RA_N, RA_D>,
02220                 BSUtilities::Rational<RLU_N, RLU_D> >,
02221                                                 BT, UL, DU, ST>, SU, DD>
02222                                       (std::floor (variable.value ()));}
02223 
02225 
02227 template<template<class, class, class> class Q, class BT, 
02228   long RL_N, long RL_D, long RM_N, long RM_D,
02229     long RT_N, long RT_D, long RE_N, long RE_D,
02230       long RTE_N, long RTE_D, long RA_N, long RA_D,
02231         long RLU_N, long RLU_D, 
02232                        class UL, class DU, class ST, class SU, class DD>
02233   inline Variable<Quantity<
02234     dimension::Dimension<BSUtilities::Rational<RL_N, RL_D>,
02235       BSUtilities::Rational<RM_N, RM_D>,
02236         BSUtilities::Rational<RT_N, RT_D>,
02237           BSUtilities::Rational<RE_N, RE_D>,
02238             BSUtilities::Rational<RTE_N, RTE_D>,
02239               BSUtilities::Rational<RA_N, RA_D>,
02240                 BSUtilities::Rational<RLU_N, RLU_D> >,
02241                                                 BT, UL, DU, ST>, SU, DD>
02242   frexp (const Q<Quantity<
02243     dimension::Dimension<BSUtilities::Rational<RL_N, RL_D>,
02244       BSUtilities::Rational<RM_N, RM_D>,
02245         BSUtilities::Rational<RT_N, RT_D>,
02246           BSUtilities::Rational<RE_N, RE_D>,
02247             BSUtilities::Rational<RTE_N, RTE_D>,
02248               BSUtilities::Rational<RA_N, RA_D>,
02249                 BSUtilities::Rational<RLU_N, RLU_D> >,
02250                       BT, UL, DU, ST>, SU, DD> &variable, int *exponent)
02251   {return Variable<Quantity<
02252     dimension::Dimension<BSUtilities::Rational<RL_N, RL_D>,
02253       BSUtilities::Rational<RM_N, RM_D>,
02254         BSUtilities::Rational<RT_N, RT_D>,
02255           BSUtilities::Rational<RE_N, RE_D>,
02256             BSUtilities::Rational<RTE_N, RTE_D>,
02257               BSUtilities::Rational<RA_N, RA_D>,
02258                 BSUtilities::Rational<RLU_N, RLU_D> >,
02259                                                 BT, UL, DU, ST>, SU, DD>
02260                             (std::frexp (variable.value (), exponent));}
02261 
02263 
02265 template<template<class, class, class> class Q, class BT, 
02266   long RL_N, long RL_D, long RM_N, long RM_D,
02267     long RT_N, long RT_D, long RE_N, long RE_D,
02268       long RTE_N, long RTE_D, long RA_N, long RA_D,
02269         long RLU_N, long RLU_D, 
02270                        class UL, class DU, class ST, class SU, class DD>
02271   inline Variable<Quantity<
02272     dimension::Dimension<BSUtilities::Rational<RL_N, RL_D>,
02273       BSUtilities::Rational<RM_N, RM_D>,
02274         BSUtilities::Rational<RT_N, RT_D>,
02275           BSUtilities::Rational<RE_N, RE_D>,
02276             BSUtilities::Rational<RTE_N, RTE_D>,
02277               BSUtilities::Rational<RA_N, RA_D>,
02278                 BSUtilities::Rational<RLU_N, RLU_D> >,
02279                                                 BT, UL, DU, ST>, SU, DD>
02280   ldexp (const Q<Quantity<
02281     dimension::Dimension<BSUtilities::Rational<RL_N, RL_D>,
02282       BSUtilities::Rational<RM_N, RM_D>,
02283         BSUtilities::Rational<RT_N, RT_D>,
02284           BSUtilities::Rational<RE_N, RE_D>,
02285             BSUtilities::Rational<RTE_N, RTE_D>,
02286               BSUtilities::Rational<RA_N, RA_D>,
02287                 BSUtilities::Rational<RLU_N, RLU_D> >,
02288                        BT, UL, DU, ST>, SU, DD> &variable, int exponent)
02289   {return Variable<Quantity<
02290     dimension::Dimension<BSUtilities::Rational<RL_N, RL_D>,
02291       BSUtilities::Rational<RM_N, RM_D>,
02292         BSUtilities::Rational<RT_N, RT_D>,
02293           BSUtilities::Rational<RE_N, RE_D>,
02294             BSUtilities::Rational<RTE_N, RTE_D>,
02295               BSUtilities::Rational<RA_N, RA_D>,
02296                 BSUtilities::Rational<RLU_N, RLU_D> >,
02297                                                 BT, UL, DU, ST>, SU, DD>
02298                             (std::ldexp (variable.value (), exponent));}
02299 
02301 
02307 template<template<class, class, class> class Q, 
02308   template<class, class, class> class Q1, class BT, 
02309     long RL_N, long RL_D, long RM_N, long RM_D,
02310       long RT_N, long RT_D, long RE_N, long RE_D,
02311         long RTE_N, long RTE_D, long RA_N, long RA_D,
02312           long RLU_N, long RLU_D, 
02313            class UL, class DU, class ST, class SU, class DD1, class DD2>
02314   inline Variable<Quantity<
02315     dimension::Dimension<BSUtilities::Rational<RL_N, RL_D>,
02316       BSUtilities::Rational<RM_N, RM_D>,
02317         BSUtilities::Rational<RT_N, RT_D>,
02318           BSUtilities::Rational<RE_N, RE_D>,
02319             BSUtilities::Rational<RTE_N, RTE_D>,
02320               BSUtilities::Rational<RA_N, RA_D>,
02321                 BSUtilities::Rational<RLU_N, RLU_D> >,
02322                                                BT, UL, DU, ST>, SU, DD1>
02323   fmod (const Q<Quantity<
02324     dimension::Dimension<BSUtilities::Rational<RL_N, RL_D>,
02325       BSUtilities::Rational<RM_N, RM_D>,
02326         BSUtilities::Rational<RT_N, RT_D>,
02327           BSUtilities::Rational<RE_N, RE_D>,
02328             BSUtilities::Rational<RTE_N, RTE_D>,
02329               BSUtilities::Rational<RA_N, RA_D>,
02330                 BSUtilities::Rational<RLU_N, RLU_D> >,
02331                                    BT, UL, DU, ST>, SU, DD1> &quantity1,
02332         const Q1<Quantity<
02333     dimension::Dimension<BSUtilities::Rational<RL_N, RL_D>,
02334       BSUtilities::Rational<RM_N, RM_D>,
02335         BSUtilities::Rational<RT_N, RT_D>,
02336           BSUtilities::Rational<RE_N, RE_D>,
02337             BSUtilities::Rational<RTE_N, RTE_D>,
02338               BSUtilities::Rational<RA_N, RA_D>,
02339                 BSUtilities::Rational<RLU_N, RLU_D> >,
02340                                    BT, UL, DU, ST>, SU, DD2> &quantity2)
02341     {return 
02342       Variable<Quantity<
02343         dimension::Dimension<BSUtilities::Rational<RL_N, RL_D>,
02344           BSUtilities::Rational<RM_N, RM_D>,
02345             BSUtilities::Rational<RT_N, RT_D>,
02346               BSUtilities::Rational<RE_N, RE_D>,
02347                 BSUtilities::Rational<RTE_N, RTE_D>,
02348                   BSUtilities::Rational<RA_N, RA_D>,
02349                     BSUtilities::Rational<RLU_N, RLU_D> >,
02350                                                BT, UL, DU, ST>, SU, DD1>
02351       (std::fmod (quantity1.value (), quantity2.value ()));
02352     }
02353 
02355 
02361 template<template<class, class, class> class Q, 
02362   template<class, class, class> class Q1, class BT, 
02363     long RL_N, long RL_D, long RM_N, long RM_D,
02364       long RT_N, long RT_D, long RE_N, long RE_D,
02365         long RTE_N, long RTE_D, long RA_N, long RA_D,
02366           long RLU_N, long RLU_D, 
02367             class UL, class DU, class ST, class SU, class SU1, 
02368                                                    class DD1, class DD2>
02369   inline Variable<Quantity<
02370     dimension::Dimension<BSUtilities::Rational<RL_N, RL_D>,
02371       BSUtilities::Rational<RM_N, RM_D>,
02372         BSUtilities::Rational<RT_N, RT_D>,
02373           BSUtilities::Rational<RE_N, RE_D>,
02374             BSUtilities::Rational<RTE_N, RTE_D>,
02375               BSUtilities::Rational<RA_N, RA_D>,
02376                 BSUtilities::Rational<RLU_N, RLU_D> >,
02377                                                BT, UL, DU, ST>, SU, DD1>
02378   fmod (const Q<Quantity<
02379     dimension::Dimension<BSUtilities::Rational<RL_N, RL_D>,
02380       BSUtilities::Rational<RM_N, RM_D>,
02381         BSUtilities::Rational<RT_N, RT_D>,
02382           BSUtilities::Rational<RE_N, RE_D>,
02383             BSUtilities::Rational<RTE_N, RTE_D>,
02384               BSUtilities::Rational<RA_N, RA_D>,
02385                 BSUtilities::Rational<RLU_N, RLU_D> >,
02386                                    BT, UL, DU, ST>, SU, DD1> &quantity1,
02387         const Q1<Quantity<
02388     dimension::Dimension<BSUtilities::Rational<RL_N, RL_D>,
02389       BSUtilities::Rational<RM_N, RM_D>,
02390         BSUtilities::Rational<RT_N, RT_D>,
02391           BSUtilities::Rational<RE_N, RE_D>,
02392             BSUtilities::Rational<RTE_N, RTE_D>,
02393               BSUtilities::Rational<RA_N, RA_D>,
02394                 BSUtilities::Rational<RLU_N, RLU_D> >,
02395                                   BT, UL, DU, ST>, SU1, DD2> &quantity2)
02396   {return 
02397     Variable<Quantity<
02398       dimension::Dimension<BSUtilities::Rational<RL_N, RL_D>,
02399         BSUtilities::Rational<RM_N, RM_D>,
02400           BSUtilities::Rational<RT_N, RT_D>,
02401             BSUtilities::Rational<RE_N, RE_D>,
02402               BSUtilities::Rational<RTE_N, RTE_D>,
02403                 BSUtilities::Rational<RA_N, RA_D>,
02404                   BSUtilities::Rational<RLU_N, RLU_D> >,
02405                                                BT, UL, DU, ST>, SU, DD1>
02406     (Reverse<SU, ST>::VAL 
02407       (std::fmod (quantity1.standard_value (), 
02408                                          quantity2.standard_value ())));
02409   }
02410 
02412 
02417 template <template<class, class, class> class Q, class BT, 
02418   long RL_N, long RL_D, long RM_N, long RM_D,
02419     long RT_N, long RT_D, long RE_N, long RE_D,
02420       long RTE_N, long RTE_D, long RA_N, long RA_D,
02421         long RLU_N, long RLU_D, class UL, class DU, class ST, class SU, 
02422           class DD1,
02423   template<class, class, class> class Q1, class BT1, 
02424     long RL1_N, long RL1_D, long RM1_N, long RM1_D,
02425       long RT1_N, long RT1_D, long RE1_N, long RE1_D,
02426         long RTE1_N, long RTE1_D, long RA1_N, long RA1_D,
02427           long RLU1_N, long RLU1_D, class UL1, class DU1, class SU1, 
02428                                                               class DD2>
02429   inline Variable<Quantity<
02430     dimension::Dimension<BSUtilities::Rational<RL_N, RL_D>,
02431       BSUtilities::Rational<RM_N, RM_D>,
02432         BSUtilities::Rational<RT_N, RT_D>,
02433           BSUtilities::Rational<RE_N, RE_D>,
02434             BSUtilities::Rational<RTE_N, RTE_D>,
02435               BSUtilities::Rational<RA_N, RA_D>,
02436                 BSUtilities::Rational<RLU_N, RLU_D> >,
02437                                                BT, UL, DU, ST>, SU, DD1>
02438   fmod (const Q<Quantity<
02439     dimension::Dimension<BSUtilities::Rational<RL_N, RL_D>,
02440       BSUtilities::Rational<RM_N, RM_D>,
02441         BSUtilities::Rational<RT_N, RT_D>,
02442           BSUtilities::Rational<RE_N, RE_D>,
02443             BSUtilities::Rational<RTE_N, RTE_D>,
02444               BSUtilities::Rational<RA_N, RA_D>,
02445                 BSUtilities::Rational<RLU_N, RLU_D> >,
02446                                    BT, UL, DU, ST>, SU, DD1> &quantity1,
02447         const Q1<Quantity<
02448     dimension::Dimension<BSUtilities::Rational<RL1_N, RL1_D>,
02449       BSUtilities::Rational<RM1_N, RM1_D>,
02450         BSUtilities::Rational<RT1_N, RT1_D>,
02451           BSUtilities::Rational<RE1_N, RE1_D>,
02452             BSUtilities::Rational<RTE1_N, RTE1_D>,
02453               BSUtilities::Rational<RA1_N, RA1_D>,
02454                 BSUtilities::Rational<RLU1_N, RLU1_D> >,
02455                                BT1, UL1, DU1, ST>, SU1, DD2> &quantity2)
02456   {return Variable<Quantity<
02457     dimension::Dimension<BSUtilities::Rational<RL_N, RL_D>,
02458       BSUtilities::Rational<RM_N, RM_D>,
02459         BSUtilities::Rational<RT_N, RT_D>,
02460           BSUtilities::Rational<RE_N, RE_D>,
02461             BSUtilities::Rational<RTE_N, RTE_D>,
02462               BSUtilities::Rational<RA_N, RA_D>,
02463                 BSUtilities::Rational<RLU_N, RLU_D> >,
02464                                                BT, UL, DU, ST>, SU, DD1>
02465     (Reverse<SU, ST>::VAL (std::fmod (quantity1.standard_value (),
02466       Standardize<typename CheckSecondDimension<
02467         Variable<Quantity<
02468           dimension::Dimension<BSUtilities::Rational<RL_N, RL_D>,
02469             BSUtilities::Rational<RM_N, RM_D>,
02470               BSUtilities::Rational<RT_N, RT_D>,
02471                 BSUtilities::Rational<RE_N, RE_D>,
02472                   BSUtilities::Rational<RTE_N, RTE_D>,
02473                     BSUtilities::Rational<RA_N, RA_D>,
02474                       BSUtilities::Rational<RLU_N, RLU_D> >,
02475                                               BT, UL, DU, ST>, SU, DD1>,
02476         Q1<Quantity<
02477           dimension::Dimension<BSUtilities::Rational<RL1_N, RL1_D>,
02478             BSUtilities::Rational<RM1_N, RM1_D>,
02479               BSUtilities::Rational<RT1_N, RT1_D>,
02480                 BSUtilities::Rational<RE1_N, RE1_D>,
02481                   BSUtilities::Rational<RTE1_N, RTE1_D>,
02482                     BSUtilities::Rational<RA1_N, RA1_D>,
02483                       BSUtilities::Rational<RLU1_N, RLU1_D> >,
02484                     BT1, UL1, DU1, ST>, SU1, DD2> >::RET::Unit, ST>::VAL
02485                                                 (quantity2.value ()))));
02486   }
02487 
02489 
02492 template<template<class, class> class Q, class BT, 
02493   long RL_N, long RL_D, long RM_N, long RM_D,
02494     long RT_N, long RT_D, long RE_N, long RE_D,
02495       long RTE_N, long RTE_D, long RA_N, long RA_D,
02496          long RLU_N, long RLU_D, class UL, class DU, class ST, class SU>
02497   inline Variable<Quantity<
02498     dimension::Dimension<BSUtilities::Rational<RL_N, RL_D>,
02499       BSUtilities::Rational<RM_N, RM_D>,
02500         BSUtilities::Rational<RT_N, RT_D>,
02501           BSUtilities::Rational<RE_N, RE_D>,
02502             BSUtilities::Rational<RTE_N, RTE_D>,
02503               BSUtilities::Rational<RA_N, RA_D>,
02504                 BSUtilities::Rational<RLU_N, RLU_D> >,
02505                                                     BT, UL, DU, ST>, SU>
02506   modf (const Q<Quantity<
02507     dimension::Dimension<BSUtilities::Rational<RL_N, RL_D>,
02508       BSUtilities::Rational<RM_N, RM_D>,
02509         BSUtilities::Rational<RT_N, RT_D>,
02510           BSUtilities::Rational<RE_N, RE_D>,
02511             BSUtilities::Rational<RTE_N, RTE_D>,
02512               BSUtilities::Rational<RA_N, RA_D>,
02513                 BSUtilities::Rational<RLU_N, RLU_D> >,
02514                                          BT, UL, DU, ST>, SU> &quantity,
02515   Variable<Quantity<
02516     dimension::Dimension<BSUtilities::Rational<RL_N, RL_D>,
02517       BSUtilities::Rational<RM_N, RM_D>,
02518         BSUtilities::Rational<RT_N, RT_D>,
02519           BSUtilities::Rational<RE_N, RE_D>,
02520             BSUtilities::Rational<RTE_N, RTE_D>,
02521               BSUtilities::Rational<RA_N, RA_D>,
02522                 BSUtilities::Rational<RLU_N, RLU_D> >,
02523                                          BT, UL, DU, ST>, SU> *integral)
02524   {ST i_ptr; 
02525     Variable<Quantity<
02526       dimension::Dimension<BSUtilities::Rational<RL_N, RL_D>,
02527         BSUtilities::Rational<RM_N, RM_D>,
02528           BSUtilities::Rational<RT_N, RT_D>,
02529             BSUtilities::Rational<RE_N, RE_D>,
02530               BSUtilities::Rational<RTE_N, RTE_D>,
02531                 BSUtilities::Rational<RA_N, RA_D>,
02532                   BSUtilities::Rational<RLU_N, RLU_D> >,
02533                                                     BT, UL, DU, ST>, SU>
02534                    new_variable (std::modf (quantity.value (), &i_ptr));
02535     Variable<Quantity<
02536       dimension::Dimension<BSUtilities::Rational<RL_N, RL_D>,
02537         BSUtilities::Rational<RM_N, RM_D>,
02538           BSUtilities::Rational<RT_N, RT_D>,
02539             BSUtilities::Rational<RE_N, RE_D>,
02540               BSUtilities::Rational<RTE_N, RTE_D>,
02541                 BSUtilities::Rational<RA_N, RA_D>,
02542                   BSUtilities::Rational<RLU_N, RLU_D> >,
02543                               BT, UL, DU, ST>, SU> int_quantity (i_ptr);
02544                           *integral = int_quantity; return new_variable;
02545         }
02546 
02548 
02552 template<template<class, class> class Q, class BT, 
02553   long RL_N, long RL_D, long RM_N, long RM_D,
02554     long RT_N, long RT_D, long RE_N, long RE_D,
02555       long RTE_N, long RTE_D, long RA_N, long RA_D,
02556         long RLU_N, long RLU_D, 
02557                       class UL, class DU, class ST, class SU, class SU1>
02558   inline Variable<Quantity<
02559     dimension::Dimension<BSUtilities::Rational<RL_N, RL_D>,
02560       BSUtilities::Rational<RM_N, RM_D>,
02561         BSUtilities::Rational<RT_N, RT_D>,
02562           BSUtilities::Rational<RE_N, RE_D>,
02563             BSUtilities::Rational<RTE_N, RTE_D>,
02564               BSUtilities::Rational<RA_N, RA_D>,
02565                 BSUtilities::Rational<RLU_N, RLU_D> >,
02566                                                     BT, UL, DU, ST>, SU>
02567   modf (const Q<Quantity<
02568     dimension::Dimension<BSUtilities::Rational<RL_N, RL_D>,
02569       BSUtilities::Rational<RM_N, RM_D>,
02570         BSUtilities::Rational<RT_N, RT_D>,
02571           BSUtilities::Rational<RE_N, RE_D>,
02572             BSUtilities::Rational<RTE_N, RTE_D>,
02573               BSUtilities::Rational<RA_N, RA_D>,
02574                 BSUtilities::Rational<RLU_N, RLU_D> >,
02575                                          BT, UL, DU, ST>, SU> &quantity,
02576   Variable<Quantity<
02577     dimension::Dimension<BSUtilities::Rational<RL_N, RL_D>,
02578       BSUtilities::Rational<RM_N, RM_D>,
02579         BSUtilities::Rational<RT_N, RT_D>,
02580           BSUtilities::Rational<RE_N, RE_D>,
02581             BSUtilities::Rational<RTE_N, RTE_D>,
02582               BSUtilities::Rational<RA_N, RA_D>,
02583                 BSUtilities::Rational<RLU_N, RLU_D> >,
02584                                         BT, UL, DU, ST>, SU1> *integral)
02585   {ST i_ptr; 
02586     Variable<Quantity<
02587       dimension::Dimension<BSUtilities::Rational<RL_N, RL_D>,
02588         BSUtilities::Rational<RM_N, RM_D>,
02589           BSUtilities::Rational<RT_N, RT_D>,
02590             BSUtilities::Rational<RE_N, RE_D>,
02591               BSUtilities::Rational<RTE_N, RTE_D>,
02592                 BSUtilities::Rational<RA_N, RA_D>,
02593                   BSUtilities::Rational<RLU_N, RLU_D> >,
02594                                                     BT, UL, DU, ST>, SU>
02595                    new_variable (std::modf (quantity.value (), &i_ptr));
02596   Variable<Quantity<
02597     dimension::Dimension<BSUtilities::Rational<RL_N, RL_D>,
02598       BSUtilities::Rational<RM_N, RM_D>,
02599         BSUtilities::Rational<RT_N, RT_D>,
02600           BSUtilities::Rational<RE_N, RE_D>,
02601             BSUtilities::Rational<RTE_N, RTE_D>,
02602               BSUtilities::Rational<RA_N, RA_D>,
02603                 BSUtilities::Rational<RLU_N, RLU_D> >,
02604                       BT, UL, DU, ST>, SU1> int_quantity (i_ptr, SU ());
02605                           *integral = int_quantity; return new_variable;
02606         }
02607 
02609 
02613 template<template<class, class> class Q, class BT, 
02614   long RL_N, long RL_D, long RM_N, long RM_D,
02615     long RT_N, long RT_D, long RE_N, long RE_D,
02616       long RTE_N, long RTE_D, long RA_N, long RA_D,
02617         long RLU_N, long RLU_D, 
02618                       class UL, class DU, class ST, class SU, class SU1,
02619   class BT1, 
02620     long RL1_N, long RL1_D, long RM1_N, long RM1_D,
02621       long RT1_N, long RT1_D, long RE1_N, long RE1_D,
02622         long RTE1_N, long RTE1_D, long RA1_N, long RA1_D,
02623                          long RLU1_N, long RLU1_D, class UL1, class DU1>
02624   inline Variable<Quantity<
02625     dimension::Dimension<BSUtilities::Rational<RL_N, RL_D>,
02626       BSUtilities::Rational<RM_N, RM_D>,
02627         BSUtilities::Rational<RT_N, RT_D>,
02628           BSUtilities::Rational<RE_N, RE_D>,
02629             BSUtilities::Rational<RTE_N, RTE_D>,
02630               BSUtilities::Rational<RA_N, RA_D>,
02631                 BSUtilities::Rational<RLU_N, RLU_D> >,
02632                                                     BT, UL, DU, ST>, SU>
02633   modf (const Q<Quantity<
02634     dimension::Dimension<BSUtilities::Rational<RL_N, RL_D>,
02635       BSUtilities::Rational<RM_N, RM_D>,
02636         BSUtilities::Rational<RT_N, RT_D>,
02637           BSUtilities::Rational<RE_N, RE_D>,
02638             BSUtilities::Rational<RTE_N, RTE_D>,
02639               BSUtilities::Rational<RA_N, RA_D>,
02640                 BSUtilities::Rational<RLU_N, RLU_D> >,
02641                                          BT, UL, DU, ST>, SU> &quantity,
02642   Variable<Quantity<
02643     dimension::Dimension<BSUtilities::Rational<RL1_N, RL1_D>,
02644       BSUtilities::Rational<RM1_N, RM1_D>,
02645         BSUtilities::Rational<RT1_N, RT1_D>,
02646           BSUtilities::Rational<RE1_N, RE1_D>,
02647             BSUtilities::Rational<RTE1_N, RTE1_D>,
02648               BSUtilities::Rational<RA1_N, RA1_D>,
02649                 BSUtilities::Rational<RLU1_N, RLU1_D> >,
02650                                      BT1, UL1, DU1, ST>, SU1> *integral)
02651   {ST i_ptr; 
02652     typename CheckSecondDimension<Variable<Quantity<
02653       dimension::Dimension<BSUtilities::Rational<RL1_N, RL1_D>,
02654         BSUtilities::Rational<RM1_N, RM1_D>,
02655           BSUtilities::Rational<RT1_N, RT1_D>,
02656             BSUtilities::Rational<RE1_N, RE1_D>,
02657               BSUtilities::Rational<RTE1_N, RTE1_D>,
02658                 BSUtilities::Rational<RA1_N, RA1_D>,
02659                   BSUtilities::Rational<RLU1_N, RLU1_D> >,
02660                                                BT1, UL1, DU1, ST>, SU1>,
02661     Variable<Quantity<
02662       dimension::Dimension<BSUtilities::Rational<RL_N, RL_D>,
02663         BSUtilities::Rational<RM_N, RM_D>,
02664           BSUtilities::Rational<RT_N, RT_D>,
02665             BSUtilities::Rational<RE_N, RE_D>,
02666               BSUtilities::Rational<RTE_N, RTE_D>,
02667                 BSUtilities::Rational<RA_N, RA_D>,
02668                   BSUtilities::Rational<RLU_N, RLU_D> >,
02669                                              BT, UL, DU, ST>, SU> >::RET
02670          new_variable (Reverse<SU, ST>::VAL 
02671                       (std::modf (quantity.standard_value (), &i_ptr)));
02672   *integral = Variable<Quantity<
02673     dimension::Dimension<BSUtilities::Rational<RL1_N, RL1_D>,
02674       BSUtilities::Rational<RM1_N, RM1_D>,
02675         BSUtilities::Rational<RT1_N, RT1_D>,
02676           BSUtilities::Rational<RE1_N, RE1_D>,
02677             BSUtilities::Rational<RTE1_N, RTE1_D>,
02678               BSUtilities::Rational<RA1_N, RA1_D>,
02679                 BSUtilities::Rational<RLU1_N, RLU1_D> >,
02680                   BT1, UL1, DU1, ST>, SU1> 
02681                                         (Reverse<SU1, ST>::VAL (i_ptr));
02682   return new_variable;
02683   }
02684 
02685 }
02686 
02687 #endif /* _Variable_h */

Generated on Fri Dec 8 19:08:33 2006 for Quantity by doxygen 1.3.6