Yesterday and about five months ago, I asked two similar questions but nobody could answer me; maybe because my question was ambiguous. But, I myself tried and I could finally find my desired answer. But, now my question is that is there a command to shorten the following and does not have the problem of memory?
My yesterday question: assume that you have an $n \times n$ matrix $A$; here for simplicity I suppose that $n=2$. Some of specified entries of this matrix is zero and the others "which we know which ones", are nonzero but the nonzero entries can have 3 different cases; for example for the $2 \times 2$ matrix, $a_{11}=a_{22}=0$ and $a_{12},a_{2,1} \neq 0 $ and can be 2,3 or 5. Now, I want a code to show me all possible values for the determinant of $A$ (that here are $-4,-6,-9,-10,-15,-25)$; My code is as follows:
a = Tuples[{2, 3, 5}, {1, 2}];
b = Table[0, {2}, {2}];
For[i = 1, i <= Length[a], i++,
{b[[1, 2]] = a[[i]][[1]][[1]]; b[[2, 1]] = a[[i]][[1]][[2]];
Print[Det[b]]}]
which gives
-4
-6
-10
-6
-9
-15
-10
-15
-25
My quesion:Now, my question is that if $A$ has for example 20 nonzero entries, this code doesn't help; because of the first line which now will be
a = Tuples[{2, 3, 5}, {1, 20}];
and the memory will be fulled.
Bests,