Skip to content

Conversation

@stevengj
Copy link
Member

@stevengj stevengj commented Dec 5, 2024

Currently, the DimensionMismatch exceptions refer to internal parameter names of gemv!, which is confusing because those don't necessarily match the caller's variables. For example:

julia> B = rand(1000,100); c = rand(1000);

julia> B * c
ERROR: DimensionMismatch: second dimension of A, 100, does not match length of x, 1000
Stacktrace:
 [1] gemv!
   @ ~/.julia/juliaup/julia-1.11.2+0.x64.apple.darwin14/share/julia/stdlib/v1.11/LinearAlgebra/src/matmul.jl:438 [inlined]

This PR changes the error messages to refer to "matrix" instead of "A" and "input vector" instead of "x", etc.

@stevengj stevengj added the docs This change adds or pertains to documentation label Dec 5, 2024
@jishnub jishnub merged commit 5cdeb46 into master Dec 6, 2024
2 checks passed
@jishnub jishnub deleted the stevengj-patch-1 branch December 6, 2024 06:28
@mcabbott
Copy link
Collaborator

Seems like a good idea. It's not just gemv! though:

julia> [1 2 3; 4 5 6] * (1:10)
ERROR: DimensionMismatch: matrix A has dimensions (2,3), vector B has length 10
Stacktrace:
 [1] _generic_matvecmul!
   @ ~/.julia/dev/julia/usr/share/julia/stdlib/v1.12/LinearAlgebra/src/matmul.jl:946 [inlined]
  
julia> rand(3,4) * rand(3,4)
ERROR: DimensionMismatch: A has dimensions (3,4) but B has dimensions (3,4)
Stacktrace:
 [1] gemm_wrapper!
   @ ~/.julia/dev/julia/usr/share/julia/stdlib/v1.12/LinearAlgebra/src/matmul.jl:752 [inlined]

@stevengj
Copy link
Member Author

Yeah, I knew there were more cases, but didn't have a chance to track them all down in this PR. File an issue?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

docs This change adds or pertains to documentation

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants