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

Constant.h

Go to the documentation of this file.
00001 
00005 /* Copyright (C) 2002 - 2004, 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 _Constant_h
00025 #define _Constant_h
00026 
00027 #include "Quantity/Quantity.h"
00028 #include "Quantity/Variable.h"
00029 
00030 namespace Quantities {
00031 
00033 //
00034 //  the Constant classes
00035 //
00037 
00039 
00044 template<class PQ, class SU = typename PQ::DefaultUnit::Unit>
00045   class Constant;
00046 
00048 
00051 template<class GT, class Head, class Tail, class DU, class SU, class ST>
00052   class Constant<Quantity<GT, Loki::Typelist<Head, Tail>, DU, ST>, SU>
00053               : public Quantity<GT, Loki::Typelist<Head, Tail>, DU, ST>
00054     {
00055       private:
00057 
00061         typedef typename 
00062                Units::CheckUnit<Units::Unit<GT, ST>, SU>::Check Checked;
00063 
00065 
00067         typedef Quantity<GT, Loki::Typelist<Head, Tail>, DU, ST> PQ;
00068 
00069       public:
00071 
00073         typedef SU Unit;
00074 
00075       private:
00077 
00081         ST constant_value;
00082 
00084 
00086         Constant & operator= (const Constant&);
00087 
00089 
00091         template<class TQ> Constant & operator= (const TQ&);
00092 
00093       public:
00095 
00097         Constant (void) : constant_value (ST(0.0)) {};
00098 
00100 
00102         Constant (const ST new_value) : constant_value (new_value) {}
00103 
00105 
00108         Constant (const ST new_value, const SU &)
00109                                         : constant_value (new_value) {}
00110 
00112 
00115         Constant (const Constant &new_constant)
00116           : PQ (), constant_value (new_constant.constant_value)
00117             { 
00118               namestring = new_constant.name ();
00119               symbolstring = new_constant.symbol ();
00120             };
00121 
00123 
00129         template<class NU>
00130           Constant (const ST new_value, const NU &) 
00131             : PQ (), constant_value (SU::Reverse 
00132               (CheckAgainstAllUnits<NU, Loki::Typelist<Head, Tail> 
00133                                        >::RET::Standard (new_value))) {}
00134 
00135 
00137 
00142         Constant (const ST new_value, const std::string &unitsymbol)
00143             : PQ ()
00144         {
00145           ::Units::Unit<GT, ST> *unitp = PQ::findBySymbol (unitsymbol);
00146           constant_value = SU::Reverse (unitp->standard (new_value));
00147 
00148           delete (unitp);
00149         }
00150 
00152 
00157         Constant (const ST new_value, const char * unitsymbol) : PQ ()
00158         {
00159           ::Units::Unit<GT, ST> *unitp
00160                           = PQ::findBySymbol (std::string (unitsymbol));
00161           constant_value = SU::Reverse (unitp->standard (new_value));
00162 
00163           delete (unitp);
00164         }
00165 
00167 
00178         template<template<class, class> class Q1, class SU1>
00179             Constant (const Q1<PQ, SU1> &source_quantity)
00180             : constant_value (SU::Reverse
00181               (CheckAgainstAllUnits<typename Q1<PQ, SU1>::Unit,
00182                 Loki::Typelist<Head, Tail> >::RET::Standard
00183                                         (source_quantity.value ())))
00184               {
00185                 namestring = source_quantity.name ();
00186                 symbolstring = source_quantity.symbol ();
00187               }
00188 
00190 
00197         template<template<class, class> class Q1, class GT1,
00198                                                    class DU1, class SU1>
00199           Constant (const Q1<Quantity<GT1,
00200             Loki::Typelist<Units::NonPrefixable<GT1, Units::GenericUnit,
00201               ST>, Loki::NullType>, DU1, ST>, SU1> &source_quantity)
00202             : constant_value (Unit::Reverse
00203               (Units::NonPrefixable<typename
00204                 CheckSecondDimension<Constant<PQ, SU>,
00205                   Q1<Quantity<GT1, 
00206                     Loki::Typelist<Units::NonPrefixable<GT1,
00207                       Units::GenericUnit, ST>, Loki::NullType>, 
00208                         DU1, ST>, SU1> >::RET::Type, Units::GenericUnit,
00209                           ST>::Standard (source_quantity.value ())))
00210               {
00211                 namestring = source_quantity.name ();
00212                 symbolstring = source_quantity.symbol ();
00213               }
00214 
00216 
00219         ST standard_value (void) const 
00220                                  {return SU::Standard (constant_value);}
00221 
00223 
00225         ST value (void) const {return constant_value;}
00226 
00228 
00233         template<class NU>
00234           ST value (const Units::NonPrefixable<GT, NU, ST> &) const
00235             {return
00236               CheckAgainstAllUnits<Units::NonPrefixable<GT, NU, ST>,
00237                 Loki::Typelist<Head, Tail> >::RET::Reverse
00238                                        (SU::Standard (constant_value));}
00239 
00241 
00246 /* NOTE: not yet tested!!! */
00247         template<class NU, class P>
00248           ST value
00249             (const Units::Prefixed<Units::Prefixable<GT, NU, ST>, P> &)
00250                                                                    const
00251             {return
00252                CheckAgainstAllUnits
00253                      <Units::Prefixed<Units::Prefixable<GT, NU, ST>, P>,
00254                  Loki::Typelist<Head, Tail> >::RET::Reverse
00255                                        (SU::Standard (constant_value));}
00256 
00258 
00263 /* NOTE: not yet tested!!! */
00264         template<class CUL, class EL>
00265           ST value
00266             (const Units::Composed<Units::Compound<GT, CUL, ST>, EL> &)
00267                                                                    const
00268             {return
00269               CheckAgainstAllUnits
00270                      <Units::Composed<Units::Compound<GT, CUL, ST>, EL>,
00271                 Loki::Typelist<Head, Tail> >::RET::Reverse
00272                                        (SU::Standard (constant_value));}
00273 
00275 
00282         ST value (const std::string &symbol)
00283           {ST value;
00284             ::Units::Unit<GT, ST> *unitp = PQ::findBySymbol (symbol);
00285 
00286             value = unitp->reverse (SU::Standard (constant_value));
00287 
00288             delete (unitp);
00289 
00290             return value;
00291           }
00292 
00294 
00299         template<class NU>
00300           Constant<PQ, NU> operator () (const NU &) const
00301             {return Constant<PQ, NU> (constant_value, SU());}
00302 
00304 
00306         const std::string unitsymbol (void) const 
00307                                                  {return SU::Symbol ();}
00308 
00310 
00312         static std::string Unitsymbol (void) {return SU::Symbol ();}
00313 
00315 
00317         const std::string unitname (void) const {return SU::Name ();}
00318 
00320 
00322         static std::string Unitname (void) {return SU::Name ();}
00323 
00325 
00328         Variable<PQ, SU> operator+ (void) const
00329            {Variable<PQ, SU> new_constant (*this);
00330              return new_constant;
00331            }
00332 
00334 
00337         Variable<PQ, SU> operator- (void) const
00338            {Variable<PQ, SU> new_constant (*this);
00339              return new_constant * -1.0;
00340            }
00341 
00343 
00345         template <class Q>
00346           Variable<PQ, SU> operator+ (const Q &new_variable) const
00347             {Variable<PQ, SU> new_object = *this;
00348               return new_object += new_variable;
00349             }
00350 
00352 
00354         template <class Q>
00355           Variable<PQ, SU> operator- (const Q &new_variable) const
00356             {Variable<PQ, SU> new_object = *this;
00357               return new_object -= new_variable;
00358             }
00359 
00361 
00363         Variable<PQ, SU> operator* (const ST factor) const
00364           {Variable<PQ, SU> new_object = *this;
00365             return new_object *= factor;
00366           }
00367 
00369 
00371         Variable<PQ, SU> operator/ (const ST factor) const
00372           {Variable<PQ, SU> new_object = *this;
00373             return new_object /= factor;
00374           }
00375 
00377 
00379         friend Variable<PQ, SU> operator*
00380                 (const ST factor, const Constant &constant)
00381         {Variable<PQ, SU> new_variable = constant;
00382            return new_variable *= factor;
00383         }
00384 
00386 
00388         friend Variable<PQ, SU> abs (const Constant &constant)
00389         {Variable<PQ, SU> new_variable = constant;
00390            return new_variable.variable_value
00391                                          = std::abs (constant.value ());
00392         }
00393 
00395 
00397         friend Variable<PQ, SU> ceil (const Constant &constant)
00398         {Variable<PQ, SU> new_variable  = constant;
00399            return new_variable.variable_value
00400                                         = std::ceil (constant.value ());
00401         }
00402 
00404 
00406         friend Variable<PQ, SU> floor (const Constant &constant)
00407         {Variable<PQ, SU> new_variable = constant;
00408            return new_variable.variable_value
00409                                        = std::floor (constant.value ());
00410         }
00411 
00413 
00417         friend Variable<PQ, SU> modf
00418                   (const Constant &constant, Variable<PQ, SU> *integral)
00419         {Variable<PQ, SU> new_variable = constant;
00420           ST i_ptr;
00421             new_variable.variable_value
00422                                 = std::modf (constant.value (), &i_ptr);
00423               Variable<PQ, SU> int_quantity (i_ptr);
00424                 *integral = int_quantity; return new_variable;
00425         }
00426 
00428 
00430         friend Variable<PQ, SU> 
00431                          frexp (const Constant &constant, int *exponent)
00432         {Variable<PQ, SU> new_variable = constant;
00433            return new_variable.variable_value
00434                              = std::frexp (constant.value (), exponent);
00435         }
00436 
00438 
00440         friend Variable<PQ, SU> 
00441                          ldexp (const Constant &constant, int *exponent)
00442         {Variable<PQ, SU> new_variable = constant;
00443            return new_variable.variable_value
00444                              = std::ldexp (constant.value (), exponent);
00445         }
00446 
00448 
00454         template <template<class, class> class Q1, class SU1>
00455           friend Variable<PQ, SU> fmod 
00456                 (const Constant &constant, const Q1<PQ, SU1> &quantity)
00457           {return Variable<PQ, SU>
00458             (SU::Reverse (std::fmod (constant.standard_value (), 
00459                                          quantity.standard_value ())));
00460           }    
00461 
00463 
00468         template <template<class, class> class Q1, class GT1,
00469                                                    class DU1, class SU1>
00470           friend Variable<PQ,SU> fmod
00471             (const Constant &constant, const Q1<Quantity<GT1,
00472               Loki::Typelist<Units::NonPrefixable<GT1,
00473                 Units::GenericUnit, ST>, Loki::NullType>, DU1, ST>, SU1>
00474                                                               &quantity)
00475             {
00476              return Variable<PQ,SU>
00477                (SU::Reverse
00478                  (std::fmod (constant.standard_value (),
00479                    CheckSecondDimension<Variable<PQ, SU>,
00480                      Q1<Quantity<GT1,
00481                        Loki::Typelist<Units::NonPrefixable<GT1,
00482                          Units::GenericUnit, ST>, Loki::NullType>,
00483                            DU1, ST>, SU1> >::RET::Unit::Standard
00484                                                  (quantity.value ()))));
00485             }
00486 
00488 
00493         template <template<class, class> class Q1, class GT1, 
00494           class DU1, class SU1>
00495           friend Q1<Quantity<GT1, 
00496             Loki::Typelist<Units::NonPrefixable<GT1, Units::GenericUnit,
00497                                ST>, Loki::NullType>, DU1, ST>, SU1> fmod
00498             (const Q1<Quantity<GT1,
00499               Loki::Typelist<Units::NonPrefixable<GT1, 
00500                 Units::GenericUnit, ST>, Loki::NullType>, DU1, ST>, SU1>
00501                                  &variable1, const Constant &constant)
00502             {
00503              return Q1<Quantity<GT1, 
00504                Loki::Typelist<Units::NonPrefixable<GT1, 
00505                  Units::GenericUnit, ST>, Loki::NullType>, DU1, ST>, 
00506                                                                     SU1>
00507                (SU::Reverse 
00508                  (std::fmod (variable1.standard_value (),
00509                    CheckSecondDimension< Q1<Quantity<GT1, 
00510                      Loki::Typelist<Units::NonPrefixable<GT1,
00511                        Units::GenericUnit, ST>, Loki::NullType>, 
00512                          DU1, ST>, SU1>, Constant
00513                            >::RET::Unit::Standard 
00514                                                 (constant.value ())))); 
00515             }
00516 
00518 
00522         bool operator== (const Constant &rhs_variable) const
00523                    {return constant_value == rhs_variable.value ();}
00524 
00526 
00531         template <template<class, class> class Q1, class SU1>
00532           bool operator== (const Q1<PQ, SU1> &rhs_variable) const
00533             {return standard_value () == rhs_variable.standard_value ();
00534             }
00535 
00537 
00542         template <template<class, class> class Q1, class GT1, 
00543                                                    class DU1, class SU1>
00544           bool operator== (const Q1<Quantity<GT1, 
00545             Loki::Typelist<Units::NonPrefixable<GT1, 
00546               Units::GenericUnit, ST>, Loki::NullType>, 
00547                                      DU1, ST>, SU1> &rhs_variable) const
00548             {
00549              return standard_value () == 
00550                CheckSecondDimension<Constant<PQ, SU>, 
00551                  Q1<Quantity<GT1, 
00552                    Loki::Typelist<Units::NonPrefixable<GT1,
00553                      Units::GenericUnit, ST>, Loki::NullType>, 
00554                        DU1, ST>, SU1> >::RET::Unit::Standard 
00555                                                 (rhs_variable.value ());
00556             }
00557 
00559 
00566         template <template<class, class> class Q1, class GT1, 
00567                          class Head1, class Tail1, class DU1, class SU1>
00568           bool operator== 
00569            (const Q1<Quantity<GT1, Loki::Typelist<Head1, Tail1>,
00570                                      DU1, ST>, SU1> &rhs_variable) const
00571             {
00572              return 
00573                BSUtilities::IF<BSUtilities::SameType<SU, 
00574                  Units::NonPrefixable<GT, Units::GenericUnit, ST> 
00575                    >::sameType, SU, Units::UnitError<false> 
00576                      >::RET::Standard (constant_value) == 
00577                CheckSecondDimension<Constant<PQ, SU>, 
00578                  Q1<Quantity<GT1, 
00579                    Loki::Typelist<Units::NonPrefixable<GT1,
00580                      Units::GenericUnit, ST>, Loki::NullType>, 
00581                        DU1, ST>, SU1> >::RET::Unit::Standard 
00582                                                 (rhs_variable.value ());
00583             }
00584 
00586 
00590         bool operator!= (const Constant &rhs_variable) const
00591                    {return constant_value != rhs_variable.value ();}
00592 
00594 
00599         template <template<class, class> class Q1, class SU1>
00600           bool operator!= (const Q1<PQ, SU1> &rhs_variable) const
00601             {return standard_value () != rhs_variable.standard_value ();
00602             }
00603 
00605 
00610         template <template<class, class> class Q1, class GT1,
00611                                                    class DU1, class SU1>
00612           bool operator!= (const Q1<Quantity<GT1,
00613             Loki::Typelist<Units::NonPrefixable<GT1, Units::GenericUnit,
00614               ST>, Loki::NullType>, DU1, ST>, SU1> &rhs_variable) const
00615             {
00616              return standard_value () !=
00617                CheckSecondDimension<Constant<PQ, SU>,
00618                  Q1<Quantity<GT1, 
00619                    Loki::Typelist<Units::NonPrefixable<GT1,
00620                      Units::GenericUnit, ST>, Loki::NullType>, 
00621                        DU1, ST>, SU1> >::RET::Unit::Standard
00622                                                 (rhs_variable.value ());
00623             }
00624 
00626 
00633         template <template<class, class> class Q1, class GT1,
00634                          class Head1, class Tail1, class DU1, class SU1>
00635           bool operator!=
00636            (const Q1<Quantity<GT1, Loki::Typelist<Head1, Tail1>,
00637                                      DU1, ST>, SU1> &rhs_variable) const
00638             {
00639              return 
00640                BSUtilities::IF<BSUtilities::SameType<SU, 
00641                  Units::NonPrefixable<GT, Units::GenericUnit, ST>
00642                    >::sameType, SU, Units::UnitError<false> 
00643                      >::RET::Standard (constant_value) !=
00644                CheckSecondDimension<Constant<PQ, SU>,
00645                  Q1<Quantity<GT1, 
00646                    Loki::Typelist<Units::NonPrefixable<GT1,
00647                      Units::GenericUnit, ST>, Loki::NullType>, 
00648                        DU1, ST>, SU1> >::RET::Unit::Standard
00649                                                 (rhs_variable.value ());
00650             }
00651 
00653 
00657         bool operator> (const Constant &rhs_variable) const
00658                    {return constant_value > rhs_variable.value ();}
00659 
00661 
00666         template <template<class, class> class Q1, class SU1>
00667           bool operator> (const Q1<PQ, SU1> &rhs_variable) const
00668             {return standard_value () > rhs_variable.standard_value ();
00669             }
00670 
00672 
00677         template <template<class, class> class Q1, class GT1,
00678                                                    class DU1, class SU1>
00679           bool operator> (const Q1<Quantity<GT1,
00680             Loki::Typelist<Units::NonPrefixable<GT1, Units::GenericUnit,
00681               ST>, Loki::NullType>, DU1, ST>, SU1> &rhs_variable) const
00682             {
00683              return standard_value () >
00684                CheckSecondDimension<Constant<PQ, SU>,
00685                  Q1<Quantity<GT1, 
00686                    Loki::Typelist<Units::NonPrefixable<GT1,
00687                      Units::GenericUnit, ST>, Loki::NullType>, 
00688                        DU1, ST>, SU1> >::RET::Unit::Standard
00689                                                 (rhs_variable.value ());
00690             }
00691 
00693 
00700         template <template<class, class> class Q1, class GT1,
00701                          class Head1, class Tail1, class DU1, class SU1>
00702           bool operator>
00703            (const Q1<Quantity<GT1, Loki::Typelist<Head1, Tail1>,
00704                                      DU1, ST>, SU1> &rhs_variable) const
00705             {
00706              return 
00707                BSUtilities::IF<BSUtilities::SameType<SU, 
00708                  Units::NonPrefixable<GT, Units::GenericUnit, ST>
00709                    >::sameType, SU, Units::UnitError<false> 
00710                      >::RET::Standard (constant_value) >
00711                CheckSecondDimension<Constant<PQ, SU>,
00712                  Q1<Quantity<GT1, 
00713                    Loki::Typelist<Units::NonPrefixable<GT1,
00714                      Units::GenericUnit, ST>, Loki::NullType>, 
00715                        DU1, ST>, SU1> >::RET::Unit::Standard
00716                                                 (rhs_variable.value ());
00717             }
00718 
00720 
00724         bool operator< (const Constant &rhs_variable) const
00725                    {return constant_value < rhs_variable.value ();}
00726 
00728 
00733         template <template<class, class> class Q1, class SU1>
00734           bool operator< (const Q1<PQ, SU1> &rhs_variable) const
00735             {return standard_value () < rhs_variable.standard_value ();
00736             }
00737 
00739 
00744         template <template<class, class> class Q1, class GT1,
00745                                                    class DU1, class SU1>
00746           bool operator< (const Q1<Quantity<GT1,
00747             Loki::Typelist<Units::NonPrefixable<GT1, Units::GenericUnit,
00748               ST>, Loki::NullType>, DU1, ST>, SU1> &rhs_variable) const
00749             {
00750              return standard_value () <
00751                CheckSecondDimension<Constant<PQ, SU>,
00752                  Q1<Quantity<GT1, 
00753                    Loki::Typelist<Units::NonPrefixable<GT1,
00754                      Units::GenericUnit, ST>, Loki::NullType>, 
00755                        DU1, ST>, SU1> >::RET::Unit::Standard
00756                                                 (rhs_variable.value ());
00757             }
00758 
00760 
00767         template <template<class, class> class Q1, class GT1,
00768                          class Head1, class Tail1, class DU1, class SU1>
00769           bool operator<
00770            (const Q1<Quantity<GT1, Loki::Typelist<Head1, Tail1>,
00771                                      DU1, ST>, SU1> &rhs_variable) const
00772             {
00773              return 
00774                BSUtilities::IF<BSUtilities::SameType<SU, 
00775                  Units::NonPrefixable<GT, Units::GenericUnit, ST>
00776                    >::sameType, SU, Units::UnitError<false> 
00777                      >::RET::Standard (constant_value) <
00778                CheckSecondDimension<Constant<PQ, SU>,
00779                  Q1<Quantity<GT1, 
00780                    Loki::Typelist<Units::NonPrefixable<GT1,
00781                      Units::GenericUnit, ST>, Loki::NullType>, 
00782                        DU1, ST>, SU1> >::RET::Unit::Standard
00783                                                 (rhs_variable.value ());
00784             }
00785 
00787 
00791         bool operator>= (const Constant &rhs_variable) const
00792                    {return constant_value >= rhs_variable.value ();}
00793 
00795 
00800         template <template<class, class> class Q1, class SU1>
00801           bool operator>= (const Q1<PQ, SU1> &rhs_variable) const
00802             {return standard_value () >= rhs_variable.standard_value ();
00803             }
00804 
00806 
00811         template <template<class, class> class Q1, class GT1,
00812                                                    class DU1, class SU1>
00813           bool operator>= (const Q1<Quantity<GT1,
00814             Loki::Typelist<Units::NonPrefixable<GT1, Units::GenericUnit,
00815               ST>, Loki::NullType>, DU1, ST>, SU1> &rhs_variable) const
00816             {
00817              return standard_value () >=
00818                CheckSecondDimension<Constant<PQ, SU>,
00819                  Q1<Quantity<GT1, 
00820                    Loki::Typelist<Units::NonPrefixable<GT1,
00821                      Units::GenericUnit, ST>, Loki::NullType>, 
00822                        DU1, ST>, SU1> >::RET::Unit::Standard
00823                                                 (rhs_variable.value ());
00824             }
00825 
00827 
00834         template <template<class, class> class Q1, class GT1,
00835                          class Head1, class Tail1, class DU1, class SU1>
00836           bool operator>=
00837            (const Q1<Quantity<GT1, Loki::Typelist<Head1, Tail1>,
00838                                      DU1, ST>, SU1> &rhs_variable) const
00839             {
00840              return 
00841                BSUtilities::IF<BSUtilities::SameType<SU, 
00842                  Units::NonPrefixable<GT, Units::GenericUnit, ST>
00843                    >::sameType, SU, Units::UnitError<false> 
00844                      >::RET::Standard (constant_value) >=
00845                CheckSecondDimension<Constant<PQ, SU>,
00846                  Q1<Quantity<GT1, 
00847                    Loki::Typelist<Units::NonPrefixable<GT1,
00848                      Units::GenericUnit, ST>, Loki::NullType>, 
00849                        DU1, ST>, SU1> >::RET::Unit::Standard
00850                                                 (rhs_variable.value ());
00851             }
00852 
00854 
00858         bool operator<= (const Constant &rhs_variable) const
00859                    {return constant_value <= rhs_variable.value ();}
00860 
00862 
00867         template <template<class, class> class Q1, class SU1>
00868           bool operator<= (const Q1<PQ, SU1> &rhs_variable) const
00869             {return standard_value () <= rhs_variable.standard_value ();
00870             }
00871 
00873 
00878         template <template<class, class> class Q1, class GT1,
00879                                                    class DU1, class SU1>
00880           bool operator<= (const Q1<Quantity<GT1,
00881             Loki::Typelist<Units::NonPrefixable<GT1, Units::GenericUnit,
00882               ST>, Loki::NullType>, DU1, ST>, SU1> &rhs_variable) const
00883            {
00884              return standard_value () <=
00885                CheckSecondDimension<Constant<PQ, SU>,
00886                  Q1<Quantity<GT1, 
00887                    Loki::Typelist<Units::NonPrefixable<GT1,
00888                      Units::GenericUnit, ST>, Loki::NullType>, 
00889                        DU1, ST>, SU1> >::RET::Unit::Standard
00890                                                 (rhs_variable.value ());
00891             }
00892 
00894 
00901         template <template<class, class> class Q1, class GT1,
00902                          class Head1, class Tail1, class DU1, class SU1>
00903           bool operator<=
00904            (const Q1<Quantity<GT1, Loki::Typelist<Head1, Tail1>,
00905                                      DU1, ST>, SU1> &rhs_variable) const
00906             {
00907              return 
00908                BSUtilities::IF<BSUtilities::SameType<SU, 
00909                  Units::NonPrefixable<GT, Units::GenericUnit, ST>
00910                    >::sameType, SU, Units::UnitError<false> 
00911                      >::RET::Standard (constant_value) <=
00912                CheckSecondDimension<Constant<PQ, SU>,
00913                  Q1<Quantity<GT1, 
00914                    Loki::Typelist<Units::NonPrefixable<GT1,
00915                      Units::GenericUnit, ST>, Loki::NullType>, 
00916                        DU1, ST>, SU1> >::RET::Unit::Standard
00917                                                 (rhs_variable.value ());
00918             }
00919 
00921 
00926         template<class Q>
00927           typename GenerateVariable<Constant, Q>::Add operator*
00928                                                        (const Q &factor)
00929             {
00930               return typename GenerateVariable<Constant, Q>::Add
00931                          (standard_value () * factor.standard_value ());
00932             }
00933 
00935 
00940         template<class Q>
00941           typename GenerateVariable<Constant, Q>::Sub operator/
00942                                                        (const Q &factor)
00943             {
00944               return typename GenerateVariable<Constant, Q>::Sub
00945                          (standard_value () / factor.standard_value ());
00946             }
00947 
00949 
00952         friend
00953           typename GenerateVariable<Constant, Loki::NullType>::Neg 
00954                   operator/ (const ST numerator, const Constant &factor)
00955           {
00956             return typename 
00957               GenerateVariable<Constant, Loki::NullType>::Neg
00958                                  (numerator / factor.standard_value ());
00959           }
00960 
00962 
00964         template<long N, long D>
00965           friend typename
00966             GenerateVariable<Constant,
00967               BSUtilities::Rational<N, D> >::Mult
00968                 pow (const Constant &variable,
00969                                     const BSUtilities::Rational<N, D> &)
00970           {
00971             return typename
00972               GenerateVariable<Constant,
00973                                      BSUtilities::Rational<N, D> >::Mult
00974                (std::pow(variable.standard_value (),
00975                         static_cast<double>(N)/static_cast<double>(D)));
00976           }
00977 
00979 
00981         template<long N, long D>
00982           typename GenerateVariable<Constant,
00983                                      BSUtilities::Rational<N, D> >::Mult
00984                                pow (const BSUtilities::Rational<N, D> &)
00985           {
00986             return typename
00987               GenerateVariable<Constant,
00988                                      BSUtilities::Rational<N, D> >::Mult
00989                 (std::pow(standard_value (),
00990                         static_cast<double>(N)/static_cast<double>(D)));
00991           }
00992 
00994 
00996         friend
00997           typename
00998             GenerateVariable<Constant, BSUtilities::Rational<1, 2> 
00999               >::Mult sqrt (const Constant &constant)
01000           {
01001             return typename
01002               GenerateVariable<Constant, BSUtilities::Rational<1, 2> 
01003                         >::Mult (std::sqrt(constant.standard_value ()));
01004           }
01005 
01007 
01009         typename
01010           GenerateVariable<Constant, BSUtilities::Rational<1, 2> 
01011                                                      >::Mult sqrt (void)
01012           {
01013             return typename
01014               GenerateVariable<Constant, BSUtilities::Rational<1, 2> 
01015                                  >::Mult (std::sqrt(standard_value ()));
01016           }
01017 
01019 
01022       std::ostream & print_value (std::ostream &os) const
01023         {return os << constant_value << " " << SU::Symbol ();}
01024 
01026 
01028       void operator>> (std::string &str) const
01029           {str = BSUtilities::Conversion<Constant>::to_string (*this);}
01030 
01032 
01036       std::ostream & operator>> (std::ostream &os) const
01037                    {return this->print (os);}
01038 
01039     };
01040 
01041 }
01042 
01043 #endif /* _Constant_h */

Generated on Sun Jan 15 13:57:59 2006 for Quantity by doxygen 1.3.6