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

Failure to check dimensions when multiplying an empty array #1147

Closed
timholy opened this issue Dec 11, 2024 · 0 comments · Fixed by #1152
Closed

Failure to check dimensions when multiplying an empty array #1147

timholy opened this issue Dec 11, 2024 · 0 comments · Fixed by #1152
Labels
regression Regression in behavior compared to a previous version
Milestone

Comments

@timholy
Copy link
Member

timholy commented Dec 11, 2024

Using 1.12.0-DEV.1738 (2024-12-10)

julia> using LinearAlgebra

julia> A = rand(0, 0); B = rand(1, 5);

julia> A*B
0×5 Matrix{Float64}

julia> A = rand(0, 1); B = rand(2, 5);

julia> A*B
0×5 Matrix{Float64}

julia> A = rand(1, 1); B = rand(2, 5);

julia> A*B
ERROR: DimensionMismatch: A has dimensions (1,1) but B has dimensions (2,5)
Stacktrace:
 [1] gemm_wrapper!
   @ ~/src/juliaw/usr/share/julia/stdlib/v1.12/LinearAlgebra/src/matmul.jl:752 [inlined]
 [2] _syrk_herk_gemm_wrapper!
   @ ~/src/juliaw/usr/share/julia/stdlib/v1.12/LinearAlgebra/src/matmul.jl:470 [inlined]
 [3] generic_matmatmul_wrapper!(C::Matrix{…}, tA::Char, tB::Char, A::Matrix{…}, B::Matrix{…}, α::Bool, β::Bool, val::Val{…})
   @ LinearAlgebra ~/src/juliaw/usr/share/julia/stdlib/v1.12/LinearAlgebra/src/matmul.jl:450
 [4] _mul!
   @ ~/src/juliaw/usr/share/julia/stdlib/v1.12/LinearAlgebra/src/matmul.jl:326 [inlined]
 [5] mul!
   @ ~/src/juliaw/usr/share/julia/stdlib/v1.12/LinearAlgebra/src/matmul.jl:295 [inlined]
 [6] mul!
   @ ~/src/juliaw/usr/share/julia/stdlib/v1.12/LinearAlgebra/src/matmul.jl:263 [inlined]
 [7] *(A::Matrix{Float64}, B::Matrix{Float64})
   @ LinearAlgebra ~/src/juliaw/usr/share/julia/stdlib/v1.12/LinearAlgebra/src/matmul.jl:134
 [8] top-level scope
   @ REPL[7]:1
Some type information was truncated. Use `show(err)` to see complete types.

The last case is correct, the others should also throw a DimensionMismatch.

Noticed in JuliaStats/PDMats.jl#212

@KristofferC KristofferC added the regression Regression in behavior compared to a previous version label Dec 11, 2024
@KristofferC KristofferC added this to the 1.12 milestone Dec 11, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
regression Regression in behavior compared to a previous version
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants