Help with compile_file()




On Fri, 22 May 2009, Martin Sch?necker wrote:

< Joshua Stults schrieb:
< > Hello,
< > 
< > I'm trying to learn how to use compile_file(), but am having a bit of
< > trouble. 
< 
< I have no experience with compliling either, but let's see: Firstly, it 
< seems that the compiler cannot handle the undefined function f, however 
< doing as maxima proposes:
< 
<  > Warning: f has a function or macro call which has not been translated 
< properly.
<  > The function was totaly undefined. Maybe you want to quote it.
 
< explicit_fde(steps, deriv, f) := block([A, a_f, b, coef_list, fde, 
< func_vals, f_coefs, f_taylor, M, n, points, i],

<    );
< 
< 
< (%i1) kill(all);
< (%o0) done
< (%i1) compile_file("m:/maxima/explicit_fde.mac");
< Translation begun on #pm:/maxima/explicit_fde.mac.
< See the `unlisp' file for possible optimizations.
< Compiling m:/maxima/explicit_fde.LISP.
< End of Pass 1.
< End of Pass 2.
< OPTIMIZE levels: Safety=2, Space=3, Speed=3
< Finished compiling NIL.
< (%o1) 
< [m:/maxima/explicit_fde.mac,m:/maxima/explicit_fde.LISP,m:/maxima/explicit_fde.UNLISP,#pm:/maxima/explicit_fde.o]
< (%i2) explicit_fde([-2, -1,0,1,2], 1, f);
< matrix([1,-(x0-x),(x0-x)^2/2,-(x0-x)^3/6,(x0-x)^4/24])
< Is  h  positive, negative, or zero?p;
< (%o2) -(f(x0+2*h)-8*f(x0+h)+8*f(x0-h)-f(x0-2*h))/(12*h)
 

Interestingly, if you load the file and compile the function, you get
extra information

(%i1) load("maxima/scripts/compilef.mac");

(%o1) "maxima/scripts/compilef.mac"
(%i2) compile(explicit_fde);

Warning-> x is an undefined global variable.
Warning-> x0 is an undefined global variable.
Warning-> h is an undefined global variable.

...

Leo
-- 
The University of Edinburgh is a charitable body, registered in
Scotland, with registration number SC005336.