Maxima/Ecl on 32-bit machine cannot evaluate "apply(union, listify({{..}}))"
Subject: Maxima/Ecl on 32-bit machine cannot evaluate "apply(union, listify({{..}}))"
From: Stavros Macrakis
Date: Thu, 4 Sep 2008 10:46:25 -0400
What I don't understand is why rreduce isn't the fastest in the case
makelist({i},i,1,N). If you look at the pattern of unions, it is glomming
on to the left, which should take just one call to great.
But then I traced set-union and great (see below), and found that
rreduce('union,makelist({i},i,1,5)) calls great 11 times. But only 4 of
those times are in the core set-union function. The other times,
require-set calls simp-set, which IGNORES the simp flag (!!!) and re-sorts
every intermediate result!!! Fix this, and all set operations will suddenly
become much much faster.
-s
(%i44) rreduce('union,makelist({i},i,1,5));
1> (SET-UNION NIL (4))
<1 (SET-UNION (4))
1> (SET-UNION (4) (5))
2> (GREAT 5 4)
<2 (GREAT T)
<1 (SET-UNION (4 5))
1> (SET-UNION NIL (3))
<1 (SET-UNION (3))
1> (GREAT 5 4)
<1 (GREAT T)
1> (SET-UNION (3) (4 5))
2> (GREAT 4 3)
<2 (GREAT T)
<1 (SET-UNION (3 4 5))
1> (SET-UNION NIL (2))
<1 (SET-UNION (2))
1> (GREAT 5 4)
<1 (GREAT T)
1> (GREAT 4 3)
<1 (GREAT T)
1> (SET-UNION (2) (3 4 5))
2> (GREAT 3 2)
<2 (GREAT T)
<1 (SET-UNION (2 3 4 5))
1> (SET-UNION NIL (1))
<1 (SET-UNION (1))
1> (GREAT 3 2)
<1 (GREAT T)
1> (GREAT 5 4)
<1 (GREAT T)
1> (GREAT 4 2)
<1 (GREAT T)
1> (GREAT 4 3)
<1 (GREAT T)
1> (SET-UNION (1) (2 3 4 5))
2> (GREAT 2 1)
<2 (GREAT T)
<1 (SET-UNION (1 2 3 4 5))