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

incorrect norms for vectors with typemin(Int) #30466

Closed
stevengj opened this issue Dec 20, 2018 · 0 comments · Fixed by #30481
Closed

incorrect norms for vectors with typemin(Int) #30466

stevengj opened this issue Dec 20, 2018 · 0 comments · Fixed by #30481
Labels
bug Indicates an unexpected problem or unintended behavior linear algebra Linear algebra

Comments

@stevengj
Copy link
Member

Our L1 and Linf norms give a negative result for typemin(Int) (since the abs function wraps around), even though they return a floating-point result (see #29685) that could represent the correct answer.

julia> norm([typemin(Int), typemin(Int)], Inf) # wrong
-9.223372036854776e18

julia> norm([typemin(Int), typemin(Int)], 1) # wrong
-1.8446744073709552e19

julia> norm([typemin(Int), typemin(Int)], 2) # correct
1.3043817825332783e19

Suggested solution: convert to float before computing abs in these functions.

The hypot function has a similar problem.

cc @andreasnoack

@stevengj stevengj added bug Indicates an unexpected problem or unintended behavior linear algebra Linear algebra labels Dec 20, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Indicates an unexpected problem or unintended behavior linear algebra Linear algebra
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant