A contribution to GMP
Lukasz Komsta
sp8qed at onet.eu
Wed Oct 23 20:41:41 CEST 2013
Dear Developers,
I like using GMP in my research and the main drawback of current library
is a very limited set of float functions. I see that implementing these
is listed in developing plans.
I have developed a set of following functions and I would like to share
code with you and (if possible) to contribute to GMP.
void mpf_atan(mpf_t rop, const mpf_t op)
void mpf_asin(mpf_t rop, const mpf_t op)
void mpf_asinh(mpf_t rop, const mpf_t op)
void mpf_sin(mpf_t rop, const mpf_t op)
void mpf_cos(mpf_t rop, const mpf_t op)
void mpf_sinh(mpf_t rop, const mpf_t op)
void mpf_cosh(mpf_t rop, const mpf_t op)
void mpf_tan(mpf_t rop, const mpf_t op)
void mpf_tanh(mpf_t rop, const mpf_t op)
void mpf_exp(mpf_t rop, const mpf_t op)
void mpf_log(mpf_t rop, const mpf_t op)
void mpf_log10(mpf_t rop, const mpf_t op)
void mpf_pow(mpf_t rop, const mpf_t op1, const mpf_t op2)
void mpf_secant(mpf_t rop, void (*f)(mpf_t,const mpf_t), const mpf_t
op1, const mpf_t op2)
The code with commented functions and example main() is placed here:
http://www.komsta.net/gmp.c
This file contains some "internal" functions called with modified
parameters by another ones to prevent code duplication:
void mpf_arcsin(mpf_t rop, const mpf_t op, int plusminus)
void mpf_trig(mpf_t rop, const mpf_t op, int one, int plusminus)
All names should be self explaining except of mpf_secant, which solves
f(x) = 0 in some interval numerically by secant method. It needs to be
given a function void f(mpf_t rop, const mpf_t op) which computes rop
from op as y = f(x).
I have planned to create mpf_atan2, however it should use pi number in
certain cases, so I suspended developing due to lack of function
creating pi with desired precision.
My functions use typical algorithms (mainly Taylor Series) so their
efficiency should be enough for most computations unless we require
billions of digits.
If you like the code you can put it into further versions of GMP - I
release it under GNU LGPL and if possible I would appreciate credit in
source code and contributor list.
Of course I cannot guarantee that everything works 100% fine, but I have
done all my best.
Regards,
Lukasz
--
Lukasz Komsta, PhD, DSc
Department of Medicinal Chemistry
Medical University of Lublin, Poland
http://www.komsta.net/
More information about the gmp-devel
mailing list