Some linear algebra and APL results


Table of Contents

1. Affine transformation
2. Solve linear equations

1. Affine transformation

Equation 1. Affine equations

[uv1]=[abcdef001][xy1]

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
     ⎕IO←0 ⋄ s←⍴⍵
     g←¯1↓⍉⌊0.5+⍺+.×⍤2 1⊢1,⍨⍉s⊤⍳×/s
     m←∧⌿(s>⍤0 1⊢g)∧0<g
     s⍴(0,,⍵)[m×1+s⊥g]
 }

2. Solve linear equations

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

AX=BX=(A1)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