optimize and add index range check for "index" in FiniteSetAggregate
In particular, this optimizes for CharacterClass a lot, because
size()$CharacterClass is huge. This patch reduce run time
of "testLookupIndex(CharacterClass)" in finite.input from 18.3s
to 0.05s.
diff --git a/src/algebra/aggcat.spad b/src/algebra/aggcat.spad
index 2d7db60a..8e70ed83 100644
--- a/src/algebra/aggcat.spad
+++ b/src/algebra/aggcat.spad
@@ -662,7 +662,8 @@
complement s == difference(universe(), s )
size() == 2 ^ size()$S
index i ==
- set([index(j::PositiveInteger)$S for j in 1..size()$S
+ (l := length(i-1)) > size()$S => error "index out of bound"
+ set([index(j::PositiveInteger)$S for j in 1..l
| bit?(i-1, j-1)])
lookup s ==
--
You received this message because you are subscribed to the Google Groups
"FriCAS - computer algebra system" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
Visit this group at https://groups.google.com/group/fricas-devel.
For more options, visit https://groups.google.com/d/optout.