1+ macro get_cacheval (cache, algsym)
2+ quote
3+ if $ (esc (cache)). alg isa DefaultLinearSolver
4+ getfield ($ (esc (cache)). cacheval, $ algsym)
5+ else
6+ $ (esc (cache)). cacheval
7+ end
8+ end
9+ end
10+
111_ldiv! (x, A, b) = ldiv! (x, A, b)
212
313function _ldiv! (x:: Vector , A:: Factorization , b:: Vector )
@@ -712,11 +722,11 @@ function SciMLBase.solve!(cache::LinearCache, alg::UMFPACKFactorization; kwargs.
712722 if alg. check_pattern && ! (SuiteSparse. decrement (SparseArrays. getcolptr (A)) ==
713723 cache. cacheval. colptr &&
714724 SuiteSparse. decrement (SparseArrays. getrowval (A)) ==
715- get_cacheval (cache, :UMFPACKFactorization ). rowval)
725+ @ get_cacheval (cache, :UMFPACKFactorization ). rowval)
716726 fact = lu (SparseMatrixCSC (size (A)... , getcolptr (A), rowvals (A),
717727 nonzeros (A)))
718728 else
719- fact = lu! (get_cacheval (cache, :UMFPACKFactorization ),
729+ fact = lu! (@ get_cacheval (cache, :UMFPACKFactorization ),
720730 SparseMatrixCSC (size (A)... , getcolptr (A), rowvals (A),
721731 nonzeros (A)))
722732 end
@@ -727,7 +737,7 @@ function SciMLBase.solve!(cache::LinearCache, alg::UMFPACKFactorization; kwargs.
727737 cache. isfresh = false
728738 end
729739
730- y = ldiv! (cache. u, get_cacheval (cache, :UMFPACKFactorization ), cache. b)
740+ y = ldiv! (cache. u, @ get_cacheval (cache, :UMFPACKFactorization ), cache. b)
731741 SciMLBase. build_linear_solution (alg, y, nothing , cache)
732742end
733743
@@ -782,7 +792,7 @@ function SciMLBase.solve!(cache::LinearCache, alg::KLUFactorization; kwargs...)
782792 A = convert (AbstractMatrix, A)
783793
784794 if cache. isfresh
785- cacheval = get_cacheval (cache, :KLUFactorization )
795+ cacheval = @ get_cacheval (cache, :KLUFactorization )
786796 if cacheval != = nothing && alg. reuse_symbolic
787797 if alg. check_pattern && ! (SuiteSparse. decrement (SparseArrays. getcolptr (A)) ==
788798 cacheval. colptr &&
@@ -811,7 +821,7 @@ function SciMLBase.solve!(cache::LinearCache, alg::KLUFactorization; kwargs...)
811821 cache. isfresh = false
812822 end
813823
814- y = ldiv! (cache. u, get_cacheval (cache, :KLUFactorization ), cache. b)
824+ y = ldiv! (cache. u, @ get_cacheval (cache, :KLUFactorization ), cache. b)
815825 SciMLBase. build_linear_solution (alg, y, nothing , cache)
816826end
817827
@@ -863,7 +873,7 @@ function SciMLBase.solve!(cache::LinearCache, alg::CHOLMODFactorization; kwargs.
863873 A = convert (AbstractMatrix, A)
864874
865875 if cache. isfresh
866- cacheval = get_cacheval (cache, :CHOLMODFactorization )
876+ cacheval = @ get_cacheval (cache, :CHOLMODFactorization )
867877 fact = cholesky (A; check = false )
868878 if ! LinearAlgebra. issuccess (fact)
869879 ldlt! (fact, A; check = false )
@@ -872,7 +882,7 @@ function SciMLBase.solve!(cache::LinearCache, alg::CHOLMODFactorization; kwargs.
872882 cache. isfresh = false
873883 end
874884
875- cache. u .= get_cacheval (cache, :CHOLMODFactorization ) \ cache. b
885+ cache. u .= @ get_cacheval (cache, :CHOLMODFactorization ) \ cache. b
876886 SciMLBase. build_linear_solution (alg, cache. u, nothing , cache)
877887end
878888
@@ -928,7 +938,7 @@ function SciMLBase.solve!(cache::LinearCache, alg::RFLUFactorization{P, T};
928938 kwargs... ) where {P, T}
929939 A = cache. A
930940 A = convert (AbstractMatrix, A)
931- fact, ipiv = get_cacheval (cache, :RFLUFactorization )
941+ fact, ipiv = @ get_cacheval (cache, :RFLUFactorization )
932942 if cache. isfresh
933943 if length (ipiv) != min (size (A)... )
934944 ipiv = Vector {LinearAlgebra.BlasInt} (undef, min (size (A)... ))
@@ -937,7 +947,7 @@ function SciMLBase.solve!(cache::LinearCache, alg::RFLUFactorization{P, T};
937947 cache. cacheval = (fact, ipiv)
938948 cache. isfresh = false
939949 end
940- y = ldiv! (cache. u, get_cacheval (cache, :RFLUFactorization )[1 ], cache. b)
950+ y = ldiv! (cache. u, @ get_cacheval (cache, :RFLUFactorization )[1 ], cache. b)
941951 SciMLBase. build_linear_solution (alg, y, nothing , cache)
942952end
943953
@@ -1025,10 +1035,10 @@ function SciMLBase.solve!(cache::LinearCache, alg::NormalCholeskyFactorization;
10251035 cache. isfresh = false
10261036 end
10271037 if A isa SparseMatrixCSC
1028- cache. u .= get_cacheval (cache, :NormalCholeskyFactorization ) \ (A' * cache. b)
1038+ cache. u .= @ get_cacheval (cache, :NormalCholeskyFactorization ) \ (A' * cache. b)
10291039 y = cache. u
10301040 else
1031- y = ldiv! (cache. u, get_cacheval (cache, :NormalCholeskyFactorization ), A' * cache. b)
1041+ y = ldiv! (cache. u, @ get_cacheval (cache, :NormalCholeskyFactorization ), A' * cache. b)
10321042 end
10331043 SciMLBase. build_linear_solution (alg, y, nothing , cache)
10341044end
@@ -1072,7 +1082,7 @@ function SciMLBase.solve!(cache::LinearCache, alg::NormalBunchKaufmanFactorizati
10721082 cache. cacheval = fact
10731083 cache. isfresh = false
10741084 end
1075- y = ldiv! (cache. u, get_cacheval (cache, :NormalBunchKaufmanFactorization ), A' * cache. b)
1085+ y = ldiv! (cache. u, @ get_cacheval (cache, :NormalBunchKaufmanFactorization ), A' * cache. b)
10761086 SciMLBase. build_linear_solution (alg, y, nothing , cache)
10771087end
10781088
@@ -1131,7 +1141,7 @@ end
11311141function SciMLBase. solve! (cache:: LinearCache , alg:: FastLUFactorization ; kwargs... )
11321142 A = cache. A
11331143 A = convert (AbstractMatrix, A)
1134- ws_and_fact = get_cacheval (cache, :FastLUFactorization )
1144+ ws_and_fact = @ get_cacheval (cache, :FastLUFactorization )
11351145 if cache. isfresh
11361146 # we will fail here if A is a different *size* than in a previous version of the same cache.
11371147 # it may instead be desirable to resize the workspace.
@@ -1201,7 +1211,7 @@ function SciMLBase.solve!(cache::LinearCache, alg::FastQRFactorization{P};
12011211 kwargs... ) where {P}
12021212 A = cache. A
12031213 A = convert (AbstractMatrix, A)
1204- ws_and_fact = get_cacheval (cache, :FastQRFactorization )
1214+ ws_and_fact = @ get_cacheval (cache, :FastQRFactorization )
12051215 if cache. isfresh
12061216 # we will fail here if A is a different *size* than in a previous version of the same cache.
12071217 # it may instead be desirable to resize the workspace.
@@ -1281,7 +1291,7 @@ function SciMLBase.solve!(cache::LinearCache, alg::SparspakFactorization; kwargs
12811291 A = cache. A
12821292 if cache. isfresh
12831293 if cache. cacheval != = nothing && alg. reuse_symbolic
1284- fact = sparspaklu! (get_cacheval (cache, :SparspakFactorization ),
1294+ fact = sparspaklu! (@ get_cacheval (cache, :SparspakFactorization ),
12851295 SparseMatrixCSC (size (A)... , getcolptr (A), rowvals (A),
12861296 nonzeros (A)))
12871297 else
@@ -1291,6 +1301,6 @@ function SciMLBase.solve!(cache::LinearCache, alg::SparspakFactorization; kwargs
12911301 cache. cacheval = fact
12921302 cache. isfresh = false
12931303 end
1294- y = ldiv! (cache. u, get_cacheval (cache, :SparspakFactorization ), cache. b)
1304+ y = ldiv! (cache. u, @ get_cacheval (cache, :SparspakFactorization ), cache. b)
12951305 SciMLBase. build_linear_solution (alg, y, nothing , cache)
12961306end
0 commit comments