Skip to content

Solver fail when jac_prototype is BandedMatrix{BigFloat} #587

Closed
SciML/LinearSolve.jl
#598
@ErikQQY

Description

@ErikQQY

Describe the bug 🐞

When the jac_prototype is a BandedMatrix{BigFloat}, solvers would throw some UndefVarError, I think this is related to JuliaLinearAlgebra/BandedMatrices.jl#121

Expected behavior

Should successfully solve the problem

Minimal Reproducible Example 👇

Without MRE, we would only be able to help you to a limited extent, and attention to the issue would be limited. to know more about MRE refer to wikipedia and stackoverflow.

function test!(du, u, p)
    du[1] = u[1] - 1
    du[2] = u[2] - 1
    du[3] = u[3] - 1
end
nlf = NonlinearFunction(test!, jac_prototype = BandedMatrix{BigFloat}(ones(3,3), (0,0)))
prob = NonlinearProblem(nlf, BigFloat[0.0, 0.0, 0.0], (0.0, 1.0))
sol = solve(prob, NewtonRaphson())

Error & Stacktrace ⚠️

ERROR: UndefVarError: `banded_lufact!` not defined in `BandedMatrices`
Suggestion: check for spelling errors or missing imports.
Stacktrace:
  [1] lu!_layout(::BandedMatrices.BandedColumns{…}, axes::Tuple{…}, A::BandedMatrix{…}, pivot::Val{…}; check::Bool)
    @ BandedMatrices ~/.julia/packages/BandedMatrices/i60tK/src/banded/BandedLU.jl:108
  [2] lu!_layout
    @ ~/.julia/packages/BandedMatrices/i60tK/src/banded/BandedLU.jl:108 [inlined]
  [3] lu!
    @ ~/.julia/packages/ArrayLayouts/B2wRU/src/factorizations.jl:429 [inlined]
  [4] #_lu#22
    @ ~/.julia/packages/BandedMatrices/i60tK/src/banded/BandedLU.jl:113 [inlined]
  [5] lu_layout (repeats 2 times)
    @ ~/.julia/packages/BandedMatrices/i60tK/src/banded/BandedLU.jl:111 [inlined]
  [6] lu
    @ ~/.julia/packages/ArrayLayouts/B2wRU/src/factorizations.jl:428 [inlined]
  [7] init_cacheval
    @ ~/.julia/packages/LinearSolve/KN05h/ext/LinearSolveBandedMatricesExt.jl:47 [inlined]
  [8] macro expansion
    @ ~/.julia/packages/LinearSolve/KN05h/src/default.jl:308 [inlined]
  [9] init_cacheval(alg::LinearSolve.DefaultLinearSolver, A::BandedMatrix{…}, b::Vector{…}, u::Vector{…}, Pl::IdentityOperator, Pr::IdentityOperator, maxiters::Int64, abstol::BigFloat, reltol::BigFloat, verbose::Bool, assump::OperatorAssumptions{…})
    @ LinearSolve ~/.julia/packages/LinearSolve/KN05h/src/default.jl:291
 [10] init(::LinearProblem{…}, ::LinearSolve.DefaultLinearSolver; alias::LinearAliasSpecifier, abstol::BigFloat, reltol::BigFloat, maxiters::Int64, verbose::Bool, Pl::Nothing, Pr::Nothing, assumptions::OperatorAssumptions{…}, sensealg::LinearSolveAdjoint{…}, kwargs::@Kwargs{})
    @ LinearSolve ~/.julia/packages/LinearSolve/KN05h/src/common.jl:239
 [11] init
    @ ~/.julia/packages/LinearSolve/KN05h/src/common.jl:140 [inlined]
 [12] #init#95
    @ ~/.julia/packages/LinearSolve/KN05h/src/default.jl:270 [inlined]
 [13] init
    @ ~/.julia/packages/LinearSolve/KN05h/src/default.jl:266 [inlined]
 [14] construct_linear_solver(alg::NewtonDescent{…}, linsolve::Nothing, A::BandedMatrix{…}, b::Vector{…}, u::Vector{…}; stats::SciMLBase.NLStats, kwargs::@Kwargs{})
    @ NonlinearSolveBase ~/.julia/packages/NonlinearSolveBase/5ckRl/src/linear_solve.jl:77
 [15] construct_linear_solver
    @ ~/.julia/packages/NonlinearSolveBase/5ckRl/src/linear_solve.jl:61 [inlined]
 [16] init(prob::NonlinearProblem{…}, alg::NewtonDescent{…}, J::BandedMatrix{…}, fu::Vector{…}, u::Vector{…}; stats::SciMLBase.NLStats, shared::Val{…}, pre_inverted::Val{…}, linsolve_kwargs::@NamedTuple{}, abstol::BigFloat, reltol::BigFloat, timer::Nothing, kwargs::@Kwargs{})
    @ NonlinearSolveBase ~/.julia/packages/NonlinearSolveBase/5ckRl/src/descent/newton.jl:41
 [17] __init(::NonlinearProblem{…}, ::GeneralizedFirstOrderAlgorithm{…}; stats::SciMLBase.NLStats, alias_u0::Bool, maxiters::Int64, abstol::Nothing, reltol::Nothing, maxtime::Nothing, termination_condition::Nothing, internalnorm::Function, linsolve_kwargs::@NamedTuple{}, initializealg::NonlinearSolveBase.NonlinearSolveDefaultInit, kwargs::@Kwargs{})
    @ NonlinearSolveFirstOrder ~/.julia/packages/NonlinearSolveFirstOrder/yeYrV/src/solve.jl:167
 [18] __init
    @ ~/.julia/packages/NonlinearSolveFirstOrder/yeYrV/src/solve.jl:121 [inlined]
 [19] __solve(::NonlinearProblem{…}, ::GeneralizedFirstOrderAlgorithm{…}; kwargs::@Kwargs{})
    @ NonlinearSolveBase ~/.julia/packages/NonlinearSolveBase/5ckRl/src/solve.jl:5
 [20] __solve
    @ ~/.julia/packages/NonlinearSolveBase/5ckRl/src/solve.jl:1 [inlined]
 [21] #solve_call#35
    @ ~/.julia/packages/DiffEqBase/zYZst/src/solve.jl:635 [inlined]
 [22] solve_call
    @ ~/.julia/packages/DiffEqBase/zYZst/src/solve.jl:592 [inlined]
 [23] #solve_up#44
    @ ~/.julia/packages/DiffEqBase/zYZst/src/solve.jl:1126 [inlined]
 [24] solve_up
    @ ~/.julia/packages/DiffEqBase/zYZst/src/solve.jl:1120 [inlined]
 [25] #solve#43
    @ ~/.julia/packages/DiffEqBase/zYZst/src/solve.jl:1114 [inlined]
 [26] solve(prob::NonlinearProblem{…}, args::GeneralizedFirstOrderAlgorithm{…})
    @ DiffEqBase ~/.julia/packages/DiffEqBase/zYZst/src/solve.jl:1104
 [27] top-level scope
    @ REPL[252]:1
Some type information was truncated. Use `show(err)` to see complete types.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions