@@ -120,7 +120,7 @@ function init_cacheval(alg::Union{LUFactorization, GenericLUFactorization},
120
120
nothing
121
121
end
122
122
123
- @static if VERSION < v " 1.7 -"
123
+ @static if VERSION < v " 1.9 -"
124
124
function init_cacheval (alg:: Union{LUFactorization, GenericLUFactorization} ,
125
125
A:: Union{Diagonal, SymTridiagonal} , b, u, Pl, Pr,
126
126
maxiters:: Int , abstol, reltol, verbose:: Bool ,
@@ -188,7 +188,7 @@ function init_cacheval(alg::QRFactorization, A::AbstractSciMLOperator, b, u, Pl,
188
188
nothing
189
189
end
190
190
191
- @static if VERSION < v " 1.7 -"
191
+ @static if VERSION < v " 1.9 -"
192
192
function init_cacheval (alg:: QRFactorization ,
193
193
A:: Union{Diagonal, SymTridiagonal, Tridiagonal} , b, u, Pl, Pr,
194
194
maxiters:: Int , abstol, reltol, verbose:: Bool ,
220
220
221
221
function CholeskyFactorization (; pivot = nothing , tol = 0.0 , shift = 0.0 , perm = nothing )
222
222
if pivot === nothing
223
- pivot = @static if VERSION < v " 1.7beta "
223
+ pivot = @static if VERSION < v " 1.8beta "
224
224
Val (false )
225
225
else
226
226
NoPivot ()
@@ -229,16 +229,30 @@ function CholeskyFactorization(; pivot = nothing, tol = 0.0, shift = 0.0, perm =
229
229
CholeskyFactorization (pivot, 16 , shift, perm)
230
230
end
231
231
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
240
255
end
241
- return fact
242
256
end
243
257
244
258
function init_cacheval (alg:: CholeskyFactorization , A, b, u, Pl, Pr,
@@ -247,7 +261,7 @@ function init_cacheval(alg::CholeskyFactorization, A, b, u, Pl, Pr,
247
261
ArrayInterface. cholesky_instance (convert (AbstractMatrix, A), alg. pivot)
248
262
end
249
263
250
- @static if VERSION < v " 1.7beta "
264
+ @static if VERSION < v " 1.8beta "
251
265
cholpivot = Val (false )
252
266
else
253
267
cholpivot = NoPivot ()
@@ -268,7 +282,7 @@ function init_cacheval(alg::CholeskyFactorization,
268
282
nothing
269
283
end
270
284
271
- @static if VERSION < v " 1.7beta "
285
+ @static if VERSION < v " 1.9beta "
272
286
function init_cacheval (alg:: CholeskyFactorization ,
273
287
A:: Union{SymTridiagonal, Tridiagonal} , b, u, Pl, Pr,
274
288
maxiters:: Int , abstol, reltol, verbose:: Bool ,
@@ -361,7 +375,7 @@ function init_cacheval(alg::SVDFactorization, A, b, u, Pl, Pr,
361
375
nothing
362
376
end
363
377
364
- @static if VERSION < v " 1.7 -"
378
+ @static if VERSION < v " 1.9 -"
365
379
function init_cacheval (alg:: SVDFactorization ,
366
380
A:: Union{Diagonal, SymTridiagonal, Tridiagonal} , b, u, Pl, Pr,
367
381
maxiters:: Int , abstol, reltol, verbose:: Bool ,
@@ -852,22 +866,42 @@ function init_cacheval(alg::CHOLMODFactorization,
852
866
PREALLOCATED_CHOLMOD
853
867
end
854
868
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)
858
873
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
864
882
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)
867
886
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
868
901
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
871
905
end
872
906
873
907
# # RFLUFactorization
@@ -909,7 +943,7 @@ function init_cacheval(alg::RFLUFactorization,
909
943
nothing , nothing
910
944
end
911
945
912
- @static if VERSION < v " 1.7 -"
946
+ @static if VERSION < v " 1.9 -"
913
947
function init_cacheval (alg:: RFLUFactorization ,
914
948
A:: Union{Diagonal, SymTridiagonal, Tridiagonal} , b, u, Pl, Pr,
915
949
maxiters:: Int ,
954
988
955
989
function NormalCholeskyFactorization (; pivot = nothing )
956
990
if pivot === nothing
957
- pivot = @static if VERSION < v " 1.7beta "
991
+ pivot = @static if VERSION < v " 1.8beta "
958
992
Val (false )
959
993
else
960
994
NoPivot ()
966
1000
default_alias_A (:: NormalCholeskyFactorization , :: Any , :: Any ) = true
967
1001
default_alias_b (:: NormalCholeskyFactorization , :: Any , :: Any ) = true
968
1002
969
- @static if VERSION < v " 1.7beta "
1003
+ @static if VERSION < v " 1.8beta "
970
1004
normcholpivot = Val (false )
971
1005
else
972
1006
normcholpivot = NoPivot ()
@@ -996,7 +1030,7 @@ function init_cacheval(alg::NormalCholeskyFactorization,
996
1030
nothing
997
1031
end
998
1032
999
- @static if VERSION < v " 1.7 -"
1033
+ @static if VERSION < v " 1.9 -"
1000
1034
function init_cacheval (alg:: NormalCholeskyFactorization ,
1001
1035
A:: Union{Tridiagonal, SymTridiagonal, Adjoint} , b, u, Pl, Pr,
1002
1036
maxiters:: Int , abstol, reltol, verbose:: Bool ,
@@ -1005,26 +1039,54 @@ end
1005
1039
end
1006
1040
end
1007
1041
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
1013
1056
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
1015
1059
else
1016
- fact = cholesky (Symmetric ((A)' * A, :L ), alg. pivot)
1060
+ y = ldiv! (cache. u,
1061
+ @get_cacheval (cache, :NormalCholeskyFactorization ),
1062
+ A' * cache. b)
1017
1063
end
1018
- cache. cacheval = fact
1019
- cache. isfresh = false
1064
+ SciMLBase. build_linear_solution (alg, y, nothing , cache)
1020
1065
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)
1026
1089
end
1027
- SciMLBase. build_linear_solution (alg, y, nothing , cache)
1028
1090
end
1029
1091
1030
1092
# # NormalBunchKaufmanFactorization
0 commit comments