[pythran] Re: gmp

  • From: serge Guelton <serge.guelton@xxxxxxxxxxxxxxxx>
  • To: pythran@xxxxxxxxxxxxx
  • Date: Mon, 29 Oct 2012 07:10:09 +0100

On Sun, Oct 28, 2012 at 11:24:44PM +0100, Brunet Pierrick wrote:
> Le 28/10/2012 12:49, serge Guelton a écrit :
> >On Sun, Oct 28, 2012 at 11:19:29AM +0100, Brunet Pierrick wrote:
> >>Le 28/10/2012 09:27, serge Guelton a écrit :
> >>>On Sat, Oct 27, 2012 at 11:56:21PM +0200, serge Guelton wrote:
> >>>>>>Does it mean we have to make all arguments assignable ?
> >>>>>The problem is not with assignable. For now, when we have a
> >>>>>__gmp_expr<T,G>, Assignable say : "ho, I have a specialisation which
> >>>>>say it is a mpz_class" but in fact, is is not really a mpz_class. It
> >>>>>is for exemple a __gmp_expr<mpz_struct,
> >>>>>gmp_binary<__gmp_expr<mpz_struct,mpz_struct>,double,binary_plus> >
> >>>>>or something like this.
> >>>>>As you can see, in fact this is the result of an addition between a
> >>>>>double and a mpz_class and it should be a mpf_class because we can
> >>>>>see a double in this expression. But it should be more complicated
> >>>>>otherwise gmp developper may have fix this problem isn't it?
> >>>>OK I got it. Pythran cast the result to long and python to float,
> >>>>because we do not try to expand the __gmp_expr...
> >>>Or
> >>>__gmp_resolve_expr
> >>>__gmp_resolve_temp
> >>>...
> >>>
> >>Looking at this, it seems to solve at least a part of the issue. We
> >>will just need to specify __gmp_binary_...<>.
> >>For example:
> >>__gmp_binary_op<mpz_class,double,...> type is mpf_class as here is a
> >>double. This specification isn't in gmpxx.h AFAIK.
> >>
> >>To use all of these features, I will first need to convert python
> >>float to pythran mpf_class as we doesn't have big floating point
> >>number in pythran.
> >In [1]: a=11111111111111111111111111L
> >
> >In [2]: b=a+0.5
> >
> >In [3]: b-a
> >Out[3]: 0.0
> >
> >In [4]: type(b)
> >Out[4]: float
> >
> >
> 
> I did some work about typing today and we have a correct type
> management. I mean type declaration are correct for example:
> 
> mpz_class + double = double.

Really great !
> 
> BUT, it doesn't really work as we can see:
> 
> #export pythran test(long)
> def test(a):
>     return a + 0.5
> 
> with a + 0.5, the return type is double and it is correct but (a +
> 0.5) result is __gmp_expr<mpz_struct [1],
> __gmp_binary_expr<mpz_class, double, gmp_binary_plus> > and we can't
> converte it to double.

:-( 
You'll have to explain this to me... I am at TB the whole day...

-- 
serge

Other related posts: