Jutho / KrylovKit.jl

Krylov methods for linear problems, eigenvalues, singular values and matrix functions
Other
284 stars 37 forks source link

Reuse initial apply in expintegrator #53

Closed emstoudenmire closed 2 years ago

emstoudenmire commented 2 years ago

At the beginning of expintegrator, apply is called to apply the linear map for the purpose of determining the type T of other variables. However, the result is not used later in the code. This PR uses the result to start building the vectors w, saving one call to apply while giving exactly the same results. This could lead to a significant performance increase in cases where only a few Krylov vectors are computed, such as for small time steps.

emstoudenmire commented 2 years ago

I'm happy to make that change. One question though: in changing the loop range to start at 2, the code at the bottom of that loop won't get run for the j=1 case. Is that a concern?

Jutho commented 2 years ago

You are of course absolute right; I was clearly not very well awake when I wrote that. I will just merge the current version. Thanks again.

emstoudenmire commented 2 years ago

Great! I just went ahead and did change that one line to be w[2] = mul!(similar(w₀), Au₀, one(T)) as you mentioned.

codecov[bot] commented 2 years ago

Codecov Report

Merging #53 (efc4e2c) into master (ab3549e) will increase coverage by 0.01%. The diff coverage is 100.00%.

@@            Coverage Diff             @@
##           master      #53      +/-   ##
==========================================
+ Coverage   82.47%   82.48%   +0.01%     
==========================================
  Files          27       27              
  Lines        2750     2752       +2     
==========================================
+ Hits         2268     2270       +2     
  Misses        482      482              
Impacted Files Coverage Δ
src/matrixfun/expintegrator.jl 74.02% <100.00%> (+0.34%) :arrow_up:

Continue to review full report at Codecov.

Legend - Click here to learn more Δ = absolute <relative> (impact), ø = not affected, ? = missing data Powered by Codecov. Last update ab3549e...efc4e2c. Read the comment docs.