Commit 4191e7fb authored by Yannick Ulrich's avatar Yannick Ulrich

Extended GiNaC interface to inum

parent 14e345d6
......@@ -413,7 +413,7 @@ CONTAINS
if (what .eq. 0) then
evalt = G(arr(1:l))
elseif (what.eq.1) then
evalt = geval(arr(1:l),l)
evalt = geval(toinum(arr(1:l)),l)
endif
end function
......
......@@ -5,18 +5,25 @@ using namespace GiNaC;
#include <iostream>
typedef struct {double r,i;} complex_t;
typedef struct {complex_t c; signed char i0;} inum_t;
extern "C"{
complex_t geval_(complex_t * z, int* n);
complex_t geval_(inum_t * z, int* n);
};
complex_t geval_(complex_t * z, int* n) {
complex_t geval_(inum_t * z, int* n) {
cln::cl_inhibit_floating_point_underflow = true;
lst w;
lst w,s;
for(long i=0;i<(*n)-1;i++)
{
w.append((z->r)+(z->i)*I);
ex zz;
if (abs(z->c.i) < 1e-15)
w.append((z->c.r));
else
w.append((z->c.r)+(z->c.i)*I);
s.append(z->i0);
z++;
}
ex ans = G(w,z->r).evalf();
ex ans = G(w,s,z->c.r).evalf();
return {
.r = ex_to<numeric>(evalf(real_part(ans))).to_double(),
.i = ex_to<numeric>(evalf(imag_part(ans))).to_double()
......
  • There is a subtlety in GiNaC. The explicitly given ieps prescription for valueis ignored if

       cln::instanceof(value, cln::cl_R_ring)

    Of course it would make sense to ignore the explicit value if value is indeed complex (cf. 63b4cc59). However, even if it is real, my old C++ interface

      for(long i=0;i<(*n)-1;i++)
      {
        w.append((z->r)+(z->i)*I);
        z++;
      }

    would create an cln::cl_R_ring. We now check whether z is real and act accordingly.

Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment