Skip to content

Commit

Permalink
Ensure norm succeeds on numerical errors in inner(...) (#68)
Browse files Browse the repository at this point in the history
* Ensure norm succeeds on numerical errors in inner

Due to numerical errors the inner product can sometimes return an infinitesimal negative number (e.g. -1e-26). This negative number causes the sqrt to fail with a domain error

This fix ensures that the result of the inner product of X and X is always greater than or equal to zero (which it should be by definition)
  • Loading branch information
TimQuelch authored May 15, 2021
1 parent 98e5c87 commit e1babe4
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
2 changes: 1 addition & 1 deletion Project.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
name = "ManifoldsBase"
uuid = "3362f125-f0bb-47a3-aa74-596ffd7ef2fb"
authors = ["Seth Axen <seth.axen@gmail.com>", "Mateusz Baran <mateuszbaran89@gmail.com>", "Ronny Bergmann <manopt@ronnybergmann.net>", "Antoine Levitt <antoine.levitt@gmail.com>"]
version = "0.10.6"
version = "0.10.7"

[deps]
LinearAlgebra = "37e2e46d-f89d-539d-b4ee-838fcccc9c8e"
Expand Down
2 changes: 1 addition & 1 deletion src/ManifoldsBase.jl
Original file line number Diff line number Diff line change
Expand Up @@ -669,7 +669,7 @@ end
Compute the norm of tangent vector `X` at point `p` from a [`Manifold`](@ref) `M`.
By default this is computed using [`inner`](@ref).
"""
norm(M::Manifold, p, X) = sqrt(real(inner(M, p, X, X)))
norm(M::Manifold, p, X) = sqrt(max(real(inner(M, p, X, X)), 0))

"""
number_eltype(x)
Expand Down

2 comments on commit e1babe4

@kellertuer
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@JuliaRegistrator
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Registration pull request created: JuliaRegistries/General/36796

After the above pull request is merged, it is recommended that a tag is created on this repository for the registered package version.

This will be done automatically if the Julia TagBot GitHub Action is installed, or can be done manually through the github interface, or via:

git tag -a v0.10.7 -m "<description of version>" e1babe45ebc6b9ccbec9e4946f8f947d4575aa48
git push origin v0.10.7

Please sign in to comment.