K=(HTH)-1HT where HT is the transpose of H (rows and columns transposed). The exponent -1 means inverse.
EXAMPLE (N=3 and n=2)
H=
⎛ 1 2 ⎞
⎜ 3 4 ⎟
⎝ 5 6 ⎠
and
HT=
⎛ 1 3 5 ⎞
⎝ 2 4 6 ⎠
HTH=
⎛ 1 3 5 ⎞⎛ 1 2 ⎞
⎝ 2 4 6 ⎠⎜ 3 4 ⎟=
⎝ 5 6 ⎠
⎛ 35 44 ⎞
⎝ 44 56 ⎠
To calculate the inverse we must first find the determinant Δ=35×56-442=24.
(HTH)-1=
⎛ 56 -44 ⎞
⎝ -44 35 ⎠=
24
⎛ 7/3 -11/6 ⎞
⎝ -11/6 35/24 ⎠
K=(HTH)-1HT=
⎛ 7/3 -11/6 ⎞⎛ 1 3 5 ⎞
⎝ -11/6 35/24 ⎠⎝ 2 4 6 ⎠=
⎛ -4/3 -1/3 2/3 ⎞
⎝ 13/12 1/3 -5/12 ⎠
CHECK: KH=
⎛ -4/3 -1/3 2/3 ⎞⎛ 1 2 ⎞
⎝ 13/12 1/3 -5/12 ⎠⎜ 3 4 ⎟=
⎝ 5 6 ⎠
⎛ 1 0 ⎞
⎝ 0 1 ⎠
=I