Brian Schott wrote:
> John,
>
>       I don't understand how you have identified hh as the
> inverse of h. I see that it does accomplish the desired or
> simpler result of using { rather that }, but in general how
> can an inverse like hh be identified from its dual (is dual
> the right terminology)? That is, I thought I could use h
> with amend, but if I can always find hh from h and then use
> {, that could be superior. Also, could you demonstrate that
> h and hh are really inverses. My understanding says that an
> inverse reverses the effect of its dual, but I don't see hh
> reversing h. Are you saying that { and } are inverse
> (functors -- I don't even know what a functor is, but this
> sounds like it might be right) and if { and } are
> inverses, then that is a revelation to me.
>

Brian:

Here are a couple of ways of finding the inverse of a permutation.
This is the inverse in a group-theoretic sense, where the group
multiplication is (non-commutative) composition of permutations.  If
the permutations are expressed in direct form, composition is { .

   h=:1 2 0 3
   hh=:2 0 1 3
   h { hh
0 1 2 3
   hh { h
0 1 2 3

The easiest "mathematical" way of thinking about inverses of
permutations is the following:

h=:1 2 0 3

In 2-row notation this is

0 1 2 3
1 2 0 3

You get the inverse by flipping the rows,

1 2 0 3
0 1 2 3

sorting the columns,

0 1 2 3
2 0 1 3

and taking the last row

2 0 1 3

This corresponds to the J verb

   pinv=:3 : '{: /:~&.|: |.(i.#y),:y'
   pinv h
2 0 1 3

However, you can do this in one:

  /: h
2 0 1 3

Alternatively, you can find the inverse by reversing each cycle when
the permutation is expressed in disjoint cycle form.

Convert h to cycle form,

+-----+-+
|2 0 1|3|
+-----+-+

reverse each cycle,

+-----+-+
|1 0 2|3|
+-----+-+

convert back to direct form

2 0 1 3

This corresponds to

   pinv3=:|.&.>&.C.
   pinv3 h
2 0 1 3

Obviously this method is most useful when you start and finish with
the permutation in cycle form, and you find the inverse with |.&.> .

Finally, { and } and (kind of) inverses with respect to permutations,
but this is really the result of the inverse permutation being given
by /: .  This is what I was getting at:

   f=:3 : 'y { i.#y'  NB. identity
   f h
1 2 0 3

   g=:3 : '(i.#y) y } y' NB. inverse: only shape of RHA to } matters
   g h
2 0 1 3

Best wishes,

John




----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm

Reply via email to