From 4a5ba1c594c2817aa89af3bd7ea4f67e373adf5e Mon Sep 17 00:00:00 2001 From: Alexis Montoison Date: Fri, 17 Jan 2025 22:16:14 -0600 Subject: [PATCH] Use similar for dynamic allocations --- src/fgmres.jl | 2 +- src/fom.jl | 2 +- src/gmres.jl | 2 +- src/gpmr.jl | 4 ++-- 4 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/fgmres.jl b/src/fgmres.jl index ef8d2bf1d..f8f13462f 100644 --- a/src/fgmres.jl +++ b/src/fgmres.jl @@ -239,7 +239,7 @@ kwargs_fgmres = (:M, :N, :ldiv, :restart, :reorthogonalization, :atol, :rtol, :i end push!(s, zero(FC)) push!(c, zero(T)) - push!(Z, S(undef, n)) + push!(Z, similar(solver.x)) end # Continue the process. diff --git a/src/fom.jl b/src/fom.jl index d81cf3268..fb84383bb 100644 --- a/src/fom.jl +++ b/src/fom.jl @@ -291,7 +291,7 @@ kwargs_fom = (:M, :N, :ldiv, :restart, :reorthogonalization, :atol, :rtol, :itma # Compute vₖ₊₁. if !(solved || inner_tired || breakdown || user_requested_exit || overtimed) if !restart && (inner_iter ≥ mem) - push!(V, S(undef, n)) + push!(V, similar(solver.x)) end V[inner_iter+1] .= q ./ Hbis # hₖ₊₁.ₖvₖ₊₁ = q end diff --git a/src/gmres.jl b/src/gmres.jl index 37a254dad..b43a00525 100644 --- a/src/gmres.jl +++ b/src/gmres.jl @@ -301,7 +301,7 @@ kwargs_gmres = (:M, :N, :ldiv, :restart, :reorthogonalization, :atol, :rtol, :it # Compute vₖ₊₁. if !(solved || inner_tired || breakdown || user_requested_exit || overtimed) if !restart && (inner_iter ≥ mem) - push!(V, S(undef, n)) + push!(V, similar(solver.x)) push!(z, zero(FC)) end V[inner_iter+1] .= q ./ Hbis # hₖ₊₁.ₖvₖ₊₁ = q diff --git a/src/gpmr.jl b/src/gpmr.jl index beeb395a9..3c172e594 100644 --- a/src/gpmr.jl +++ b/src/gpmr.jl @@ -459,8 +459,8 @@ kwargs_gpmr = (:C, :D, :E, :F, :ldiv, :gsp, :λ, :μ, :reorthogonalization, :ato # Compute vₖ₊₁ and uₖ₊₁ if !(solved || tired || breakdown || user_requested_exit || overtimed) if iter ≥ mem - push!(V, S(undef, m)) - push!(U, S(undef, n)) + push!(V, similar(solver.x)) + push!(U, similar(solver.y)) push!(zt, zero(FC), zero(FC)) end