Ok, thank you.

For the exp calculation: you are right; the problem was that (EDIT: now 
using exp(0.1) instead of exp(0.01)),  I used mpf_set_d(x, 0.1) to set the 
argument of exp_calc to 0.1, but the double "0.1" was, which I saw only 
when gmp_printf-ing it), converted to the mpf_t x as 
"x is 0.100000000000000005551115123125782702118158340454101562500000000 ."
Thus, as my solution, I used the mpf_t's a_numer and a_denom and set them 
to 1 and 10, resp., and then did mpf_div(a, a_numer, a_denom); now the 
exp(0.1) (and the exp(-0.01)) give the same result as Matlab and Wolfram.
Thanks again for responding quickly and effectively.
Pat

On Sunday, June 21, 2015 at 8:34:12 PM UTC+2, Bill Hart wrote:
>
>
>
> On 21 June 2015 at 19:57, <highcal...@gmail.com <javascript:>> 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+...@googlegroups.com <javascript:>.
>> To post to this group, send email to mpir-...@googlegroups.com 
>> <javascript:>.
>> 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.

Reply via email to