I have seen that there is question here which does almost what I wanted to ask but it's not quite what I wanted.
Efficiently generating tuples with Outer
What I would like to have is a Tuples of a fixed number elements such that, that combination needs to satisfy a condition. Not very efficiently is
Select[Tuples[{a1,a2,a3,...,aN},fixeddimension],criterion]
I know that it seems similar to the other one, but what I want is an efficient way to write Tuples of fixeddimension each of them satisfying a criterion. I don't know if it's possible to generalize to a multiple criteria the previous idea, so something like
Select[Tuples[{a1,a2,a3,...,aN}],criterion1 && criterion2]
but I already have a problem with Tuples[{a1,a2,a3,...aN}]
because the inputs "aN" contain subscripts and I would like to have Tuples which leave the expression as it is, without expanding the subscripts. This is solved ones I add the "fixeddimension" of the tuplet.
What I wrote is anyway inefficient because the machine needs to store all the possible tuples before starting to select them (which was also the problem with the previous question). So here what I would like to have:
- A generalization of the previous question for multiple criteria and a way to solve why when I don't specify the dimension of the tuples, the variables with subscripts are separated by their subscript.
- A generalization of the previous question in which we make a selection of the tuplet of fixed length which satisfy a condition.