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+
134@doc doc"""
235
336Defines a linear system problem.
@@ -50,20 +83,23 @@ parameters. Any extra keyword arguments are passed on to the solvers.
5083* `b`: The right-hand side of the linear system.
5184* `p`: The parameters for the problem. Defaults to `NullParameters`. Currently unused.
5285* `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.
5388* `kwargs`: The keyword arguments passed on to the solvers.
5489"""
55- struct LinearProblem{uType, isinplace, F, bType, P, K} < :
90+ struct LinearProblem{uType, isinplace, F, bType, P, I <: Union{SymbolicLinearInterface, Nothing} , K} < :
5691 AbstractLinearProblem{bType, isinplace}
5792 A:: F
5893 b:: bType
5994 u0:: uType
6095 p:: P
96+ f:: I
6197 kwargs:: K
6298 @add_kwonly function LinearProblem {iip} (A, b, p = NullParameters (); u0 = nothing ,
63- kwargs... ) where {iip}
99+ f = nothing , kwargs... ) where {iip}
64100 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)
67103 end
68104end
69105
@@ -77,6 +113,16 @@ function LinearProblem(A, b, args...; kwargs...)
77113 end
78114end
79115
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+
80126@doc doc"""
81127Holds information on what variables to alias
82128when solving a LinearProblem. Conforms to the AbstractAliasSpecifier interface.
0 commit comments