Some linear algebra and APL results

1 Affine transformation

[ u v 1 ] = [ a b c d e f 0 0 1 ] [ x y 1 ]
Equation 1.1 Affine equations

Where ( u , v ) is the new coordinate and ( x , y ) is the old coordinate.

The APL code mapping an image by this transformation is like:

  | affine{
  |     ⍝ affine transformation
  |     ⎕IO0  s
  |     g¯1↓⍉⌊0.5++.×2 11,s⊤⍳×/s
5 |     m(s>0 1g)0<g
  |     s(0,,)[m×1+sg]
  | }

2 Solve linear equations

For coefficient matrix A , variable matrix X and constant matrix B , then

A X = B X = ( A 1 ) B

Then the APL code is just (⌹A)+.×B, or even simpler, B⌹A. As the APL2 specification writes:

If Z←L⌹R is executable, Z is determined to minimize the value of the least squares expression:

  |+/,(L-R+.×Z)*2

3 Norm in n

The norm of inner product space, a = a , a , is:

  |2*÷+.×

4 Use linear transformation to define polynomial functions

Due to the "superposition" principle, for 4 that basis B = [ 1 , x , x 2 , x 3 ] , L ( p ) = x + x find M that [ L ( p ) ] B = M [ p ] B .

Then M is just:

M = [ 0 1 2 0 0 0 2 6 0 0 0 3 0 0 0 0 ]

This may comes handy when some extent of symbolic computation is needed.

5 Determinant, Generalized

There is already a general determinant from APLcart.info. However, I am not able to explain the mathematics behind it. I could only tell it involves taking the matrix product of upper matrix and diagonal replaced by accumulative sum minus the total sum and itself, negate it, and repeat with the result. Sorry, so far I am only familiar with cofactor expansion method

Actually, Iversion had assigned a special combinator for determinant: monadic -.×. This would not work in most of today's APL implementations, but there is the similar operator in J. Since he has recorded the definition, we are still able to figure out what it means.

Let's first review the cofactor expansion method with a 3 by 3 matrix:

| a b c d e f g h i | = a | e f h i | b | d f g i | + c | d e g h |

Then, here is a play on trick of visualizing the method in APL(⎕IO←0 and remember the evaluation order in APL):

      ⎕←perm←3 6⍴0 0 1 1 2 2 1 2 2 0 0 1 2 1 0 2 1 0
0 0 1 1 2 2
1 2 2 0 0 1
2 1 0 2 1 0
      (⊣,'-',⊢)/(⊣,'×',⊢)/1 0 1⍉(3 3⍴'abcdefghi')[perm;]
┌───────────────────────────────────┐
│a×e×i-a×h×f-d×h×c-d×b×i-g×b×f-g×e×c│
└───────────────────────────────────┘

Now, the only problem left is what is perm? It is not the unique index value since any permutation that can correctly arrange the parity should work.

According to Iverson, matrix determinant can be characterized as:

  | det  {-/×/1 0 1[perm;]}
  | mod  {0=⊃⍴⍵:⍵  [0;],[0]Z+[(1↑⍴Z)0;]Z 1 0}
  |perm  {(mod Z)[;(⍳⍴P)+P-(P2|+Zrep )0 1]}
  | rep  {(⊢⊤(⍳×/))1+⍳1}

Replacing - and × by other functions can give other interesting results, but that would not be covered here. A similar implementation in Dyalog can be found at dfns.

Bibliography

[Iverson] Two combinatoric operators. Kenneth E. Iverson. Proceedings of the eighth international conference on APL. 22 September 1976. G Truman Hunter. 233–237. Association for Computing Machinery. New York, NY, United States. doi:10.1145/800114.803681.

[dfns] Alternant. Adám Brudzewsky. https://dfns.dyalog.com/n_alt.htm.