I'll try what you suggested, copy the input list to a local array. Question
is... How do I mode_declare a local variable which is an array of floats?
2011/10/18 dlakelan <dlakelan at street-artists.org>
> On 10/18/2011 07:32 AM, Panagiotis Papasotiriou wrote:
> > The problem is that I need to declare local variables as lists of floats.
> In
> > your example, you define l as a list of floats, but l is a dummy
> variable,
> > not a local variable. Nevertheless, I tried to do something similar in my
> > code. To make things simple, declarations look like in the following
> simple
> > example:
> >
> > f(y):=block([z],mode_declare(z,list),for el in z do
> > mode_declare(el,float),z:y);
> > translate(f);
> > f([1,2,3]);
>
> it's not at all clear to me what you're trying to do here, but perhaps
> we can clear up some confusion for you.
>
> in this block of code you first declare a local variable z, then you
> declare z to be a list, then you run through each element in the list
> but each time you do nothing with the element (other than declare it
> which has no effect by itself) but you do set z equal to the input list
> multiple times...
>
> also, your input list is NOT a list of floats, it's a list of integers.
>
> mode_declare is a declaration, not a function that has any effect, so
> for i in foo do mode_declare(i,float) would not be expected to do
> anything really.
>
> I think what you want to do is to take your lists as input, declare a
> local array of floats of the appropriate size, and copy the floats out
> of the list into your array, then you can do fast arithmetic on the
> array in your algorithm.
>
> see info on declared arrays here:
>
> http://maxima.sourceforge.net/docs/manual/en/maxima_5.html
>
> Also, thanks again for working on these numerical algorithms. They will
> be much appreciated by maxima users such as myself!
> _______________________________________________
> Maxima mailing list
> Maxima at math.utexas.edu
> http://www.math.utexas.edu/mailman/listinfo/maxima
>