On Wed, May 15, 2013 at 3:42 PM, Elton Wang <[email protected]> wrote:
> Can anyone please help me understand u. v on monad case?
> For instance, -/ . * i.3, how's it get reduced step by step on the definition
> below?
>
> DET=: 2 : 'v/@,`({."1 u . v $:@minors)@.(0<{:@$) @ ,. "2' minors=: }."1 @
> (1&([\.))
First, your mail software merged those two lines. Sometimes it helps
to add extra blank lines to defeat these mechanisms.
DET=: 2 : 'v/@,`({."1 u . v $:@minors)@.(0<{:@$) @ ,. "2'
minors=: }."1 @ (1&([\.))
As it happens, -/ .* i.3 is different from -/ DET * i.3 and I think
the difference has to do with handling of edge cases, but that's not a
small issue.
I'd inspect the result of
< . (,&<"0) i. 3 3
to get an understanding of the mechanism.
Possibly relevant past threads include
http://www.jsoftware.com/pipermail/programming/2006-December/004260.html
That said, we know, from reading the dictionary that DET implements
recursive expansion of minors. In other words, it splits out the
first column (but what's the first column for i.3?) and then for each
element of that first column, it combines that value with -/ .*
applied to <<the remaining columns with the row that had that value
removed>> using * (the right argument to . ) and then assembles those
results into an array which it passes to -/.
So let's take a look at < DET (,&<"0)
,&<"0/@,`({."1 < .(,&<"0) $:@minors)@.(0 < {:@$)@,."2
Or -/ DET *
*/@,`({."1 -/ .* $:@minors)@.(0 < {:@$)@,."2
First, note that this thing is rank 2, so we can mostly ignore
dimensions higher than 2.
Looking at this procedurally, after limiting the scope of the function
to rank 2 arguments, it then uses ,. to ensure that if the rank is
less than 2 that that can also be ignored. So i.3 becomes i.3 1
The next procedural step after that checks whether the final dimension
of the result is 0 (*/ i.2 0 for that case, in your example - repeated
3 times) or not ({."1 < .(,&<"0) $:@minors i.3 1 for that case).
...
...oh, it looks like Henry's responding here, I've got other things to
do so I'll step back from this, at least for now.
Thanks,
--
Raul
----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm