Home > Enterprise >  numpy matmul does not compute matrix
numpy matmul does not compute matrix

Time:03-29

I have the following 3x3 matrix H and 3x1 matrix point. Calling the matmul function simply returns the original point. Why and how can I fix this?

H = np.array([[1, -1.07059445e-13,7.30192357e-11],[-1.07136486e-13,1,1.19101035e-11],[-2.88444403e-16,9.61481343e-17,1]])
point = np.array([443.8957214, 198.19000244, 1])
np.matmul(H, np.transpose(point))

CodePudding user response:

Because H is approximately an eye matrix (identical matrix)

H = array([[ 1.00000000e 00, -1.07059445e-13,  7.30192357e-11],
          [-1.07136486e-13,  1.00000000e 00,  1.19101035e-11],
          [-2.88444403e-16,  9.61481343e-17,  1.00000000e 00]])

and multiplying H by point is equal to point:

import numpy as np
H = np.array([[1, -1.07059445e-13,7.30192357e-11],[-1.07136486e-13,1,1.19101035e-11],[-2.88444403e-16,9.61481343e-17,1]])
point = np.array([443.8957214, 198.19000244, 1])
out = np.matmul(H, np.transpose(point))

as you can see here, difference between output and pint is too small.

out - point
array([ 5.18411980e-11, -3.56408236e-11, -1.09023901e-13])
  • Related