Encapsulated transformation of expression to compiled function

November 22 2011 by icegood 255
false

0


How to do subj? Straightforward way doesn't compile:

restart;

myint:= proc(u::float)::float;
return int(exp(x^6), x=0.0..u);
end proc:


createcomp:=proc (expr::evaln, exprfunc::evaln);
exprfunc:=(v::float)->unapply(evaln(expr),a)(v);
return Compiler:-Compile(exprfunc,optimize);
end proc:
global_expr:=myint(a)+a^a;
s:=createcomp(global_expr, global_exprfunc);


"Error, (in Print) cannot translate value of lexically scoped parameter `expr'". So, compiler see how to calculate value of local exprfunc but doesn't see how to calculate expr... Is it somehow related to absence of nested functions support? Also want to compile global_expr "as is" i.e. in this example myint(a) should be compiled to call of myint from maple while a^a should be compiled to internal pow(a,a) call.

 
Loading Comments & Answers

You must be logged into your MaplePrimes account in order to post a comment. If you don't have an account, you can create an account here.

     

Forgot Your Password? Create an Account