Skip to content

solving the same problem twice is broken #302

@karajan9

Description

@karajan9

On Julia 1.9.0 with LinearSolve 1.42.0 solving the same problem twice doesn't give the same result:

A = [1.0 2.0; 3.0 4.0]
b = [1.0, 2.0]
prob = LinearProblem(A, b)
linsolve = init(prob)
sol1 = solve(linsolve)
# julia> sol1.u
# 2-element Vector{Float64}:
#  0.0
#  0.5
sol2 = solve(linsolve)
# julia> sol2.u
# 2-element Vector{Float64}:
#  -10.999999999999995
#    8.499999999999996

This is also true when set_b is used in between.

A = [1.0 2.0; 3.0 4.0]
b = [1.0, 2.0]
prob = LinearProblem(A, b)
linsolve = init(prob)
sol1 = solve(linsolve)
# julia> sol1.u
# 2-element Vector{Float64}:
#  0.0
#  0.5
linsolve = LinearSolve.set_b(linsolve, [2.0, 3.0])
sol2 = solve(linsolve)
# julia> sol2.u
# 2-element Vector{Float64}:
# -15.999999999999993
#  12.499999999999995
# should be [-1.0, 1.5]

That means that the examples in the README are currently broken.

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