16

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

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

https://www.researchgate.net/profile/James-Muldowney-2/publication/38372479_Compound_matrices_and_ordinary_differential_equations/links/58b1b9a8aca2725b5416ed5f/Compound-matrices-and-ordinary-differential-equations.pdf

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

florin
  • 1,798
  • 7
  • 12
  • 12
    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. – Daniel Lichtblau Jan 08 '22 at 16:44
  • 2
    @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? – Hausdorff Jan 14 '22 at 14:15
  • 1
    @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]}}]`

    – Daniel Lichtblau Jan 17 '22 at 21:04
  • 1
    @DanielLichtblau It does do it if you specify the order of the minor matrix, e.g. Minors[Array[a, {2, 3}], 2] – Hausdorff Jan 17 '22 at 23:17
  • 1
    @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. – Hausdorff Jan 18 '22 at 00:06
  • Thanks @Hausdorff, I did not think to check that. – Daniel Lichtblau Jan 18 '22 at 16:53
  • @DanielLichtblau hausdorff Brilliant, these comments are well worth putting as an answer. – pglpm Nov 24 '23 at 07:56

2 Answers2

17

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}}

Henrik Schumacher
  • 106,770
  • 7
  • 179
  • 309
  • 1
    The variables i, j used for Table should also be made local in Module to avoid bugs, such as for example here – Hausdorff Jan 14 '22 at 14:39
  • 1
    @Hausdorff The variables i and j are scoped by Table itself. This should not be the reason for any bugs. – Henrik Schumacher Jan 14 '22 at 17:22
  • 1
    @Hausdorff The documentation of Table says: "Table effectively uses Block to localize values or variables." – Henrik Schumacher Jan 14 '22 at 17:26
  • 1
    But the scoping includes the first argument of Table. After setting f = i, compare for example Table[f, {i, 1, 3}] and Module[{i}, Table[f, {i, 1, 3}]]. In the latter, Module ensures that i is different from any other i in definitions outside the Module. – Hausdorff Jan 14 '22 at 20:49
  • 1
    I don't see how this is relevant here. After all, all other variables are scoped either by the pattern or by ˋModuleˋ. – Henrik Schumacher Jan 14 '22 at 20:52
  • 1
    It is relevant if you for example pass a matrix like A = {{i, j}, {j, i}} into CompoundMatrix. In this case, the i and j of the matrix elements will also be replaced with the iterator values – Hausdorff Jan 14 '22 at 20:55
  • 3
    Oh wow, you're right. This never occured to me. Thanks for the lesson! =) – Henrik Schumacher Jan 14 '22 at 21:01
  • 2
    No worries, this is also the first time I have stumbled over this :) – Hausdorff Jan 14 '22 at 21:06
3

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.

SPPearce
  • 5,653
  • 2
  • 18
  • 40