do you have plans to implement trigonometric functions like sin(), cos(), tan() etc. ?
Best regards
Ettl Martin
they are defined but only for Big<> objects, sample:
#include <iostream>
#include <ttmath/ttmath.h>
using namespace ttmath;
int main()
{
Big<1, 3> a = "123.456";
std::cout << Sin(a) << std::endl;
std::cout << Cos(a) << std::endl;
std::cout << Tan(a) << std::endl;
std::cout << Ctg(a) << std::endl;
}
Oh, great!
Thanks for the sample!!
Is there a reason why you have this special name convention for trigonometric functions that differ from the
well known from math.h.
e.g. in math.h the tangens is declared as tan(). In ttmath the tangens is declared as Tan().
All functions/methods in ttmath begin with a capital letter.
Yes, exactly. This was my question! Why does the function name start with capital letters? In other words, why break with the normally used names from <math.h> and writing Sin() instead of sin()? Is there any reason for that, or just some design rule convention?
There is not a special reason. I think about giving wrappers:
Sin(x) -> sin(x)
object.Log(y) -> object.log(y)
object.LongName(y) -> object.long_name(y)
I noticed that people prefer the latter way.
Wrappers are good. I think the best way is to stay as compatible as possible to the functions that allready exist in math.h ... This makes it easier to switch between multiprecision and standard datatypes like double.
Best regards
here are some wrappers for trigonometric functions i have created to stay closer to the C-standardlibrary names:
template<class ValueType> ValueType sin (const ValueType &x){return ttmath::Sin(x);}
template<class ValueType> ValueType cos (const ValueType &x){return ttmath::Cos(x);}
template<class ValueType> ValueType tan (const ValueType &x){return ttmath::Tan(x);}
template<class ValueType> ValueType asin (const ValueType &x){return ttmath::ASin(x);}
template<class ValueType> ValueType acos (const ValueType &x){return ttmath::ACos(x);}
template<class ValueType> ValueType atan (const ValueType &x){return ttmath::ATan(x);}
template<class ValueType> ValueType sqrt (const ValueType &x){return ttmath::Sqrt(x);}
Best regards
Martin
thanks, will be added soon