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

Matrix multiplication and type stability #25

Closed
denshd opened this issue Dec 3, 2023 · 2 comments · Fixed by #26
Closed

Matrix multiplication and type stability #25

denshd opened this issue Dec 3, 2023 · 2 comments · Fixed by #26

Comments

@denshd
Copy link

denshd commented Dec 3, 2023

Hello! Didn't get an answer on Discourse, so hope to succeed here.

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 example:

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?

@fkastner
Copy link
Collaborator

fkastner commented Dec 4, 2023

Hi,
many thanks for using the package and for reporting this issue!
This is not normal behaviour and was caused by a type instability in the code.
I just pushed an update that should hopefully fix this.
It should be available from the registry shortly.
Please report back if it doesn't fix your issue.

@anj1
Copy link
Owner

anj1 commented Dec 5, 2023

Thanks @fkastner for looking into this.

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 a pull request may close this issue.

3 participants