Difference between revisions of "CompoundMatrix"

From QETLAB
Jump to navigation Jump to search
m (Created page for CompoundMatrix (a couple edits ago, made some small changes))
m (Capitalize variables in syntax and argument descriptions)
 
(4 intermediate revisions by the same user not shown)
Line 3: Line 3:
 
|desc=Computes the compound matrix of a given matrix
 
|desc=Computes the compound matrix of a given matrix
 
|cat=[[List of functions#Miscellaneous|Miscellaneous]]
 
|cat=[[List of functions#Miscellaneous|Miscellaneous]]
|upd=November 12, 2014
+
|upd=August 23, 2024
|v=0.50}}
+
|v=0.90}}
 
<tt>'''CompoundMatrix'''</tt> is a [[List of functions|function]] that computes the ''r'' <sup>th</sup> [https://en.wikipedia.org/wiki/Compound_matrix compound matrix] of a given matrix.
 
<tt>'''CompoundMatrix'''</tt> is a [[List of functions|function]] that computes the ''r'' <sup>th</sup> [https://en.wikipedia.org/wiki/Compound_matrix compound matrix] of a given matrix.
  
 
==Syntax==
 
==Syntax==
* <tt>comp = CompoundMatrix(A, r)</tt>
+
* <tt>COMP = CompoundMatrix(A, R)</tt>
  
 
==Argument descriptions==
 
==Argument descriptions==
* <tt>A</tt>: A matrix.
+
* <tt>A</tt>: An <tt>m</tt>-by-<tt>n</tt> matrix.
* <tt>r</tt>: An integer denoting the size of the minors to compute.
+
* <tt>R</tt>: An integer denoting the size of the minors to compute. Must be between <tt>1</tt> and <tt>min{m, n}</tt>, inclusive. If <tt>R > min{m, n}</tt>, then the result is the <tt>0x0</tt> matrix.
  
 
==Example==
 
==Example==
Taking the 2<sup>nd</sup> compound matrix involves calculating 2 by 2 minors of the matrix. For a 3 by 4 matrix, the entries for these minors can be indexed by the row index sets {1,2}, {1,3}, and {2,3} and the column index sets {1,2}, {1,3}, {1,4}, {2,3}, {2,4}, and {3,4}. The computed values are placed in the resulting compound matrix according to the lexicographic ordering of the index sets. The following code shows an example:
+
Taking the 2<sup>nd</sup> compound matrix involves calculating 2-by-2 minors of the matrix. For a 3-by-4 matrix, the entries for these minors can be indexed by the row index sets {1,2}, {1,3}, and {2,3} and the column index sets {1,2}, {1,3}, {1,4}, {2,3}, {2,4}, and {3,4}. The computed values are placed in the resulting compound matrix according to the lexicographic ordering of the index sets. The following code shows an example:
 
<syntaxhighlight>
 
<syntaxhighlight>
 
>> A = [1, 3, 7, 2; 8, 5, 3, 4; 6, 9, 0, 1]
 
>> A = [1, 3, 7, 2; 8, 5, 3, 4; 6, 9, 0, 1]
>> r = 2
 
>> compoundMatrix(A, r)
 
 
  
 
A =
 
A =
Line 29: Line 26:
  
  
 +
>> r = 2
  
 
r =
 
r =
Line 35: Line 33:
  
  
 +
>> CompoundMatrix(A, r)
  
 
ans =
 
ans =
Line 42: Line 41:
 
   42  -18  -16  -27  -31    3
 
   42  -18  -16  -27  -31    3
 
</syntaxhighlight>
 
</syntaxhighlight>
Notice that the size of the resulting matrix is not necessarily the same size as the original matrix. In general, the size of the compound matrix is (''m'' choose ''r'' ) by (''n'' choose ''r'' ) for an ''m'' by ''n'' matrix.
+
Notice that the size of the resulting matrix is not necessarily the same size as the original matrix. In general, the size of the compound matrix is (''m'' choose ''r'' )-by-(''n'' choose ''r'' ) for an ''m''-by-''n'' matrix.
  
 
{{SourceCode|name=CompoundMatrix}}
 
{{SourceCode|name=CompoundMatrix}}

Latest revision as of 14:06, 26 August 2024

CompoundMatrix
Computes the compound matrix of a given matrix

Other toolboxes required none
Function category Miscellaneous

CompoundMatrix is a function that computes the r th compound matrix of a given matrix.

Syntax

  • COMP = CompoundMatrix(A, R)

Argument descriptions

  • A: An m-by-n matrix.
  • R: An integer denoting the size of the minors to compute. Must be between 1 and min{m, n}, inclusive. If R > min{m, n}, then the result is the 0x0 matrix.

Example

Taking the 2nd compound matrix involves calculating 2-by-2 minors of the matrix. For a 3-by-4 matrix, the entries for these minors can be indexed by the row index sets {1,2}, {1,3}, and {2,3} and the column index sets {1,2}, {1,3}, {1,4}, {2,3}, {2,4}, and {3,4}. The computed values are placed in the resulting compound matrix according to the lexicographic ordering of the index sets. The following code shows an example:

>> A = [1, 3, 7, 2; 8, 5, 3, 4; 6, 9, 0, 1]

A =

     1     3     7     2
     8     5     3     4
     6     9     0     1


>> r = 2

r =

     2


>> CompoundMatrix(A, r)

ans =

  -19  -53  -12  -26    2   22
   -9  -42  -11  -63  -15    7
   42  -18  -16  -27  -31    3

Notice that the size of the resulting matrix is not necessarily the same size as the original matrix. In general, the size of the compound matrix is (m choose r )-by-(n choose r ) for an m-by-n matrix.

Source code

Click here to view this function's source code on github.