Source code for cla_utils.exercises8
import numpy as np
[docs]def Q1AQ1s(A):
"""
For a matrix A, find the unitary matrix Q1 such that the first
column of Q1*A has zeros below the diagonal. Then return A1 = Q1*A*Q1^*.
:param A: an mxm numpy array
:return A1: an mxm numpy array
"""
raise NotImplementedError
[docs]def hessenberg(A):
"""
For a matrix A, transform to Hessenberg form H by Householder
similarity transformations, in place.
:param A: an mxm numpy array
"""
raise NotImplementedError
[docs]def hessenbergQ(A):
"""
For a matrix A, transform to Hessenberg form H by Householder
similarity transformations, in place, and return the matrix Q
for which QHQ^* = A.
:param A: an mxm numpy array
:return Q: an mxm numpy array
"""
raise NotImplementedError
[docs]def hessenberg_ev(H):
"""
Given a Hessenberg matrix, return the eigenvectors.
:param H: an mxm numpy array
:return V: an mxm numpy array whose columns are the eigenvectors of H
Do not change this function.
"""
m, n = H.shape
assert(m==n)
assert(cla_utils.norm(H[np.tril_indices(m, -2)]) < 1.0e-6)
_, V = np.linalg.eig(H)
return V
[docs]def ev(A):
"""
Given a matrix A, return the eigenvectors of A. This should
be done by using your functions to reduce to upper Hessenberg
form, before calling hessenberg_ev (which you should not edit!).
:param A: an mxm numpy array
:return V: an mxm numpy array whose columns are the eigenvectors of A
"""
raise NotImplementedError