Re: F2CL ODEPACK problems.

Marco Antoniotti <[email protected]> Tue, 17 Aug 2004 17:17:52 -0400
Newsgroups gmane.lisp.clocc.general
Message-ID <[email protected]>
On Aug 17, 2004, at 5:00 PM, Raymond Toy wrote:

>>>>>> "Marco" == Marco Antoniotti <[email protected]> writes:
>
>     Marco> Hi
>
>
>     Marco> I think I got another problem with odepack-lsode.
>
>     Marco> I wrote the following routine, which, AFAIU, is a 
> translation of the
>     Marco> Fortran example given in the main opkdmain.f file from 
> netlib (sorry if
>     Marco> it is long.)
>
> [snip]
>
>     Marco> I tracked down this error to the DPREPJ routine in the call 
> to the JEX
>     Marco> local function, which expects a 2D array, but it seems to 
> get a 1D array
>     Marco> slice.
>
>     Marco> Is this the correct diagnosis?  Is this a Fortran trick to 
> pass around
>     Marco> things that can be seen of different shapes at different 
> times?
>
> You are correct.  All arrays in Fortran are in column-major order,
> which doesn't fit well with Lisp's (and C) row-major order.  Thus, in
> f2cl, all arrays are converted to 1D arrays.  You will have to do the
> same thing.  (It might have been beneficial to take the Fortran
> example and run f2cl over it to see what happens.  And then write your
> own lisp version.)
>
> You can use the fref and fset macros to access the multi-dimensional
> arrays.  In Fortran, if you have an array with dimensions x(8,10), and
> you want to access element x(1,2), you can use
>
>     (fref x (1 2) ((1 8) (1 10)))
>
> (I think.)  The last arg there gives the upper and lower bounds on the
> dimensions of the array so that fref can access the right element.
> (Fortran arrays can have negative indices.)
>
> Let me know if this solves your problem.
>

I'll try.

How should I declare the CL array?

X(8, 10) ==> (make-array (* 8 10) ....)

?

So that

Also, FREF seems quite strange to me.  I tried the following

(defvar arr (make-array (* 8 10) ....)) ;; filled in from 0 to 79.

(f2cl-lib:fref arr (-9 11) ((1 8) (1 10))) ==> 70

What is the meaning of this?

Cheers

marco

--
Marco Antoniotti					http://bioinformatics.nyu.edu
NYU Courant Bioinformatics Group		tel. +1 - 212 - 998 3488
715 Broadway 10th FL				fax. +1 - 212 - 998 3484
New York, NY, 10003, U.S.A.



-------------------------------------------------------
SF.Net email is sponsored by Shop4tech.com-Lowest price on Blank Media
100pk Sonic DVD-R 4x for only $29 -100pk Sonic DVD+R for only $33
Save 50% off Retail on Ink & Toner - Free Shipping and Free Gift.
http://www.shop4tech.com/z/Inkjet_Cartridges/9_108_r285