Skip to content

Fix sign error in derivative output#68

Open
petergehler wants to merge 1 commit intoFoundations-of-Computer-Vision:mainfrom
petergehler:fix
Open

Fix sign error in derivative output#68
petergehler wants to merge 1 commit intoFoundations-of-Computer-Vision:mainfrom
petergehler:fix

Conversation

@petergehler
Copy link

There is a sign error in the derivation, this PR fixes it, the other equations in the section are correct.

  • See the python code below.
  • The PR fc7b84c also concerns this but only fixes one sign, not both.
import numpy as np

# Define the 5x5 matrix - you can change these values
D = np.array([
 #   [1.0, .0, .0, .0, .0],
    [-1.0, 1.0, .0, .0, .0],
    [.0, -1.0, 1.0, .0, .0],
    [.0, .0, -1.0, 1.0, .0],
    [.0, .0, .0, -1.0, 1.0]
])

# Define the 5x1 vector - you can change these values
l = np.array([
    [1.0],
    [1.0],
    [2.0],
    [2.0],
    [0.0]
])

# Compute the matrix-vector product: r = D * l
r = D @ l

invD = np.linalg.pinv(D)
lhat = invD @ r


print("Matrix D (5x5):")
print(D)
print("Matrix 5* inv D (5x5):")
print(5*np.round(invD,1))
print("\nSignal l (5x1):")
print(l)
print("\nProduct r = D * l:")
print(r)
print("\nProduct lhat = pinv(D) * t:")
print(np.round(lhat, 1))

with output:

Matrix D (5x5):
[[-1.  1.  0.  0.  0.]
 [ 0. -1.  1.  0.  0.]
 [ 0.  0. -1.  1.  0.]
 [ 0.  0.  0. -1.  1.]]
Matrix 5* inv D (5x5):
[[-4. -3. -2. -1.]
 [ 1. -3. -2. -1.]
 [ 1.  2. -2. -1.]
 [ 1.  2.  3. -1.]
 [ 1.  2.  3.  4.]]

Signal l (5x1):
[[1.]
 [1.]
 [2.]
 [2.]
 [0.]]

Product r = D * l:
[[ 0.]
 [ 1.]
 [ 0.]
 [-2.]]

Product lhat = pinv(D) * t:
[[-0.2]
 [-0.2]
 [ 0.8]
 [ 0.8]
 [-1.2]]

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant