Skip to content

Eigen decomposition fails with Measurements #163

@BambOoxX

Description

@BambOoxX

Hello, I have attempted to use GenericLinearAlgebra along with Measurements but that seems to fail in a fresh environment.
See JuliaPhysics/Measurements.jl#189 for first analysis by @giordano.

The environment

Status `D:\bamboo\AppData\Local\Temp\jl_hvNm0T\Project.toml`
  [14197337] GenericLinearAlgebra v0.3.18
  [eff96d63] Measurements v2.14.0

The example

] add Measurements GenericLinearAlgebra
using LinearAlgebra, GenericLinearAlgebra, Measurements
Ar = rand(10,10)  rand(10,10)
Ai = rand(10,10)  rand(10,10)
A = Ar + im * Ai
eigvals(Ar) # fails
eigvals(A) # fails

The reproduced stacktrace

julia> eigvals(Ar)
ERROR: MethodError: no method matching Float64(::Measurement{Float64})
The type `Float64` exists, but no method is defined for this combination of argument types when trying to construct it.

Closest candidates are:
  (::Type{T})(::Real, ::RoundingMode) where T<:AbstractFloat
   @ Base rounding.jl:265
  (::Type{T})(::T) where T<:Number
   @ Core boot.jl:900
  Float64(::Irrational{:SQRT_HALF})
   @ Random irrationals.jl:251
  ...

Stacktrace:
  [1] givensAlgorithm(f::Measurement{Float64}, g::Measurement{Float64})
    @ LinearAlgebra D:\bamboo\AppData\Local\Programs\Julia-1.11.5\share\julia\stdlib\v1.11\LinearAlgebra\src\givens.jl:80
  [2] givens(f::Measurement{Float64}, g::Measurement{Float64}, i1::Int64, i2::Int64)
    @ LinearAlgebra D:\bamboo\AppData\Local\Programs\Julia-1.11.5\share\julia\stdlib\v1.11\LinearAlgebra\src\givens.jl:292
  [3] doubleShiftQR!(HH::Matrix{…}, τ::LinearAlgebra.Rotation{…}, shiftTrace::Measurement{…}, shiftDeterminant::Measurement{…}, istart::Int64, iend::Int64)
    @ GenericLinearAlgebra D:\bamboo\.julia\packages\GenericLinearAlgebra\jlOvW\src\eigenGeneral.jl:241
  [4] _schur!(H::GenericLinearAlgebra.HessenbergFactorization{…}; tol::Float64, shiftmethod::Symbol, maxiter::Int64)
    @ GenericLinearAlgebra D:\bamboo\.julia\packages\GenericLinearAlgebra\jlOvW\src\eigenGeneral.jl:161
  [5] _schur!
    @ D:\bamboo\.julia\packages\GenericLinearAlgebra\jlOvW\src\eigenGeneral.jl:89 [inlined]
  [6] _schur!
    @ D:\bamboo\.julia\packages\GenericLinearAlgebra\jlOvW\src\eigenGeneral.jl:182 [inlined]
  [7] _eigvals!
    @ D:\bamboo\.julia\packages\GenericLinearAlgebra\jlOvW\src\eigenGeneral.jl:281 [inlined]
  [8] eigvals!(A::Matrix{Measurement{Float64}}; sortby::typeof(LinearAlgebra.eigsortby), kwargs::@Kwargs{})
    @ GenericLinearAlgebra D:\bamboo\.julia\packages\GenericLinearAlgebra\jlOvW\src\eigenGeneral.jl:294
  [9] eigvals!
    @ D:\bamboo\.julia\packages\GenericLinearAlgebra\jlOvW\src\eigenGeneral.jl:285 [inlined]
 [10] eigvals(A::Matrix{Measurement{Float64}}; kws::@Kwargs{})
    @ LinearAlgebra D:\bamboo\AppData\Local\Programs\Julia-1.11.5\share\julia\stdlib\v1.11\LinearAlgebra\src\eigen.jl:343
 [11] eigvals(A::Matrix{Measurement{Float64}})
    @ LinearAlgebra D:\bamboo\AppData\Local\Programs\Julia-1.11.5\share\julia\stdlib\v1.11\LinearAlgebra\src\eigen.jl:343
 [12] top-level scope
    @ REPL[12]:1
Some type information was truncated. Use `show(err)` to see complete types.

The problem seems to be that GenericLinearAlgebra forwards Measurements to LinearAlgebra instead of standard float types, but that is not really helpful to solve the problem :)

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