Skip to content

Weird DivideError: materialize and rational matmul #199

Open
@Voltobene

Description

@Voltobene

I came across some strange behaviour which I was able to break down to the following:

julia> using LazyArrays
julia> A = zeros(Rational{Int64}, 2, 2);
julia> B = zeros(Rational{Int64}, 2, 25);
julia> materialize(@~ A * B)

throws (even on a clean julia 1.6.3, LazyArrays V 0.22.1)

julia> materialize(@~ A * B)
ERROR: DivideError: integer division error
Stacktrace:
  [1] div
    @ ./int.jl:261 [inlined]
  [2] divgcd
    @ ./rational.jl:45 [inlined]
  [3] *(y::Bool, x::Rational{Int64})
    @ Base ./rational.jl:319
...

Interestingly enough, the following (invoking A * B upfront) works:

julia> A * B;
julia> materialize(@~ A * B)
2×25 Matrix{Rational{Int64}}:
 0//1  0//1  0//1  0//1  0//1  0//1    0//1  0//1  0//1  0//1  0//1  0//1
 0//1  0//1  0//1  0//1  0//1  0//1     0//1  0//1  0//1  0//1  0//1  0//1

Maybe some not yet compiled code is the culprit?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions