00001
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
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
00032 #include "Typelist.h"
00033
00034 namespace quantity {
00035
00037
00038
00039
00041
00043
00047 template<bool>
00048 struct AssignmentError;
00049
00051
00055 template<>
00056 struct AssignmentError<false>
00057 {
00059
00061 static const bool RET = true;
00062 };
00063
00065
00069 template<bool>
00070 struct OperationError;
00071
00073
00077 template<>
00078 struct OperationError<false>
00079 {
00081
00083 static const bool RET = true;
00084 };
00085
00087
00090 template<class Q1, class Q2> struct GenerateVariable;
00091
00093
00095 template<class Q1, class Q2> struct SameDimensioned;
00096
00098
00106 template<template<class, class> class Q1, class UT1,
00107 long RL1_N, long RL1_D, long RM1_N, long RM1_D,
00108 long RT1_N, long RT1_D, long RE1_N, long RE1_D,
00109 long RTE1_N, long RTE1_D, long RA1_N, long RA1_D,
00110 long RLU1_N, long RLU1_D,
00111 class UL1, class DU1, class U1, class ST1,
00112 template<class, class> class Q2, class UT2,
00113 long RL2_N, long RL2_D, long RM2_N, long RM2_D,
00114 long RT2_N, long RT2_D, long RE2_N, long RE2_D,
00115 long RTE2_N, long RTE2_D, long RA2_N, long RA2_D,
00116 long RLU2_N, long RLU2_D,
00117 class UL2, class DU2, class U2, class ST2>
00118 struct SameDimensioned
00119 <Q1<Quantity<
00120 dimension::Dimension<BSUtilities::Rational<RL1_N, RL1_D>,
00121 BSUtilities::Rational<RM1_N, RM1_D>,
00122 BSUtilities::Rational<RT1_N, RT1_D>,
00123 BSUtilities::Rational<RE1_N, RE1_D>,
00124 BSUtilities::Rational<RTE1_N, RTE1_D>,
00125 BSUtilities::Rational<RA1_N, RA1_D>,
00126 BSUtilities::Rational<RLU1_N, RLU1_D> >,
00127 UT1, UL1, DU1, ST1>, U1>,
00128 Q2<Quantity<
00129 dimension::Dimension<BSUtilities::Rational<RL2_N, RL2_D>,
00130 BSUtilities::Rational<RM2_N, RM2_D>,
00131 BSUtilities::Rational<RT2_N, RT2_D>,
00132 BSUtilities::Rational<RE2_N, RE2_D>,
00133 BSUtilities::Rational<RTE2_N, RTE2_D>,
00134 BSUtilities::Rational<RA2_N, RA2_D>,
00135 BSUtilities::Rational<RLU2_N, RLU2_D> >,
00136 UT2, UL2, DU2, ST2>, U2> >
00137 {
00138 enum {RET = dimension::Equal<
00139 dimension::Dimension<BSUtilities::Rational<RL1_N, RL1_D>,
00140 BSUtilities::Rational<RM1_N, RM1_D>,
00141 BSUtilities::Rational<RT1_N, RT1_D>,
00142 BSUtilities::Rational<RE1_N, RE1_D>,
00143 BSUtilities::Rational<RTE1_N, RTE1_D>,
00144 BSUtilities::Rational<RA1_N, RA1_D>,
00145 BSUtilities::Rational<RLU1_N, RLU1_D> >,
00146 dimension::Dimension<BSUtilities::Rational<RL2_N, RL2_D>,
00147 BSUtilities::Rational<RM2_N, RM2_D>,
00148 BSUtilities::Rational<RT2_N, RT2_D>,
00149 BSUtilities::Rational<RE2_N, RE2_D>,
00150 BSUtilities::Rational<RTE2_N, RTE2_D>,
00151 BSUtilities::Rational<RA2_N, RA2_D>,
00152 BSUtilities::Rational<RLU2_N, RLU2_D> > >::EQ};
00153 };
00154
00155
00157
00162 template<class Q1, class Q2> struct CheckSecondDimension;
00163
00164 template<template<class, class> class Q1, class UT1, class D1,
00165 class UL1, class DU1, class U1, class ST1,
00166 template<class, class> class Q2, class UT2, class D2,
00167 class UL2, class DU2, class U2, class ST2>
00168 struct CheckSecondDimension
00169 <Q1<Quantity<D1, UT1, UL1, DU1, ST1>, U1>,
00170 Q2<Quantity<D2, UT2, UL2, DU2, ST2>, U2> >
00171 {
00172 private:
00173 typedef Q1<Quantity<D1, UT1, UL1, DU1, ST1>, U1> Quant1;
00174 typedef Q2<Quantity<D2, UT2, UL2, DU2, ST2>, U2> Quant2;
00175
00176 public:
00177 typedef
00178 typename BSUtilities::IF<SameDimensioned<Quant1, Quant2>::RET,
00179 Quant2, DimensionError<true> >::RET RET;
00180 };
00181
00183
00184
00185
00187
00189
00193 template<class PQ, class SU = typename PQ::DefaultUnit::Unit>
00194 class Variable;
00196
00199 template<long RL_N, long RL_D, long RM_N, long RM_D,
00200 long RT_N, long RT_D, long RE_N, long RE_D, long RTE_N, long RTE_D,
00201 long RA_N, long RA_D, long RLU_N, long RLU_D,
00202 class BT, class UL, class DU, class SU, class ST>
00203 class Variable<Quantity<dimension::Dimension<
00204 BSUtilities::Rational<RL_N, RL_D>,
00205 BSUtilities::Rational<RM_N, RM_D>,
00206 BSUtilities::Rational<RT_N, RT_D>,
00207 BSUtilities::Rational<RE_N, RE_D>,
00208 BSUtilities::Rational<RTE_N, RTE_D>,
00209 BSUtilities::Rational<RA_N, RA_D>,
00210 BSUtilities::Rational<RLU_N, RLU_D> >, BT, UL, DU, ST>,
00211 SU> : public
00212 Quantity<dimension::Dimension<BSUtilities::Rational<RL_N, RL_D>,
00213 BSUtilities::Rational<RM_N, RM_D>,
00214 BSUtilities::Rational<RT_N, RT_D>,
00215 BSUtilities::Rational<RE_N, RE_D>,
00216 BSUtilities::Rational<RTE_N, RTE_D>,
00217 BSUtilities::Rational<RA_N, RA_D>,
00218 BSUtilities::Rational<RLU_N, RLU_D> >, BT, UL, DU, ST>
00219 {
00220 private:
00222
00224 typedef dimension::Dimension<BSUtilities::Rational<RL_N, RL_D>,
00225 BSUtilities::Rational<RM_N, RM_D>,
00226 BSUtilities::Rational<RT_N, RT_D>,
00227 BSUtilities::Rational<RE_N, RE_D>,
00228 BSUtilities::Rational<RTE_N, RTE_D>,
00229 BSUtilities::Rational<RA_N, RA_D>,
00230 BSUtilities::Rational<RLU_N, RLU_D> > DIM;
00231
00232 public:
00234
00237 typedef Quantity<DIM, BT, UL, DU, ST> PQ;
00238
00240
00245 typedef
00246 typename unit::CheckUnit<unit::Unit<BT>, SU>::Check Unit;
00247
00248 protected:
00250
00253 ST variable_value;
00254
00255 public:
00257
00260 Variable (void) : variable_value (ST(0)) {}
00261
00263
00265 Variable (const ST value) : variable_value (value) {}
00266
00268
00271 Variable (const ST value, const SU &)
00272 : variable_value (value) {}
00273
00274
00276
00282 template<class NU>
00283 Variable (const ST value, const NU &)
00284 : PQ (), variable_value (Reverse<SU, ST>::VAL
00285 (Standardize<typename CheckAgainstAllUnits<NU, UL>::RET,
00286 ST>::VAL (value))) {}
00287
00289
00298 Variable (const ST value, const std::string &symbol)
00299 : PQ ()
00300 {::unit::Unit<BT> *unitp = PQ::findBySymbol (symbol);
00301
00302 variable_value = Reverse<SU, ST>::VAL
00303 (dynamic_standardize<UL>::VAL (value, *unitp));
00304
00305 delete (unitp);
00306 }
00307
00309
00316 Variable (const ST value, const char * symbol)
00317 : PQ ()
00318 {::unit::Unit<BT> *unitp
00319 = PQ::findBySymbol (std::string (symbol));
00320 variable_value = Reverse<SU, ST>::VAL
00321 (dynamic_standardize<UL>::VAL (value, *unitp));
00322
00323 delete (unitp);
00324 }
00325
00327
00330 template<template<class, class> class Q1>
00331 Variable (const Q1<PQ, SU> &quantity)
00332 : PQ (), variable_value (quantity.value ())
00333 {namestring = quantity.name ();
00334 symbolstring = quantity.symbol ();
00335 }
00336
00338
00350 template<template<class, class> class Q1, class SU1>
00351 Variable (const Q1<PQ, SU1> &quantity)
00352 : PQ (), variable_value (Reverse<SU, ST>::VAL
00353 (Standardize<SU1, ST>::VAL (quantity.value ())))
00354 {namestring = quantity.name ();
00355 symbolstring = quantity.symbol ();
00356 }
00357
00359
00367 template<template<class, class> class Q1,
00368 class BT1, class DIM1, class DU1, class SU1>
00369 Variable (const Q1<Quantity<DIM1, BT1,
00370 Loki::Typelist<unit::NonPrefixable<BT1, unit::GenericUnit>,
00371 Loki::NullType>, DU1, ST>, SU1> &quantity)
00372 : PQ (), variable_value (Reverse<Unit, ST>::VAL
00373 (Standardize<typename
00374 CheckSecondDimension<Variable<PQ, SU>,
00375 Q1<Quantity<DIM1, BT1,
00376 Loki::Typelist<unit::NonPrefixable<BT1,
00377 unit::GenericUnit>, Loki::NullType>,
00378 DU1, ST>, SU1> >::RET::Unit, ST>::VAL
00379 (quantity.value ())))
00380 {namestring = quantity.name ();
00381 symbolstring = quantity.symbol ();
00382 }
00383
00385
00392 template<template<class, class> class Q1, class PQ1, class SU1>
00393 Variable (const Q1<PQ1, SU1> &);
00394
00396
00401 Variable (const Dynamic<ST> &dynamic)
00402 {if (dynamic._rl_n == RL_N/BSUtilities::Gcd<RL_N, RL_D>::RET
00403 && dynamic._rl_d == RL_D/BSUtilities::Gcd<RL_N, RL_D>::RET
00404 && dynamic._rm_n == RM_N/BSUtilities::Gcd<RM_N, RM_D>::RET
00405 && dynamic._rm_d == RM_D/BSUtilities::Gcd<RM_N, RM_D>::RET
00406 && dynamic._rt_n == RT_N/BSUtilities::Gcd<RT_N, RT_D>::RET
00407 && dynamic._rt_d == RT_D/BSUtilities::Gcd<RT_N, RT_D>::RET
00408 && dynamic._re_n == RE_N/BSUtilities::Gcd<RE_N, RE_D>::RET
00409 && dynamic._re_d == RE_D/BSUtilities::Gcd<RE_N, RE_D>::RET
00410 && dynamic._rte_n
00411 == RTE_N/BSUtilities::Gcd<RTE_N, RTE_D>::RET
00412 && dynamic._rte_d
00413 == RTE_D/BSUtilities::Gcd<RTE_N, RTE_D>::RET
00414 && dynamic._ra_n == RA_N/BSUtilities::Gcd<RA_N, RA_D>::RET
00415 && dynamic._ra_d == RA_D/BSUtilities::Gcd<RA_N, RA_D>::RET
00416 && dynamic._rlu_n
00417 == RLU_N/BSUtilities::Gcd<RLU_N, RLU_D>::RET
00418 && dynamic._rlu_d
00419 == RLU_D/BSUtilities::Gcd<RLU_N, RLU_D>::RET)
00420
00421 variable_value = Reverse<SU, ST>::VAL (dynamic.value ());
00422
00423 else
00424 {throw DimensionMismatch ();}
00425
00426 }
00427
00429
00436 Variable & operator= (const Variable &new_variable)
00437 {if (this != &new_variable)
00438 {variable_value = new_variable.value ();}
00439
00440 return *this;
00441 }
00442
00444
00462 template<template<class, class> class Q1, class SU1>
00463 Variable & operator= (const Q1<PQ, SU1> &quantity)
00464 {
00465 void *this_pointer = this;
00466 const void *new_pointer = &quantity;
00467
00468 if (this_pointer != new_pointer)
00469 {variable_value = Reverse<SU, ST>::VAL
00470 (Standardize<SU1, ST>::VAL (quantity.value ()));
00471 }
00472
00473 return *this;
00474 }
00475
00477
00485 template<template<class, class> class Q1, class PQ1, class SU1>
00486 Variable & operator= (const Q1<PQ1, SU1> &quantity)
00487 {
00488 static const bool RET =
00489 BSUtilities::IF<BSUtilities::SameType<PQ, PQ1>::sameType,
00490 DimensionError<false>, DimensionError<true> >::RET::RET;
00491 return *this;
00492 }
00493
00495
00515 template<template<class, class> class Q1,
00516 class BT1, class DIM1, class DU1, class SU1>
00517 Variable & operator= (const Q1<Quantity<DIM1, BT1,
00518 Loki::Typelist<unit::NonPrefixable<BT1, unit::GenericUnit>,
00519 Loki::NullType>, DU1, ST>, SU1> &quantity)
00520 {void *this_pointer = this;
00521 const void *new_pointer = &quantity;
00522
00523 if (this_pointer != new_pointer)
00524 {variable_value = Reverse<SU, ST>::VAL
00525 (Standardize<typename
00526 CheckSecondDimension<Variable<PQ, SU>,
00527 Q1<Quantity<DIM1, BT1,
00528 Loki::Typelist<unit::NonPrefixable<BT1,
00529 unit::GenericUnit>, Loki::NullType>,
00530 DU1, ST>, SU1> >::RET::Unit, ST>::VAL
00531 (quantity.value ()));
00532 }
00533 return *this;
00534 }
00535
00537
00540 Variable & operator= (const Dynamic<ST> &dynamic)
00541 {if (dynamic._rl_n == RL_N && dynamic._rl_d == RL_D &&
00542 dynamic._rm_n == RM_N && dynamic._rm_d == RM_D &&
00543 dynamic._rt_n == RT_N && dynamic._rt_d == RT_D &&
00544 dynamic._re_n == RE_N && dynamic._re_d == RE_D &&
00545 dynamic._rte_n == RTE_N && dynamic._rte_d == RTE_D &&
00546 dynamic._ra_n == RA_N && dynamic._ra_d == RA_D &&
00547 dynamic._rlu_n == RLU_N && dynamic._rlu_d == RLU_D)
00548 variable_value = Reverse<SU, ST>::VAL (dynamic.value ());
00549
00550 else
00551 {throw DimensionMismatch ();}
00552
00553 return *this;
00554 }
00555
00557
00559 ST value (void) const {return variable_value;}
00560
00562
00565 ST standard_value (void) const
00566 {return Standardize<SU, ST>::VAL (variable_value);}
00567
00569
00574 template<class NU>
00575 ST value (const unit::NonPrefixable<BT, NU> &) const
00576 {return Reverse<typename CheckAgainstAllUnits<
00577 unit::NonPrefixable<BT, NU>, UL>::RET, ST>::VAL
00578 (Standardize<SU, ST>::VAL (variable_value));}
00579
00581
00586 template<class NU, class P>
00587 ST value
00588 (const unit::Prefixed<unit::Prefixable<BT, NU>, P> &) const
00589 {return Reverse<typename CheckAgainstAllUnits<
00590 unit::Prefixed<unit::Prefixable<BT, NU>, P>, UL>::RET,
00591 ST>::VAL (Standardize<SU, ST>::VAL (variable_value));}
00592
00594
00599 template<class CUL, class EL>
00600 ST value
00601 (const unit::Composed<unit::ComposeBase<BT, CUL>, EL> &)
00602 const
00603 {return Reverse<typename CheckAgainstAllUnits<
00604 unit::Composed<unit::ComposeBase<BT, CUL>, EL>, UL>::RET,
00605 ST>::VAL (Standardize<SU, ST>::VAL (variable_value));}
00606
00608
00617 ST value (const std::string &symbol)
00618 {ST value;
00619 ::unit::Unit<BT> *unitp = PQ::findBySymbol (symbol);
00620
00621 value = dynamic_reverse<UL>::VAL
00622 (Standardize<SU, ST>::VAL (variable_value), *unitp);
00623
00624 delete (unitp);
00625
00626 return value;
00627 }
00628
00630
00635 template<class NU>
00636 Variable<PQ, NU> operator () (const NU &) const
00637 {return Variable<PQ, NU> (variable_value, SU());}
00638
00640
00642 const std::string unitsymbol (void) const
00643 {return SU::Symbol ();}
00644
00646
00648 static std::string Unitsymbol (void) {return SU::Symbol ();}
00649
00651
00653 const std::string unitname (void) const {return SU::Name ();}
00654
00656
00658 static std::string Unitname (void) {return SU::Name ();}
00659
00661
00675 Variable & operator+= (const Variable &variable)
00676 {if(BSUtilities::IF<BSUtilities::SameType<UL,
00677 Loki::Typelist<unit::NonPrefixable<BT, unit::GenericUnit>,
00678 Loki::NullType> >::sameType, AssignmentError<true>,
00679 AssignmentError<false> >::RET::RET)
00680 variable_value += variable.value ();
00681 return *this;
00682 }
00683
00685
00693 template <template<class, class> class Q1, class SU1>
00694 Variable & operator+= (const Q1<PQ, SU1> &quantity)
00695 {variable_value = Reverse<SU, ST>::VAL
00696 (Standardize<Unit, ST>::VAL (variable_value) +
00697 Standardize<SU1, ST>::VAL (quantity.value ()));
00698 return *this;
00699 }
00700
00702
00708 template <template<class, class> class Q1, class BT1,
00709 class DIM1, class DU1, class SU1>
00710 Variable & operator+= (const Q1<Quantity<DIM1, BT1,
00711 Loki::Typelist<unit::NonPrefixable<BT1, unit::GenericUnit>,
00712 Loki::NullType>, DU1, ST>, SU1> &quantity)
00713 {variable_value = Reverse<SU, ST>::VAL
00714 (Standardize<Unit, ST>::VAL (variable_value) +
00715 Standardize<typename CheckSecondDimension<
00716 Variable<PQ, SU>, Q1<Quantity<DIM1, BT1,
00717 Loki::Typelist<unit::NonPrefixable<BT1,
00718 unit::GenericUnit>, Loki::NullType>, DU1, ST>,
00719 SU1> >::RET::Unit, ST>::VAL
00720 (quantity.value ()));
00721 return *this;
00722 }
00723
00725
00730 template<template<class, class> class Q1, class PQ1, class SU1>
00731 Variable & operator+= (const Q1<PQ1, SU1> &quantity)
00732 {
00733 static const bool RET =
00734 BSUtilities::IF<BSUtilities::SameType<PQ, PQ1>::sameType,
00735 DimensionError<false>, DimensionError<true> >::RET::RET;
00736 return *this;
00737 }
00738
00740
00754 Variable & operator-= (const Variable &new_variable)
00755 {if(BSUtilities::IF<BSUtilities::SameType<UL,
00756 Loki::Typelist<unit::NonPrefixable<BT, unit::GenericUnit>,
00757 Loki::NullType> >::sameType, AssignmentError<true>,
00758 AssignmentError<false> >::RET::RET)
00759 variable_value -= new_variable.value ();
00760 return *this;
00761 }
00762
00764
00772 template <template<class, class> class Q1, class SU1>
00773 Variable & operator-= (const Q1<PQ, SU1> &quantity)
00774 {variable_value = Reverse<SU, ST>::VAL
00775 (Standardize<Unit, ST>::VAL (variable_value) -
00776 Standardize<SU1, ST>::VAL (quantity.value ()));
00777 return *this;
00778 }
00779
00781
00787 template <template<class, class> class Q1, class BT1,
00788 class DIM1, class DU1, class SU1>
00789 Variable & operator-= (const Q1<Quantity<DIM1, BT1,
00790 Loki::Typelist<unit::NonPrefixable<BT1, unit::GenericUnit>,
00791 Loki::NullType>, DU1, ST>, SU1> &quantity)
00792 {variable_value = Reverse<SU, ST>::VAL
00793 (Standardize<Unit, ST>::VAL (variable_value) -
00794 Standardize<typename CheckSecondDimension<
00795 Variable<PQ, SU>, Q1<Quantity<DIM1, BT1,
00796 Loki::Typelist<unit::NonPrefixable<BT1,
00797 unit::GenericUnit>, Loki::NullType>, DU1, ST>,
00798 SU1> >::RET::Unit, ST>::VAL
00799 (quantity.value ()));
00800 return *this;
00801 }
00802
00804
00808 template<template<class, class> class Q1, class PQ1, class SU1>
00809 Variable & operator-= (const Q1<PQ1, SU1> &quantity)
00810 {
00811 static const bool RET =
00812 BSUtilities::IF<BSUtilities::SameType<PQ, PQ1>::sameType,
00813 DimensionError<false>, DimensionError<true> >::RET::RET;
00814 return *this;
00815 }
00816
00818
00821 Variable & operator*= (const ST factor)
00822 {variable_value *= factor;
00823 return *this;
00824 }
00825
00827
00831 Variable & operator/= (const ST divisor)
00832 {variable_value /= divisor;
00833 return *this;
00834 }
00835
00837
00839 Variable operator+ (void) const
00840 {return Variable (*this);}
00841
00843
00845 Variable operator- (void) const
00846 {return Variable (*this) *= ST(-1.0);}
00847
00849
00852 template<class Q>
00853 struct Plus
00854 {static Variable<PQ,SU> exec
00855 (const Variable<PQ, SU> &variable, const Q &quantity)
00856 {Variable<PQ, SU> new_object (variable);
00857 return new_object += quantity;
00858 }
00859 };
00860
00862
00865 template<template<class, class> class Q1, class DIM1, class BT1,
00866 class UL1, class DU1, class SU1>
00867 struct PlusGenerated
00868 {static Variable<PQ,SU> exec
00869 (const Variable<PQ,SU> &variable,
00870 const Q1<Quantity<DIM1, BT1, UL1, DU1, ST>, SU1> &quantity)
00871 {return Variable<PQ, SU> (Reverse<SU, ST>::VAL
00872 (Standardize<SU, ST>::VAL (variable.value ())
00873 + Standardize<typename CheckSecondDimension<
00874 Variable<PQ, SU>, Q1<Quantity<DIM1, BT1, UL1, DU1,
00875 ST>, SU1> >::RET::Unit, ST>::VAL
00876 (quantity.value ())));
00877 }
00878 };
00879
00881
00887 template <template<class, class> class Q1, class DIM1,
00888 class BT1, class UL1, class DU1, class SU1>
00889 Variable operator+ (const Q1<Quantity<DIM1, BT1, UL1, DU1,
00890 ST>, SU1> &quantity) const
00891 {return BSUtilities::IF<BSUtilities::SameType<UL,
00892 Loki::Typelist<unit::NonPrefixable<BT,
00893 unit::GenericUnit>, Loki::NullType> >::sameType,
00894 typename PlusGenerated<Q1, DIM1, BT1, UL1,
00895 DU1, SU1>::PlusGenerated,
00896 typename Plus<Q1<Quantity<DIM1, BT1, UL1, DU1, ST>,
00897 SU1> >::Plus>::RET::exec (*this, quantity);
00898 }
00899
00901
00908 Variable operator+ (const Dynamic<ST> &quantity) const
00909 {Variable new_variable (quantity);
00910 return *this + new_variable;
00911 }
00912
00914
00921 template<template<class, class> class Q>
00922 friend Variable operator+
00923 (const Dynamic<ST> &quantity1,
00924 const Q<Quantity<DIM, BT, UL, DU, ST>, SU> &quantity2)
00925 {Variable new_variable (quantity1);
00926 return new_variable + quantity2;
00927 }
00928
00930
00933 template<class Q>
00934 struct Minus
00935 {static Variable<PQ,SU> exec
00936 (const Variable<PQ, SU> &variable, const Q &quantity)
00937 {Variable<PQ, SU> new_object (variable);
00938 return new_object -= quantity;
00939 }
00940 };
00941
00943
00946 template<template<class, class> class Q1, class DIM1, class BT1,
00947 class UL1, class DU1, class SU1>
00948 struct MinusGenerated
00949 {static Variable<PQ,SU> exec
00950 (const Variable<PQ,SU> &variable,
00951 const Q1<Quantity<DIM1, BT1, UL1, DU1, ST>, SU1> &quantity)
00952 {return Variable<PQ, SU> (Reverse<SU, ST>::VAL
00953 (Standardize<SU, ST>::VAL (variable.value ())
00954 - Standardize<typename CheckSecondDimension<
00955 Variable<PQ, SU>, Q1<Quantity<DIM1, BT1, UL1, DU1,
00956 ST>, SU1> >::RET::Unit, ST>::VAL
00957 (quantity.value ())));
00958 }
00959 };
00960
00962
00968 template <template<class, class> class Q1, class DIM1,
00969 class BT1, class UL1, class DU1, class SU1>
00970 Variable operator- (const Q1<Quantity<DIM1, BT1, UL1, DU1,
00971 ST>, SU1> &quantity) const
00972 {return BSUtilities::IF<BSUtilities::SameType<UL,
00973 Loki::Typelist<unit::NonPrefixable<BT,
00974 unit::GenericUnit>, Loki::NullType> >::sameType,
00975 typename MinusGenerated<Q1, DIM1, BT1, UL1,
00976 DU1, SU1>::MinusGenerated,
00977 typename Minus<Q1<Quantity<DIM1, BT1, UL1, DU1, ST>,
00978 SU1> >::Minus>::RET::exec (*this, quantity);
00979 }
00980
00982
00988 Variable operator- (const Dynamic<ST> &quantity) const
00989 {Variable new_variable (quantity);
00990 return *this - new_variable;
00991 }
00992
00994
01001 template<template<class, class> class Q>
01002 friend Variable operator-
01003 (const Dynamic<ST> &quantity1,
01004 const Q<Quantity<DIM, BT, UL, DU, ST>, SU> &quantity2)
01005 {Variable new_variable (quantity1);
01006 return new_variable - quantity2;
01007 }
01008
01010
01012 Variable operator* (const ST factor) const
01013 {Variable<PQ, SU> new_object (*this);
01014 return new_object *= factor;
01015 }
01016
01018
01020 Variable operator/ (const ST divisor) const
01021 {Variable<PQ, SU> new_object (*this);
01022 return new_object /= divisor;
01023 }
01024
01026
01036 template <template<class, class> class Q1>
01037 friend Variable operator*
01038 (const ST factor, const Q1<PQ, SU> &variable)
01039 {return Variable<PQ, SU> (variable) *= factor;}
01040
01042
01046 bool operator== (const Variable &rhs_variable) const
01047 {return variable_value == rhs_variable.value ();}
01048
01050
01055 template <template<class, class> class Q1, class SU1>
01056 bool operator== (const Q1<PQ, SU1> &rhs_variable) const
01057 {return standard_value () == rhs_variable.standard_value ();
01058 }
01059
01061
01066 template <template<class, class> class Q1,
01067 class DIM1, class BT1, class UL1, class DU1, class SU1>
01068 bool operator==
01069 (const Q1<Quantity<DIM1, BT1, UL1, DU1, ST>, SU1>
01070 &rhs_variable) const
01071 {
01072 return standard_value () == Standardize<typename
01073 CheckSecondDimension<Variable<PQ, SU>,
01074 Q1<Quantity<DIM1, BT1, UL1, DU1, ST>, SU1>
01075 >::RET::Unit, ST>::VAL (rhs_variable.value ());
01076 }
01077
01079
01083 bool operator!= (const Variable &rhs_variable) const
01084 {return variable_value != rhs_variable.value ();}
01085
01087
01092 template <template<class, class> class Q1, class SU1>
01093 bool operator!= (const Q1<PQ, SU1> &rhs_variable) const
01094 {return standard_value () != rhs_variable.standard_value ();
01095 }
01096
01098
01103 template <template<class, class> class Q1,
01104 class DIM1, class BT1, class UL1, class DU1, class SU1>
01105 bool operator!=
01106 (const Q1<Quantity<DIM1, BT1, UL1, DU1, ST>, SU1>
01107 &rhs_variable) const
01108 {
01109 return standard_value () != Standardize<typename
01110 CheckSecondDimension<Variable<PQ, SU>,
01111 Q1<Quantity<DIM1, BT1, UL1, DU1, ST>, SU1>
01112 >::RET::Unit, ST>::VAL (rhs_variable.value ());
01113 }
01114
01116
01120 bool operator> (const Variable &rhs_variable) const
01121 {return variable_value > rhs_variable.value ();}
01122
01124
01129 template <template<class, class> class Q1, class SU1>
01130 bool operator> (const Q1<PQ, SU1> &rhs_variable) const
01131 {return standard_value () > rhs_variable.standard_value ();
01132 }
01133
01135
01140 template <template<class, class> class Q1,
01141 class DIM1, class BT1, class UL1, class DU1, class SU1>
01142 bool operator>
01143 (const Q1<Quantity<DIM1, BT1, UL1, DU1, ST>, SU1>
01144 &rhs_variable) const
01145 {
01146 return standard_value () > Standardize<typename
01147 CheckSecondDimension<Variable<PQ, SU>,
01148 Q1<Quantity<DIM1, BT1, UL1, DU1, ST>, SU1>
01149 >::RET::Unit, ST>::VAL (rhs_variable.value ());
01150 }
01151
01153
01157 bool operator< (const Variable &rhs_variable) const
01158 {return variable_value < rhs_variable.value ();}
01159
01161
01166 template <template<class, class> class Q1, class SU1>
01167 bool operator< (const Q1<PQ, SU1> &rhs_variable) const
01168 {return standard_value () < rhs_variable.standard_value ();
01169 }
01170
01172
01177 template <template<class, class> class Q1,
01178 class DIM1, class BT1, class UL1, class DU1, class SU1>
01179 bool operator<
01180 (const Q1<Quantity<DIM1, BT1, UL1, DU1, ST>, SU1>
01181 &rhs_variable) const
01182 {
01183 return standard_value () < Standardize<typename
01184 CheckSecondDimension<Variable<PQ, SU>,
01185 Q1<Quantity<DIM1, BT1, UL1, DU1, ST>, SU1>
01186 >::RET::Unit, ST>::VAL (rhs_variable.value ());
01187 }
01188
01190
01194 bool operator>= (const Variable &rhs_variable) const
01195 {return variable_value >= rhs_variable.value ();}
01196
01198
01203 template <template<class, class> class Q1, class SU1>
01204 bool operator>= (const Q1<PQ, SU1> &rhs_variable) const
01205 {return standard_value () >= rhs_variable.standard_value ();
01206 }
01207
01209
01214 template <template<class, class> class Q1,
01215 class DIM1, class BT1, class UL1, class DU1, class SU1>
01216 bool operator>=
01217 (const Q1<Quantity<DIM1, BT1, UL1, DU1, ST>, SU1>
01218 &rhs_variable) const
01219 {
01220 return standard_value () >= Standardize<typename
01221 CheckSecondDimension<Variable<PQ, SU>,
01222 Q1<Quantity<DIM1, BT1, UL1, DU1, ST>, SU1>
01223 >::RET::Unit, ST>::VAL (rhs_variable.value ());
01224 }
01225
01227
01231 bool operator<= (const Variable &rhs_variable) const
01232 {return variable_value <= rhs_variable.value ();}
01233
01235
01240 template <template<class, class> class Q1, class SU1>
01241 bool operator<= (const Q1<PQ, SU1> &rhs_variable) const
01242 {return standard_value () <= rhs_variable.standard_value ();
01243 }
01244
01246
01251 template <template<class, class> class Q1,
01252 class DIM1, class BT1, class UL1, class DU1, class SU1>
01253 bool operator<=
01254 (const Q1<Quantity<DIM1, BT1, UL1, DU1, ST>, SU1>
01255 &rhs_variable) const
01256 {
01257 return standard_value () <= Standardize<typename
01258 CheckSecondDimension<Variable<PQ, SU>,
01259 Q1<Quantity<DIM1, BT1, UL1, DU1, ST>, SU1>
01260 >::RET::Unit, ST>::VAL (rhs_variable.value ());
01261 }
01262
01264
01269 template<class Q>
01270 typename GenerateVariable<Variable, Q>::Add operator*
01271 (const Q &factor) const
01272 {
01273 return typename GenerateVariable<Variable, Q>::Add
01274 (standard_value () * factor.standard_value ());
01275 }
01276
01278
01283 template<class Q>
01284 typename GenerateVariable<Variable, Q>::Sub operator/
01285 (const Q &factor) const
01286 {
01287 return typename GenerateVariable<Variable, Q>::Sub
01288 (standard_value () / factor.standard_value ());
01289 }
01290
01292
01295 friend
01296 typename GenerateVariable<Variable, Loki::NullType>::Inv
01297 operator/ (const ST numerator, const Variable &factor)
01298 {
01299 return typename
01300 GenerateVariable<Variable, Loki::NullType>::Inv
01301 (numerator / factor.standard_value ());
01302 }
01303
01305
01311 template<long N, long D>
01312 typename GenerateVariable<Variable,
01313 BSUtilities::Rational<N, D> >::Mult
01314 pow (const BSUtilities::Rational<N, D> &)
01315 {return
01316 ::quantity::pow (*this, BSUtilities::Rational<N, D> ());}
01317
01319
01325 template<int I>
01326 typename GenerateVariable<Variable,
01327 BSUtilities::Rational<I, long(1)> >::Mult
01328 pow (typename Loki::Int2Type<I>)
01329 {return ::quantity::pow (*this, Loki::Int2Type<I> ());}
01330
01332
01338 template<class T>
01339 Dynamic<ST> pow (const T &exp) const
01340 {return ::quantity::pow (*this, exp);}
01341
01343
01345 friend typename
01346 GenerateVariable<Variable, BSUtilities::Rational<1, 2>
01347 >::Mult sqrt (const Variable &variable)
01348 {
01349 return typename
01350 GenerateVariable<Variable, BSUtilities::Rational<1, 2>
01351 >::Mult (std::sqrt(variable.standard_value ()));
01352 }
01353
01355
01357 typename
01358 GenerateVariable<Variable, BSUtilities::Rational<1, 2>
01359 >::Mult sqrt (void) const
01360 {
01361 return typename
01362 GenerateVariable<Variable, BSUtilities::Rational<1, 2>
01363 >::Mult (std::sqrt(standard_value ()));
01364 }
01365
01367
01370 std::ostream & print_value (std::ostream &os) const
01371 {return os << variable_value << " " << SU::Symbol ();}
01372
01374
01376 void operator>> (std::string &str) const
01377 {str = BSUtilities::Conversion<Variable>::to_string (*this);}
01378
01380
01384 std::ostream & operator>> (std::ostream &os) const
01385 {return this->print (os);}
01386
01388
01390 void read_value (const std::string &str);
01391
01393
01395 friend void operator>>
01396 (const std::string &str, Variable &variable)
01397 {variable.read_value (str);}
01398
01400 void operator<< (const std::string &str) {read_value (str);}
01401
01403 void operator= (const std::string &str) {this->read_value (str);}
01404
01406
01410 std::istream & operator<< (std::istream &is)
01411 {std::string string; getline (is, string);
01412 this->read_value (string); return is;}
01413
01415
01418 friend std::istream & operator>>
01419 (std::istream &is, Variable &variable) {return variable << is;}
01420
01422
01426
01427
01428
01430
01433
01434
01435
01437
01441
01442
01443
01444 };
01445
01450 template<long RL_N, long RL_D, long RM_N, long RM_D,
01451 long RT_N, long RT_D, long RE_N, long RE_D, long RTE_N, long RTE_D,
01452 long RA_N, long RA_D, long RLU_N, long RLU_D,
01453 class BT, class UL, class DU, class SU, class ST>
01454
01455 void
01456 Variable<Quantity<dimension::Dimension<
01457 BSUtilities::Rational<RL_N, RL_D>,
01458 BSUtilities::Rational<RM_N, RM_D>,
01459 BSUtilities::Rational<RT_N, RT_D>,
01460 BSUtilities::Rational<RE_N, RE_D>,
01461 BSUtilities::Rational<RTE_N, RTE_D>,
01462 BSUtilities::Rational<RA_N, RA_D>,
01463 BSUtilities::Rational<RLU_N, RLU_D> >, BT, UL, DU, ST>,
01464 SU> ::read_value (const std::string &str)
01465 {
01466 std::string value;
01467 std::string unit;
01468
01469 std::string::size_type start;
01470 std::string::size_type end;
01471
01472 start = str.find_first_not_of (" \0");
01473 end = start;
01474
01475 if (RS.name ())
01476 {
01477 if (start == std::string::npos)
01478 throw InputError ();
01479
01480 else
01481 {
01482 end = str.find_first_of (" \0", start);
01483
01484 if (end == std::string::npos)
01485 namestring = str.substr (start);
01486
01487 else
01488 namestring = (str.substr (start, end - start));
01489 }
01490 }
01491
01492 start = str.find_first_not_of (" \0", end);
01493 end = start;
01494
01495 if (RS.symbol ())
01496 {
01497 if (start == std::string::npos)
01498 throw InputError ();
01499
01500 else
01501 {
01502 end = str.find_first_of (" \0", start);
01503
01504 if (end == std::string::npos)
01505 symbolstring = str.substr (start);
01506
01507 else
01508 symbolstring = (str.substr (start, end - start));
01509 }
01510 }
01511
01512 start = str.find_first_not_of (" \0", end);
01513 end = start;
01514
01515 if (RS.equal () && (RS.name () || RS.symbol ()))
01516 {
01517 if (start == std::string::npos)
01518 throw InputError ();
01519
01520 else
01521 {
01522 end = str.find_first_of (" \0", start);
01523
01524 if (end == std::string::npos)
01525 throw InputError ();
01526
01527 else if (str.substr (start, end - start) != "=")
01528 throw InputError ();
01529 }
01530 }
01531
01532 start = str.find_first_not_of (" \0", end);
01533 end = start;
01534
01535 if (start == std::string::npos)
01536 throw InputError ();
01537
01538 else
01539 {
01540 end = str.find_first_of (" \0", start);
01541
01542 if (end == std::string::npos)
01543 value = str.substr (start);
01544
01545 else
01546 value = str.substr (start, end - start);
01547
01548 start = str.find_first_not_of (" \0", end);
01549
01550 if (start == std::string::npos)
01551 unit = "";
01552
01553 else
01554 {
01555 end = str.find_first_of (" \0\n", start);
01556
01557 if (end = std::string::npos)
01558 unit = str.substr (start);
01559
01560 else
01561 unit = str.substr (start, end - start);
01562 }
01563 }
01564
01565 ST intermediate;
01566
01567 try {
01568 intermediate = BSUtilities::Conversion<ST>::string_to (value);
01569 }
01570
01571 catch (BSUtilities::ConversionFailure) {throw InputError ();}
01572
01573 start = unit.find_first_not_of (" \0");
01574 end = start;
01575
01576
01577
01578
01579 if (start == std::string::npos)
01580 {
01581 std::string assume_unit;
01582
01583
01584
01585
01586
01587 if ((assume_unit = RS.unit ()) != "")
01588 {
01589 try {
01590 ::unit::Unit<BT> *unitp = PQ::findBySymbol (assume_unit);
01591 intermediate
01592 = Reverse<SU, ST>::VAL
01593 (dynamic_standardize<UL>::VAL (intermediate, *unitp));
01594
01595 delete (unitp);
01596 }
01597
01598 catch (UnitMismatch) {throw InputError ();}
01599
01600 }
01601 }
01602
01603
01604
01605
01606 else
01607 {
01608 end = unit.find_first_of (" \0", start);
01609 try {
01610 ::unit::Unit<BT> *unitp
01611 = PQ::findBySymbol (unit.substr (start, end - start));
01612
01613 intermediate
01614 = Reverse<SU, ST>::VAL
01615 (dynamic_standardize<UL>::VAL (intermediate, *unitp));
01616
01617 delete (unitp);
01618 }
01619 catch (UnitMismatch) {throw InputError ();}
01620 }
01621
01622
01623 variable_value = intermediate;
01624
01625 }
01626
01628
01631 template<template<class, class> class Q1, class BT1,
01632 long RL1_N, long RL1_D, long RM1_N, long RM1_D,
01633 long RT1_N, long RT1_D, long RE1_N, long RE1_D,
01634 long RTE1_N, long RTE1_D, long RA1_N, long RA1_D,
01635 long RLU1_N, long RLU1_D, class UL1, class DU1, class SU1,
01636 template<class, class> class Q2, class BT2,
01637 long RL2_N, long RL2_D, long RM2_N, long RM2_D,
01638 long RT2_N, long RT2_D, long RE2_N, long RE2_D,
01639 long RTE2_N, long RTE2_D, long RA2_N, long RA2_D,
01640 long RLU2_N, long RLU2_D,
01641 class UL2, class DU2, class SU2, class ST>
01642 struct GenerateVariable
01643 <Q1<Quantity<
01644 dimension::Dimension<BSUtilities::Rational<RL1_N, RL1_D>,
01645 BSUtilities::Rational<RM1_N, RM1_D>,
01646 BSUtilities::Rational<RT1_N, RT1_D>,
01647 BSUtilities::Rational<RE1_N, RE1_D>,
01648 BSUtilities::Rational<RTE1_N, RTE1_D>,
01649 BSUtilities::Rational<RA1_N, RA1_D>,
01650 BSUtilities::Rational<RLU1_N, RLU1_D> >,
01651 BT1, UL1, DU1, ST>, SU1>,
01652 Q2<Quantity<
01653 dimension::Dimension<BSUtilities::Rational<RL2_N, RL2_D>,
01654 BSUtilities::Rational<RM2_N, RM2_D>,
01655 BSUtilities::Rational<RT2_N, RT2_D>,
01656 BSUtilities::Rational<RE2_N, RE2_D>,
01657 BSUtilities::Rational<RTE2_N, RTE2_D>,
01658 BSUtilities::Rational<RA2_N, RA2_D>,
01659 BSUtilities::Rational<RLU2_N, RLU2_D> >,
01660 BT2, UL2, DU2, ST>, SU2> >
01661 {
01662 private:
01664 typedef typename
01665 dimension::Dimension<BSUtilities::Rational<RL1_N, RL1_D>,
01666 BSUtilities::Rational<RM1_N, RM1_D>,
01667 BSUtilities::Rational<RT1_N, RT1_D>,
01668 BSUtilities::Rational<RE1_N, RE1_D>,
01669 BSUtilities::Rational<RTE1_N, RTE1_D>,
01670 BSUtilities::Rational<RA1_N, RA1_D>,
01671 BSUtilities::Rational<RLU1_N, RLU1_D> >
01672 ::template Add<dimension::Dimension<
01673 BSUtilities::Rational<RL2_N, RL2_D>,
01674 BSUtilities::Rational<RM2_N, RM2_D>,
01675 BSUtilities::Rational<RT2_N, RT2_D>,
01676 BSUtilities::Rational<RE2_N, RE2_D>,
01677 BSUtilities::Rational<RTE2_N, RTE2_D>,
01678 BSUtilities::Rational<RA2_N, RA2_D>,
01679 BSUtilities::Rational<RLU2_N, RLU2_D> > > AddT;
01680
01681 typedef unit::NonPrefixable<GenericClass<typename AddT::Res>,
01682 unit::GenericUnit> AddU;
01683 typedef Loki::Typelist<AddU, Loki::NullType> AddUnits;
01684 typedef Quantity<typename AddT::Res,
01685 GenericClass<typename AddT::Res>, AddUnits, AddU, ST> AddNewQ;
01686
01688 typedef typename
01689 dimension::Dimension<BSUtilities::Rational<RL1_N, RL1_D>,
01690 BSUtilities::Rational<RM1_N, RM1_D>,
01691 BSUtilities::Rational<RT1_N, RT1_D>,
01692 BSUtilities::Rational<RE1_N, RE1_D>,
01693 BSUtilities::Rational<RTE1_N, RTE1_D>,
01694 BSUtilities::Rational<RA1_N, RA1_D>,
01695 BSUtilities::Rational<RLU1_N, RLU1_D> >
01696 ::template Sub<dimension::Dimension<
01697 BSUtilities::Rational<RL2_N, RL2_D>,
01698 BSUtilities::Rational<RM2_N, RM2_D>,
01699 BSUtilities::Rational<RT2_N, RT2_D>,
01700 BSUtilities::Rational<RE2_N, RE2_D>,
01701 BSUtilities::Rational<RTE2_N, RTE2_D>,
01702 BSUtilities::Rational<RA2_N, RA2_D>,
01703 BSUtilities::Rational<RLU2_N, RLU2_D> > > SubT;
01704
01705 typedef unit::NonPrefixable<GenericClass<typename SubT::Res>,
01706 unit::GenericUnit> SubU;
01707 typedef Loki::Typelist<SubU, Loki::NullType> SubUnits;
01708 typedef Quantity<typename SubT::Res,
01709 GenericClass<typename SubT::Res>, SubUnits, SubU, ST> SubNewQ;
01710
01711 public:
01712 typedef Variable<AddNewQ, AddU> Add;
01713 typedef Variable<SubNewQ, SubU> Sub;
01714 };
01715
01717
01720 template<template<class, class> class Q1, class BT1,
01721 long RL1_N, long RL1_D, long RM1_N, long RM1_D,
01722 long RT1_N, long RT1_D, long RE1_N, long RE1_D,
01723 long RTE1_N, long RTE1_D, long RA1_N, long RA1_D,
01724 long RLU1_N, long RLU1_D,
01725 class UL1, class DU1, class SU1, class ST1>
01726 struct GenerateVariable
01727 <Q1<Quantity<
01728 dimension::Dimension<BSUtilities::Rational<RL1_N, RL1_D>,
01729 BSUtilities::Rational<RM1_N, RM1_D>,
01730 BSUtilities::Rational<RT1_N, RT1_D>,
01731 BSUtilities::Rational<RE1_N, RE1_D>,
01732 BSUtilities::Rational<RTE1_N, RTE1_D>,
01733 BSUtilities::Rational<RA1_N, RA1_D>,
01734 BSUtilities::Rational<RLU1_N, RLU1_D> >,
01735 BT1, UL1, DU1, ST1>, SU1>, Loki::NullType>
01736 {
01737 private:
01739 typedef typename
01740 dimension::Dimension<BSUtilities::Rational<RL1_N, RL1_D>,
01741 BSUtilities::Rational<RM1_N, RM1_D>,
01742 BSUtilities::Rational<RT1_N, RT1_D>,
01743 BSUtilities::Rational<RE1_N, RE1_D>,
01744 BSUtilities::Rational<RTE1_N, RTE1_D>,
01745 BSUtilities::Rational<RA1_N, RA1_D>,
01746 BSUtilities::Rational<RLU1_N, RLU1_D> >::Inv InvT;
01747
01748 typedef unit::NonPrefixable<GenericClass<typename InvT::Res>,
01749 unit::GenericUnit> InvU;
01750 typedef Loki::Typelist<InvU, Loki::NullType> InvUnits;
01751 typedef Quantity< typename InvT::Res,
01752 GenericClass<typename InvT::Res>, InvUnits, InvU, ST1> InvNewQ;
01753
01754 public:
01755 typedef Variable<InvNewQ, InvU> Inv;
01756 };
01757
01759
01762 template<template<class, class> class Q1, class BT1,
01763 long RL1_N, long RL1_D, long RM1_N, long RM1_D,
01764 long RT1_N, long RT1_D, long RE1_N, long RE1_D,
01765 long RTE1_N, long RTE1_D, long RA1_N, long RA1_D,
01766 long RLU1_N, long RLU1_D,
01767 class UL1, class DU1, class ST1, class SU1, long N, long D>
01768 struct GenerateVariable
01769 <Q1<Quantity<
01770 dimension::Dimension<BSUtilities::Rational<RL1_N, RL1_D>,
01771 BSUtilities::Rational<RM1_N, RM1_D>,
01772 BSUtilities::Rational<RT1_N, RT1_D>,
01773 BSUtilities::Rational<RE1_N, RE1_D>,
01774 BSUtilities::Rational<RTE1_N, RTE1_D>,
01775 BSUtilities::Rational<RA1_N, RA1_D>,
01776 BSUtilities::Rational<RLU1_N, RLU1_D> >,
01777 BT1, UL1, DU1, ST1>, SU1>,
01778 BSUtilities::Rational<N, D> >
01779 {
01780 private:
01782 typedef typename
01783 dimension::Dimension<BSUtilities::Rational<RL1_N, RL1_D>,
01784 BSUtilities::Rational<RM1_N, RM1_D>,
01785 BSUtilities::Rational<RT1_N, RT1_D>,
01786 BSUtilities::Rational<RE1_N, RE1_D>,
01787 BSUtilities::Rational<RTE1_N, RTE1_D>,
01788 BSUtilities::Rational<RA1_N, RA1_D>,
01789 BSUtilities::Rational<RLU1_N, RLU1_D> >::template
01790 Mult<N, D> MultT;
01791
01792 typedef unit::NonPrefixable<GenericClass<typename MultT::Res>,
01793 unit::GenericUnit> MultU;
01794 typedef Loki::Typelist<MultU, Loki::NullType> MultUnits;
01795 typedef Quantity<typename MultT::Res,
01796 GenericClass<typename MultT::Res>, MultUnits, MultU, ST1>
01797 MultNewQ;
01798
01799 public:
01800 typedef Variable<MultNewQ, MultU> Mult;
01801 };
01802
01804
01807 template<template<class, class> class Q1, class BT1,
01808 long RL1_N, long RL1_D, long RM1_N, long RM1_D,
01809 long RT1_N, long RT1_D, long RE1_N, long RE1_D,
01810 long RTE1_N, long RTE1_D, long RA1_N, long RA1_D,
01811 long RLU1_N, long RLU1_D,
01812 class UL1, class DU1, class ST1, class SU1, int I>
01813 inline typename GenerateVariable
01814 <Q1<Quantity<
01815 dimension::Dimension<BSUtilities::Rational<RL1_N, RL1_D>,
01816 BSUtilities::Rational<RM1_N, RM1_D>,
01817 BSUtilities::Rational<RT1_N, RT1_D>,
01818 BSUtilities::Rational<RE1_N, RE1_D>,
01819 BSUtilities::Rational<RTE1_N, RTE1_D>,
01820 BSUtilities::Rational<RA1_N, RA1_D>,
01821 BSUtilities::Rational<RLU1_N, RLU1_D> >,
01822 BT1, UL1, DU1, ST1>, SU1>,
01823 BSUtilities::Rational<I, long(1)> >::Mult
01824 pow (const
01825 Q1<Quantity<
01826 dimension::Dimension<BSUtilities::Rational<RL1_N, RL1_D>,
01827 BSUtilities::Rational<RM1_N, RM1_D>,
01828 BSUtilities::Rational<RT1_N, RT1_D>,
01829 BSUtilities::Rational<RE1_N, RE1_D>,
01830 BSUtilities::Rational<RTE1_N, RTE1_D>,
01831 BSUtilities::Rational<RA1_N, RA1_D>,
01832 BSUtilities::Rational<RLU1_N, RLU1_D> >,
01833 BT1, UL1, DU1, ST1>, SU1> &quantity,
01834 typename Loki::Int2Type<I>)
01835 {
01836 return typename
01837 GenerateVariable<
01838 Q1<Quantity<
01839 dimension::Dimension<BSUtilities::Rational<RL1_N, RL1_D>,
01840 BSUtilities::Rational<RM1_N, RM1_D>,
01841 BSUtilities::Rational<RT1_N, RT1_D>,
01842 BSUtilities::Rational<RE1_N, RE1_D>,
01843 BSUtilities::Rational<RTE1_N, RTE1_D>,
01844 BSUtilities::Rational<RA1_N, RA1_D>,
01845 BSUtilities::Rational<RLU1_N, RLU1_D> >,
01846 BT1, UL1, DU1, ST1>, SU1>,
01847 BSUtilities::Rational<long(I), long(1)> >::Mult
01848 (std::pow(quantity.standard_value (), I));
01849 }
01850
01852
01856 template<template<class, class> class Q1, class BT1,
01857 long RL1_N, long RL1_D, long RM1_N, long RM1_D,
01858 long RT1_N, long RT1_D, long RE1_N, long RE1_D,
01859 long RTE1_N, long RTE1_D, long RA1_N, long RA1_D,
01860 long RLU1_N, long RLU1_D,
01861 class UL1, class DU1, class ST1, class SU1, long N, long D>
01862 inline typename GenerateVariable
01863 <Q1<Quantity<
01864 dimension::Dimension<BSUtilities::Rational<RL1_N, RL1_D>,
01865 BSUtilities::Rational<RM1_N, RM1_D>,
01866 BSUtilities::Rational<RT1_N, RT1_D>,
01867 BSUtilities::Rational<RE1_N, RE1_D>,
01868 BSUtilities::Rational<RTE1_N, RTE1_D>,
01869 BSUtilities::Rational<RA1_N, RA1_D>,
01870 BSUtilities::Rational<RLU1_N, RLU1_D> >,
01871 BT1, UL1, DU1, ST1>, SU1>,
01872 BSUtilities::Rational<N, D> >::Mult
01873 pow (const
01874 Q1<Quantity<
01875 dimension::Dimension<BSUtilities::Rational<RL1_N, RL1_D>,
01876 BSUtilities::Rational<RM1_N, RM1_D>,
01877 BSUtilities::Rational<RT1_N, RT1_D>,
01878 BSUtilities::Rational<RE1_N, RE1_D>,
01879 BSUtilities::Rational<RTE1_N, RTE1_D>,
01880 BSUtilities::Rational<RA1_N, RA1_D>,
01881 BSUtilities::Rational<RLU1_N, RLU1_D> >,
01882 BT1, UL1, DU1, ST1>, SU1> &quantity,
01883 const BSUtilities::Rational<N, D> &)
01884 { return typename
01885 GenerateVariable
01886 <Q1<Quantity<
01887 dimension::Dimension<BSUtilities::Rational<RL1_N, RL1_D>,
01888 BSUtilities::Rational<RM1_N, RM1_D>,
01889 BSUtilities::Rational<RT1_N, RT1_D>,
01890 BSUtilities::Rational<RE1_N, RE1_D>,
01891 BSUtilities::Rational<RTE1_N, RTE1_D>,
01892 BSUtilities::Rational<RA1_N, RA1_D>,
01893 BSUtilities::Rational<RLU1_N, RLU1_D> >,
01894 BT1, UL1, DU1, ST1>, SU1>,
01895 BSUtilities::Rational<N, D> >::Mult
01896 (std::pow(quantity.standard_value (),
01897 static_cast<double>(N)/static_cast<double>(D)));
01898 }
01899
01901
01903 template<template<class, class> class Q, class BT,
01904 long RL_N, long RL_D, long RM_N, long RM_D,
01905 long RT_N, long RT_D, long RE_N, long RE_D,
01906 long RTE_N, long RTE_D, long RA_N, long RA_D,
01907 long RLU_N, long RLU_D, class UL, class DU, class ST, class SU>
01908 inline Variable<Quantity<
01909 dimension::Dimension<BSUtilities::Rational<RL_N, RL_D>,
01910 BSUtilities::Rational<RM_N, RM_D>,
01911 BSUtilities::Rational<RT_N, RT_D>,
01912 BSUtilities::Rational<RE_N, RE_D>,
01913 BSUtilities::Rational<RTE_N, RTE_D>,
01914 BSUtilities::Rational<RA_N, RA_D>,
01915 BSUtilities::Rational<RLU_N, RLU_D> >,
01916 BT, UL, DU, ST>, SU>
01917 abs (const Q<Quantity<
01918 dimension::Dimension<BSUtilities::Rational<RL_N, RL_D>,
01919 BSUtilities::Rational<RM_N, RM_D>,
01920 BSUtilities::Rational<RT_N, RT_D>,
01921 BSUtilities::Rational<RE_N, RE_D>,
01922 BSUtilities::Rational<RTE_N, RTE_D>,
01923 BSUtilities::Rational<RA_N, RA_D>,
01924 BSUtilities::Rational<RLU_N, RLU_D> >,
01925 BT, UL, DU, ST>, SU> &variable)
01926 {return Variable<Quantity<
01927 dimension::Dimension<BSUtilities::Rational<RL_N, RL_D>,
01928 BSUtilities::Rational<RM_N, RM_D>,
01929 BSUtilities::Rational<RT_N, RT_D>,
01930 BSUtilities::Rational<RE_N, RE_D>,
01931 BSUtilities::Rational<RTE_N, RTE_D>,
01932 BSUtilities::Rational<RA_N, RA_D>,
01933 BSUtilities::Rational<RLU_N, RLU_D> >,
01934 BT, UL, DU, ST>, SU>
01935 (std::abs (variable.value ()));}
01936
01938
01940 template<template<class, class> class Q, class BT,
01941 long RL_N, long RL_D, long RM_N, long RM_D,
01942 long RT_N, long RT_D, long RE_N, long RE_D,
01943 long RTE_N, long RTE_D, long RA_N, long RA_D,
01944 long RLU_N, long RLU_D, class UL, class DU, class ST, class SU>
01945 inline Variable<Quantity<
01946 dimension::Dimension<BSUtilities::Rational<RL_N, RL_D>,
01947 BSUtilities::Rational<RM_N, RM_D>,
01948 BSUtilities::Rational<RT_N, RT_D>,
01949 BSUtilities::Rational<RE_N, RE_D>,
01950 BSUtilities::Rational<RTE_N, RTE_D>,
01951 BSUtilities::Rational<RA_N, RA_D>,
01952 BSUtilities::Rational<RLU_N, RLU_D> >,
01953 BT, UL, DU, ST>, SU>
01954 ceil (const Q<Quantity<
01955 dimension::Dimension<BSUtilities::Rational<RL_N, RL_D>,
01956 BSUtilities::Rational<RM_N, RM_D>,
01957 BSUtilities::Rational<RT_N, RT_D>,
01958 BSUtilities::Rational<RE_N, RE_D>,
01959 BSUtilities::Rational<RTE_N, RTE_D>,
01960 BSUtilities::Rational<RA_N, RA_D>,
01961 BSUtilities::Rational<RLU_N, RLU_D> >,
01962 BT, UL, DU, ST>, SU> &variable)
01963 {return Variable<Quantity<
01964 dimension::Dimension<BSUtilities::Rational<RL_N, RL_D>,
01965 BSUtilities::Rational<RM_N, RM_D>,
01966 BSUtilities::Rational<RT_N, RT_D>,
01967 BSUtilities::Rational<RE_N, RE_D>,
01968 BSUtilities::Rational<RTE_N, RTE_D>,
01969 BSUtilities::Rational<RA_N, RA_D>,
01970 BSUtilities::Rational<RLU_N, RLU_D> >,
01971 BT, UL, DU, ST>, SU>
01972 (std::ceil (variable.value ()));}
01973
01975
01977 template<template<class, class> class Q, class BT,
01978 long RL_N, long RL_D, long RM_N, long RM_D,
01979 long RT_N, long RT_D, long RE_N, long RE_D,
01980 long RTE_N, long RTE_D, long RA_N, long RA_D,
01981 long RLU_N, long RLU_D, class UL, class DU, class ST, class SU>
01982 inline Variable<Quantity<
01983 dimension::Dimension<BSUtilities::Rational<RL_N, RL_D>,
01984 BSUtilities::Rational<RM_N, RM_D>,
01985 BSUtilities::Rational<RT_N, RT_D>,
01986 BSUtilities::Rational<RE_N, RE_D>,
01987 BSUtilities::Rational<RTE_N, RTE_D>,
01988 BSUtilities::Rational<RA_N, RA_D>,
01989 BSUtilities::Rational<RLU_N, RLU_D> >,
01990 BT, UL, DU, ST>, SU>
01991 floor (const Q<Quantity<
01992 dimension::Dimension<BSUtilities::Rational<RL_N, RL_D>,
01993 BSUtilities::Rational<RM_N, RM_D>,
01994 BSUtilities::Rational<RT_N, RT_D>,
01995 BSUtilities::Rational<RE_N, RE_D>,
01996 BSUtilities::Rational<RTE_N, RTE_D>,
01997 BSUtilities::Rational<RA_N, RA_D>,
01998 BSUtilities::Rational<RLU_N, RLU_D> >,
01999 BT, UL, DU, ST>, SU> &variable)
02000 {return Variable<Quantity<
02001 dimension::Dimension<BSUtilities::Rational<RL_N, RL_D>,
02002 BSUtilities::Rational<RM_N, RM_D>,
02003 BSUtilities::Rational<RT_N, RT_D>,
02004 BSUtilities::Rational<RE_N, RE_D>,
02005 BSUtilities::Rational<RTE_N, RTE_D>,
02006 BSUtilities::Rational<RA_N, RA_D>,
02007 BSUtilities::Rational<RLU_N, RLU_D> >,
02008 BT, UL, DU, ST>, SU>
02009 (std::floor (variable.value ()));}
02010
02012
02014 template<template<class, class> class Q, class BT,
02015 long RL_N, long RL_D, long RM_N, long RM_D,
02016 long RT_N, long RT_D, long RE_N, long RE_D,
02017 long RTE_N, long RTE_D, long RA_N, long RA_D,
02018 long RLU_N, long RLU_D, class UL, class DU, class ST, class SU>
02019 inline Variable<Quantity<
02020 dimension::Dimension<BSUtilities::Rational<RL_N, RL_D>,
02021 BSUtilities::Rational<RM_N, RM_D>,
02022 BSUtilities::Rational<RT_N, RT_D>,
02023 BSUtilities::Rational<RE_N, RE_D>,
02024 BSUtilities::Rational<RTE_N, RTE_D>,
02025 BSUtilities::Rational<RA_N, RA_D>,
02026 BSUtilities::Rational<RLU_N, RLU_D> >,
02027 BT, UL, DU, ST>, SU>
02028 frexp (const Q<Quantity<
02029 dimension::Dimension<BSUtilities::Rational<RL_N, RL_D>,
02030 BSUtilities::Rational<RM_N, RM_D>,
02031 BSUtilities::Rational<RT_N, RT_D>,
02032 BSUtilities::Rational<RE_N, RE_D>,
02033 BSUtilities::Rational<RTE_N, RTE_D>,
02034 BSUtilities::Rational<RA_N, RA_D>,
02035 BSUtilities::Rational<RLU_N, RLU_D> >,
02036 BT, UL, DU, ST>, SU> &variable, int *exponent)
02037 {return Variable<Quantity<
02038 dimension::Dimension<BSUtilities::Rational<RL_N, RL_D>,
02039 BSUtilities::Rational<RM_N, RM_D>,
02040 BSUtilities::Rational<RT_N, RT_D>,
02041 BSUtilities::Rational<RE_N, RE_D>,
02042 BSUtilities::Rational<RTE_N, RTE_D>,
02043 BSUtilities::Rational<RA_N, RA_D>,
02044 BSUtilities::Rational<RLU_N, RLU_D> >,
02045 BT, UL, DU, ST>, SU>
02046 (std::frexp (variable.value (), exponent));}
02047
02049
02051 template<template<class, class> class Q, class BT,
02052 long RL_N, long RL_D, long RM_N, long RM_D,
02053 long RT_N, long RT_D, long RE_N, long RE_D,
02054 long RTE_N, long RTE_D, long RA_N, long RA_D,
02055 long RLU_N, long RLU_D, class UL, class DU, class ST, class SU>
02056 inline Variable<Quantity<
02057 dimension::Dimension<BSUtilities::Rational<RL_N, RL_D>,
02058 BSUtilities::Rational<RM_N, RM_D>,
02059 BSUtilities::Rational<RT_N, RT_D>,
02060 BSUtilities::Rational<RE_N, RE_D>,
02061 BSUtilities::Rational<RTE_N, RTE_D>,
02062 BSUtilities::Rational<RA_N, RA_D>,
02063 BSUtilities::Rational<RLU_N, RLU_D> >,
02064 BT, UL, DU, ST>, SU>
02065 ldexp (const Q<Quantity<
02066 dimension::Dimension<BSUtilities::Rational<RL_N, RL_D>,
02067 BSUtilities::Rational<RM_N, RM_D>,
02068 BSUtilities::Rational<RT_N, RT_D>,
02069 BSUtilities::Rational<RE_N, RE_D>,
02070 BSUtilities::Rational<RTE_N, RTE_D>,
02071 BSUtilities::Rational<RA_N, RA_D>,
02072 BSUtilities::Rational<RLU_N, RLU_D> >,
02073 BT, UL, DU, ST>, SU> &variable, int exponent)
02074 {return Variable<Quantity<
02075 dimension::Dimension<BSUtilities::Rational<RL_N, RL_D>,
02076 BSUtilities::Rational<RM_N, RM_D>,
02077 BSUtilities::Rational<RT_N, RT_D>,
02078 BSUtilities::Rational<RE_N, RE_D>,
02079 BSUtilities::Rational<RTE_N, RTE_D>,
02080 BSUtilities::Rational<RA_N, RA_D>,
02081 BSUtilities::Rational<RLU_N, RLU_D> >,
02082 BT, UL, DU, ST>, SU>
02083 (std::ldexp (variable.value (), exponent));}
02084
02086
02092 template<template<class, class> class Q,
02093 template<class, class> class Q1, class BT,
02094 long RL_N, long RL_D, long RM_N, long RM_D,
02095 long RT_N, long RT_D, long RE_N, long RE_D,
02096 long RTE_N, long RTE_D, long RA_N, long RA_D,
02097 long RLU_N, long RLU_D,
02098 class UL, class DU, class ST, class SU>
02099 inline Variable<Quantity<
02100 dimension::Dimension<BSUtilities::Rational<RL_N, RL_D>,
02101 BSUtilities::Rational<RM_N, RM_D>,
02102 BSUtilities::Rational<RT_N, RT_D>,
02103 BSUtilities::Rational<RE_N, RE_D>,
02104 BSUtilities::Rational<RTE_N, RTE_D>,
02105 BSUtilities::Rational<RA_N, RA_D>,
02106 BSUtilities::Rational<RLU_N, RLU_D> >,
02107 BT, UL, DU, ST>, SU>
02108 fmod (const Q<Quantity<
02109 dimension::Dimension<BSUtilities::Rational<RL_N, RL_D>,
02110 BSUtilities::Rational<RM_N, RM_D>,
02111 BSUtilities::Rational<RT_N, RT_D>,
02112 BSUtilities::Rational<RE_N, RE_D>,
02113 BSUtilities::Rational<RTE_N, RTE_D>,
02114 BSUtilities::Rational<RA_N, RA_D>,
02115 BSUtilities::Rational<RLU_N, RLU_D> >,
02116 BT, UL, DU, ST>, SU> &quantity1,
02117 const Q1<Quantity<
02118 dimension::Dimension<BSUtilities::Rational<RL_N, RL_D>,
02119 BSUtilities::Rational<RM_N, RM_D>,
02120 BSUtilities::Rational<RT_N, RT_D>,
02121 BSUtilities::Rational<RE_N, RE_D>,
02122 BSUtilities::Rational<RTE_N, RTE_D>,
02123 BSUtilities::Rational<RA_N, RA_D>,
02124 BSUtilities::Rational<RLU_N, RLU_D> >,
02125 BT, UL, DU, ST>, SU> &quantity2)
02126 {return
02127 Variable<Quantity<
02128 dimension::Dimension<BSUtilities::Rational<RL_N, RL_D>,
02129 BSUtilities::Rational<RM_N, RM_D>,
02130 BSUtilities::Rational<RT_N, RT_D>,
02131 BSUtilities::Rational<RE_N, RE_D>,
02132 BSUtilities::Rational<RTE_N, RTE_D>,
02133 BSUtilities::Rational<RA_N, RA_D>,
02134 BSUtilities::Rational<RLU_N, RLU_D> >,
02135 BT, UL, DU, ST>, SU>
02136 (std::fmod (quantity1.value (), quantity2.value ()));
02137 }
02138
02140
02146 template<template<class, class> class Q,
02147 template<class, class> class Q1, class BT,
02148 long RL_N, long RL_D, long RM_N, long RM_D,
02149 long RT_N, long RT_D, long RE_N, long RE_D,
02150 long RTE_N, long RTE_D, long RA_N, long RA_D,
02151 long RLU_N, long RLU_D,
02152 class UL, class DU, class ST, class SU, class SU1>
02153 inline Variable<Quantity<
02154 dimension::Dimension<BSUtilities::Rational<RL_N, RL_D>,
02155 BSUtilities::Rational<RM_N, RM_D>,
02156 BSUtilities::Rational<RT_N, RT_D>,
02157 BSUtilities::Rational<RE_N, RE_D>,
02158 BSUtilities::Rational<RTE_N, RTE_D>,
02159 BSUtilities::Rational<RA_N, RA_D>,
02160 BSUtilities::Rational<RLU_N, RLU_D> >,
02161 BT, UL, DU, ST>, SU>
02162 fmod (const Q<Quantity<
02163 dimension::Dimension<BSUtilities::Rational<RL_N, RL_D>,
02164 BSUtilities::Rational<RM_N, RM_D>,
02165 BSUtilities::Rational<RT_N, RT_D>,
02166 BSUtilities::Rational<RE_N, RE_D>,
02167 BSUtilities::Rational<RTE_N, RTE_D>,
02168 BSUtilities::Rational<RA_N, RA_D>,
02169 BSUtilities::Rational<RLU_N, RLU_D> >,
02170 BT, UL, DU, ST>, SU> &quantity1,
02171 const Q1<Quantity<
02172 dimension::Dimension<BSUtilities::Rational<RL_N, RL_D>,
02173 BSUtilities::Rational<RM_N, RM_D>,
02174 BSUtilities::Rational<RT_N, RT_D>,
02175 BSUtilities::Rational<RE_N, RE_D>,
02176 BSUtilities::Rational<RTE_N, RTE_D>,
02177 BSUtilities::Rational<RA_N, RA_D>,
02178 BSUtilities::Rational<RLU_N, RLU_D> >,
02179 BT, UL, DU, ST>, SU1> &quantity2)
02180 {return
02181 Variable<Quantity<
02182 dimension::Dimension<BSUtilities::Rational<RL_N, RL_D>,
02183 BSUtilities::Rational<RM_N, RM_D>,
02184 BSUtilities::Rational<RT_N, RT_D>,
02185 BSUtilities::Rational<RE_N, RE_D>,
02186 BSUtilities::Rational<RTE_N, RTE_D>,
02187 BSUtilities::Rational<RA_N, RA_D>,
02188 BSUtilities::Rational<RLU_N, RLU_D> >,
02189 BT, UL, DU, ST>, SU>
02190 (Reverse<SU, ST>::VAL
02191 (std::fmod (quantity1.standard_value (),
02192 quantity2.standard_value ())));
02193 }
02194
02196
02201 template <template<class, class> class Q, class BT,
02202 long RL_N, long RL_D, long RM_N, long RM_D,
02203 long RT_N, long RT_D, long RE_N, long RE_D,
02204 long RTE_N, long RTE_D, long RA_N, long RA_D,
02205 long RLU_N, long RLU_D, class UL, class DU, class ST, class SU,
02206 template<class, class> class Q1, class BT1,
02207 long RL1_N, long RL1_D, long RM1_N, long RM1_D,
02208 long RT1_N, long RT1_D, long RE1_N, long RE1_D,
02209 long RTE1_N, long RTE1_D, long RA1_N, long RA1_D,
02210 long RLU1_N, long RLU1_D, class UL1, class DU1, class SU1>
02211 inline Variable<Quantity<
02212 dimension::Dimension<BSUtilities::Rational<RL_N, RL_D>,
02213 BSUtilities::Rational<RM_N, RM_D>,
02214 BSUtilities::Rational<RT_N, RT_D>,
02215 BSUtilities::Rational<RE_N, RE_D>,
02216 BSUtilities::Rational<RTE_N, RTE_D>,
02217 BSUtilities::Rational<RA_N, RA_D>,
02218 BSUtilities::Rational<RLU_N, RLU_D> >,
02219 BT, UL, DU, ST>, SU>
02220 fmod (const Q<Quantity<
02221 dimension::Dimension<BSUtilities::Rational<RL_N, RL_D>,
02222 BSUtilities::Rational<RM_N, RM_D>,
02223 BSUtilities::Rational<RT_N, RT_D>,
02224 BSUtilities::Rational<RE_N, RE_D>,
02225 BSUtilities::Rational<RTE_N, RTE_D>,
02226 BSUtilities::Rational<RA_N, RA_D>,
02227 BSUtilities::Rational<RLU_N, RLU_D> >,
02228 BT, UL, DU, ST>, SU> &quantity1,
02229 const Q1<Quantity<
02230 dimension::Dimension<BSUtilities::Rational<RL1_N, RL1_D>,
02231 BSUtilities::Rational<RM1_N, RM1_D>,
02232 BSUtilities::Rational<RT1_N, RT1_D>,
02233 BSUtilities::Rational<RE1_N, RE1_D>,
02234 BSUtilities::Rational<RTE1_N, RTE1_D>,
02235 BSUtilities::Rational<RA1_N, RA1_D>,
02236 BSUtilities::Rational<RLU1_N, RLU1_D> >,
02237 BT1, UL1, DU1, ST>, SU1> &quantity2)
02238 {return Variable<Quantity<
02239 dimension::Dimension<BSUtilities::Rational<RL_N, RL_D>,
02240 BSUtilities::Rational<RM_N, RM_D>,
02241 BSUtilities::Rational<RT_N, RT_D>,
02242 BSUtilities::Rational<RE_N, RE_D>,
02243 BSUtilities::Rational<RTE_N, RTE_D>,
02244 BSUtilities::Rational<RA_N, RA_D>,
02245 BSUtilities::Rational<RLU_N, RLU_D> >,
02246 BT, UL, DU, ST>, SU>
02247 (Reverse<SU, ST>::VAL (std::fmod (quantity1.standard_value (),
02248 Standardize<typename CheckSecondDimension<
02249 Variable<Quantity<
02250 dimension::Dimension<BSUtilities::Rational<RL_N, RL_D>,
02251 BSUtilities::Rational<RM_N, RM_D>,
02252 BSUtilities::Rational<RT_N, RT_D>,
02253 BSUtilities::Rational<RE_N, RE_D>,
02254 BSUtilities::Rational<RTE_N, RTE_D>,
02255 BSUtilities::Rational<RA_N, RA_D>,
02256 BSUtilities::Rational<RLU_N, RLU_D> >,
02257 BT, UL, DU, ST>, SU>,
02258 Q1<Quantity<
02259 dimension::Dimension<BSUtilities::Rational<RL1_N, RL1_D>,
02260 BSUtilities::Rational<RM1_N, RM1_D>,
02261 BSUtilities::Rational<RT1_N, RT1_D>,
02262 BSUtilities::Rational<RE1_N, RE1_D>,
02263 BSUtilities::Rational<RTE1_N, RTE1_D>,
02264 BSUtilities::Rational<RA1_N, RA1_D>,
02265 BSUtilities::Rational<RLU1_N, RLU1_D> >,
02266 BT1, UL1, DU1, ST>, SU1> >::RET::Unit, ST>::VAL
02267 (quantity2.value ()))));
02268 }
02269
02271
02274 template<template<class, class> class Q, class BT,
02275 long RL_N, long RL_D, long RM_N, long RM_D,
02276 long RT_N, long RT_D, long RE_N, long RE_D,
02277 long RTE_N, long RTE_D, long RA_N, long RA_D,
02278 long RLU_N, long RLU_D, class UL, class DU, class ST, class SU>
02279 inline Variable<Quantity<
02280 dimension::Dimension<BSUtilities::Rational<RL_N, RL_D>,
02281 BSUtilities::Rational<RM_N, RM_D>,
02282 BSUtilities::Rational<RT_N, RT_D>,
02283 BSUtilities::Rational<RE_N, RE_D>,
02284 BSUtilities::Rational<RTE_N, RTE_D>,
02285 BSUtilities::Rational<RA_N, RA_D>,
02286 BSUtilities::Rational<RLU_N, RLU_D> >,
02287 BT, UL, DU, ST>, SU>
02288 modf (const Q<Quantity<
02289 dimension::Dimension<BSUtilities::Rational<RL_N, RL_D>,
02290 BSUtilities::Rational<RM_N, RM_D>,
02291 BSUtilities::Rational<RT_N, RT_D>,
02292 BSUtilities::Rational<RE_N, RE_D>,
02293 BSUtilities::Rational<RTE_N, RTE_D>,
02294 BSUtilities::Rational<RA_N, RA_D>,
02295 BSUtilities::Rational<RLU_N, RLU_D> >,
02296 BT, UL, DU, ST>, SU> &quantity,
02297 Variable<Quantity<
02298 dimension::Dimension<BSUtilities::Rational<RL_N, RL_D>,
02299 BSUtilities::Rational<RM_N, RM_D>,
02300 BSUtilities::Rational<RT_N, RT_D>,
02301 BSUtilities::Rational<RE_N, RE_D>,
02302 BSUtilities::Rational<RTE_N, RTE_D>,
02303 BSUtilities::Rational<RA_N, RA_D>,
02304 BSUtilities::Rational<RLU_N, RLU_D> >,
02305 BT, UL, DU, ST>, SU> *integral)
02306 {ST i_ptr;
02307 Variable<Quantity<
02308 dimension::Dimension<BSUtilities::Rational<RL_N, RL_D>,
02309 BSUtilities::Rational<RM_N, RM_D>,
02310 BSUtilities::Rational<RT_N, RT_D>,
02311 BSUtilities::Rational<RE_N, RE_D>,
02312 BSUtilities::Rational<RTE_N, RTE_D>,
02313 BSUtilities::Rational<RA_N, RA_D>,
02314 BSUtilities::Rational<RLU_N, RLU_D> >,
02315 BT, UL, DU, ST>, SU>
02316 new_variable (std::modf (quantity.value (), &i_ptr));
02317 Variable<Quantity<
02318 dimension::Dimension<BSUtilities::Rational<RL_N, RL_D>,
02319 BSUtilities::Rational<RM_N, RM_D>,
02320 BSUtilities::Rational<RT_N, RT_D>,
02321 BSUtilities::Rational<RE_N, RE_D>,
02322 BSUtilities::Rational<RTE_N, RTE_D>,
02323 BSUtilities::Rational<RA_N, RA_D>,
02324 BSUtilities::Rational<RLU_N, RLU_D> >,
02325 BT, UL, DU, ST>, SU> int_quantity (i_ptr);
02326 *integral = int_quantity; return new_variable;
02327 }
02328
02330
02334 template<template<class, class> class Q, class BT,
02335 long RL_N, long RL_D, long RM_N, long RM_D,
02336 long RT_N, long RT_D, long RE_N, long RE_D,
02337 long RTE_N, long RTE_D, long RA_N, long RA_D,
02338 long RLU_N, long RLU_D,
02339 class UL, class DU, class ST, class SU, class SU1>
02340 inline Variable<Quantity<
02341 dimension::Dimension<BSUtilities::Rational<RL_N, RL_D>,
02342 BSUtilities::Rational<RM_N, RM_D>,
02343 BSUtilities::Rational<RT_N, RT_D>,
02344 BSUtilities::Rational<RE_N, RE_D>,
02345 BSUtilities::Rational<RTE_N, RTE_D>,
02346 BSUtilities::Rational<RA_N, RA_D>,
02347 BSUtilities::Rational<RLU_N, RLU_D> >,
02348 BT, UL, DU, ST>, SU>
02349 modf (const Q<Quantity<
02350 dimension::Dimension<BSUtilities::Rational<RL_N, RL_D>,
02351 BSUtilities::Rational<RM_N, RM_D>,
02352 BSUtilities::Rational<RT_N, RT_D>,
02353 BSUtilities::Rational<RE_N, RE_D>,
02354 BSUtilities::Rational<RTE_N, RTE_D>,
02355 BSUtilities::Rational<RA_N, RA_D>,
02356 BSUtilities::Rational<RLU_N, RLU_D> >,
02357 BT, UL, DU, ST>, SU> &quantity,
02358 Variable<Quantity<
02359 dimension::Dimension<BSUtilities::Rational<RL_N, RL_D>,
02360 BSUtilities::Rational<RM_N, RM_D>,
02361 BSUtilities::Rational<RT_N, RT_D>,
02362 BSUtilities::Rational<RE_N, RE_D>,
02363 BSUtilities::Rational<RTE_N, RTE_D>,
02364 BSUtilities::Rational<RA_N, RA_D>,
02365 BSUtilities::Rational<RLU_N, RLU_D> >,
02366 BT, UL, DU, ST>, SU1> *integral)
02367 {ST i_ptr;
02368 Variable<Quantity<
02369 dimension::Dimension<BSUtilities::Rational<RL_N, RL_D>,
02370 BSUtilities::Rational<RM_N, RM_D>,
02371 BSUtilities::Rational<RT_N, RT_D>,
02372 BSUtilities::Rational<RE_N, RE_D>,
02373 BSUtilities::Rational<RTE_N, RTE_D>,
02374 BSUtilities::Rational<RA_N, RA_D>,
02375 BSUtilities::Rational<RLU_N, RLU_D> >,
02376 BT, UL, DU, ST>, SU>
02377 new_variable (std::modf (quantity.value (), &i_ptr));
02378 Variable<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>, SU1> int_quantity (i_ptr, SU ());
02387 *integral = int_quantity; return new_variable;
02388 }
02389
02391
02395 template<template<class, class> class Q, class BT,
02396 long RL_N, long RL_D, long RM_N, long RM_D,
02397 long RT_N, long RT_D, long RE_N, long RE_D,
02398 long RTE_N, long RTE_D, long RA_N, long RA_D,
02399 long RLU_N, long RLU_D,
02400 class UL, class DU, class ST, class SU, class SU1,
02401 class BT1,
02402 long RL1_N, long RL1_D, long RM1_N, long RM1_D,
02403 long RT1_N, long RT1_D, long RE1_N, long RE1_D,
02404 long RTE1_N, long RTE1_D, long RA1_N, long RA1_D,
02405 long RLU1_N, long RLU1_D, class UL1, class DU1>
02406 inline Variable<Quantity<
02407 dimension::Dimension<BSUtilities::Rational<RL_N, RL_D>,
02408 BSUtilities::Rational<RM_N, RM_D>,
02409 BSUtilities::Rational<RT_N, RT_D>,
02410 BSUtilities::Rational<RE_N, RE_D>,
02411 BSUtilities::Rational<RTE_N, RTE_D>,
02412 BSUtilities::Rational<RA_N, RA_D>,
02413 BSUtilities::Rational<RLU_N, RLU_D> >,
02414 BT, UL, DU, ST>, SU>
02415 modf (const Q<Quantity<
02416 dimension::Dimension<BSUtilities::Rational<RL_N, RL_D>,
02417 BSUtilities::Rational<RM_N, RM_D>,
02418 BSUtilities::Rational<RT_N, RT_D>,
02419 BSUtilities::Rational<RE_N, RE_D>,
02420 BSUtilities::Rational<RTE_N, RTE_D>,
02421 BSUtilities::Rational<RA_N, RA_D>,
02422 BSUtilities::Rational<RLU_N, RLU_D> >,
02423 BT, UL, DU, ST>, SU> &quantity,
02424 Variable<Quantity<
02425 dimension::Dimension<BSUtilities::Rational<RL1_N, RL1_D>,
02426 BSUtilities::Rational<RM1_N, RM1_D>,
02427 BSUtilities::Rational<RT1_N, RT1_D>,
02428 BSUtilities::Rational<RE1_N, RE1_D>,
02429 BSUtilities::Rational<RTE1_N, RTE1_D>,
02430 BSUtilities::Rational<RA1_N, RA1_D>,
02431 BSUtilities::Rational<RLU1_N, RLU1_D> >,
02432 BT1, UL1, DU1, ST>, SU1> *integral)
02433 {ST i_ptr;
02434 typename CheckSecondDimension<Variable<Quantity<
02435 dimension::Dimension<BSUtilities::Rational<RL1_N, RL1_D>,
02436 BSUtilities::Rational<RM1_N, RM1_D>,
02437 BSUtilities::Rational<RT1_N, RT1_D>,
02438 BSUtilities::Rational<RE1_N, RE1_D>,
02439 BSUtilities::Rational<RTE1_N, RTE1_D>,
02440 BSUtilities::Rational<RA1_N, RA1_D>,
02441 BSUtilities::Rational<RLU1_N, RLU1_D> >,
02442 BT1, UL1, DU1, ST>, SU1>,
02443 Variable<Quantity<
02444 dimension::Dimension<BSUtilities::Rational<RL_N, RL_D>,
02445 BSUtilities::Rational<RM_N, RM_D>,
02446 BSUtilities::Rational<RT_N, RT_D>,
02447 BSUtilities::Rational<RE_N, RE_D>,
02448 BSUtilities::Rational<RTE_N, RTE_D>,
02449 BSUtilities::Rational<RA_N, RA_D>,
02450 BSUtilities::Rational<RLU_N, RLU_D> >,
02451 BT, UL, DU, ST>, SU> >::RET
02452 new_variable (Reverse<SU, ST>::VAL
02453 (std::modf (quantity.standard_value (), &i_ptr)));
02454 *integral = Variable<Quantity<
02455 dimension::Dimension<BSUtilities::Rational<RL1_N, RL1_D>,
02456 BSUtilities::Rational<RM1_N, RM1_D>,
02457 BSUtilities::Rational<RT1_N, RT1_D>,
02458 BSUtilities::Rational<RE1_N, RE1_D>,
02459 BSUtilities::Rational<RTE1_N, RTE1_D>,
02460 BSUtilities::Rational<RA1_N, RA1_D>,
02461 BSUtilities::Rational<RLU1_N, RLU1_D> >,
02462 BT1, UL1, DU1, ST>, SU1>
02463 (Reverse<SU1, ST>::VAL (i_ptr));
02464 return new_variable;
02465 }
02466
02467 }
02468
02469 #endif