Skip to content

Commit

Permalink
Relax check of positive definite constraint. (pyro-ppl#1784)
Browse files Browse the repository at this point in the history
  • Loading branch information
tillahoffmann authored Apr 18, 2024
1 parent b0a348a commit 2f1bccd
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion numpyro/distributions/constraints.py
Original file line number Diff line number Diff line change
Expand Up @@ -603,7 +603,7 @@ class _PositiveDefinite(_SingletonConstraint):
def __call__(self, x):
jnp = np if isinstance(x, (np.ndarray, np.generic)) else jax.numpy
# check for symmetric
symmetric = jnp.all(jnp.all(x == jnp.swapaxes(x, -2, -1), axis=-1), axis=-1)
symmetric = jnp.all(jnp.isclose(x, jnp.swapaxes(x, -2, -1)), axis=(-2, -1))
# check for the smallest eigenvalue is positive
positive = jnp.linalg.eigh(x)[0][..., 0] > 0
return symmetric & positive
Expand Down

0 comments on commit 2f1bccd

Please sign in to comment.