[GAP Forum] cartesian product

Dmitrii Pasechnik dima at ntu.edu.sg
Thu Nov 29 14:01:26 GMT 2007


Inneke,

this looks like a straightforward programming task:
think of elements of your product as indexed by lists, or better, as
"numbers in mixed base" (e.g. if all yours sets are of size 10 then these
numbers will be usual decimal numbers). All you need to implement is a
function that computes the "next number", and this is really less than 10
lines of GAP code.
Then you call this function in a repeat/until loop, and store the elements
that satisfy your conditions only.

HTH,
m.v.g.,
Dmitrii

On 11/29/07 8:01 PM, "Inneke Van Gelder" <ivgelder at vub.ac.be> wrote:

> Hi,
> 
>  
> 
>  
> 
> I need to compute the Cartesian product of an arbitrary number of sets and
> test the members of the Cartesian product to some conditions. But only a few
> satisfy the conditions. My problem is that I exceed the permitted memory to
> soon. Is there a way to compute the Cartesian product member by member and
> test before saving? If the number of sets is known, it isn't difficult,
> because you can avoid recursion. But what about an arbitrary number of sets?
> 
>  
> 
>  
> 
> Thanks for helping,
> 
>  
> 
> Inneke
> 
> _______________________________________________
> Forum mailing list
> Forum at mail.gap-system.org
> http://mail.gap-system.org/mailman/listinfo/forum

-- 
Dima Pasechnik
http://www.ntu.edu.sg/home/dima/





More information about the Forum mailing list