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+ SymbolicIndexingInterface. symbolic_container (sli:: SymbolicLinearInterface ) = sli. sys
30+
131@doc doc"""
232
333Defines a linear system problem.
@@ -50,20 +80,23 @@ parameters. Any extra keyword arguments are passed on to the solvers.
5080* `b`: The right-hand side of the linear system.
5181* `p`: The parameters for the problem. Defaults to `NullParameters`. Currently unused.
5282* `u0`: The initial condition used by iterative solvers.
83+ * `symbolic_interface`: An instance of `SymbolicLinearInterface` if the problem was
84+ generated by a symbolic backend.
5385* `kwargs`: The keyword arguments passed on to the solvers.
5486"""
55- struct LinearProblem{uType, isinplace, F, bType, P, K} < :
87+ struct LinearProblem{uType, isinplace, F, bType, P, I <: Union{SymbolicLinearInterface, Nothing} , K} < :
5688 AbstractLinearProblem{bType, isinplace}
5789 A:: F
5890 b:: bType
5991 u0:: uType
6092 p:: P
93+ symbolic_interface:: I
6194 kwargs:: K
6295 @add_kwonly function LinearProblem {iip} (A, b, p = NullParameters (); u0 = nothing ,
63- kwargs... ) where {iip}
96+ symbolic_interface = nothing , kwargs... ) where {iip}
6497 warn_paramtype (p)
65- new {typeof(u0), iip, typeof(A), typeof(b), typeof(p), typeof(kwargs)} (A, b, u0, p,
66- kwargs)
98+ new {typeof(u0), iip, typeof(A), typeof(b), typeof(p), typeof(symbolic_interface), typeof( kwargs)} (A, b, u0, p,
99+ symbolic_interface, kwargs)
67100 end
68101end
69102
@@ -77,6 +110,16 @@ function LinearProblem(A, b, args...; kwargs...)
77110 end
78111end
79112
113+ SymbolicIndexingInterface. symbolic_container (prob:: LinearProblem ) = prob. symbolic_interface
114+ SymbolicIndexingInterface. state_values (prob:: LinearProblem ) = prob. u0
115+ SymbolicIndexingInterface. parameter_values (prob:: LinearProblem ) = prob. p
116+ SymbolicIndexingInterface. is_time_dependent (:: LinearProblem ) = false
117+ function SymbolicIndexingInterface. set_parameter! (valp:: LinearProblem{A, B, C, D, E, <:SymbolicLinearInterface} , val, idx) where {A, B, C, D, E}
118+ set_parameter! (parameter_values (valp), val, idx)
119+ valp. symbolic_interface. update_A! (valp. A, valp. p)
120+ valp. symbolic_interface. update_b! (valp. b, valp. p)
121+ end
122+
80123@doc doc"""
81124Holds information on what variables to alias
82125when solving a LinearProblem. Conforms to the AbstractAliasSpecifier interface.
0 commit comments