On 21 June 2015 at 19:57, <highcalcula...@gmail.com> wrote: > I am referring to using MPIR with gcc in the MinGW shell (outside Matlab). > > > First question (of two): > > In MPIR, is it possible to declare / define a function with return type > mpf_t (for example, or mpz_t)? > No. You would have to use C++ for this sort of thing. It's not possible in C.
> My calculation of exp(x) via the function exp_calc(mpf_t x, int NN) works > with type void, but when I declare it to be void , gcc complains: > > > “exp_calc.h:2:7: error: 'exp_calc' declared as function returning an > array mpf_t exp_calc(mpf_t x, int NN); > testest.c: In function 'main': testest.c:27:8: error: incompatible types > when assigning exp_a = exp_calc(a, num_exp_terms); In file included from > exp_calc.c:2:0: > exp_calc.h:2:7: error: 'exp_calc' declared as function mpf_t exp_calc(mpf_t > x, int NN); > > > Here is the beginning and end of exp_calc.c : > > > #include "mpir.h" > #include "exp_calc.h" > > mpf_t exp_calc(mpf_t x, int NN) { > mpf_t denominator, numerator, frac_val, outvalue; > mpz_t fac_value; > […calculations via the Taylor sum representation of exp …] > return outvalue; > } > > > Second question (regarding the accuracy of exp(-0.01) ): > > In my current (naive?) working implementation of the calculation of > exp(-0.01) (and smaller negative numbers), which uses the type void for the > function, the result does not seem to be correct to more than 15 digits in > MPIR, when using mp_bitcnt_t bct = 2000; and NN = 1000 terms in the > Taylor sum for exp (I've compared it to Matlab vpa and Wolfram alpha, who > agree in the result (to at least 100 digits)). > I can only imagine there is a bug in your code for computing exp. Bill. > Any ideas what to change? I will post the code upon request. Thanks again! > > -- > You received this message because you are subscribed to the Google Groups > "mpir-devel" group. > To unsubscribe from this group and stop receiving emails from it, send an > email to mpir-devel+unsubscr...@googlegroups.com. > To post to this group, send email to mpir-devel@googlegroups.com. > Visit this group at http://groups.google.com/group/mpir-devel. > For more options, visit https://groups.google.com/d/optout. > -- You received this message because you are subscribed to the Google Groups "mpir-devel" group. To unsubscribe from this group and stop receiving emails from it, send an email to mpir-devel+unsubscr...@googlegroups.com. To post to this group, send email to mpir-devel@googlegroups.com. Visit this group at http://groups.google.com/group/mpir-devel. For more options, visit https://groups.google.com/d/optout.