x
-x
import numpy as np
from scipy.linalg import sqrtm
from scipy.stats import ortho_group
#--------------------------------------------
# Generate example input
#--------------------------------------------
dim = 10
# Create a positive definite matrix H with shape (dim, dim).
# evals is the vector of eigenvalues of H. This can be replaced
# with any vector of length `dim` containing positive values.
evals = (np.arange(1, dim + 1)/2)**2
# Use a random orthogonal matrix to generate H.
R = ortho_group.rvs(dim)
H = R.T.dot(np.diag(evals).dot(R))
# y determines the level set to be computed.
y = 3.0
#--------------------------------------------
# Compute various points on the ellipsoid
#--------------------------------------------
Hinv