Skip to content

Commit

Permalink
Fix issue with two solutions
Browse files Browse the repository at this point in the history
  • Loading branch information
amontoison committed Oct 13, 2024
1 parent 857df50 commit be43b3d
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 5 deletions.
1 change: 1 addition & 0 deletions src/block_krylov_solvers.jl
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,7 @@ for (KS, fun, nsol, nA, nAt, warm_start) in [
Atprod(solver :: $KS) = $nAt * solver.stats.niter
nsolution(solver :: $KS) = $nsol
if $nsol == 1
solution_tuple(solver :: $KS) = (solver.X,)
solution(solver :: $KS) = solver.X
solution(solver :: $KS, p :: Integer) = (p == 1) ? solution(solver) : error("solution(solver) has only one output.")
end
Expand Down
8 changes: 4 additions & 4 deletions src/krylov_solve.jl
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ for (KS, fun, fun2, args, def_args, optargs, def_optargs, kwargs, def_kwargs) in
timemax -= elapsed_time
$(fun)(solver, $(args...); $(kwargs...))
solver.stats.timer += elapsed_time
return ((solution(solver),)..., solver.stats)
return (solution_tuple(solver)..., solver.stats)
end

if !isempty($optargs)
Expand All @@ -68,7 +68,7 @@ for (KS, fun, fun2, args, def_args, optargs, def_optargs, kwargs, def_kwargs) in
timemax -= elapsed_time
$(fun)(solver, $(args...); $(kwargs...))
solver.stats.timer += elapsed_time
return ((solution(solver),)..., solver.stats)
return (solution_tuple(solver)..., solver.stats)
end
end
end
Expand Down Expand Up @@ -107,7 +107,7 @@ for (KS, fun, fun2, args, def_args, optargs, def_optargs, kwargs, def_kwargs) in
timemax -= elapsed_time
$(fun)(solver, $(args...); $(kwargs...))
solver.stats.timer += elapsed_time
return ((solution(solver),)..., solver.stats)
return (solution_tuple(solver)..., solver.stats)
end

if !isempty($optargs)
Expand All @@ -119,7 +119,7 @@ for (KS, fun, fun2, args, def_args, optargs, def_optargs, kwargs, def_kwargs) in
timemax -= elapsed_time
$(fun)(solver, $(args...); $(kwargs...))
solver.stats.timer += elapsed_time
return ((solution(solver),)..., solver.stats)
return (solution_tuple(solver)..., solver.stats)
end
end

Expand Down
4 changes: 3 additions & 1 deletion src/krylov_solvers.jl
Original file line number Diff line number Diff line change
Expand Up @@ -1944,11 +1944,13 @@ for (KS, fun, nsol, nA, nAt, warm_start) in [
end
nsolution(solver :: $KS) = $nsol
if $nsol == 1
solution_tuple(solver :: $KS) = (solver.x,)
solution(solver :: $KS) = solver.x
solution(solver :: $KS, p :: Integer) = (p == 1) ? solution(solver) : error("solution(solver) has only one output.")
end
if $nsol == 2
solution(solver :: $KS) = solver.x, solver.y
solution_tuple(solver :: $KS) = (solver.x, solver.y)
solution(solver :: $KS) = (solver.x, solver.y)
solution(solver :: $KS, p :: Integer) = (1 p 2) ? solution(solver)[p] : error("solution(solver) has only two outputs.")
end
if $KS (BilqrSolver, TrilqrSolver)
Expand Down

0 comments on commit be43b3d

Please sign in to comment.