42. Minors
{(↓~⍤1 0⍨⍳≢⍵)(⍉⌷)⍤0 99⊢⍵}⍤2⍣2
A minor of size one less than the size of a matrix obtains by removing row i
and column j ;
the array of such minors can be computed as follows:
minors← {(↓~⍤1 0⍨⍳≢⍵)(⍉⌷)⍤0 99⊢⍵}⍤2⍣2
⊢ m← 3 4⍴⍳12
0 1 2 3
4 5 6 7
8 9 10 11
⍴ minors m
3 4 2 3
⊂⍤¯2 minors m
┌───────┬───────┬──────┬──────┐
│5 6 7│4 6 7│4 5 7│4 5 6│
│9 10 11│8 10 11│8 9 11│8 9 10│
├───────┼───────┼──────┼──────┤
│1 2 3│0 2 3│0 1 3│0 1 2│
│9 10 11│8 10 11│8 9 11│8 9 10│
├───────┼───────┼──────┼──────┤
│1 2 3 │0 2 3 │0 1 3 │0 1 2 │
│5 6 7 │4 6 7 │4 5 7 │4 5 6 │
└───────┴───────┴──────┴──────┘
⊂⍤¯2 minors 4 4⍴⎕a
┌───┬───┬───┬───┐
│FGH│EGH│EFH│EFG│
│JKL│IKL│IJL│IJK│
│NOP│MOP│MNP│MNO│
├───┼───┼───┼───┤
│BCD│ACD│ABD│ABC│
│JKL│IKL│IJL│IJK│
│NOP│MOP│MNP│MNO│
├───┼───┼───┼───┤
│BCD│ACD│ABD│ABC│
│FGH│EGH│EFH│EFG│
│NOP│MOP│MNP│MNO│
├───┼───┼───┼───┤
│BCD│ACD│ABD│ABC│
│FGH│EGH│EFH│EFG│
│JKL│IKL│IJL│IJK│
└───┴───┴───┴───┘

Anecdote
One time, I visited Prof. Keith Smillie in Edmonton and had lunch with him.
We took a bus returning from lunch.
The conversation got to the J mug.
Just before Prof. Smillie’s stop, I asked him if he knew what the J
expression 1&(|:\.)"2^:2 on the mug did.
He paused as he was getting off the bus,
turned right around to get back on the bus,
and we talked some more about minors.
This story elicited a chuckle from Ken Iverson
when I told him about it. (He was the author of the expression.)
Appeared in J on the J mug and in
[51f,
118].
|