Barton Willis wrote:
> Maybe you could rewrite your function using Maxima's noncommuting
> multiplication instead of using explicit sums. Since A and Y are
> nonconformable, you'll need to tinker. Try something like:
>
> partial_product(m,x,i) := block([maperror : false],
> xreduce("+", map("*", inpart(m,i),x)));
>
> gg(A,b,s,VF,x,h) := block([y, listarith : true],
> y : [VF(x)],
> for i : 2 thru s do (
> y : endcons(VF(x + h * partial_product(A,y,i)), y)),
> expand(x + h * partial_product(b,y,1)));
>
> (1) The function gg doesn't have the side-effects that fun has.
>
> (2) Some time ago I thought maperror should be expunged. This might
> be the first time I used maperror.
>
> (3) And another bug :(
>
> (%i2) ans1 : fun(matrix([1,1],[1,1]),[1,1],2,'f,[1,1],0.1)$
> (%i3) ans2 : gg(matrix([1,1],[1,1]),[1,1],2,'f,[1,1],0.1)$
> map: truncating one or more arguments.
> map: calling 'apply'.
>
> Should be [0,0]:
>
> (%i4) ans1 - ans2;
> (%o4) [1,1]+[-1,-1]
>
> (%i5) expand(%,0,0);
> (%o5) [0,0]
>
> (4) The message from "map" is sometimes nice (debugging) but
> frequently obnoxious. It would be great if Maxima had a unified way of
> suppressing & managing error messages and warnings...
>
> Barton
>
> -----maxima-bounces at math.utexas.edu wrote: -----
>
>
>> fun(A,b,s,VF,x,h):= block([Y],
>> Y[1]: x,
>> for i:2 thru s do
>> Y[i]: x + h*(sum(A[i,j]*VF(Y[j]),j,1,i-1)),
>> x: expand(x + h*sum(b[i]*VF(Y[i]),i,1,s))
>> )$
>>
>
>
> _______________________________________________
> Maxima mailing list
> Maxima at math.utexas.edu
> http://www.math.utexas.edu/mailman/listinfo/maxima
> .
>
>
Thanks to all who replied to my compile question. I have gotten several
ideas.
Strangely or not, one solution seems to be to do my own version of 'sum'.
Thus instead of something like
sum(aa[i],i,1,s)
for some array aa, I did
s1: aa[1], for i:2 thru s do s1:s1+aa[i]
This compiled and resulted in an increase in speed of approx 50%.
-sen