15
$\begingroup$

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 :)

$\endgroup$
6
  • 10
    $\begingroup$ 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. $\endgroup$ Jan 8 at 16:44
  • 1
    $\begingroup$ @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? $\endgroup$
    – Hausdorff
    Jan 14 at 14:15
  • 1
    $\begingroup$ @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]}}] $\endgroup$ Jan 17 at 21:04
  • 1
    $\begingroup$ @DanielLichtblau It does do it if you specify the order of the minor matrix, e.g. Minors[Array[a, {2, 3}], 2] $\endgroup$
    – Hausdorff
    Jan 17 at 23:17
  • $\begingroup$ @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. $\endgroup$
    – Hausdorff
    Jan 18 at 0:06
15
$\begingroup$

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

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

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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