ROOTPWA
Public Member Functions | Private Attributes | List of all members
TFracNum Class Reference

Fractional Number. More...

#include <TFracNum.h>

Public Member Functions

 TFracNum ()
 Default constructor with numerator and denominator set to 1.
 TFracNum (Int_t mN, Int_t mD, Int_t *N, Int_t *D, Int_t s)
 Constructor using the internal representation of the class.
 TFracNum (Int_t inom, Int_t iden)
 Constructor by the integer values of the numerator and denominator.
 TFracNum (Int_t N, Int_t D, const char *s)
 Constructor when numerator and denominator are factorial numbers, N!/D!
Int_t DenomCommonDivisor (const TFracNum &) const
 Largest common divisor of numerator and denominator.
TFracNumSumSignedRoots (TFracNum *)
 The return value c satisfies ssqrt(c)=ssqrt(a)+ssqrt(b)
const char * FracString ()
 String in the form Num/Den. If Den=1, only Num is given.
const char * FracStringSqrt ()
 String of the square-root in the form Num/Den#RNum/RDen
Double_t Print () const
 Complete information about the fractional number is put to cout.
Double_t PrintToErr () const
 Complete information about the fractional number is put to cerr.
Double_t Dval ()
 Return the double-precision real value.
Bool_t Sqrt ()
 Try square root operation.
Bool_t FlipSign ()
 Flip sign of number.
Bool_t Abs ()
 Force sign to plus.
Bool_t Invert ()
 Inversion of number, so nominator and denumerator are flipped.
Int_t GetSign ()
 Return sign as +1 (also for zero or undefined number) or -1.
Int_t GetNumerator ()
 Return numerator.
Int_t GetDenominator ()
 Return denominator.
Bool_t PrintDifference (const TFracNum &) const
 Output some comparative values for two fractional numbers.
char * HeaderString ()
 String containing NOM and DEN.
Bool_t operator== (const TFracNum &) const
 Check whether two fractional numbers are equal.
Bool_t operator> (const TFracNum &) const
 Check whether left-hand number is greater than right-hand number.
TFracNum operator* (const TFracNum &) const
 Multiply two fractional numbers.
TFracNum operator+ (const TFracNum &) const
 Add two fractional numbers.
Bool_t SetINTs ()

Private Attributes

Int_t maxPrimNom
Int_t maxPrimDen
Int_tNOM
Int_tDEN
Int_t sign_prefac
Int_t NOM_INT
Int_t DEN_INT
Double_t dvalue

Detailed Description

Fractional Number.

Fractional number with numerator and denominator represented by their prime number decomposition.
Some arithmetical operations are included but not complete.

Author
Jan.F.nosp@m.ried.nosp@m.rich@.nosp@m.ph.t.nosp@m.um.de

Definition at line 38 of file TFracNum.h.

Constructor & Destructor Documentation

TFracNum::TFracNum ( )
inline

Default constructor with numerator and denominator set to 1.

Definition at line 71 of file TFracNum.h.

References DEN, maxPrimDen, maxPrimNom, NOM, and sign_prefac.

TFracNum::TFracNum ( Int_t  mN,
Int_t  mD,
Int_t N,
Int_t D,
Int_t  s 
)

Constructor using the internal representation of the class.

Parameters
mNindex of the largest prime number in the numerator
mDindex of the largest prime number in the denominator
NField of exponents of the numerator's prime numbers up to mN
DField of exponents of the denominator's prime numbers up to mD
sSign variable
1 or -1 depending on the sign
s =-6666 means "undetermined" (this is for example a consequence of a division zero by zero)
-7777 means "infinity" (for example a consequence of division by zero)

Definition at line 13 of file TFracNum.cc.

References D(), debugFracNum, i, and Int_t.

TFracNum::TFracNum ( Int_t  inom,
Int_t  iden 
)

Constructor by the integer values of the numerator and denominator.

Parameters
inomnumerator
idendenominator

Definition at line 73 of file TFracNum.cc.

References debugFracNum, Double_t, i, Int_t, MAXPRIMSQUARED, NPRIMFIELD, and PRIMES.

TFracNum::TFracNum ( Int_t  N,
Int_t  D,
const char *  s 
)

Constructor when numerator and denominator are factorial numbers, N!/D!

This method is much faster than giving the factorials to TFracNum(inom, iden)

Parameters
Nnumerator
Ddenominator
scontrol string. For described function, set to "factorial", otherwise the number is set to 1

Definition at line 32 of file TFracNum.cc.

References D(), debugFracNum, i, Int_t, NPRIMFIELD, and PRIMES.

Member Function Documentation

Bool_t TFracNum::Abs ( )

Force sign to plus.

Definition at line 311 of file TFracNum.cc.

Referenced by ClebschGordanBox::ClebschGordan(), ClebschGordanInteger(), and SumSignedRoots().

Int_t TFracNum::DenomCommonDivisor ( const TFracNum b) const

Largest common divisor of numerator and denominator.

Definition at line 246 of file TFracNum.cc.

References DEN, i, Int_t, maxPrimDen, and PRIMES.

Double_t TFracNum::Dval ( )
inline

Return the double-precision real value.

Definition at line 140 of file TFracNum.h.

References dvalue.

Referenced by TSpinWaveFunction::CheckCGFormula(), and SumSignedRoots().

Bool_t TFracNum::FlipSign ( )
const char * TFracNum::FracString ( )

String in the form Num/Den. If Den=1, only Num is given.

Definition at line 623 of file TFracNum.cc.

References IOUTSTRING.

Referenced by TSpinWaveFunction::CheckCGFormula(), and ClebschGordanBox::ClebschGordan().

const char * TFracNum::FracStringSqrt ( )

String of the square-root in the form Num/Den#RNum/RDen

