Question: import numpy as np from numpy.testing import assert_allclose np.set_printoptions(precision = 4) def swap_rows(A,i,j): perform elementary row operation to swap rows i and j Args:
import numpy as np
from numpy.testing import assert_allclose
np.set_printoptions(precision = 4)
def swap_rows(A,i,j):
"""
perform elementary row operation to swap rows i and j
Args:
A: 2D numpy array representing a matrix
i,j: integer row indices
"""
pass
def dominant_eigen_iteration(A, u0, tol, max_iters):
"""
compute dominant eigenvector and eigenvalue for square matrix
Args:
A: nxn numpy array representing a matrix
u0: initial estimate of eigenvector (1D numpy array)
tol: float relative error termination criterion
max_iters: integer iteration count termination criterion
Returns:
lambda: float dominant eigenvalue
v: dominant eigenvector 1d float numpy array
"""
pass
def recessive_eigen_iteration(A, u0, tol, max_iters):
"""
compute recessive eigenvector and eigenvalue for square matrix
Args:
A: nxn numpy array representing a matrix
u0: initial estimate of eigenvector (1D numpy array)
tol: float relative error termination criterion
max_iters: integer iteration count termination criterion
Returns:
lambda: float recessive eigenvalue
v: recessive eigenvector 1d float numpy array
"""
pass
def condition(A,u0, tol, max_iters):
'''
Compute numerical estimate of condition number of a matrix based on eigenspectrum
Args:
A: 2D numpy array representing the matrix
u0: 1D numpy array that serves as initial guess for eignvector iteration
tol: float residual for termination
max_iters: int bound on number of iterations
Returns:
estimate of condition number
'''
pass
def component_of_along(v, u):
'''
Compute component of vector v along direction of vector u
Args:
v,u: 1d numpy arrays
Returns:
1d numpy array representing the component of v along u
'''
pass
def reflect(v,u):
'''
Compute reflection of vector v across mirror hyperplane with normal vector u
Args:
v,u: 1d numpy arrays
Returns:
1d numpy array representing the refelction of v
'''
pass
def reflect_to_e0(u):
'''
Compute the matrix that rotates a given vector to the e0 direction
Args:
u: 1D numpy array representing vector to rotate
Returns:
reflection: 2D numpy array representing the rotation matrix
'''
pass
def Householder(A):
'''
Compute QR0 partial matrix factorization based on Householder reflection
Args:
A: 2D numpy array representing matrix to be factored
Returns
Q: 2D float numpy array representing othrogonal factor
R0: 2D float numpy array representing whose first column is e0
'''
pass
def QR_Householder(A):
'''
Compute QR matrix factorization based on Householder reflection
Args:
A: 2D numpy array representing matrix to be factored
Returns
Q: 2D float numpy array representing othrogonal factor
R: 2D float numpy array representing upper triangular factor
'''
pass
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
