# Are compound matrices implemented in mathematica?

Compound matrices are matrices whose entries are all the minors of a given size of another matrix.

https://en.wikipedia.org/wiki/Compound_matrix

They are probably not too hard to write by the user, but maybe I am lucky and they are already implemented in mathematica ? Thanks :)

• Minors does this for square matrices. It was recently noticed that we did not extend to rectangular, so we added support for that to a future release. Commented Jan 8, 2022 at 16:44
• @DanielLichtblau Please correct me, but at least in versions 12.0.0 and 13.0.0, Minors seems to give sensible results for rectangular matrices as well? Commented Jan 14, 2022 at 14:15
• @Hausdorff Not that I can see: In[209]:= Minors[Array[a, {2, 3}]] During evaluation of In[209]:= Minors::matsq: Argument {{a[1,1],a[1,2],a[1,3]},{a[2,1],a[2,2],a[2,3]}} at position 1 is not a non-empty square matrix. Out[209]= Minors[{{a[1, 1], a[1, 2], a[1, 3]}, {a[2, 1], a[2, 2], a[2, 3]}}] Commented Jan 17, 2022 at 21:04
• @DanielLichtblau It does do it if you specify the order of the minor matrix, e.g. Minors[Array[a, {2, 3}], 2] Commented Jan 17, 2022 at 23:17
• @DanielLichtblau And it seems you would need to specify the order to make the minor matrix well-defined in the rectangular case. In your example you could image dropping either a column and row each time (leading to 1×1 "determinants"), or only a column (leading to 2×2 determinants). I don't see which would be the natural extension of the square case. Plus, for the compound matrix, you have to to specify the minor order anyways. Commented Jan 18, 2022 at 0:06

I don't think that they are built-in, but they are easy enough to implement:

CompoundMatrix[A_?MatrixQ, k_Integer] := Module[{m, n, p, q, i, j},
{m, n} = Dimensions[A];
p = Subsets[Range[1, m], {k}];
q = Subsets[Range[1, n], {k}];
Table[Det[A[[i, j]]], {i, p}, {j, q}]
];


Using the elementary example from the linked Wikipedia article:

A = Partition[Range[1, 12], 4];
CompoundMatrix[A, 2]


{{-4, -8, -12, -4, -8, -4}, {-8, -16, -24, -8, -16, -8}, {-4, -8, -12, -4, -8, -4}}

• The variables i, j used for Table should also be made local in Module to avoid bugs, such as for example here Commented Jan 14, 2022 at 14:39
• @Hausdorff The variables i and j are scoped by Table itself. This should not be the reason for any bugs. Commented Jan 14, 2022 at 17:22
• @Hausdorff The documentation of Table says: "Table effectively uses Block to localize values or variables." Commented Jan 14, 2022 at 17:26
• Oh wow, you're right. This never occured to me. Thanks for the lesson! =) Commented Jan 14, 2022 at 21:01
• No worries, this is also the first time I have stumbled over this :) Commented Jan 14, 2022 at 21:06

Sorry for answering a year-old question with a self-plug, I've moved out of the applied mathematics field and no longer keep an eye on this site.

I have a package that implements the method of compound matrices for solving eigenvalue boundary value problems by calculating the Evans function, an analytic function whose roots correspond to the eigenvalues. Some details are available at these two questions, or this PDF. Or search for CompoundMatrixMethod on this site to see my other answers here.