From 6dfeb25e780f4c2d0539735149281b85052ee545 Mon Sep 17 00:00:00 2001 From: Martin Holters Date: Wed, 25 Aug 2021 09:05:46 +0200 Subject: [PATCH] Guard against callling `gemv!` with empty output This was made an error in https://github.com/JuliaLang/julia/pull/41513. Obviously, the `gemv!` call can just be omitted if the output is empty anyway. --- src/ACME.jl | 26 +++++++++++++++----------- 1 file changed, 15 insertions(+), 11 deletions(-) diff --git a/src/ACME.jl b/src/ACME.jl index 27d878a0..05809d0a 100644 --- a/src/ACME.jl +++ b/src/ACME.jl @@ -673,18 +673,22 @@ function step!(runner::ModelRunner, y::AbstractMatrix{Float64}, u::AbstractMatri zoff += length(zsub) end #y[:,n] = model.dy * model.x + model.ey * u[:,n] + model.fy * z + model.y0 - copyto!(ycur, model.y0) - BLAS.gemv!('N', 1., model.dy, model.x, 1., ycur) - BLAS.gemv!('N', 1., model.ey, ucur, 1., ycur) - BLAS.gemv!('N', 1., model.fy, z, 1., ycur) - #y[:,n] = ycur - copyto!(y, (n-1)*ny(model)+1, ycur, 1, ny(model)) + if !isempty(ycur) + copyto!(ycur, model.y0) + BLAS.gemv!('N', 1., model.dy, model.x, 1., ycur) + BLAS.gemv!('N', 1., model.ey, ucur, 1., ycur) + BLAS.gemv!('N', 1., model.fy, z, 1., ycur) + #y[:,n] = ycur + copyto!(y, (n-1)*ny(model)+1, ycur, 1, ny(model)) + end #model.x = model.a * model.x + model.b * u[:,n] + model.c * z + model.x0 - copyto!(xnew, model.x0) - BLAS.gemv!('N', 1., model.a, model.x, 1., xnew) - BLAS.gemv!('N', 1., model.b, ucur, 1.,xnew) - BLAS.gemv!('N', 1., model.c, z, 1., xnew) - copyto!(model.x, xnew) + if !isempty(xnew) + copyto!(xnew, model.x0) + BLAS.gemv!('N', 1., model.a, model.x, 1., xnew) + BLAS.gemv!('N', 1., model.b, ucur, 1.,xnew) + BLAS.gemv!('N', 1., model.c, z, 1., xnew) + copyto!(model.x, xnew) + end end function gensolve(a, b, x, h, thresh=0.1)