Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implement norm with np.hypot #45

Open
jankrepl opened this issue Aug 16, 2021 · 2 comments
Open

Implement norm with np.hypot #45

jankrepl opened this issue Aug 16, 2021 · 2 comments

Comments

@jankrepl
Copy link
Contributor

Would be nice to check whether it is faster:)

@jankrepl jankrepl mentioned this issue Aug 16, 2021
26 tasks
@Stannislav
Copy link
Contributor

Stannislav commented Aug 16, 2021

I think np.linalg.norm and np.hypot have slightly different interfaces that correspond to different usecases:

  • np.linalg.norm(vecs, axis=1) - all coordinates in the same array
  • np.hypot(xs, ys) - coordinates in separate arrays, more like a mesh-grid; only 2D.

By in the case of DisplacementField.norm

@property
def norm(self):
"""Norm for each pixel."""
return np.sqrt(np.square(self.delta_x) + np.square(self.delta_y))

we could definitely improve by using np.hypot(self.delta_x, self.delta_y)

@jankrepl
Copy link
Contributor Author

Heh, for some reason I thought we had np.norm in the code but it is clearly not the case. I will adjust the name of this issue.

@jankrepl jankrepl changed the title Replace np.norm with np.hypot Implement norm with np.hypot Aug 17, 2021
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

No branches or pull requests

2 participants