Source code for cla_utils.exercises3

import numpy as np


[docs]def householder(A): """ Given a real mxn matrix A, find the reduction to upper triangular matrix R using Householder transformations. The reduction should be done "in-place", so that A is transformed to R. :param A: an mxn-dimensional numpy array """ m, n = A.shape raise NotImplementedError
[docs]def solve_U(U, b): """ Solve systems Ux_i=b_i for x_i with U upper triangular, i=1,2,...,k :param U: an mxm-dimensional numpy array, assumed upper triangular :param b: an mxk-dimensional numpy array, with ith column containing b_i :return x: an mxk-dimensional numpy array, with ith column containing the solution x_i """ raise NotImplementedError
[docs]def householder_solve(A, b): """ Given a real mxm matrix A, use the Householder transformation to solve Ax_i=b_i, i=1,2,...,k. :param A: an mxm-dimensional numpy array :param b: an mxk-dimensional numpy array whose columns are the \ right-hand side vectors b_1,b_2,...,b_k. :return x: an mxk-dimensional numpy array whose columns are the \ right-hand side vectors x_1,x_2,...,x_k. """ raise NotImplementedError return x
[docs]def householder_qr(A): """ Given a real mxn matrix A, use the Householder transformation to find the full QR factorisation of A. :param A: an mxn-dimensional numpy array :return Q: an mxm-dimensional numpy array :return R: an mxn-dimensional numpy array """ raise NotImplementedError return Q, R
[docs]def householder_ls(A, b): """ Given a real mxn matrix A and an m dimensional vector b, find the least squares solution to Ax = b. :param A: an mxn-dimensional numpy array :param b: an m-dimensional numpy array :return x: an n-dimensional numpy array """ raise NotImplementedError return x