Last active
March 3, 2024 06:57
-
-
Save Eddy-Morgan/51bdb566592a3bc0e386db1f8c50104b to your computer and use it in GitHub Desktop.
symbolic expression for eigenvalues and eigenvectors of a system implemented in casadi
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
def qr_eigen(A, iterations=100): | |
pQ = SX.eye(A.size1()) | |
X = copy.deepcopy(A) | |
for _ in range(iterations): | |
Q, R = qr(X) # QR decomposition in CasADi | |
pQ = pQ @ Q # Update eigenvector matrix for next iteration | |
X = R @ Q # Update eigenvalue matrix for next iteration | |
return diag(X), pQ | |
# example usage for a symbolic SX square matrix in casadi | |
w_sym , v_sym = qr_eigen(M, 100) # This get the symbolic eigenvalues and eigenvector expression |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment