Library for big numbers from http://www.ttmath.org/

Dependents:   PIDHeater82 Conceptcontroller_v_1_0 AlarmClockApp COG4050_adxl355_tilt ... more

Embed: (wiki syntax)

« Back to documentation index

CGamma< ValueType > Struct Template Reference

CGamma< ValueType > Struct Template Reference

#include <ttmathobjects.h>

Public Member Functions

void InitAll ()

Data Fields

std::vector< ValueType > fact
std::vector< ValueType > bern
History< ValueType > history

Detailed Description

template<class ValueType>
struct ttmath::CGamma< ValueType >

this is an auxiliary class used when calculating Gamma() or Factorial()

in multithreaded environment you can provide an object of this class to the Gamma() or Factorial() function, e.g; typedef Big<1, 3> MyBig; MyBig x = 123456; CGamma<MyBig> cgamma; std::cout << Gamma(x, cgamma); each thread should have its own CGamma<> object

in a single-thread environment a CGamma<> object is a static variable in a second version of Gamma() and you don't have to explicitly use it, e.g. typedef Big<1, 3> MyBig; MyBig x = 123456; std::cout << Gamma(x);

Definition at line 739 of file ttmathobjects.h.


Member Function Documentation

void InitAll (  )

this method prepares some coefficients: factorials and Bernoulli numbers stored in 'fact' and 'bern' objects

how many values should be depends on the size of the mantissa - if the mantissa is larger then we must calculate more values for a mantissa which consists of 256 bits (8 words on a 32bit platform) we have to calculate about 30 values (the size of fact and bern will be 30), and for a 2048 bits mantissa we have to calculate 306 coefficients

you don't have to call this method, these coefficients will be automatically calculated when they are needed

you must note that calculating these coefficients is a little time-consuming operation, (especially when the mantissa is large) and first call to Gamma() or Factorial() can take more time than next calls, and in the end this is the point when InitAll() comes in handy: you can call this method somewhere at the beginning of your program

this method prepares some coefficients: factorials and Bernoulli numbers stored in 'fact' and 'bern' objects

we're defining the method here because we're using Gamma() function which is not available in ttmathobjects.h

read the doc info in ttmathobjects.h file where CGamma<> struct is declared

Definition at line 2813 of file ttmath.h.


Field Documentation

std::vector<ValueType> bern

this table holds Bernoulli numbers 1 -0.5 0.166666666666666666666666667 0 -0.0333333333333333333333333333 0 0.0238095238095238095238095238 0 -0.0333333333333333333333333333 0 0.075757575757575757575757576 .....

Definition at line 770 of file ttmathobjects.h.

std::vector<ValueType> fact

this table holds factorials 1 1 2 6 24 120 720 .......

Definition at line 752 of file ttmathobjects.h.

History<ValueType> history

here we store some calculated values (this is for speeding up, if the next argument of Gamma() or Factorial() is in the 'history' then the result we are not calculating but simply return from the 'history' object)

Definition at line 779 of file ttmathobjects.h.