From be43b3d45b5dc9af66768bbc94ff4d8b1eb77f93 Mon Sep 17 00:00:00 2001 From: Alexis Montoison Date: Sun, 13 Oct 2024 12:15:02 -0500 Subject: [PATCH] Fix issue with two solutions --- src/block_krylov_solvers.jl | 1 + src/krylov_solve.jl | 8 ++++---- src/krylov_solvers.jl | 4 +++- 3 files changed, 8 insertions(+), 5 deletions(-) diff --git a/src/block_krylov_solvers.jl b/src/block_krylov_solvers.jl index c6c128aeb..21d361f59 100644 --- a/src/block_krylov_solvers.jl +++ b/src/block_krylov_solvers.jl @@ -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 diff --git a/src/krylov_solve.jl b/src/krylov_solve.jl index c95a3705e..5429e831c 100644 --- a/src/krylov_solve.jl +++ b/src/krylov_solve.jl @@ -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) @@ -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 @@ -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) @@ -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 diff --git a/src/krylov_solvers.jl b/src/krylov_solvers.jl index d9f9fd9b1..aca001b32 100644 --- a/src/krylov_solvers.jl +++ b/src/krylov_solvers.jl @@ -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)