1
1
2
+
3
+ function SciMLBase. solve (cache:: LinearCache , alg:: AbstractFactorization )
4
+ if cache. isfresh
5
+ fact = init_cacheval (alg, cache. A, cache. b, cache. u)
6
+ cache = set_cacheval (cache, fact)
7
+ end
8
+
9
+ ldiv! (cache. u,cache. cacheval, cache. b)
10
+ end
11
+
2
12
# # LUFactorization
3
13
4
- struct LUFactorization{P} <: SciMLLinearSolveAlgorithm
14
+ struct LUFactorization{P} <: AbstractFactorization
5
15
pivot:: P
6
16
end
7
17
@@ -14,25 +24,16 @@ function LUFactorization()
14
24
LUFactorization (pivot)
15
25
end
16
26
17
- function init_cacheval (A, alg:: LUFactorization )
27
+ function init_cacheval (alg:: LUFactorization , A, b, u )
18
28
A isa Union{AbstractMatrix,AbstractDiffEqOperator} ||
19
29
error (" LU is not defined for $(typeof (A)) " )
20
30
fact = lu! (A, alg. pivot)
21
31
return fact
22
32
end
23
33
24
- function SciMLBase. solve (cache:: LinearCache , alg:: LUFactorization )
25
- if cache. isfresh
26
- fact = init_cacheval (cache. A, alg)
27
- cache = set_cacheval (cache, fact)
28
- end
29
-
30
- ldiv! (cache. u,cache. cacheval, cache. b)
31
- end
32
-
33
34
# # QRFactorization
34
35
35
- struct QRFactorization{P} <: SciMLLinearSolveAlgorithm
36
+ struct QRFactorization{P} <: AbstractFactorization
36
37
pivot:: P
37
38
blocksize:: Int
38
39
end
@@ -46,45 +47,28 @@ function QRFactorization()
46
47
QRFactorization (pivot, 16 )
47
48
end
48
49
49
- function init_cacheval (A, alg:: QRFactorization )
50
+ function init_cacheval (alg:: QRFactorization , A, b, u )
50
51
A isa Union{AbstractMatrix,AbstractDiffEqOperator} ||
51
52
error (" QR is not defined for $(typeof (A)) " )
52
53
53
54
fact = qr! (A. A, alg. pivot; blocksize = alg. blocksize)
54
55
return fact
55
56
end
56
57
57
- function SciMLBase. solve (cache:: LinearCache , alg:: QRFactorization )
58
- if cache. isfresh
59
- fact = init_cacheval (cache. A, alg)
60
- cache = set_cacheval (cache, fact)
61
- end
62
-
63
- ldiv! (cache. u,cache. cacheval, cache. b)
64
- end
65
-
66
58
# # SVDFactorization
67
59
68
- struct SVDFactorization{A} <: SciMLLinearSolveAlgorithm
60
+ struct SVDFactorization{A} <: AbstractFactorization
69
61
full:: Bool
70
62
alg:: A
71
63
end
72
64
73
65
SVDFactorization () = SVDFactorization (false , LinearAlgebra. DivideAndConquer ())
74
66
75
- function init_cacheval (A, alg:: SVDFactorization )
67
+ function init_cacheval (alg:: SVDFactorization , A, b, u )
76
68
A isa Union{AbstractMatrix,AbstractDiffEqOperator} ||
77
69
error (" SVD is not defined for $(typeof (A)) " )
78
70
79
71
fact = svd! (A; full = alg. full, alg = alg. alg)
80
72
return fact
81
73
end
82
74
83
- function SciMLBase. solve (cache:: LinearCache , alg:: SVDFactorization )
84
- if cache. isfresh
85
- fact = init_cacheval (cache. A, alg)
86
- cache = set_cacheval (cache, fact)
87
- end
88
-
89
- ldiv! (cache. u,cache. cacheval, cache. b)
90
- end
0 commit comments