Bill Allombert on Wed, 4 Dec 2002 20:41:03 +0100


[Date Prev] [Date Next] [Thread Prev] [Thread Next] [Date Index] [Thread Index]

Re: gp: divrem([],[]) ?


On Wed, Dec 04, 2002 at 01:49:17PM -0500, Michael Somos wrote:
> pari-dev
>
> ? divrem([],[])
> %1 = []
>
> Why does this not give an error message? Something like :
>
> ? divrem([1],[1])
>   ***   forbidden division t_INT \ t_VEC.

Because divrem make the division for each element of the array at the left:
? divrem([2,2],2)
%1 = [[1, 0]~, [1, 0]~]
Since in your example there is no division to perform no error is
raised.

it is equivalent to
f(x,y)=vector(length(x),i,divrem(x[i],y))
f([],[])

I am not sure if it is a bug. On the other hand,
? divrem(x,2)
%3 = 1/2*x
(should be a vector)
? divrem([x,2],3.);
? divrem([1.,2],x)
  ***   significant pointers are lost in gerepile !!! (please report)

are bugs...

It looks like they appeared in
-- src/basemath/gen3.c
revision 1.51
date: 2001/11/17 18:15:15;  author: karim;  state: Exp;  lines: +174 -74
extend gdivent,gdiventres,gdivround, fix gmod(x,y) when y < 0 inexact:
2 % (-3.) --> -1.  !!

when Karim has rewritten gen3.c.

Also the way divrem handle pol,pol is suspicious.

Cheers,
Bill.