Transient
General transformations and utilities for transient modeling.
Functions
def linear_hot(f, df)
-
Add a linear higher order term to a function
Examples
First define some matrices
>>A = jnp.array([[1.0, 0.0, 0.0], 0.0, 4.0, 2.0], [0.0, 2.0, 4.0]]) [>>B = jnp.array([[-0.23939017, 0.58743526, -0.77305379], 0.81921268, -0.30515101, -0.48556508], [ -0.52113619, -0.74953498, -0.40818426]]) [>>C = A@B
Next define a linear function,
f: x -> Ax
:>>f = anon.dual.wrap( lambda x,*args,**kwds: x, A@x, {}, =3 dim )
Create a new function with a linear higher order term (
ff: x,dx -> f(x) + Bdx
)>>ff = linear_hot(f, B) >>x = dx = jnp.ones((3,1)) >>f(x) 1.], (DeviceArray([[1.], [1.]], dtype=float32), [1.], DeviceArray([[6.], [6.]], dtype=float32), [ {}) >>ff((x, dx)) 1.], ((DeviceArray([[1.], [1.]], dtype=float32), [1.], DeviceArray([[1.], [1.]], dtype=float32)), [0.57499135], DeviceArray([[6.0284967 ], [4.3211446 ]], dtype=float32), [ {})
Studies