@@ -402,15 +402,15 @@ function do_factorization(alg::GenericFactorization, A, b, u)
402402 return fact
403403end
404404
405- function init_cacheval (alg:: GenericFactorization{typeof(lu)} , A, b, u, Pl, Pr,
405+ function init_cacheval (alg:: GenericFactorization{typeof(lu)} , A:: AbstractMatrix , b, u, Pl, Pr,
406406 maxiters:: Int ,
407407 abstol, reltol, verbose:: Bool , assumptions:: OperatorAssumptions )
408- ArrayInterface. lu_instance (convert (AbstractMatrix, A) )
408+ ArrayInterface. lu_instance (A )
409409end
410- function init_cacheval (alg:: GenericFactorization{typeof(lu!)} , A, b, u, Pl, Pr,
410+ function init_cacheval (alg:: GenericFactorization{typeof(lu!)} , A:: AbstractMatrix , b, u, Pl, Pr,
411411 maxiters:: Int ,
412412 abstol, reltol, verbose:: Bool , assumptions:: OperatorAssumptions )
413- ArrayInterface. lu_instance (convert (AbstractMatrix, A) )
413+ ArrayInterface. lu_instance (A )
414414end
415415
416416function init_cacheval (alg:: GenericFactorization{typeof(lu)} ,
@@ -445,16 +445,36 @@ function init_cacheval(alg::GenericFactorization{typeof(lu!)}, A::Tridiagonal, b
445445 assumptions:: OperatorAssumptions )
446446 ArrayInterface. lu_instance (A)
447447end
448+ function init_cacheval (alg:: GenericFactorization{typeof(lu!)} , A:: SymTridiagonal{T, V} , b, u, Pl, Pr,
449+ maxiters:: Int , abstol, reltol, verbose:: Bool ,
450+ assumptions:: OperatorAssumptions ) where {T, V}
451+ LinearAlgebra. LDLt {T, SymTridiagonal{T, V}} (A)
452+ end
453+ function init_cacheval (alg:: GenericFactorization{typeof(lu)} , A:: SymTridiagonal{T, V} , b, u, Pl, Pr,
454+ maxiters:: Int , abstol, reltol, verbose:: Bool ,
455+ assumptions:: OperatorAssumptions ) where {T, V}
456+ LinearAlgebra. LDLt {T, SymTridiagonal{T, V}} (A)
457+ end
448458
449- function init_cacheval (alg:: GenericFactorization{typeof(qr)} , A, b, u, Pl, Pr,
459+ function init_cacheval (alg:: GenericFactorization{typeof(qr)} , A:: AbstractMatrix , b, u, Pl, Pr,
450460 maxiters:: Int ,
451461 abstol, reltol, verbose:: Bool , assumptions:: OperatorAssumptions )
452- ArrayInterface. qr_instance (convert (AbstractMatrix, A) )
462+ ArrayInterface. qr_instance (A )
453463end
454- function init_cacheval (alg:: GenericFactorization{typeof(qr!)} , A, b, u, Pl, Pr,
464+ function init_cacheval (alg:: GenericFactorization{typeof(qr!)} , A:: AbstractMatrix , b, u, Pl, Pr,
455465 maxiters:: Int ,
456466 abstol, reltol, verbose:: Bool , assumptions:: OperatorAssumptions )
457- ArrayInterface. qr_instance (convert (AbstractMatrix, A))
467+ ArrayInterface. qr_instance (A)
468+ end
469+ function init_cacheval (alg:: GenericFactorization{typeof(qr)} , A:: SymTridiagonal{T, V} , b, u, Pl, Pr,
470+ maxiters:: Int , abstol, reltol, verbose:: Bool ,
471+ assumptions:: OperatorAssumptions ) where {T, V}
472+ LinearAlgebra. LDLt {T, SymTridiagonal{T, V}} (A)
473+ end
474+ function init_cacheval (alg:: GenericFactorization{typeof(qr!)} , A:: SymTridiagonal{T, V} , b, u, Pl, Pr,
475+ maxiters:: Int , abstol, reltol, verbose:: Bool ,
476+ assumptions:: OperatorAssumptions ) where {T, V}
477+ LinearAlgebra. LDLt {T, SymTridiagonal{T, V}} (A)
458478end
459479
460480function init_cacheval (alg:: GenericFactorization{typeof(qr)} ,
@@ -490,15 +510,15 @@ function init_cacheval(alg::GenericFactorization{typeof(qr!)}, A::Tridiagonal, b
490510 ArrayInterface. qr_instance (A)
491511end
492512
493- function init_cacheval (alg:: GenericFactorization{typeof(svd)} , A, b, u, Pl, Pr,
513+ function init_cacheval (alg:: GenericFactorization{typeof(svd)} , A:: AbstractMatrix , b, u, Pl, Pr,
494514 maxiters:: Int ,
495515 abstol, reltol, verbose:: Bool , assumptions:: OperatorAssumptions )
496- ArrayInterface. svd_instance (convert (AbstractMatrix, A) )
516+ ArrayInterface. svd_instance (A )
497517end
498- function init_cacheval (alg:: GenericFactorization{typeof(svd!)} , A, b, u, Pl, Pr,
518+ function init_cacheval (alg:: GenericFactorization{typeof(svd!)} , A:: AbstractMatrix , b, u, Pl, Pr,
499519 maxiters:: Int ,
500520 abstol, reltol, verbose:: Bool , assumptions:: OperatorAssumptions )
501- ArrayInterface. svd_instance (convert (AbstractMatrix, A) )
521+ ArrayInterface. svd_instance (A )
502522end
503523
504524function init_cacheval (alg:: GenericFactorization{typeof(svd)} ,
@@ -534,6 +554,16 @@ function init_cacheval(alg::GenericFactorization{typeof(svd!)}, A::Tridiagonal,
534554 assumptions:: OperatorAssumptions )
535555 ArrayInterface. svd_instance (A)
536556end
557+ function init_cacheval (alg:: GenericFactorization{typeof(svd!)} , A:: SymTridiagonal{T, V} , b, u, Pl, Pr,
558+ maxiters:: Int , abstol, reltol, verbose:: Bool ,
559+ assumptions:: OperatorAssumptions ) where {T, V}
560+ LinearAlgebra. LDLt {T, SymTridiagonal{T, V}} (A)
561+ end
562+ function init_cacheval (alg:: GenericFactorization{typeof(svd)} , A:: SymTridiagonal{T, V} , b, u, Pl, Pr,
563+ maxiters:: Int , abstol, reltol, verbose:: Bool ,
564+ assumptions:: OperatorAssumptions ) where {T, V}
565+ LinearAlgebra. LDLt {T, SymTridiagonal{T, V}} (A)
566+ end
537567
538568function init_cacheval (alg:: GenericFactorization , A:: Diagonal , b, u, Pl, Pr, maxiters:: Int ,
539569 abstol, reltol, verbose:: Bool , assumptions:: OperatorAssumptions )
@@ -549,6 +579,18 @@ function init_cacheval(alg::GenericFactorization, A::SymTridiagonal{T, V}, b, u,
549579 assumptions:: OperatorAssumptions ) where {T, V}
550580 LinearAlgebra. LDLt {T, SymTridiagonal{T, V}} (A)
551581end
582+ function init_cacheval (alg:: GenericFactorization , A, b, u, Pl, Pr,
583+ maxiters:: Int ,
584+ abstol, reltol, verbose:: Bool , assumptions:: OperatorAssumptions )
585+ init_cacheval (alg, convert (AbstractMatrix, A), b, u, Pl, Pr,
586+ maxiters:: Int , abstol, reltol, verbose:: Bool ,
587+ assumptions:: OperatorAssumptions )
588+ end
589+ function init_cacheval (alg:: GenericFactorization , A:: AbstractMatrix , b, u, Pl, Pr,
590+ maxiters:: Int ,
591+ abstol, reltol, verbose:: Bool , assumptions:: OperatorAssumptions )
592+ do_factorization (alg, A, b, u)
593+ end
552594
553595function init_cacheval (alg:: Union {GenericFactorization{typeof (bunchkaufman!)},
554596 GenericFactorization{typeof (bunchkaufman)}},
@@ -573,15 +615,49 @@ end
573615# Try to never use it.
574616
575617# Cholesky needs the posdef matrix, for GenericFactorization assume structure is needed
576- function init_cacheval (alg:: Union {GenericFactorization{typeof (cholesky)},
577- GenericFactorization{typeof (cholesky!)}}, A, b, u, Pl, Pr,
578- maxiters:: Int , abstol, reltol, verbose:: Bool ,
618+ function init_cacheval (alg:: GenericFactorization{typeof(cholesky)} , A:: AbstractMatrix , b, u, Pl, Pr,
619+ maxiters:: Int , abstol, reltol, verbose:: Bool ,
620+ assumptions:: OperatorAssumptions )
621+ newA = copy (convert (AbstractMatrix, A))
622+ do_factorization (alg, newA, b, u)
623+ end
624+ function init_cacheval (alg:: GenericFactorization{typeof(cholesky!)} , A:: AbstractMatrix , b, u, Pl, Pr,
625+ maxiters:: Int , abstol, reltol, verbose:: Bool ,
579626 assumptions:: OperatorAssumptions )
580627 newA = copy (convert (AbstractMatrix, A))
581628 do_factorization (alg, newA, b, u)
582629end
630+ function init_cacheval (alg:: GenericFactorization{typeof(cholesky!)} , A:: Diagonal , b, u, Pl, Pr, maxiters:: Int ,
631+ abstol, reltol, verbose:: Bool , assumptions:: OperatorAssumptions )
632+ Diagonal (inv .(A. diag))
633+ end
634+ function init_cacheval (alg:: GenericFactorization{typeof(cholesky!)} , A:: Tridiagonal , b, u, Pl, Pr,
635+ maxiters:: Int ,
636+ abstol, reltol, verbose:: Bool , assumptions:: OperatorAssumptions )
637+ ArrayInterface. lu_instance (A)
638+ end
639+ function init_cacheval (alg:: GenericFactorization{typeof(cholesky!)} , A:: SymTridiagonal{T, V} , b, u, Pl, Pr,
640+ maxiters:: Int , abstol, reltol, verbose:: Bool ,
641+ assumptions:: OperatorAssumptions ) where {T, V}
642+ LinearAlgebra. LDLt {T, SymTridiagonal{T, V}} (A)
643+ end
644+ function init_cacheval (alg:: GenericFactorization{typeof(cholesky)} , A:: Diagonal , b, u, Pl, Pr, maxiters:: Int ,
645+ abstol, reltol, verbose:: Bool , assumptions:: OperatorAssumptions )
646+ Diagonal (inv .(A. diag))
647+ end
648+ function init_cacheval (alg:: GenericFactorization{typeof(cholesky)} , A:: Tridiagonal , b, u, Pl, Pr,
649+ maxiters:: Int ,
650+ abstol, reltol, verbose:: Bool , assumptions:: OperatorAssumptions )
651+ ArrayInterface. lu_instance (A)
652+ end
653+ function init_cacheval (alg:: GenericFactorization{typeof(cholesky)} , A:: SymTridiagonal{T, V} , b, u, Pl, Pr,
654+ maxiters:: Int , abstol, reltol, verbose:: Bool ,
655+ assumptions:: OperatorAssumptions ) where {T, V}
656+ LinearAlgebra. LDLt {T, SymTridiagonal{T, V}} (A)
657+ end
658+
583659
584- function init_cacheval (alg:: Union{ GenericFactorization} ,
660+ function init_cacheval (alg:: GenericFactorization ,
585661 A:: Union {Hermitian{T, <: SparseMatrixCSC },
586662 Symmetric{T, <: SparseMatrixCSC }}, b, u, Pl, Pr,
587663 maxiters:: Int , abstol, reltol, verbose:: Bool ,
@@ -1063,21 +1139,29 @@ end
10631139# but QRFactorization uses 16.
10641140FastQRFactorization () = FastQRFactorization (NoPivot (), 36 )
10651141
1066- function init_cacheval (alg:: FastQRFactorization{NoPivot} , A, b, u, Pl, Pr,
1142+ function init_cacheval (alg:: FastQRFactorization{NoPivot} , A:: AbstractMatrix , b, u, Pl, Pr,
10671143 maxiters:: Int , abstol, reltol, verbose:: Bool ,
10681144 assumptions:: OperatorAssumptions )
10691145 ws = QRWYWs (A; blocksize = alg. blocksize)
10701146 return WorkspaceAndFactors (ws,
10711147 ArrayInterface. qr_instance (convert (AbstractMatrix, A)))
10721148end
1073- function init_cacheval (:: FastQRFactorization{ColumnNorm} , A, b, u, Pl, Pr,
1149+ function init_cacheval (:: FastQRFactorization{ColumnNorm} , A:: AbstractMatrix , b, u, Pl, Pr,
10741150 maxiters:: Int , abstol, reltol, verbose:: Bool ,
10751151 assumptions:: OperatorAssumptions )
10761152 ws = QRpWs (A)
10771153 return WorkspaceAndFactors (ws,
10781154 ArrayInterface. qr_instance (convert (AbstractMatrix, A)))
10791155end
10801156
1157+ function init_cacheval (alg:: FastQRFactorization , A, b, u, Pl, Pr,
1158+ maxiters:: Int , abstol, reltol, verbose:: Bool ,
1159+ assumptions:: OperatorAssumptions )
1160+ return init_cacheval (alg, convert (AbstractMatrix, A), b, u, Pl, Pr,
1161+ maxiters:: Int , abstol, reltol, verbose:: Bool ,
1162+ assumptions:: OperatorAssumptions )
1163+ end
1164+
10811165function SciMLBase. solve! (cache:: LinearCache , alg:: FastQRFactorization{P} ;
10821166 kwargs... ) where {P}
10831167 A = cache. A
@@ -1184,4 +1268,4 @@ for alg in InteractiveUtils.subtypes(AbstractFactorization)
11841268 maxiters:: Int , abstol, reltol, verbose:: Bool ,
11851269 assumptions:: OperatorAssumptions )
11861270 end
1187- end
1271+ end
0 commit comments