Givens matrix for an integer vector

As a newcomer to Julia I am still struggling with various type-related issues. One of them is this:

using LinearAlgebra
julia> x = [3,4]
2-element Array{Int64,1}:

julia> G,r = givens(x,1,2)
ERROR: MethodError: no method matching givensAlgorithm(::Int64, ::Int64)
 [1] givens(::Int64, ::Int64, ::Int64, ::Int64) at /buildworker/worker/package_linux64/build/usr/share/julia/stdlib/v1.1/LinearAlgebra/src/givens.jl:276
 [2] givens(::Array{Int64,1}, ::Int64, ::Int64) at /buildworker/worker/package_linux64/build/usr/share/julia/stdlib/v1.1/LinearAlgebra/src/givens.jl:317
 [3] top-level scope at none:0

If instead I define x as a vector containing floats, things are fine:

julia> x = [3.0,4.0]
2-element Array{Float64,1}:

julia> G,r = givens(x,1,2)
(LinearAlgebra.Givens{Float64}(1, 2, 0.6, 0.8), 5.0)

Is this really an anticipated behavior? In the documentation I can read that givens can be called as givens(x::AbstractVector, i1::Integer, i2::Integer). Shouldn’t then a vector of integers be perfectly fine?

1 Like

This looks like a bug, I’d file an issue


Interestingly, there is a method

givensAlgorithm(f, g) = givensAlgorithm(promote(float(f), float(g))...)

As @dlfivefifty said, this looks like a bug and should work.

1 Like

Notice that this method was added very recently so it’s not available in the latest release of Julia.

1 Like

Thanks for the opinion. I have filed a bug:

Andreas, you closed the issue on github while explaining that the problem had already been fixed. Could you, however, give me a hint on how to proceed now, before the fix reaches the release of Julia? For example, will my switching to some nightly build help? Thanks.

Yes. You could either use nightly but it is probably simpler just to carry the definition locally until the next version of Julia is released since it is so small.