1
+ """
2
+ $(TYPEDEF)
3
+
4
+ A utility struct stored inside `LinearProblem` to enable a symbolic interface.
5
+
6
+ # Fields
7
+
8
+ $(TYPEDFIELDS)
9
+ """
10
+ struct SymbolicLinearInterface{F1, F2, S, M}
11
+ """
12
+ A function which takes `A` and the parameter object `p` and updates `A` in-place.
13
+ """
14
+ update_A!:: F1
15
+ """
16
+ A function which takes `b` and the parameter object `p` and updates `b` in-place.
17
+ """
18
+ update_b!:: F2
19
+ """
20
+ The symbolic backend for the `LinearProblem`.
21
+ """
22
+ sys:: S
23
+ """
24
+ Arbitrary metadata useful for the symbolic backend.
25
+ """
26
+ metadata:: M
27
+ end
28
+
29
+ __has_sys (:: SymbolicLinearInterface ) = true
30
+ has_sys (:: SymbolicLinearInterface ) = true
31
+
32
+ SymbolicIndexingInterface. symbolic_container (sli:: SymbolicLinearInterface ) = sli. sys
33
+
1
34
@doc doc"""
2
35
3
36
Defines a linear system problem.
@@ -50,20 +83,23 @@ parameters. Any extra keyword arguments are passed on to the solvers.
50
83
* `b`: The right-hand side of the linear system.
51
84
* `p`: The parameters for the problem. Defaults to `NullParameters`. Currently unused.
52
85
* `u0`: The initial condition used by iterative solvers.
86
+ * `symbolic_interface`: An instance of `SymbolicLinearInterface` if the problem was
87
+ generated by a symbolic backend.
53
88
* `kwargs`: The keyword arguments passed on to the solvers.
54
89
"""
55
- struct LinearProblem{uType, isinplace, F, bType, P, K} < :
90
+ struct LinearProblem{uType, isinplace, F, bType, P, I <: Union{SymbolicLinearInterface, Nothing} , K} < :
56
91
AbstractLinearProblem{bType, isinplace}
57
92
A:: F
58
93
b:: bType
59
94
u0:: uType
60
95
p:: P
96
+ f:: I
61
97
kwargs:: K
62
98
@add_kwonly function LinearProblem {iip} (A, b, p = NullParameters (); u0 = nothing ,
63
- kwargs... ) where {iip}
99
+ f = nothing , kwargs... ) where {iip}
64
100
warn_paramtype (p)
65
- new {typeof(u0), iip, typeof(A), typeof(b), typeof(p), typeof(kwargs)} (A, b, u0, p,
66
- kwargs)
101
+ new {typeof(u0), iip, typeof(A), typeof(b), typeof(p), typeof(f), typeof( kwargs)} (A, b, u0, p,
102
+ f, kwargs)
67
103
end
68
104
end
69
105
@@ -77,6 +113,16 @@ function LinearProblem(A, b, args...; kwargs...)
77
113
end
78
114
end
79
115
116
+ SymbolicIndexingInterface. symbolic_container (prob:: LinearProblem ) = prob. f
117
+ SymbolicIndexingInterface. state_values (prob:: LinearProblem ) = prob. u0
118
+ SymbolicIndexingInterface. parameter_values (prob:: LinearProblem ) = prob. p
119
+ SymbolicIndexingInterface. is_time_dependent (:: LinearProblem ) = false
120
+ function SymbolicIndexingInterface. set_parameter! (valp:: LinearProblem{A, B, C, D, E, <:SymbolicLinearInterface} , val, idx) where {A, B, C, D, E}
121
+ set_parameter! (parameter_values (valp), val, idx)
122
+ valp. f. update_A! (valp. A, valp. p)
123
+ valp. f. update_b! (valp. b, valp. p)
124
+ end
125
+
80
126
@doc doc"""
81
127
Holds information on what variables to alias
82
128
when solving a LinearProblem. Conforms to the AbstractAliasSpecifier interface.
0 commit comments