compiling Maxima code with arrays



Am 14 Feb 2006 um 12:22 hat Raymond Toy geschrieben:

> fabrizio.caruso at math.univ-rennes1.fr wrote:
> > Hi!
> >
> > When I compile:
> > foo(x) := block([r], r : make_array('fixnum,2), r[0]:x,r[1]:x+1, return(r));
> > or
> > foo(x) := block([r:make_array('fixnum,2)], r[0]:x,r[1]:x+1, return(r));
> >
> > foo stops working and gives the following error message:
> >   
> This bug is caused by essentially the same bug that makes your previous 
> compiled array reference example fail.

Hello Ray,
it was me the last time, not Fabrizio. And you answered the following. 

Ray> I think this is a bug in maref1 in src/trans2.lisp.  I think the
Ray> method it's using to figure the type of AR is confused wrt to Common
Ray> Lisp.  
Ray> 
Ray> If I insert a new clause for cond like so:
Ray> 
Ray>     (cond
Ray>       ((typep ar 'cl:array)
Ray>       (apply #'aref ar inds)) ;; <- new stuff
Ray>       ((one-of-types .type. (make-array 3))     (apply #'aref ar inds))
Ray> 
Ray> the compiled version actually works.

I did THIS change and everything is fine. Now your fix is a little bit different, especially 
for a different function. ???
Volker van Nek

> 
> In src/trans2.lisp, you can add a new clause like so to make it work:
> 
> (defun maset1 (val ar &rest inds &aux )
>   ...
>   (cond
>     ((typep ar 'cl:array)  ; <--- new stuff
>      (setf (apply #'aref ar inds) val))
>     ((one-of-types .type. (make-array 3))
>     ...)))
> 
> Ray
> 
> 
> 
> _______________________________________________
> Maxima mailing list
> Maxima at math.utexas.edu
> http://www.math.utexas.edu/mailman/listinfo/maxima
>