Library for big numbers from http://www.ttmath.org/
Dependents: PIDHeater82 Conceptcontroller_v_1_0 AlarmClockApp COG4050_adxl355_tilt ... more
ttmath Namespace Reference
a namespace for the TTMath library More...
Namespaces | |
namespace | auxiliaryfunctions |
Data Structures | |
class | Big |
Big implements the floating point numbers. More... | |
class | Int |
Int implements a big integer value with a sign. More... | |
class | Misc |
class | Objects |
class | History |
struct | CGamma |
class | Parser |
Mathematical parser. More... | |
class | ThreadLock |
struct | Conv |
class | StopCalculating |
class | ExceptionInfo |
class | ReferenceError |
class | RuntimeError |
class | UInt |
UInt implements a big integer value without a sign. More... | |
class | UInt< 0 > |
Typedefs | |
typedef unsigned int | uint |
typedef unsigned long long int | ulint |
Enumerations | |
enum | LibTypeCode |
enum | ErrorCode |
Functions | |
template<class ValueType > | |
ValueType | SkipFraction (const ValueType &x) |
template<class ValueType > | |
ValueType | Round (const ValueType &x, ErrorCode *err=0) |
template<class ValueType > | |
ValueType | Ceil (const ValueType &x, ErrorCode *err=0) |
template<class ValueType > | |
ValueType | Floor (const ValueType &x, ErrorCode *err=0) |
template<class ValueType > | |
ValueType | Ln (const ValueType &x, ErrorCode *err=0) |
template<class ValueType > | |
ValueType | Log (const ValueType &x, const ValueType &base, ErrorCode *err=0) |
template<class ValueType > | |
ValueType | Exp (const ValueType &x, ErrorCode *err=0) |
template<class ValueType > | |
ValueType | Sin (ValueType x, ErrorCode *err=0) |
template<class ValueType > | |
ValueType | Cos (ValueType x, ErrorCode *err=0) |
template<class ValueType > | |
ValueType | Tan (const ValueType &x, ErrorCode *err=0) |
template<class ValueType > | |
ValueType | Tg (const ValueType &x, ErrorCode *err=0) |
template<class ValueType > | |
ValueType | Cot (const ValueType &x, ErrorCode *err=0) |
template<class ValueType > | |
ValueType | Ctg (const ValueType &x, ErrorCode *err=0) |
template<class ValueType > | |
ValueType | ASin (ValueType x, ErrorCode *err=0) |
template<class ValueType > | |
ValueType | ACos (const ValueType &x, ErrorCode *err=0) |
template<class ValueType > | |
ValueType | ATan (ValueType x) |
template<class ValueType > | |
ValueType | ATg (const ValueType &x) |
template<class ValueType > | |
ValueType | ACot (const ValueType &x) |
template<class ValueType > | |
ValueType | ACtg (const ValueType &x) |
template<class ValueType > | |
ValueType | Sinh (const ValueType &x, ErrorCode *err=0) |
template<class ValueType > | |
ValueType | Cosh (const ValueType &x, ErrorCode *err=0) |
template<class ValueType > | |
ValueType | Tanh (const ValueType &x, ErrorCode *err=0) |
template<class ValueType > | |
ValueType | Tgh (const ValueType &x, ErrorCode *err=0) |
template<class ValueType > | |
ValueType | Coth (const ValueType &x, ErrorCode *err=0) |
template<class ValueType > | |
ValueType | Ctgh (const ValueType &x, ErrorCode *err=0) |
template<class ValueType > | |
ValueType | ASinh (const ValueType &x, ErrorCode *err=0) |
template<class ValueType > | |
ValueType | ACosh (const ValueType &x, ErrorCode *err=0) |
template<class ValueType > | |
ValueType | ATanh (const ValueType &x, ErrorCode *err=0) |
template<class ValueType > | |
ValueType | ATgh (const ValueType &x, ErrorCode *err=0) |
template<class ValueType > | |
ValueType | ACoth (const ValueType &x, ErrorCode *err=0) |
template<class ValueType > | |
ValueType | ACtgh (const ValueType &x, ErrorCode *err=0) |
template<class ValueType > | |
ValueType | DegToRad (const ValueType &x, ErrorCode *err=0) |
template<class ValueType > | |
ValueType | RadToDeg (const ValueType &x, ErrorCode *err=0) |
template<class ValueType > | |
ValueType | DegToDeg (const ValueType &d, const ValueType &m, const ValueType &s, ErrorCode *err=0) |
template<class ValueType > | |
ValueType | DegToRad (const ValueType &d, const ValueType &m, const ValueType &s, ErrorCode *err=0) |
template<class ValueType > | |
ValueType | GradToRad (const ValueType &x, ErrorCode *err=0) |
template<class ValueType > | |
ValueType | RadToGrad (const ValueType &x, ErrorCode *err=0) |
template<class ValueType > | |
ValueType | DegToGrad (const ValueType &x, ErrorCode *err=0) |
template<class ValueType > | |
ValueType | DegToGrad (const ValueType &d, const ValueType &m, const ValueType &s, ErrorCode *err=0) |
template<class ValueType > | |
ValueType | GradToDeg (const ValueType &x, ErrorCode *err=0) |
template<class ValueType > | |
ValueType | Sqrt (ValueType x, ErrorCode *err=0) |
template<class ValueType > | |
ValueType | Root (ValueType x, const ValueType &index, ErrorCode *err=0) |
template<class ValueType > | |
ValueType | Abs (const ValueType &x) |
template<class ValueType > | |
ValueType | Sgn (ValueType x) |
template<class ValueType > | |
ValueType | Mod (ValueType a, const ValueType &b, ErrorCode *err=0) |
template<class ValueType > | |
ValueType | Gamma (const ValueType &n, CGamma< ValueType > &cgamma, ErrorCode *err=0, const volatile StopCalculating *stop=0) |
template<class ValueType > | |
ValueType | Gamma (const ValueType &n, ErrorCode *err=0) |
template<class ValueType > | |
ValueType | Factorial (const ValueType &x, CGamma< ValueType > &cgamma, ErrorCode *err=0, const volatile StopCalculating *stop=0) |
template<class ValueType > | |
ValueType | Factorial (const ValueType &x, ErrorCode *err=0) |
Variables | |
pthread_mutex_t | ttmath_mutex |
Detailed Description
a namespace for the TTMath library
Typedef Documentation
typedef unsigned long uint |
on 32bit platforms one word (uint, sint) will be equal 32bits
on 64bit platforms one word (uint, sint) will be equal 64bits
Definition at line 155 of file ttmathtypes.h.
typedef uint64_t ulint |
on 32 bit platform ulint and slint will be equal 64 bits
Definition at line 164 of file ttmathtypes.h.
Enumeration Type Documentation
enum ErrorCode |
error codes
Definition at line 341 of file ttmathtypes.h.
enum LibTypeCode |
lib type codes: asm_vc_32 - with asm code designed for Microsoft Visual C++ (32 bits) asm_gcc_32 - with asm code designed for GCC (32 bits) asm_vc_64 - with asm for VC (64 bit) asm_gcc_64 - with asm for GCC (64 bit) no_asm_32 - pure C++ version (32 bit) - without any asm code no_asm_64 - pure C++ version (64 bit) - without any asm code
Definition at line 327 of file ttmathtypes.h.
Function Documentation
ValueType ttmath::Abs | ( | const ValueType & | x ) |
ValueType ttmath::ACos | ( | const ValueType & | x, |
ErrorCode * | err = 0 |
||
) |
ValueType ttmath::ACosh | ( | const ValueType & | x, |
ErrorCode * | err = 0 |
||
) |
ValueType ttmath::ACot | ( | const ValueType & | x ) |
ValueType ttmath::ACoth | ( | const ValueType & | x, |
ErrorCode * | err = 0 |
||
) |
ValueType ttmath::ACtg | ( | const ValueType & | x ) |
ValueType ttmath::ACtgh | ( | const ValueType & | x, |
ErrorCode * | err = 0 |
||
) |
ValueType ttmath::ASin | ( | ValueType | x, |
ErrorCode * | err = 0 |
||
) |
ValueType ttmath::ASinh | ( | const ValueType & | x, |
ErrorCode * | err = 0 |
||
) |
ValueType ttmath::ATan | ( | ValueType | x ) |
ValueType ttmath::ATanh | ( | const ValueType & | x, |
ErrorCode * | err = 0 |
||
) |
ValueType ttmath::ATg | ( | const ValueType & | x ) |
ValueType ttmath::ATgh | ( | const ValueType & | x, |
ErrorCode * | err = 0 |
||
) |
ValueType ttmath::Ceil | ( | const ValueType & | x, |
ErrorCode * | err = 0 |
||
) |
ValueType ttmath::Cos | ( | ValueType | x, |
ErrorCode * | err = 0 |
||
) |
ValueType ttmath::Cosh | ( | const ValueType & | x, |
ErrorCode * | err = 0 |
||
) |
ValueType ttmath::Cot | ( | const ValueType & | x, |
ErrorCode * | err = 0 |
||
) |
ValueType ttmath::Coth | ( | const ValueType & | x, |
ErrorCode * | err = 0 |
||
) |
ValueType ttmath::Ctg | ( | const ValueType & | x, |
ErrorCode * | err = 0 |
||
) |
ValueType ttmath::Ctgh | ( | const ValueType & | x, |
ErrorCode * | err = 0 |
||
) |
ValueType ttmath::DegToDeg | ( | const ValueType & | d, |
const ValueType & | m, | ||
const ValueType & | s, | ||
ErrorCode * | err = 0 |
||
) |
this function converts degrees in the long format into one value
long format: (degrees, minutes, seconds) minutes and seconds must be greater than or equal zero
result: if d>=0 : result= d + ((s/60)+m)/60 if d<0 : result= d - ((s/60)+m)/60
((s/60)+m)/60 = (s+60*m)/3600 (second version is faster because there's only one division)
for example: DegToDeg(10, 30, 0) = 10.5 DegToDeg(10, 24, 35.6)=10.4098(8)
ValueType ttmath::DegToGrad | ( | const ValueType & | x, |
ErrorCode * | err = 0 |
||
) |
ValueType ttmath::DegToGrad | ( | const ValueType & | d, |
const ValueType & | m, | ||
const ValueType & | s, | ||
ErrorCode * | err = 0 |
||
) |
ValueType ttmath::DegToRad | ( | const ValueType & | x, |
ErrorCode * | err = 0 |
||
) |
ValueType ttmath::DegToRad | ( | const ValueType & | d, |
const ValueType & | m, | ||
const ValueType & | s, | ||
ErrorCode * | err = 0 |
||
) |
ValueType ttmath::Exp | ( | const ValueType & | x, |
ErrorCode * | err = 0 |
||
) |
ValueType ttmath::Factorial | ( | const ValueType & | x, |
CGamma< ValueType > & | cgamma, | ||
ErrorCode * | err = 0 , |
||
const volatile StopCalculating * | stop = 0 |
||
) |
the factorial from given 'x' e.g. Factorial(4) = 4! = 1*2*3*4
it's multithread safe, you should create a CGamma<> object and use it whenever you call the Factorial() e.g. typedef Big<1,2> MyBig; MyBig x=234, y=54345; CGamma<MyBig> cgamma; std::cout << Factorial(x, cgamma) << std::endl; std::cout << Factorial(y, cgamma) << std::endl; in the CGamma<> object the function stores some coefficients (factorials, Bernoulli numbers), and they will be reused in next calls to the function
each thread should have its own CGamma<> object, and you can use these objects with Gamma() function too
ValueType ttmath::Factorial | ( | const ValueType & | x, |
ErrorCode * | err = 0 |
||
) |
ValueType ttmath::Floor | ( | const ValueType & | x, |
ErrorCode * | err = 0 |
||
) |
ValueType ttmath::Gamma | ( | const ValueType & | n, |
CGamma< ValueType > & | cgamma, | ||
ErrorCode * | err = 0 , |
||
const volatile StopCalculating * | stop = 0 |
||
) |
this function calculates the Gamma function
it's multithread safe, you should create a CGamma<> object and use it whenever you call the Gamma() e.g. typedef Big<1,2> MyBig; MyBig x=234, y=345.53; CGamma<MyBig> cgamma; std::cout << Gamma(x, cgamma) << std::endl; std::cout << Gamma(y, cgamma) << std::endl; in the CGamma<> object the function stores some coefficients (factorials, Bernoulli numbers), and they will be reused in next calls to the function
each thread should have its own CGamma<> object, and you can use these objects with Factorial() function too
ValueType ttmath::Gamma | ( | const ValueType & | n, |
ErrorCode * | err = 0 |
||
) |
ValueType ttmath::GradToDeg | ( | const ValueType & | x, |
ErrorCode * | err = 0 |
||
) |
ValueType ttmath::GradToRad | ( | const ValueType & | x, |
ErrorCode * | err = 0 |
||
) |
ValueType ttmath::Ln | ( | const ValueType & | x, |
ErrorCode * | err = 0 |
||
) |
ValueType ttmath::Log | ( | const ValueType & | x, |
const ValueType & | base, | ||
ErrorCode * | err = 0 |
||
) |
ValueType ttmath::Mod | ( | ValueType | a, |
const ValueType & | b, | ||
ErrorCode * | err = 0 |
||
) |
ValueType ttmath::RadToDeg | ( | const ValueType & | x, |
ErrorCode * | err = 0 |
||
) |
ValueType ttmath::RadToGrad | ( | const ValueType & | x, |
ErrorCode * | err = 0 |
||
) |
ValueType ttmath::Root | ( | ValueType | x, |
const ValueType & | index, | ||
ErrorCode * | err = 0 |
||
) |
indexth Root of x index must be integer and not negative <0;1;2;3....)
if index==0 the result is one if x==0 the result is zero and we assume root(0;0) is not defined
if index is even (2;4;6...) the result is x^(1/index) and x>0 if index is odd (1;2;3;...) the result is either -(abs(x)^(1/index)) if x<0 or x^(1/index)) if x>0
(for index==1 the result is equal x)
ValueType ttmath::Round | ( | const ValueType & | x, |
ErrorCode * | err = 0 |
||
) |
ValueType ttmath::Sgn | ( | ValueType | x ) |
ValueType ttmath::Sin | ( | ValueType | x, |
ErrorCode * | err = 0 |
||
) |
ValueType ttmath::Sinh | ( | const ValueType & | x, |
ErrorCode * | err = 0 |
||
) |
ValueType ttmath::SkipFraction | ( | const ValueType & | x ) |
ValueType ttmath::Sqrt | ( | ValueType | x, |
ErrorCode * | err = 0 |
||
) |
ValueType ttmath::Tan | ( | const ValueType & | x, |
ErrorCode * | err = 0 |
||
) |
this function calulates the Tangent we're using the formula tan(x) = sin(x) / cos(x)
it takes more time than calculating the Tan directly from for example Taylor series but should be a bit preciser because Tan receives its values from -infinity to +infinity and when we calculate it from any series then we can make a greater mistake than calculating 'sin/cos'
ValueType ttmath::Tanh | ( | const ValueType & | x, |
ErrorCode * | err = 0 |
||
) |
ValueType ttmath::Tg | ( | const ValueType & | x, |
ErrorCode * | err = 0 |
||
) |
ValueType ttmath::Tgh | ( | const ValueType & | x, |
ErrorCode * | err = 0 |
||
) |
Variable Documentation
pthread_mutex_t ttmath_mutex |
ttmath_mutex will be defined by TTMATH_MULTITHREADS_HELPER macro
Generated on Tue Jul 12 2022 14:03:18 by 1.7.2