All numbers after the '#' are to be square-rooted, so Num/Den#RNum/RDen=Num/Den*sqrt(RNum/RDen)

Definition at line 643 of file TFracNum.cc.

References Bool_t, Int_t, IOUTSTRING, NULLSTRING, PRIMES, and SQUAREROOT_CHAR.

Referenced by TLSContrib::TLSContrib().

Int_t TFracNum::GetDenominator ( )
inline

Return denominator.

Definition at line 163 of file TFracNum.h.

References DEN_INT.

Referenced by TJSS::PrintHFILE().

Int_t TFracNum::GetNumerator ( )
inline

Return numerator.

Definition at line 160 of file TFracNum.h.

References NOM_INT.

Referenced by TJSS::PrintHFILE().

Int_t TFracNum::GetSign ( )

Return sign as +1 (also for zero or undefined number) or -1.

Definition at line 350 of file TFracNum.cc.

Referenced by ClebschGordanBox::ClebschGordan(), ClebschGordanInteger(), and TJSS::PrintHFILE().

char * TFracNum::HeaderString ( )

String containing NOM and DEN.

Definition at line 405 of file TFracNum.cc.

Bool_t TFracNum::Invert ( )

Inversion of number, so nominator and denumerator are flipped.

Definition at line 320 of file TFracNum.cc.

References Int_t.

Referenced by TLSContrib::Add(), ClebschGordanBox::ClebschGordan(), ClebschGordanInteger(), TLSNonRel::PrintG(), and TLSContrib::TLSContrib().

TFracNum TFracNum::operator* ( const TFracNum b) const

Multiply two fractional numbers.

Definition at line 434 of file TFracNum.cc.

References debugFracNum, DEN, i, Int_t, maxPrimDen, maxPrimNom, NOM, and sign_prefac.

TFracNum TFracNum::operator+ ( const TFracNum b) const

Add two fractional numbers.

Definition at line 423 of file TFracNum.cc.

References DEN_INT, Int_t, NOM_INT, and sign_prefac.

Bool_t TFracNum::operator== ( const TFracNum b) const

Check whether two fractional numbers are equal.

Definition at line 356 of file TFracNum.cc.

References DEN, i, Int_t, maxPrimDen, maxPrimNom, NOM, and sign_prefac.

Bool_t TFracNum::operator> ( const TFracNum b) const

Check whether left-hand number is greater than right-hand number.

Definition at line 416 of file TFracNum.cc.

References dvalue.

Double_t TFracNum::Print ( ) const

Complete information about the fractional number is put to cout.

Definition at line 511 of file TFracNum.cc.

References debugFracNum, Double_t, i, Int_t, and PRIMES.

Referenced by ClebschGordanBox::ClebschGordan(), and ClebschGordanInteger().

Bool_t TFracNum::PrintDifference ( const TFracNum b) const

Output some comparative values for two fractional numbers.

Definition at line 369 of file TFracNum.cc.

References DEN, i, Int_t, maxPrimDen, maxPrimNom, NOM, and sign_prefac.

Double_t TFracNum::PrintToErr ( ) const

Complete information about the fractional number is put to cerr.

Definition at line 568 of file TFracNum.cc.

References Double_t, i, Int_t, and PRIMES.

Bool_t TFracNum::SetINTs ( )

Definition at line 207 of file TFracNum.cc.

References Double_t, Int_t, and PRIMES.

Referenced by ClebschGordanBox::ClebschGordan().

Bool_t TFracNum::Sqrt ( )

Try square root operation.

In case of success, return true. In case this does not lead to a fractional number, the number is left untouched and return value is false

Definition at line 281 of file TFracNum.cc.

References debugFracNum, i, and Int_t.

Referenced by ClebschGordanBox::ClebschGordan(), ClebschGordanInteger(), and SumSignedRoots().

TFracNum * TFracNum::SumSignedRoots ( TFracNum b)

The return value c satisfies ssqrt(c)=ssqrt(a)+ssqrt(b)

Here the signed square root function ssqrt(n)=sign(n)*sqrt(abs(n)) is used

Definition at line 259 of file TFracNum.cc.

References Abs(), Bool_t, Dval(), FlipSign(), Sqrt(), and TFracNum_Two().

Referenced by TLSContrib::Add(), TTensorTerm::AddTwoTerms(), and TLSContrib::TLSContrib().

Member Data Documentation

Int_t* TFracNum::DEN
private

Definition at line 55 of file TFracNum.h.

Referenced by DenomCommonDivisor(), operator*(), operator==(), PrintDifference(), and TFracNum().

Int_t TFracNum::DEN_INT
private

Definition at line 66 of file TFracNum.h.

Referenced by GetDenominator(), and operator+().

Double_t TFracNum::dvalue
private

Definition at line 67 of file TFracNum.h.

Referenced by Dval(), and operator>().

Int_t TFracNum::maxPrimDen
private

Definition at line 49 of file TFracNum.h.

Referenced by DenomCommonDivisor(), operator*(), operator==(), PrintDifference(), and TFracNum().

Int_t TFracNum::maxPrimNom
private

Definition at line 46 of file TFracNum.h.

Referenced by operator*(), operator==(), PrintDifference(), and TFracNum().

Int_t* TFracNum::NOM
private

Definition at line 53 of file TFracNum.h.

Referenced by operator*(), operator==(), PrintDifference(), and TFracNum().

Int_t TFracNum::NOM_INT
private

Definition at line 65 of file TFracNum.h.

Referenced by GetNumerator(), and operator+().

Int_t TFracNum::sign_prefac
private

Definition at line 62 of file TFracNum.h.

Referenced by operator*(), operator+(), operator==(), PrintDifference(), and TFracNum().


The documentation for this class was generated from the following files: