From: Richard F. <fa...@be...> - 2014-04-21 14:05:02
|
I haven't looked at your program in detail, but it is highly unlikely that you should be doing a matchdeclare inside a function. It should be used on the top level, and not used to declare local variables. RJF On 4/21/2014 1:54 AM, Dimiter Prodanov wrote: > Dear all, > > I am truing to implement a Fourier trnasform package in Maxima > > I came across the follwing problem. I can't make this code to work as > I expect > > ( "modulation by exp ", > matchdeclare( [t, f], atom, V, lambda([u], not atom(u)), it, complexp ), > defrule (simftexpmod, FT (V*exp(it)), ftmodsim2 (V, exp(it), t )), > defrule (simftexpmod, IFT (V*exp(it)), iftmodsim2 (V, exp(it), f )), > > ftmodsim2(V, fn, s):=opmodsimp2(V, fn, s, FT), > iftmodsim2(V, fn, s):=opmodsimp2(V, fn, s, IFT), > > opmodsimp2(V, fn, s, OP ):= block( [ %B, res ], > matchdeclare( %B , lambda([x], freeof(s, x) ), s, atom, g, > symbolp), > defmatch (opexp, exp(%B*s), s), > res: opexp(fn, s), > if (res#false) then ( > "print (%B)", > return ([OP(V), 1, [%B, exp]]) > ) > else return (OP(V*fn)) > ) > )$ > > complexp (u) := not atom(u) and not listp(u) and not freeof(%i, u)$ > > Output: > > correct: > >> ftmodsim2(u(t), exp(%i*a*t), t); > >> [FT(u(t)),1,[%i*a,exp]] > > wrong: > >> simftexpmod(FT(u(t)*exp(%i*t))); > >> false > > I had similar problems also for other rules where the solution was > either to unnecessary broaden the scope or to define global variables > with unique names and thus limit the scope artificially. > > best regards, > > Dimiter > > > > > ------------------------------------------------------------------------------ > Start Your Social Network Today - Download eXo Platform > Build your Enterprise Intranet with eXo Platform Software > Java Based Open Source Intranet - Social, Extensible, Cloud Ready > Get Started Now And Turn Your Intranet Into A Collaboration Platform > http://p.sf.net/sfu/ExoPlatform > > > _______________________________________________ > Maxima-discuss mailing list > Max...@li... > https://lists.sourceforge.net/lists/listinfo/maxima-discuss |