Created
May 22, 2023 14:29
-
-
Save silgon/103a0e8c168ccc4f206e8dfe4768ad53 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import numpy as np | |
import cvxpy as cp | |
α = 0.3 | |
A = np.array([[1., α], [α, 1.5]]) | |
# maximum eigenvalue | |
t = cp.Variable() | |
prob = cp.Problem(cp.Minimize(t), [np.eye(2)*t-A>>0]) | |
prob.solve() | |
# minimum eigenvalue | |
t = cp.Variable() | |
prob = cp.Problem(cp.Minimize(-t), [A-np.eye(2)*t>>0]) | |
prob.solve() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment