1+ """
2+ AbstractWrappedFunction{iip}
3+
4+ Abstract base type for function wrappers used in automatic differentiation and sensitivity analysis.
5+ These wrappers provide specialized interfaces for computing derivatives with respect to different variables.
6+
7+ # Type Parameter
8+ - `iip`: Boolean indicating if the function is in-place (`true`) or out-of-place (`false`)
9+ """
110abstract type AbstractWrappedFunction{iip} end
211isinplace (f:: AbstractWrappedFunction{iip} ) where {iip} = iip
12+
13+ """
14+ TimeGradientWrapper{iip, fType, uType, P} <: AbstractWrappedFunction{iip}
15+
16+ Wraps functions to compute gradients with respect to time. This wrapper is particularly useful for
17+ sensitivity analysis and optimization problems where the time dependence of the solution is critical.
18+
19+ # Fields
20+ - `f`: The function to wrap
21+ - `uprev`: Previous state value
22+ - `p`: Parameters
23+
24+ # Type Parameters
25+ - `iip`: Boolean indicating if the function is in-place (`true`) or out-of-place (`false`)
26+ - `fType`: Type of the wrapped function
27+ - `uType`: Type of the state variables
28+ - `P`: Type of the parameters
29+
30+ This wrapper enables automatic differentiation with respect to time by providing a consistent
31+ interface for computing `∂f/∂t` across different AD systems.
32+ """
333mutable struct TimeGradientWrapper{iip, fType, uType, P} <: AbstractWrappedFunction{iip}
434 f:: fType
535 uprev:: uType
2050
2151(ff:: TimeGradientWrapper{false} )(t) = ff. f (ff. uprev, ff. p, t)
2252
53+ """
54+ UJacobianWrapper{iip, fType, tType, P} <: AbstractWrappedFunction{iip}
55+
56+ Wraps functions to compute Jacobians with respect to state variables `u`. This is one of the most
57+ commonly used wrappers in the SciML ecosystem for computing the derivative of the right-hand side
58+ function with respect to the state variables.
59+
60+ # Fields
61+ - `f`: The function to wrap
62+ - `t`: Time value
63+ - `p`: Parameters
64+
65+ # Type Parameters
66+ - `iip`: Boolean indicating if the function is in-place (`true`) or out-of-place (`false`)
67+ - `fType`: Type of the wrapped function
68+ - `tType`: Type of the time variable
69+ - `P`: Type of the parameters
70+
71+ This wrapper enables efficient computation of `∂f/∂u` for Jacobian calculations in numerical solvers
72+ and automatic differentiation systems.
73+ """
2374mutable struct UJacobianWrapper{iip, fType, tType, P} <: AbstractWrappedFunction{iip}
2475 f:: fType
2576 t:: tType
4394(ff:: UJacobianWrapper{false} )(uprev) = ff. f (uprev, ff. p, ff. t)
4495(ff:: UJacobianWrapper{false} )(uprev, p, t) = ff. f (uprev, p, t)
4596
97+ """
98+ TimeDerivativeWrapper{iip, F, uType, P} <: AbstractWrappedFunction{iip}
99+
100+ Wraps functions to compute derivatives with respect to time. This wrapper is used when you need to
101+ compute `∂f/∂t` for sensitivity analysis or when the function has explicit time dependence.
102+
103+ # Fields
104+ - `f`: The function to wrap
105+ - `u`: State variables
106+ - `p`: Parameters
107+
108+ # Type Parameters
109+ - `iip`: Boolean indicating if the function is in-place (`true`) or out-of-place (`false`)
110+ - `F`: Type of the wrapped function
111+ - `uType`: Type of the state variables
112+ - `P`: Type of the parameters
113+
114+ This wrapper provides a consistent interface for time derivative computations across different
115+ automatic differentiation backends.
116+ """
46117mutable struct TimeDerivativeWrapper{iip, F, uType, P} <: AbstractWrappedFunction{iip}
47118 f:: F
48119 u:: uType
60131(ff:: TimeDerivativeWrapper{true} )(du1, t) = ff. f (du1, ff. u, ff. p, t)
61132(ff:: TimeDerivativeWrapper{true} )(t) = (du1 = similar (ff. u); ff. f (du1, ff. u, ff. p, t); du1)
62133
134+ """
135+ UDerivativeWrapper{iip, F, tType, P} <: AbstractWrappedFunction{iip}
136+
137+ Wraps functions to compute derivatives with respect to state variables. This wrapper is used for
138+ computing `∂f/∂u` and is fundamental for Jacobian computations in numerical solvers.
139+
140+ # Fields
141+ - `f`: The function to wrap
142+ - `t`: Time value
143+ - `p`: Parameters
144+
145+ # Type Parameters
146+ - `iip`: Boolean indicating if the function is in-place (`true`) or out-of-place (`false`)
147+ - `F`: Type of the wrapped function
148+ - `tType`: Type of the time variable
149+ - `P`: Type of the parameters
150+
151+ This wrapper enables efficient state derivative computations for use in automatic differentiation
152+ and numerical analysis algorithms.
153+ """
63154mutable struct UDerivativeWrapper{iip, F, tType, P} <: AbstractWrappedFunction{iip}
64155 f:: F
65156 t:: tType
@@ -75,6 +166,26 @@ UDerivativeWrapper(f::F, t, p) where {F} = UDerivativeWrapper{isinplace(f, 4)}(f
75166(ff:: UDerivativeWrapper{true} )(du1, u) = ff. f (du1, u, ff. p, ff. t)
76167(ff:: UDerivativeWrapper{true} )(u) = (du1 = similar (u); ff. f (du1, u, ff. p, ff. t); du1)
77168
169+ """
170+ ParamJacobianWrapper{iip, fType, tType, uType} <: AbstractWrappedFunction{iip}
171+
172+ Wraps functions to compute Jacobians with respect to parameters `p`. This wrapper is essential for
173+ parameter estimation, inverse problems, and sensitivity analysis with respect to model parameters.
174+
175+ # Fields
176+ - `f`: The function to wrap
177+ - `t`: Time value
178+ - `u`: State variables
179+
180+ # Type Parameters
181+ - `iip`: Boolean indicating if the function is in-place (`true`) or out-of-place (`false`)
182+ - `fType`: Type of the wrapped function
183+ - `tType`: Type of the time variable
184+ - `uType`: Type of the state variables
185+
186+ This wrapper enables efficient computation of `∂f/∂p` for parameter sensitivity analysis and
187+ optimization algorithms.
188+ """
78189mutable struct ParamJacobianWrapper{iip, fType, tType, uType} <: AbstractWrappedFunction{iip}
79190 f:: fType
80191 t:: tType
@@ -97,6 +208,24 @@ function (ff::ParamJacobianWrapper{false})(du1, p)
97208 du1 .= ff. f (ff. u, p, ff. t)
98209end
99210
211+ """
212+ JacobianWrapper{iip, fType, pType} <: AbstractWrappedFunction{iip}
213+
214+ A general-purpose Jacobian wrapper that can be configured for different types of Jacobian computations.
215+ This wrapper provides a unified interface for various Jacobian calculations across the SciML ecosystem.
216+
217+ # Fields
218+ - `f`: The function to wrap
219+ - `p`: Parameters
220+
221+ # Type Parameters
222+ - `iip`: Boolean indicating if the function is in-place (`true`) or out-of-place (`false`)
223+ - `fType`: Type of the wrapped function
224+ - `pType`: Type of the parameters
225+
226+ This wrapper provides a flexible interface for Jacobian computations that can adapt to different
227+ automatic differentiation backends and numerical methods.
228+ """
100229mutable struct JacobianWrapper{iip, fType, pType} <: AbstractWrappedFunction{iip}
101230 f:: fType
102231 p:: pType
0 commit comments