ev-bug



On Wed, May 13, 2009 at 3:41 PM, Oliver Kullmann
<O.Kullmann at swansea.ac.uk> wrote:
> It's really the opposite: Loops are *much* slower!

Try compiling the loop form (with declarations).  You are comparing an
interpreted for-loop with a compiled loop (create_list and + are
compiled code).

Also, it is better practice to use xreduce than to use apply for
things like this.

              -s

>
> ?(%i13) block([s:0], for i from 1 thru 1000000 do s : s + i, s);
> Evaluation took 21.9220 seconds (42.0870 elapsed)
> (%o13) 500000500000
> (%i14) apply("+",create_list(i,i,1,1000000));
> Evaluation took 1.4680 seconds (1.4670 elapsed)
> (%o14) 500000500000
>
> (And this becomes worse for longer loops; of course, at some
> point memory doesn't follow ;-()
>
>> (3) The usage of a Maxima set as an input to rcs seems spurious.
>>
>
> sure --- this comes from the context where this is all used.
>
>> (4) As for the calls to ev in your code, I don't want to think about it.
>> Ev makes my head hurt.
>>
>
> But it seems to be the only possibility in this application?
>
> thanks!
>
> Oliver
>
>> > Barton
>> >
>> > -----maxima-bounces at math.utexas.edu wrote: -----
>> >
>> >
>> > >Maxima?5.18.1?http://maxima.sourceforge.net
>> > >Using?Lisp?ECL?9.4.1
>> > >declare(rv,noun)$
>> > >rcs(S)?:=?block([L?:?listify(S)],
>> > >??apply("+",create_list(binomial(L[i]-1,i),?i,1,length(L)))?+?1)$
>> > >(%i4)?ev(rv(1,4),rv([L]):=rcs(setify(L)),nouns);
>> > >(%o4)?4
>> > >(%i5)?ev(rv(1,5),rv([L]):=rcs(setify(L)),nouns);
>> > >(%o5)?7.0
>> > >(%i6)?rcs({1,5});
>> > >(%o6)?7
>> > >
>> > >I?hope?you?see?the?disaster:?o6?is?correct,?and?should?be?the?same
>> > >as?o5,?but?somehow?suddenly?the?result?is?turned?into?a?floating-point
>> > >number?(which?depends?on?the?values?---?doesn't?happen?with?o4).
>> > >
>> > >I?guess?I?should?submit?this?as?a?bug,?but?wanted?to?hear?some?comments
>> > >first.
>> > >
>> > >(Workarounds??Currently?the?above?behaviour?blocks?a?whole?development;
>> > >but
>> > >using?floor?doesn't?seem?safe?...)
>> > >
>> > >Oliver
>> > >
>> > >_______________________________________________
>> > >Maxima?mailing?list
>> > >Maxima at math.utexas.edu
>> > >http://www.math.utexas.edu/mailman/listinfo/maxima
>>
>> --
>> Dr. Oliver Kullmann
>> Computer Science Department
>> Swansea University
>> Faraday Building, Singleton Park
>> Swansea SA2 8PP, UK
>> http://cs.swan.ac.uk/~csoliver/
>
> --
> Dr. Oliver Kullmann
> Computer Science Department
> Swansea University
> Faraday Building, Singleton Park
> Swansea SA2 8PP, UK
> http://cs.swan.ac.uk/~csoliver/
> _______________________________________________
> Maxima mailing list
> Maxima at math.utexas.edu
> http://www.math.utexas.edu/mailman/listinfo/maxima
>