Skip to content

make dot docstring match the implementation #1400

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

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

adienes
Copy link
Member

@adienes adienes commented Jul 3, 2025

as written it's incorrect since sum will promote the types but + (and dot) overflow

julia> x = collect(0xf0:0xff); y = copy(x);

julia> sum(dot(i, j) for (i, j) in zip(x, y))
0x00000000000004d8

julia> dot(x, y)
0xd8

closes JuliaLang/julia#15690

@stevengj
Copy link
Member

stevengj commented Jul 3, 2025

Should we instead fix the code to match the docstring?

@adienes
Copy link
Member Author

adienes commented Jul 3, 2025

I suppose that depends on whether you think of dot more as a reducing operation or a "scalar" operation on scalars-that-are-actually-vectors, in that reducing operations typically widen types and arithmetic does not.

note that numpy also chooses to overflow on np.dot (so Julia and numpy are at the moment consistent)

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.

dot overflows
2 participants