@@ -113,7 +113,7 @@ def post(x: Array) -> tuple[Array, Array]:
113113 u = jnp .sqrt (jnp .diag (U ))
114114 return U .reshape (x .shape + x .shape ), u .reshape (x .shape )
115115
116- def res (x : Array , U : Array ) -> Array :
116+ def resolution (x : Array , U : Array , H : Array ) -> Array : # noqa: N806
117117 r"""
118118 Computes the resolution tensor.
119119
@@ -124,15 +124,13 @@ def res(x: Array, U: Array) -> Array:
124124 the effective degrees of freedom.
125125
126126 :param x: The posterior :math:`\hat{x} \in \mathbb{R}^{m}`.
127- :param U: The posterior uncertainty tensor.
127+ :param x: The posterior uncertainty tensor.
128+ :param H: The inverse prior uncertainty tensor.
128129 :returns: The resolution tensor.
129130 """
130- R = jnp .eye (x .size ) - ( # noqa: N806
131- U .reshape (x .size , - 1 ) * hx .reshape (- 1 )
132- if hx .ndim == x .ndim
133- else U .reshape (x .size , - 1 ) @ hx .reshape (x .size , - 1 )
131+ return jnp .eye (x .size ).reshape (U .shape ) - (
132+ jnp .tensordot (U , H , x .ndims ) if H .ndim != x .ndim else U * H
134133 )
135- return R .reshape (x .shape + x .shape )
136134
137135 def invert (u : Array , t : Array ) -> Array :
138136 """
@@ -163,11 +161,11 @@ def make_minimizer():
163161 )
164162 xopt = optimum .value
165163 xcov , xunc = post (xopt )
164+ xres = resolution (xopt , xcov , hx ) if hx is not None else None
166165 cost = misfit (xopt )
167166 info = jnp .where (optimum .result == optimistix .RESULTS .successful , 0 , 1 )
168- rslv = res (xopt , xcov ) if hx is not None else None
169167
170- return xopt , xcov , xunc , cost , info , rslv
168+ return ( xopt , xcov , xunc , cost , info , xres )
171169
172170
173171@jax .jit (static_argnums = (0 ,), static_argnames = ("max_steps" ,))
@@ -266,7 +264,7 @@ def retrieve(
266264 :param max_steps: The maximum number of steps the optimizer can take.
267265 :returns: The retrieved result.
268266 """
269- xopt , xcov , xunc , cost , info , rslv = _batch (
267+ xopt , xcov , xunc , cost , info , xres = _batch (
270268 f .f ,
271269 jnp .asarray (x ),
272270 jnp .asarray (y ),
@@ -285,5 +283,5 @@ def retrieve(
285283 zvar = zvar ,
286284 cost = np .asarray (cost ),
287285 info = np .asarray (info ),
288- resolution = np .asarray (rslv ) if rslv is not None else None ,
286+ xres = np .asarray (xres ) if xres is not None else None ,
289287 )
0 commit comments