EDIT 1: thanks to the user @orpanter, author of the OP, for running the diagnostics and checking that the suggested solution indeed works correctly.
We code in a matrix
matrix = {{1, 2, 3, 4}, {7, 8, 9, 10}, {5, 4, 3, 2}, {11, 9, 6,
5}, {12, 13, 3, 4}, {1, 0, 14, 4}};
with Dimensions
given by
matrix // Dimensions
{6, 4}
From the documentation, we know that Subsets
gives a list of all possible subsets of list.
subsets = Subsets[matrix];
From the above sublists, we keep only the ones that are square
res = Select[subsets, SquareMatrixQ[##] &];
and then we calculate their determinants
Det /@ res
{0, 0, 0, -66, 36, -594, -66, 36, -594, -1375, -132, 72, -1188, -2593, 157}
Edit 2: substantial edit
After the comments, the matrix we consider here is given by:
matrix = {{1, 1, 1, 1, 0, 0, 0}, {1, 0, 0, 0, 1, 1, 1}, {0, -1, 0, 0,
1, 0, 0}, {0, 0, -1, 0, 0, 1, 0}, {0, 0, 0, -1, 0, 0, 1}, {A, 0,
1, A/B, 0, 0, 0}, {B, 0, B/A, 1, 0, 0, 0}};
Dimensions@matrix
MatrixForm@matrix
{7, 7}
For the reader's convenience, the task at hand is to compute the determinant of the initial/seed matrix and all submatrices. Hence, we need to compute ALL SQUARE submatrices.
0
- Step 2: Previously, I suggested
Subsets
, but upon reflection I think that the way to go about it is Minors
.
For the seed $7 \times 7$ matrix we run
obo = Minors[matrix, 1, Identity];
tbt = Minors[matrix, 2, Identity];
ttbtt = Minors[matrix, 3, Identity];
fbf = Minors[matrix, 4, Identity];
ffbff = Minors[matrix, 5, Identity];
sbs = Minors[matrix, 6, Identity];
To obtain all the sub-ones. The outputs are large, however, for display purposes one can try for instance
Grid@Partition[MatrixForm /@ sbs[[1]], 5]
and for sbs[[2]]
etc up until sbs[[Length@sbs]]
. The output of the above looks as follows:
Thus, we have obtained all $1 \times 1$, $2 \times 2$, etc.
- Step 3: computing their determinants.
A demonstration for the $1 \times 1$ cases.
obo
returns
{{{{1}}, {{1}}, {{1}}, {{1}}, {{0}}, {{0}}, {{0}}}, {{{1}}, {{0}}, \ {{0}}, {{0}}, {{1}}, {{1}}, {{1}}}, {{{0}}, {{-1}}, {{0}}, {{0}}, \ {{1}}, {{0}}, {{0}}}, {{{0}}, {{0}}, {{-1}}, {{0}}, {{0}}, {{1}}, \ {{0}}}, {{{0}}, {{0}}, {{0}}, {{-1}}, {{0}}, {{0}}, {{1}}}, {{{A}}, \ {{0}}, {{1}}, {{A/B}}, {{0}}, {{0}}, {{0}}}, {{{B}}, {{0}}, {{B/ A}}, {{1}}, {{0}}, {{0}}, {{0}}}}
and we can calculate and display the determinants as follows:
Grid@Partition[Table[Det /@ obo[[i]], {i, 1, Length@obo}], 4]
The $2 \times 2$ cases
Grid@Partition[Table[Det /@ tbt[[i]], {i, 1, Length@tbt}], 4]
Minors[matrix, 4, Det]
? $\endgroup$