Library for big numbers from http://www.ttmath.org/
Dependents: PIDHeater82 Conceptcontroller_v_1_0 AlarmClockApp COG4050_adxl355_tilt ... more
ttmath::auxiliaryfunctions Namespace Reference
Functions | |
template<class ValueType > | |
uint | PrepareSin (ValueType &x, bool &change_sign) |
template<class ValueType > | |
ValueType | Sin0pi05 (const ValueType &x) |
template<class ValueType > | |
ValueType | ASin_0 (const ValueType &x) |
template<class ValueType > | |
ValueType | ASin_1 (const ValueType &x) |
template<class ValueType > | |
ValueType | ATan0 (const ValueType &x) |
template<class ValueType > | |
ValueType | ATan01 (const ValueType &x) |
template<class ValueType > | |
ValueType | ATanGreaterThanPlusOne (const ValueType &x) |
template<class ValueType > | |
void | SetFactorialSequence (std::vector< ValueType > &fact, uint more=20) |
template<class ValueType > | |
ValueType | SetBernoulliNumbersSum (CGamma< ValueType > &cgamma, const ValueType &n_, uint m, const volatile StopCalculating *stop=0) |
template<class ValueType > | |
bool | SetBernoulliNumbersMore (CGamma< ValueType > &cgamma, uint start, const volatile StopCalculating *stop=0) |
template<class ValueType > | |
bool | SetBernoulliNumbers (CGamma< ValueType > &cgamma, uint more=20, const volatile StopCalculating *stop=0) |
template<class ValueType > | |
ValueType | GammaFactorialHighSum (const ValueType &n, CGamma< ValueType > &cgamma, ErrorCode &err, const volatile StopCalculating *stop) |
template<class ValueType > | |
ValueType | GammaFactorialHigh (const ValueType &n, CGamma< ValueType > &cgamma, ErrorCode &err, const volatile StopCalculating *stop) |
template<class ValueType > | |
ValueType | GammaPlusHigh (ValueType n, CGamma< ValueType > &cgamma, ErrorCode &err, const volatile StopCalculating *stop) |
template<class ValueType > | |
ValueType | GammaPlusLowIntegerInt (uint n, CGamma< ValueType > &cgamma) |
template<class ValueType > | |
ValueType | GammaPlusLowInteger (const ValueType &n, CGamma< ValueType > &cgamma) |
template<class ValueType > | |
ValueType | GammaPlusLow (ValueType n, CGamma< ValueType > &cgamma, ErrorCode &err, const volatile StopCalculating *stop) |
template<class ValueType > | |
ValueType | GammaPlus (const ValueType &n, CGamma< ValueType > &cgamma, ErrorCode &err, const volatile StopCalculating *stop) |
template<class ValueType > | |
ValueType | GammaMinus (const ValueType &n, CGamma< ValueType > &cgamma, ErrorCode &err, const volatile StopCalculating *stop) |
template<class ValueType > | |
ValueType | Factorial2 (ValueType x, CGamma< ValueType > *cgamma=0, ErrorCode *err=0, const volatile StopCalculating *stop=0) |
Detailed Description
trigonometric functions
Function Documentation
ValueType ttmath::auxiliaryfunctions::ASin_0 | ( | const ValueType & | x ) |
ValueType ttmath::auxiliaryfunctions::ASin_1 | ( | const ValueType & | x ) |
an auxiliary function for calculating the Arc Sine
we're calculating asin from the following formula: asin(x) = pi/2 - sqrt(2)*sqrt(1-x) * asin_temp asin_temp = 1 + (1*(1-x))/((2*3)*(2)) + (1*3*(1-x)^2)/((2*4*5)*(4)) + (1*3*5*(1-x)^3)/((2*4*6*7)*(8)) + ...
where abs(x) <= 1
we're using this formula when x is from (1/2, 1>
ValueType ttmath::auxiliaryfunctions::ATan0 | ( | const ValueType & | x ) |
ValueType ttmath::auxiliaryfunctions::ATan01 | ( | const ValueType & | x ) |
ValueType ttmath::auxiliaryfunctions::ATanGreaterThanPlusOne | ( | const ValueType & | x ) |
ValueType ttmath::auxiliaryfunctions::Factorial2 | ( | ValueType | x, |
CGamma< ValueType > * | cgamma = 0 , |
||
ErrorCode * | err = 0 , |
||
const volatile StopCalculating * | stop = 0 |
||
) |
ValueType ttmath::auxiliaryfunctions::GammaFactorialHigh | ( | const ValueType & | n, |
CGamma< ValueType > & | cgamma, | ||
ErrorCode & | err, | ||
const volatile StopCalculating * | stop | ||
) |
an auxiliary function used to calculate the Gamma() function
we calculate a helper function GammaFactorialHigh() by using Stirling's series: n! = (n/e)^n * sqrt(2*pi*n) * exp( sum(n) ) where n is a real number (not only an integer) and is sufficient large (greater than TTMATH_GAMMA_BOUNDARY) and sum(n) is calculated by GammaFactorialHighSum()
ValueType ttmath::auxiliaryfunctions::GammaFactorialHighSum | ( | const ValueType & | n, |
CGamma< ValueType > & | cgamma, | ||
ErrorCode & | err, | ||
const volatile StopCalculating * | stop | ||
) |
an auxiliary function used to calculate the Gamma() function
we calculate a sum: sum(n) = sum_{m=2} { B(m) / ( (m^2 - m) * n^(m-1) ) } = 1/(12*n) - 1/(360*n^3) + 1/(1260*n^5) + ... B(m) means a mth Bernoulli number the sum starts from m=2, we calculate as long as the value will not change after adding a next part
ValueType ttmath::auxiliaryfunctions::GammaMinus | ( | const ValueType & | n, |
CGamma< ValueType > & | cgamma, | ||
ErrorCode & | err, | ||
const volatile StopCalculating * | stop | ||
) |
ValueType ttmath::auxiliaryfunctions::GammaPlus | ( | const ValueType & | n, |
CGamma< ValueType > & | cgamma, | ||
ErrorCode & | err, | ||
const volatile StopCalculating * | stop | ||
) |
ValueType ttmath::auxiliaryfunctions::GammaPlusHigh | ( | ValueType | n, |
CGamma< ValueType > & | cgamma, | ||
ErrorCode & | err, | ||
const volatile StopCalculating * | stop | ||
) |
ValueType ttmath::auxiliaryfunctions::GammaPlusLow | ( | ValueType | n, |
CGamma< ValueType > & | cgamma, | ||
ErrorCode & | err, | ||
const volatile StopCalculating * | stop | ||
) |
an auxiliary function used to calculate the Gamma() function
we use this function when n is a small value (from 0 to TTMATH_GAMMA_BOUNDARY] we use a recurrence formula: gamma(z+1) = z * gamma(z) then: gamma(z) = gamma(z+1) / z
e.g. gamma(3.89) = gamma(2001.89) / ( 3.89 * 4.89 * 5.89 * ... * 1999.89 * 2000.89 )
ValueType ttmath::auxiliaryfunctions::GammaPlusLowInteger | ( | const ValueType & | n, |
CGamma< ValueType > & | cgamma | ||
) |
ValueType ttmath::auxiliaryfunctions::GammaPlusLowIntegerInt | ( | uint | n, |
CGamma< ValueType > & | cgamma | ||
) |
uint ttmath::auxiliaryfunctions::PrepareSin | ( | ValueType & | x, |
bool & | change_sign | ||
) |
bool ttmath::auxiliaryfunctions::SetBernoulliNumbers | ( | CGamma< ValueType > & | cgamma, |
uint | more = 20 , |
||
const volatile StopCalculating * | stop = 0 |
||
) |
this function is used to calculate Bernoulli numbers, returns false if there was a stop signal, 'more' means how many values should be added at the end
e.g. typedef Big<1,2> MyBig; CGamma<MyBig> cgamma; SetBernoulliNumbers(cgamma, 3); now we have three first Bernoulli numbers: 1 -0.5 0.16667
SetBernoulliNumbers(cgamma, 4); now we have 7 Bernoulli numbers: 1 -0.5 0.16667 0 -0.0333 0 0.0238
bool ttmath::auxiliaryfunctions::SetBernoulliNumbersMore | ( | CGamma< ValueType > & | cgamma, |
uint | start, | ||
const volatile StopCalculating * | stop = 0 |
||
) |
an auxiliary function used to calculate Bernoulli numbers start is >= 2
we use the recurrence formula: B(m) = 1 / (2*(1 - 2^m)) * sum(m) where sum(m) is calculated by SetBernoulliNumbersSum()
ValueType ttmath::auxiliaryfunctions::SetBernoulliNumbersSum | ( | CGamma< ValueType > & | cgamma, |
const ValueType & | n_, | ||
uint | m, | ||
const volatile StopCalculating * | stop = 0 |
||
) |
an auxiliary function used to calculate Bernoulli numbers
this function returns a sum: sum(m) = sum_{k=0}^{m-1} {2^k * (m k) * B(k)} k in [0, m-1] (m k) means binomial coefficient = (m! / (k! * (m-k)!))
you should have sufficient factorials in cgamma.fact (cgamma.fact should have at least m items)
n_ should be equal 2
void ttmath::auxiliaryfunctions::SetFactorialSequence | ( | std::vector< ValueType > & | fact, |
uint | more = 20 |
||
) |
this function is used to store factorials in a given container 'more' means how many values should be added at the end
e.g. std::vector<ValueType> fact; SetFactorialSequence(fact, 3); now the container has three values: 1 1 2
SetFactorialSequence(fact, 2); now the container has five values: 1 1 2 6 24
ValueType ttmath::auxiliaryfunctions::Sin0pi05 | ( | const ValueType & | x ) |
an auxiliary function for calculating the Sine (you don't have to call this function)
it returns Sin(x) where 'x' is from <0, PI/2> we're calculating the Sin with using Taylor series in zero or PI/2 (depending on which point of these two points is nearer to the 'x')
Taylor series: sin(x) = sin(a) + cos(a)*(x-a)/(1!)
- sin(a)*((x-a)^2)/(2!) - cos(a)*((x-a)^3)/(3!) + sin(a)*((x-a)^4)/(4!) + ...
when a=0 it'll be: sin(x) = (x)/(1!) - (x^3)/(3!) + (x^5)/(5!) - (x^7)/(7!) + (x^9)/(9!) ...
and when a=PI/2: sin(x) = 1 - ((x-PI/2)^2)/(2!) + ((x-PI/2)^4)/(4!) - ((x-PI/2)^6)/(6!) ...
Generated on Tue Jul 12 2022 14:03:19 by 1.7.2