Skip to content

get_degopt_coeffs fails for non-number eltypes #87

@jarlebring

Description

@jarlebring

Works:

julia> A=Matrix{Any}(randn(3,4));  B=Matrix{Any}(randn(3,4));  c=Vector{Any}(randn(5));
julia> A=(randn(3,4));  B=(randn(3,4));  c=(randn(5));
julia> get_degopt_coeffs(Degopt(A,B,c))
([-0.07115712145587184 0.294480314336431 0.0 0.0; -0.33980224784420265 0.3226489842112206 -0.4831193992636389 0.0; -0.6814844816840376 -0.9646067105528249 -0.09835820977640378 0.1682353969596051], [-1.9840297106963591 0.18584404165244633 0.0 0.0; 0.06322452608982917 0.29364087412100703 0.30913772434956127 0.0; 1.36730543778655 -1.0402215387787772 1.9058454283480966 0.14458386322991343], [-0.7842997480662224, 0.24851995107244032, 0.7995947390157911, -1.074317062568139, -0.33120315667187633])

Doesn't work:

julia> A=Matrix{Any}(randn(3,4));  B=Matrix{Any}(randn(3,4));  c=Vector{Any}(randn(5));
julia> get_degopt_coeffs(Degopt(A,B,c))
ERROR: MethodError: no method matching zero(::Type{Any})

Closest candidates are:
  zero(::Type{Union{Missing, T}}) where T
   @ Base missing.jl:105
  zero(::Type{Union{}}, Any...)
   @ Base number.jl:310
  zero(::Type{Dates.Time})
   @ Dates ~/.julia/juliaup/julia-1.10.5+0.x64.linux.gnu/share/julia/stdlib/v1.10/Dates/src/types.jl:440
  ...
Stacktrace:
 [1] zero(::Type{Any})
   @ Base ./missing.jl:106
 [2] zeros(::Type{Any}, dims::Tuple{Int64, Int64})
   @ Base ./array.jl:637
 [3] zeros(::Type{Any}, ::Int64, ::Int64)
   @ Base ./array.jl:632
 [4] get_degopt_coeffs(degopt::Degopt{Any})
   @ GraphMatFun ~/jobb_synced/src/matfun/src/degopt.jl:247
 [5] top-level scope
   @ REPL[157]:1

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions