Matrix multiplication and type stability

Hello! Let’s consider MVE:

using LinearAlgebra
using AlgebraicNumbers


M = AlgebraicNumber.([
    1 2
    3 4
])

b = AlgebraicNumber.([5; 6])

println(typeof(M))
println(typeof(b))

x = M * b

println(typeof(x))

Expected a Vector{AlgebraicNumber...}, not Vector{Any}, just like in this:

using LinearAlgebra
using AlgebraicNumbers


M = Rational.([
    1 2
    3 4
])

b = Rational.([5; 6])

println(typeof(M))
println(typeof(b))

x = M * b

println(typeof(x))

That’s interesting that it works just fine with functions like det and tr, but not with matrix multiplication.

So, my question is: is it normal behavior? And if so, how should I perform this operation in order to get Vector{AlgebraicNumber...}? Should I just use conversion from type Any?

For anybody following, this should now be fixed.
See this issue and the corresponding pr.

2 Likes