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

UniqueConstant.h

Go to the documentation of this file.
00001 
00005 /* Copyright (C) 2002 - 2005, 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 _UniqueConstant_h
00025 #define _UniqueConstant_h
00026 
00027 #include "Quantity/Quantity.h"
00028 #include "Quantity/QuantityError.h"
00029 #include "Quantity/Variable.h"
00030 
00031 #include "Singleton.h"
00032 
00033 namespace quantity {
00034 
00036 //
00037 //  the UniqueConstant classes
00038 //
00040 
00042 
00047 template<class PQ, class SU = typename PQ::DefaultUnit::Unit>
00048   class UniqueConstant;
00049 
00051 
00054 template<long RL_N, long RL_D, long RM_N, long RM_D,
00055   long RT_N, long RT_D, long RE_N, long RE_D, long RTE_N, long RTE_D,
00056     long RA_N, long RA_D, long RLU_N, long RLU_D,
00057                        class BT, class UL, class DU, class SU, class ST>
00058   class UniqueConstant<Quantity<dimension::Dimension<
00059     BSUtilities::Rational<RL_N, RL_D>,
00060       BSUtilities::Rational<RM_N, RM_D>,
00061         BSUtilities::Rational<RT_N, RT_D>,
00062           BSUtilities::Rational<RE_N, RE_D>,
00063             BSUtilities::Rational<RTE_N, RTE_D>,
00064               BSUtilities::Rational<RA_N, RA_D>,
00065                 BSUtilities::Rational<RLU_N, RLU_D> >, BT, UL, DU, ST>,
00066                   SU> : public
00067       Quantity<dimension::Dimension<BSUtilities::Rational<RL_N, RL_D>,
00068         BSUtilities::Rational<RM_N, RM_D>,
00069           BSUtilities::Rational<RT_N, RT_D>,
00070             BSUtilities::Rational<RE_N, RE_D>,
00071               BSUtilities::Rational<RTE_N, RTE_D>,
00072                 BSUtilities::Rational<RA_N, RA_D>,
00073                   BSUtilities::Rational<RLU_N, RLU_D> >, BT, UL, DU, ST>
00074 
00075     {
00076       private:
00078 
00080         typedef dimension::Dimension<BSUtilities::Rational<RL_N, RL_D>,
00081             BSUtilities::Rational<RM_N, RM_D>,
00082               BSUtilities::Rational<RT_N, RT_D>,
00083                 BSUtilities::Rational<RE_N, RE_D>,
00084                   BSUtilities::Rational<RTE_N, RTE_D>,
00085                     BSUtilities::Rational<RA_N, RA_D>,
00086                               BSUtilities::Rational<RLU_N, RLU_D> > DIM;
00087 
00089 
00091         typedef Quantity<DIM, BT, UL, DU, ST> PQ;
00092 
00094         typedef UniqueConstant<Quantity<DIM, BT, UL, DU, ST>, SU> SC;
00095 
00097 
00100       friend class Loki::CreateUsingNew<SC>;
00101 
00102       public:
00104 
00108         typedef 
00109              typename unit::CheckUnit<unit::Unit<BT>, SU>::Check Unit;
00110 
00111       private:
00113 
00117         static const ST default_value_;
00118 
00120 
00123         ST constant_value;
00124 
00125       private:
00127 
00132         UniqueConstant (void) : constant_value (default_value_) {}
00133 
00134       private:
00136 
00140         UniqueConstant (const UniqueConstant &new_constant)
00141           : PQ (), constant_value (default_value_)
00142             {namestring = new_constant.name ();
00143               symbolstring = new_constant.symbol ();
00144             }
00145 
00146       public:
00148 
00150         ST value (void) const {return constant_value;}
00151 
00153 
00156         ST standard_value (void) const 
00157                      {return Standardize<SU, ST>::VAL (constant_value);}
00158 
00160 
00165         template<class NU>
00166           ST value (const unit::NonPrefixable<BT, NU> &) const
00167             {return Reverse<typename CheckAgainstAllUnits<
00168               unit::NonPrefixable<BT, NU>, UL>::RET, ST>::VAL
00169                            (Standardize<SU, ST>::VAL (constant_value));}
00170 
00172 
00177         template<class NU, class P>
00178           ST value
00179             (const unit::Prefixed<unit::Prefixable<BT, NU>, P> &) const
00180             {return Reverse<typename CheckAgainstAllUnits<
00181               unit::Prefixed<unit::Prefixable<BT, NU>, P>, UL>::RET, 
00182                   ST>::VAL (Standardize<SU, ST>::VAL (constant_value));}
00183 
00185 
00190         template<class CUL, class EL>
00191           ST value
00192             (const unit::Composed<unit::ComposeBase<BT, CUL>, EL> &)
00193                                                                    const
00194             {return Reverse<typename CheckAgainstAllUnits<
00195               unit::Composed<unit::ComposeBase<BT, CUL>, EL>, UL>::RET,
00196                   ST>::VAL (Standardize<SU, ST>::VAL (constant_value));}
00197 
00199 
00206         ST value (const std::string &symbol)
00207           {
00208             ST value;
00209             ::unit::Unit<BT> *unitp = PQ::findBySymbol (symbol);
00210 
00211             value = dynamic_reverse<UL>::VAL
00212                     (Standardize<SU, ST>::VAL (constant_value), *unitp);
00213 
00214             delete (unitp);
00215 
00216             return value;
00217           }
00218 
00220 
00225         template<class NU>
00226           Variable<PQ, NU> operator () (const NU &) const
00227             {return Variable<PQ, NU> (constant_value, SU());}
00228 
00230 
00232         const std::string unitsymbol (void) const 
00233                                                  {return SU::Symbol ();}
00234 
00236 
00238         static std::string Unitsymbol (void) {return SU::Symbol ();}
00239 
00241 
00243         const std::string unitname (void) const {return SU::Name ();}
00244 
00246 
00248         static std::string Unitname (void) {return SU::Name ();}
00249 
00251 
00254         Variable<PQ, SU> operator+ (void) const
00255            {Variable<PQ, SU> new_constant (*this);
00256              return new_constant;
00257            }
00258 
00260 
00263         Variable<PQ, SU> operator- (void) const
00264            {Variable<PQ, SU> new_constant (*this);
00265              return new_constant *= -ST(1.0);
00266            }
00267 
00269 
00271         template <class Q>
00272           Variable<PQ, SU> operator+ (const Q &new_variable) const
00273             {Variable<PQ, SU> new_object = *this;
00274               return new_object += new_variable;
00275             }
00276 
00278 
00281         template <class Q>
00282           Variable<PQ, SU> operator- (const Q &new_variable) const
00283             {Variable<PQ, SU> new_object = *this;
00284               return new_object -= new_variable;
00285             }
00286 
00288 
00290         Variable<PQ, SU> operator* (const ST factor) const
00291           {Variable<PQ, SU> new_object = *this;
00292             return new_object *= factor;
00293           }
00294 
00296 
00298         Variable<PQ, SU> operator/ (const ST factor) const
00299           {Variable<PQ, SU> new_object = *this;
00300             return new_object /= factor;
00301           }
00302 
00304 
00308         bool operator== (const UniqueConstant &rhs_variable) const
00309                    {return constant_value == rhs_variable.value ();}
00310 
00312 
00317         template <template<class, class> class Q1, class SU1>
00318           bool operator== (const Q1<PQ, SU1> &rhs_variable) const
00319             {return standard_value () == rhs_variable.standard_value ();
00320             }
00321 
00323 
00328         template <template<class, class> class Q1,
00329                  class DIM1, class BT1, class UL1, class DU1, class SU1>
00330           bool operator==
00331             (const Q1<Quantity<DIM1, BT1, UL1, DU1, ST>, SU1>
00332                                                     &rhs_variable) const
00333             {
00334              return standard_value () == Standardize<typename
00335                CheckSecondDimension<Variable<PQ, SU>,
00336                  Q1<Quantity<DIM1, BT1, UL1, DU1, ST>, SU1>
00337                          >::RET::Unit, ST>::VAL (rhs_variable.value ());
00338             }
00339 
00341 
00347         bool operator== (const Dynamic<ST> &dynamic) const
00348           {if (dynamic._rl_n == RL_N/BSUtilities::Gcd<RL_N, RL_D>::RET
00349              && dynamic._rl_d == RL_D/BSUtilities::Gcd<RL_N, RL_D>::RET
00350              && dynamic._rm_n == RM_N/BSUtilities::Gcd<RM_N, RM_D>::RET
00351              && dynamic._rm_d == RM_D/BSUtilities::Gcd<RM_N, RM_D>::RET
00352              && dynamic._rt_n == RT_N/BSUtilities::Gcd<RT_N, RT_D>::RET
00353              && dynamic._rt_d == RT_D/BSUtilities::Gcd<RT_N, RT_D>::RET
00354              && dynamic._re_n == RE_N/BSUtilities::Gcd<RE_N, RE_D>::RET
00355              && dynamic._re_d == RE_D/BSUtilities::Gcd<RE_N, RE_D>::RET
00356              && dynamic._rte_n
00357                             == RTE_N/BSUtilities::Gcd<RTE_N, RTE_D>::RET
00358              && dynamic._rte_d
00359                             == RTE_D/BSUtilities::Gcd<RTE_N, RTE_D>::RET
00360              && dynamic._ra_n == RA_N/BSUtilities::Gcd<RA_N, RA_D>::RET
00361              && dynamic._ra_d == RA_D/BSUtilities::Gcd<RA_N, RA_D>::RET
00362              && dynamic._rlu_n
00363                             == RLU_N/BSUtilities::Gcd<RLU_N, RLU_D>::RET
00364              && dynamic._rlu_d
00365                            == RLU_D/BSUtilities::Gcd<RLU_N, RLU_D>::RET)
00366 
00367              return standard_value () == dynamic.value ();
00368 
00369             else
00370                {throw DimensionMismatch ();}
00371 
00372           }
00373 
00375 
00379         bool operator!= (const UniqueConstant &rhs_variable) const
00380                    {return constant_value != rhs_variable.value ();}
00381 
00383 
00388         template <template<class, class> class Q1, class SU1>
00389           bool operator!= (const Q1<PQ, SU1> &rhs_variable) const
00390             {return standard_value () != rhs_variable.standard_value ();
00391             }
00392 
00394 
00399         template <template<class, class> class Q1,
00400                  class DIM1, class BT1, class UL1, class DU1, class SU1>
00401           bool operator!=
00402             (const Q1<Quantity<DIM1, BT1, UL1, DU1, ST>, SU1>
00403                                                     &rhs_variable) const
00404             {
00405              return standard_value () != Standardize<typename
00406                CheckSecondDimension<Variable<PQ, SU>,
00407                  Q1<Quantity<DIM1, BT1, UL1, DU1, ST>, SU1>
00408                          >::RET::Unit, ST>::VAL (rhs_variable.value ());
00409             }
00410 
00412 
00418         bool operator!= (const Dynamic<ST> &dynamic) const
00419           {if (dynamic._rl_n == RL_N/BSUtilities::Gcd<RL_N, RL_D>::RET
00420              && dynamic._rl_d == RL_D/BSUtilities::Gcd<RL_N, RL_D>::RET
00421              && dynamic._rm_n == RM_N/BSUtilities::Gcd<RM_N, RM_D>::RET
00422              && dynamic._rm_d == RM_D/BSUtilities::Gcd<RM_N, RM_D>::RET
00423              && dynamic._rt_n == RT_N/BSUtilities::Gcd<RT_N, RT_D>::RET
00424              && dynamic._rt_d == RT_D/BSUtilities::Gcd<RT_N, RT_D>::RET
00425              && dynamic._re_n == RE_N/BSUtilities::Gcd<RE_N, RE_D>::RET
00426              && dynamic._re_d == RE_D/BSUtilities::Gcd<RE_N, RE_D>::RET
00427              && dynamic._rte_n
00428                             == RTE_N/BSUtilities::Gcd<RTE_N, RTE_D>::RET
00429              && dynamic._rte_d
00430                             == RTE_D/BSUtilities::Gcd<RTE_N, RTE_D>::RET
00431              && dynamic._ra_n == RA_N/BSUtilities::Gcd<RA_N, RA_D>::RET
00432              && dynamic._ra_d == RA_D/BSUtilities::Gcd<RA_N, RA_D>::RET
00433              && dynamic._rlu_n
00434                             == RLU_N/BSUtilities::Gcd<RLU_N, RLU_D>::RET
00435              && dynamic._rlu_d
00436                            == RLU_D/BSUtilities::Gcd<RLU_N, RLU_D>::RET)
00437 
00438              return standard_value () != dynamic.value ();
00439 
00440             else
00441                {throw DimensionMismatch ();}
00442 
00443           }
00444 
00446 
00450         bool operator> (const UniqueConstant &rhs_variable) const
00451                    {return constant_value > rhs_variable.value ();}
00452 
00454 
00459         template <template<class, class> class Q1, class SU1>
00460           bool operator> (const Q1<PQ, SU1> &rhs_variable) const
00461             {return standard_value () > rhs_variable.standard_value ();
00462             }
00463 
00465 
00470         template <template<class, class> class Q1,
00471                  class DIM1, class BT1, class UL1, class DU1, class SU1>
00472           bool operator>
00473             (const Q1<Quantity<DIM1, BT1, UL1, DU1, ST>, SU1>
00474                                                     &rhs_variable) const
00475             {
00476              return standard_value () > Standardize<typename
00477                CheckSecondDimension<Variable<PQ, SU>,
00478                  Q1<Quantity<DIM1, BT1, UL1, DU1, ST>, SU1>
00479                          >::RET::Unit, ST>::VAL (rhs_variable.value ());
00480             }
00481 
00483 
00489         bool operator> (const Dynamic<ST> &dynamic) const
00490           {if (dynamic._rl_n == RL_N/BSUtilities::Gcd<RL_N, RL_D>::RET
00491              && dynamic._rl_d == RL_D/BSUtilities::Gcd<RL_N, RL_D>::RET
00492              && dynamic._rm_n == RM_N/BSUtilities::Gcd<RM_N, RM_D>::RET
00493              && dynamic._rm_d == RM_D/BSUtilities::Gcd<RM_N, RM_D>::RET
00494              && dynamic._rt_n == RT_N/BSUtilities::Gcd<RT_N, RT_D>::RET
00495              && dynamic._rt_d == RT_D/BSUtilities::Gcd<RT_N, RT_D>::RET
00496              && dynamic._re_n == RE_N/BSUtilities::Gcd<RE_N, RE_D>::RET
00497              && dynamic._re_d == RE_D/BSUtilities::Gcd<RE_N, RE_D>::RET
00498              && dynamic._rte_n
00499                             == RTE_N/BSUtilities::Gcd<RTE_N, RTE_D>::RET
00500              && dynamic._rte_d
00501                             == RTE_D/BSUtilities::Gcd<RTE_N, RTE_D>::RET
00502              && dynamic._ra_n == RA_N/BSUtilities::Gcd<RA_N, RA_D>::RET
00503              && dynamic._ra_d == RA_D/BSUtilities::Gcd<RA_N, RA_D>::RET
00504              && dynamic._rlu_n
00505                             == RLU_N/BSUtilities::Gcd<RLU_N, RLU_D>::RET
00506              && dynamic._rlu_d
00507                            == RLU_D/BSUtilities::Gcd<RLU_N, RLU_D>::RET)
00508 
00509              return standard_value () > dynamic.value ();
00510 
00511             else
00512                {throw DimensionMismatch ();}
00513 
00514           }
00515 
00517 
00521         bool operator< (const UniqueConstant &rhs_variable) const
00522                    {return constant_value < rhs_variable.value ();}
00523 
00525 
00530         template <template<class, class> class Q1, class SU1>
00531           bool operator< (const Q1<PQ, SU1> &rhs_variable) const
00532             {return standard_value () < rhs_variable.standard_value ();
00533             }
00534 
00536 
00541         template <template<class, class> class Q1,
00542                  class DIM1, class BT1, class UL1, class DU1, class SU1>
00543           bool operator<
00544             (const Q1<Quantity<DIM1, BT1, UL1, DU1, ST>, SU1>
00545                                                     &rhs_variable) const
00546             {
00547              return standard_value () < Standardize<typename
00548                CheckSecondDimension<Variable<PQ, SU>,
00549                  Q1<Quantity<DIM1, BT1, UL1, DU1, ST>, SU1>
00550                          >::RET::Unit, ST>::VAL (rhs_variable.value ());
00551             }
00552 
00554 
00560         bool operator< (const Dynamic<ST> &dynamic) const
00561           {if (dynamic._rl_n == RL_N/BSUtilities::Gcd<RL_N, RL_D>::RET
00562              && dynamic._rl_d == RL_D/BSUtilities::Gcd<RL_N, RL_D>::RET
00563              && dynamic._rm_n == RM_N/BSUtilities::Gcd<RM_N, RM_D>::RET
00564              && dynamic._rm_d == RM_D/BSUtilities::Gcd<RM_N, RM_D>::RET
00565              && dynamic._rt_n == RT_N/BSUtilities::Gcd<RT_N, RT_D>::RET
00566              && dynamic._rt_d == RT_D/BSUtilities::Gcd<RT_N, RT_D>::RET
00567              && dynamic._re_n == RE_N/BSUtilities::Gcd<RE_N, RE_D>::RET
00568              && dynamic._re_d == RE_D/BSUtilities::Gcd<RE_N, RE_D>::RET
00569              && dynamic._rte_n
00570                             == RTE_N/BSUtilities::Gcd<RTE_N, RTE_D>::RET
00571              && dynamic._rte_d
00572                             == RTE_D/BSUtilities::Gcd<RTE_N, RTE_D>::RET
00573              && dynamic._ra_n == RA_N/BSUtilities::Gcd<RA_N, RA_D>::RET
00574              && dynamic._ra_d == RA_D/BSUtilities::Gcd<RA_N, RA_D>::RET
00575              && dynamic._rlu_n
00576                             == RLU_N/BSUtilities::Gcd<RLU_N, RLU_D>::RET
00577              && dynamic._rlu_d
00578                            == RLU_D/BSUtilities::Gcd<RLU_N, RLU_D>::RET)
00579 
00580              return standard_value () < dynamic.value ();
00581 
00582             else
00583                {throw DimensionMismatch ();}
00584 
00585           }
00586 
00588 
00592         bool operator>= (const UniqueConstant &rhs_variable) const
00593                    {return constant_value >= rhs_variable.value ();}
00594 
00596 
00601         template <template<class, class> class Q1, class SU1>
00602           bool operator>= (const Q1<PQ, SU1> &rhs_variable) const
00603             {return standard_value () >= rhs_variable.standard_value ();
00604             }
00605 
00607 
00612         template <template<class, class> class Q1,
00613                  class DIM1, class BT1, class UL1, class DU1, class SU1>
00614           bool operator>=
00615             (const Q1<Quantity<DIM1, BT1, UL1, DU1, ST>, SU1>
00616                                                     &rhs_variable) const
00617             {
00618              return standard_value () >= Standardize<typename
00619                CheckSecondDimension<Variable<PQ, SU>,
00620                  Q1<Quantity<DIM1, BT1, UL1, DU1, ST>, SU1>
00621                          >::RET::Unit, ST>::VAL (rhs_variable.value ());
00622             }
00623 
00625 
00631         bool operator>= (const Dynamic<ST> &dynamic) const
00632           {if (dynamic._rl_n == RL_N/BSUtilities::Gcd<RL_N, RL_D>::RET
00633              && dynamic._rl_d == RL_D/BSUtilities::Gcd<RL_N, RL_D>::RET
00634              && dynamic._rm_n == RM_N/BSUtilities::Gcd<RM_N, RM_D>::RET
00635              && dynamic._rm_d == RM_D/BSUtilities::Gcd<RM_N, RM_D>::RET
00636              && dynamic._rt_n == RT_N/BSUtilities::Gcd<RT_N, RT_D>::RET
00637              && dynamic._rt_d == RT_D/BSUtilities::Gcd<RT_N, RT_D>::RET
00638              && dynamic._re_n == RE_N/BSUtilities::Gcd<RE_N, RE_D>::RET
00639              && dynamic._re_d == RE_D/BSUtilities::Gcd<RE_N, RE_D>::RET
00640              && dynamic._rte_n
00641                             == RTE_N/BSUtilities::Gcd<RTE_N, RTE_D>::RET
00642              && dynamic._rte_d
00643                             == RTE_D/BSUtilities::Gcd<RTE_N, RTE_D>::RET
00644              && dynamic._ra_n == RA_N/BSUtilities::Gcd<RA_N, RA_D>::RET
00645              && dynamic._ra_d == RA_D/BSUtilities::Gcd<RA_N, RA_D>::RET
00646              && dynamic._rlu_n
00647                             == RLU_N/BSUtilities::Gcd<RLU_N, RLU_D>::RET
00648              && dynamic._rlu_d
00649                            == RLU_D/BSUtilities::Gcd<RLU_N, RLU_D>::RET)
00650 
00651              return standard_value () >= dynamic.value ();
00652 
00653             else
00654                {throw DimensionMismatch ();}
00655 
00656           }
00657 
00659 
00663         bool operator<= (const UniqueConstant &rhs_variable) const
00664                    {return constant_value <= rhs_variable.value ();}
00665 
00667 
00672         template <template<class, class> class Q1, class SU1>
00673           bool operator<= (const Q1<PQ, SU1> &rhs_variable) const
00674             {return standard_value () <= rhs_variable.standard_value ();
00675             }
00676 
00678 
00683         template <template<class, class> class Q1,
00684                  class DIM1, class BT1, class UL1, class DU1, class SU1>
00685           bool operator<=
00686             (const Q1<Quantity<DIM1, BT1, UL1, DU1, ST>, SU1>
00687                                                     &rhs_variable) const
00688             {
00689              return standard_value () <= Standardize<typename
00690                CheckSecondDimension<Variable<PQ, SU>,
00691                  Q1<Quantity<DIM1, BT1, UL1, DU1, ST>, SU1>
00692                          >::RET::Unit, ST>::VAL (rhs_variable.value ());
00693             }
00694 
00696 
00702         bool operator<= (const Dynamic<ST> &dynamic) const
00703           {if (dynamic._rl_n == RL_N/BSUtilities::Gcd<RL_N, RL_D>::RET
00704              && dynamic._rl_d == RL_D/BSUtilities::Gcd<RL_N, RL_D>::RET
00705              && dynamic._rm_n == RM_N/BSUtilities::Gcd<RM_N, RM_D>::RET
00706              && dynamic._rm_d == RM_D/BSUtilities::Gcd<RM_N, RM_D>::RET
00707              && dynamic._rt_n == RT_N/BSUtilities::Gcd<RT_N, RT_D>::RET
00708              && dynamic._rt_d == RT_D/BSUtilities::Gcd<RT_N, RT_D>::RET
00709              && dynamic._re_n == RE_N/BSUtilities::Gcd<RE_N, RE_D>::RET
00710              && dynamic._re_d == RE_D/BSUtilities::Gcd<RE_N, RE_D>::RET
00711              && dynamic._rte_n
00712                             == RTE_N/BSUtilities::Gcd<RTE_N, RTE_D>::RET
00713              && dynamic._rte_d
00714                             == RTE_D/BSUtilities::Gcd<RTE_N, RTE_D>::RET
00715              && dynamic._ra_n == RA_N/BSUtilities::Gcd<RA_N, RA_D>::RET
00716              && dynamic._ra_d == RA_D/BSUtilities::Gcd<RA_N, RA_D>::RET
00717              && dynamic._rlu_n
00718                             == RLU_N/BSUtilities::Gcd<RLU_N, RLU_D>::RET
00719              && dynamic._rlu_d
00720                            == RLU_D/BSUtilities::Gcd<RLU_N, RLU_D>::RET)
00721 
00722              return standard_value () <= dynamic.value ();
00723 
00724             else
00725                {throw DimensionMismatch ();}
00726 
00727           }
00728 
00730 
00735         template<class Q>
00736           typename GenerateVariable<UniqueConstant, Q>::Add operator*
00737                                                        (const Q &factor)
00738             {
00739               return typename 
00740                 GenerateVariable<UniqueConstant, Q>::Add
00741                          (standard_value () * factor.standard_value ());
00742             }
00743 
00745 
00750         template<class Q>
00751           typename GenerateVariable<UniqueConstant, Q>::Sub 
00752                                              operator/ (const Q &factor)
00753             {
00754               return typename 
00755                 GenerateVariable<UniqueConstant, Q>::Sub
00756                          (standard_value () / factor.standard_value ());
00757             }
00758 
00760 
00763         friend 
00764           typename GenerateVariable<UniqueConstant, Loki::NullType>::Inv
00765             operator/ (const ST numerator, const UniqueConstant &factor)
00766           {
00767             return typename 
00768               GenerateVariable<UniqueConstant, Loki::NullType>::Inv
00769                                  (numerator / factor.standard_value ());
00770           }
00771 
00773 
00779         template<long N, long D> 
00780           typename GenerateVariable<UniqueConstant,
00781                                      BSUtilities::Rational<N, D> >::Mult
00782                                pow (const BSUtilities::Rational<N, D> &)
00783           {return
00784              ::quantity::pow (*this, BSUtilities::Rational<N, D> ());}
00785 
00787 
00793         template<int I>
00794           typename GenerateVariable<UniqueConstant,
00795               BSUtilities::Rational<I, long(1)> >::Mult 
00796                                         pow (typename Loki::Int2Type<I>)
00797           {return ::quantity::pow (*this, Loki::Int2Type<I> ());}
00798 
00800 
00806     template<class T>
00807       Dynamic<ST> pow (const T &exp) const
00808                                 {return ::quantity::pow (*this, exp);}
00809 
00811 
00813         friend
00814           typename
00815             GenerateVariable<UniqueConstant, 
00816                                      BSUtilities::Rational<1, 2> >::Mult
00817                                    sqrt (const UniqueConstant &constant)
00818           {
00819             return typename
00820               GenerateVariable<UniqueConstant, 
00821                 BSUtilities::Rational<1, 2> >::Mult
00822                                 (std::sqrt(constant.standard_value ()));
00823           }
00824 
00826 
00828         typename
00829           GenerateVariable<UniqueConstant, 
00830                                      BSUtilities::Rational<1, 2> >::Mult
00831                                                              sqrt (void)
00832           {
00833             return typename
00834               GenerateVariable<UniqueConstant, 
00835                 BSUtilities::Rational<1, 2> >::Mult
00836                                          (std::sqrt(standard_value ()));
00837           }
00838 
00840 
00843      std::ostream & print_value (std::ostream &os) const
00844         {return os << constant_value << " " << SU::Symbol ();}
00845 
00847 
00849       void operator>> (std::string &str) const
00850         {str = BSUtilities::Conversion<UniqueConstant>::to_string 
00851                                                                (*this);}
00853 
00857       std::ostream & operator>> (std::ostream &os) const
00858                    {return this->print (os);}
00859 
00860     };
00861 
00862 }
00863 
00864 #endif /* _UniqueConstant_h */

Generated on Sun Jan 15 14:05:20 2006 for Quantity by doxygen 1.3.6