@@ -120,7 +120,7 @@ function init_cacheval(alg::Union{LUFactorization, GenericLUFactorization},
120120 nothing
121121end
122122
123- @static if VERSION < v " 1.7 -"
123+ @static if VERSION < v " 1.9 -"
124124 function init_cacheval (alg:: Union{LUFactorization, GenericLUFactorization} ,
125125 A:: Union{Diagonal, SymTridiagonal} , b, u, Pl, Pr,
126126 maxiters:: Int , abstol, reltol, verbose:: Bool ,
@@ -188,7 +188,7 @@ function init_cacheval(alg::QRFactorization, A::AbstractSciMLOperator, b, u, Pl,
188188 nothing
189189end
190190
191- @static if VERSION < v " 1.7 -"
191+ @static if VERSION < v " 1.9 -"
192192 function init_cacheval (alg:: QRFactorization ,
193193 A:: Union{Diagonal, SymTridiagonal, Tridiagonal} , b, u, Pl, Pr,
194194 maxiters:: Int , abstol, reltol, verbose:: Bool ,
220220
221221function CholeskyFactorization (; pivot = nothing , tol = 0.0 , shift = 0.0 , perm = nothing )
222222 if pivot === nothing
223- pivot = @static if VERSION < v " 1.7beta "
223+ pivot = @static if VERSION < v " 1.8beta "
224224 Val (false )
225225 else
226226 NoPivot ()
@@ -229,16 +229,30 @@ function CholeskyFactorization(; pivot = nothing, tol = 0.0, shift = 0.0, perm =
229229 CholeskyFactorization (pivot, 16 , shift, perm)
230230end
231231
232- function do_factorization (alg:: CholeskyFactorization , A, b, u)
233- A = convert (AbstractMatrix, A)
234- if A isa SparseMatrixCSC
235- fact = cholesky! (A; shift = alg. shift, check = false , perm = alg. perm)
236- elseif alg. pivot === Val (false ) || alg. pivot === NoPivot ()
237- fact = cholesky! (A, alg. pivot; check = false )
238- else
239- fact = cholesky! (A, alg. pivot; tol = alg. tol, check = false )
232+ @static if VERSION > v " 1.8-"
233+ function do_factorization (alg:: CholeskyFactorization , A, b, u)
234+ A = convert (AbstractMatrix, A)
235+ if A isa SparseMatrixCSC
236+ fact = cholesky! (A; shift = alg. shift, check = false , perm = alg. perm)
237+ elseif alg. pivot === Val (false ) || alg. pivot === NoPivot ()
238+ fact = cholesky! (A, alg. pivot; check = false )
239+ else
240+ fact = cholesky! (A, alg. pivot; tol = alg. tol, check = false )
241+ end
242+ return fact
243+ end
244+ else
245+ function do_factorization (alg:: CholeskyFactorization , A, b, u)
246+ A = convert (AbstractMatrix, A)
247+ if A isa SparseMatrixCSC
248+ fact = cholesky! (A; shift = alg. shift, perm = alg. perm)
249+ elseif alg. pivot === Val (false ) || alg. pivot === NoPivot ()
250+ fact = cholesky! (A, alg. pivot)
251+ else
252+ fact = cholesky! (A, alg. pivot; tol = alg. tol)
253+ end
254+ return fact
240255 end
241- return fact
242256end
243257
244258function init_cacheval (alg:: CholeskyFactorization , A, b, u, Pl, Pr,
@@ -247,7 +261,7 @@ function init_cacheval(alg::CholeskyFactorization, A, b, u, Pl, Pr,
247261 ArrayInterface. cholesky_instance (convert (AbstractMatrix, A), alg. pivot)
248262end
249263
250- @static if VERSION < v " 1.7beta "
264+ @static if VERSION < v " 1.8beta "
251265 cholpivot = Val (false )
252266else
253267 cholpivot = NoPivot ()
@@ -268,7 +282,7 @@ function init_cacheval(alg::CholeskyFactorization,
268282 nothing
269283end
270284
271- @static if VERSION < v " 1.7beta "
285+ @static if VERSION < v " 1.9beta "
272286 function init_cacheval (alg:: CholeskyFactorization ,
273287 A:: Union{SymTridiagonal, Tridiagonal} , b, u, Pl, Pr,
274288 maxiters:: Int , abstol, reltol, verbose:: Bool ,
@@ -361,7 +375,7 @@ function init_cacheval(alg::SVDFactorization, A, b, u, Pl, Pr,
361375 nothing
362376end
363377
364- @static if VERSION < v " 1.7 -"
378+ @static if VERSION < v " 1.9 -"
365379 function init_cacheval (alg:: SVDFactorization ,
366380 A:: Union{Diagonal, SymTridiagonal, Tridiagonal} , b, u, Pl, Pr,
367381 maxiters:: Int , abstol, reltol, verbose:: Bool ,
@@ -852,22 +866,42 @@ function init_cacheval(alg::CHOLMODFactorization,
852866 PREALLOCATED_CHOLMOD
853867end
854868
855- function SciMLBase. solve! (cache:: LinearCache , alg:: CHOLMODFactorization ; kwargs... )
856- A = cache. A
857- A = convert (AbstractMatrix, A)
869+ @static if VERSION > v " 1.8-"
870+ function SciMLBase. solve! (cache:: LinearCache , alg:: CHOLMODFactorization ; kwargs... )
871+ A = cache. A
872+ A = convert (AbstractMatrix, A)
858873
859- if cache. isfresh
860- cacheval = @get_cacheval (cache, :CHOLMODFactorization )
861- fact = cholesky (A; check = false )
862- if ! LinearAlgebra. issuccess (fact)
863- ldlt! (fact, A; check = false )
874+ if cache. isfresh
875+ cacheval = @get_cacheval (cache, :CHOLMODFactorization )
876+ fact = cholesky (A; check = false )
877+ if ! LinearAlgebra. issuccess (fact)
878+ ldlt! (fact, A; check = false )
879+ end
880+ cache. cacheval = fact
881+ cache. isfresh = false
864882 end
865- cache. cacheval = fact
866- cache. isfresh = false
883+
884+ cache. u .= @get_cacheval (cache, :CHOLMODFactorization ) \ cache. b
885+ SciMLBase. build_linear_solution (alg, cache. u, nothing , cache)
867886 end
887+ else
888+ function SciMLBase. solve! (cache:: LinearCache , alg:: CHOLMODFactorization ; kwargs... )
889+ A = cache. A
890+ A = convert (AbstractMatrix, A)
891+
892+ if cache. isfresh
893+ cacheval = @get_cacheval (cache, :CHOLMODFactorization )
894+ fact = cholesky (A)
895+ if ! LinearAlgebra. issuccess (fact)
896+ ldlt! (fact, A)
897+ end
898+ cache. cacheval = fact
899+ cache. isfresh = false
900+ end
868901
869- cache. u .= @get_cacheval (cache, :CHOLMODFactorization ) \ cache. b
870- SciMLBase. build_linear_solution (alg, cache. u, nothing , cache)
902+ cache. u .= @get_cacheval (cache, :CHOLMODFactorization ) \ cache. b
903+ SciMLBase. build_linear_solution (alg, cache. u, nothing , cache)
904+ end
871905end
872906
873907# # RFLUFactorization
@@ -909,7 +943,7 @@ function init_cacheval(alg::RFLUFactorization,
909943 nothing , nothing
910944end
911945
912- @static if VERSION < v " 1.7 -"
946+ @static if VERSION < v " 1.9 -"
913947 function init_cacheval (alg:: RFLUFactorization ,
914948 A:: Union{Diagonal, SymTridiagonal, Tridiagonal} , b, u, Pl, Pr,
915949 maxiters:: Int ,
954988
955989function NormalCholeskyFactorization (; pivot = nothing )
956990 if pivot === nothing
957- pivot = @static if VERSION < v " 1.7beta "
991+ pivot = @static if VERSION < v " 1.8beta "
958992 Val (false )
959993 else
960994 NoPivot ()
9661000default_alias_A (:: NormalCholeskyFactorization , :: Any , :: Any ) = true
9671001default_alias_b (:: NormalCholeskyFactorization , :: Any , :: Any ) = true
9681002
969- @static if VERSION < v " 1.7beta "
1003+ @static if VERSION < v " 1.8beta "
9701004 normcholpivot = Val (false )
9711005else
9721006 normcholpivot = NoPivot ()
@@ -996,7 +1030,7 @@ function init_cacheval(alg::NormalCholeskyFactorization,
9961030 nothing
9971031end
9981032
999- @static if VERSION < v " 1.7 -"
1033+ @static if VERSION < v " 1.9 -"
10001034 function init_cacheval (alg:: NormalCholeskyFactorization ,
10011035 A:: Union{Tridiagonal, SymTridiagonal, Adjoint} , b, u, Pl, Pr,
10021036 maxiters:: Int , abstol, reltol, verbose:: Bool ,
@@ -1005,26 +1039,54 @@ end
10051039 end
10061040end
10071041
1008- function SciMLBase. solve! (cache:: LinearCache , alg:: NormalCholeskyFactorization ;
1009- kwargs... )
1010- A = cache. A
1011- A = convert (AbstractMatrix, A)
1012- if cache. isfresh
1042+ @static if VERSION > v " 1.8-"
1043+ function SciMLBase. solve! (cache:: LinearCache , alg:: NormalCholeskyFactorization ;
1044+ kwargs... )
1045+ A = cache. A
1046+ A = convert (AbstractMatrix, A)
1047+ if cache. isfresh
1048+ if A isa SparseMatrixCSC
1049+ fact = cholesky (Symmetric ((A)' * A, :L ); check = false )
1050+ else
1051+ fact = cholesky (Symmetric ((A)' * A, :L ), alg. pivot; check = false )
1052+ end
1053+ cache. cacheval = fact
1054+ cache. isfresh = false
1055+ end
10131056 if A isa SparseMatrixCSC
1014- fact = cholesky (Symmetric ((A)' * A, :L ))
1057+ cache. u .= @get_cacheval (cache, :NormalCholeskyFactorization ) \ (A' * cache. b)
1058+ y = cache. u
10151059 else
1016- fact = cholesky (Symmetric ((A)' * A, :L ), alg. pivot)
1060+ y = ldiv! (cache. u,
1061+ @get_cacheval (cache, :NormalCholeskyFactorization ),
1062+ A' * cache. b)
10171063 end
1018- cache. cacheval = fact
1019- cache. isfresh = false
1064+ SciMLBase. build_linear_solution (alg, y, nothing , cache)
10201065 end
1021- if A isa SparseMatrixCSC
1022- cache. u .= @get_cacheval (cache, :NormalCholeskyFactorization ) \ (A' * cache. b)
1023- y = cache. u
1024- else
1025- y = ldiv! (cache. u, @get_cacheval (cache, :NormalCholeskyFactorization ), A' * cache. b)
1066+ else
1067+ function SciMLBase. solve! (cache:: LinearCache , alg:: NormalCholeskyFactorization ;
1068+ kwargs... )
1069+ A = cache. A
1070+ A = convert (AbstractMatrix, A)
1071+ if cache. isfresh
1072+ if A isa SparseMatrixCSC
1073+ fact = cholesky (Symmetric ((A)' * A, :L ))
1074+ else
1075+ fact = cholesky (Symmetric ((A)' * A, :L ), alg. pivot)
1076+ end
1077+ cache. cacheval = fact
1078+ cache. isfresh = false
1079+ end
1080+ if A isa SparseMatrixCSC
1081+ cache. u .= @get_cacheval (cache, :NormalCholeskyFactorization ) \ (A' * cache. b)
1082+ y = cache. u
1083+ else
1084+ y = ldiv! (cache. u,
1085+ @get_cacheval (cache, :NormalCholeskyFactorization ),
1086+ A' * cache. b)
1087+ end
1088+ SciMLBase. build_linear_solution (alg, y, nothing , cache)
10261089 end
1027- SciMLBase. build_linear_solution (alg, y, nothing , cache)
10281090end
10291091
10301092# # NormalBunchKaufmanFactorization
0 commit comments