Skip to content

Commit

Permalink
Merge f43c264 into 1bb2a3a
Browse files Browse the repository at this point in the history
  • Loading branch information
vpuri3 authored Apr 19, 2022
2 parents 1bb2a3a + f43c264 commit 12cd6be
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
8 changes: 8 additions & 0 deletions src/common.jl
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ struct LinearCache{TA,Tb,Tu,Tp,Talg,Tc,Tl,Tr,Ttol}
isfresh::Bool # false => cacheval is set wrt A, true => update cacheval wrt A
Pl::Tl # preconditioners
Pr::Tr
solve_adjoint::Bool # solve adjoint problem
abstol::Ttol
reltol::Ttol
maxiters::Int
Expand Down Expand Up @@ -77,6 +78,7 @@ default_tol(::Type{Any}) = 0

function SciMLBase.init(prob::LinearProblem, alg::Union{SciMLLinearSolveAlgorithm,Nothing}, args...;
alias_A = false, alias_b = false,
solve_adjoint = false,
abstol=default_tol(eltype(prob.A)),
reltol=default_tol(eltype(prob.A)),
maxiters=length(prob.b),
Expand All @@ -94,6 +96,11 @@ function SciMLBase.init(prob::LinearProblem, alg::Union{SciMLLinearSolveAlgorith
fill!(u0,false)
end

if solve_adjoint & !(alg isa Union{AbstractFactorization,
AbstractSolveFunction})
A = A'
end

cacheval = init_cacheval(alg, A, b, u0, Pl, Pr, maxiters, abstol, reltol, verbose)
isfresh = true
Tc = typeof(cacheval)
Expand Down Expand Up @@ -121,6 +128,7 @@ function SciMLBase.init(prob::LinearProblem, alg::Union{SciMLLinearSolveAlgorith
isfresh,
Pl,
Pr,
solve_adjoint,
abstol,
reltol,
maxiters,
Expand Down
4 changes: 3 additions & 1 deletion src/factorization.jl
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,9 @@ function SciMLBase.solve(cache::LinearCache, alg::AbstractFactorization; kwargs.
fact = do_factorization(alg, cache.A, cache.b, cache.u)
cache = set_cacheval(cache, fact)
end
y = _ldiv!(cache.u, cache.cacheval, cache.b)
fact = cache.solve_adjoint ? cache.cacheval' : cache.cacheval

y = _ldiv!(cache.u, fact, cache.b)
SciMLBase.build_linear_solution(alg,y,nothing,cache)
end

Expand Down

0 comments on commit 12cd6be

Please sign in to comment.