2
$\begingroup$

I want to generate all possible vectors programicaly with entrys in $\Bbb Z_4$: $$A_j:=\begin{bmatrix}x_1\\ x_2\end{bmatrix}, \qquad x_i\in \{0,1,2,3\}, j=1,2,\cdots 16.$$

$\endgroup$
1
  • 3
    $\begingroup$ See first hit of the search for keys all possible vectors in the doc center. $\endgroup$
    – Michael E2
    Commented Aug 19, 2019 at 15:35

2 Answers 2

6
$\begingroup$

Use Tuples.

Tuples[{0,1,2,3}, {2}]
$\endgroup$
1
  • $\begingroup$ Thanks @Szabolcs. My purpose of this question was the detailed code of Tuples. $\endgroup$
    – C.F.G
    Commented Aug 19, 2019 at 15:11
2
$\begingroup$

You can also use Outer, since this is a kind of outer product with the function List:

elem = {0, 1, 2, 3}; Flatten[Outer[List, elem, elem], 1]
$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.