In this
assignment you will practice the use of distributed matrices and libraries such
as BLAS, LAPACK, BLACS, PBLAS, and ScaLAPACK. You will develop a program that
solves an overdetermined system of equations by the QR linear least squares method. You will
implement the solution using Fortran 77+
(take some time to learn it), measure the performance, and check the
correctness of the computed components.
Download this file and
unpack it. Your task is to fill in the pieces of code marked with TODO so that the program correctly computes the least
squares solution to the overdetermined system of
equations AX = B (multiple right hand sides).
The matrices have the following global
sizes (specified in the file inp.dat):
·
A: MxN
·
B: MxK
M is larger than or equal to N (overdetermined system).
The following MATLAB
code is used to illustrate what the code is supposed to do.
% Construct random matrices
A = rand(M,N);
B = rand(M,K);
% Make copies of A and B
Acpy = A;
Bcpy = B;
% Compute QR factorization of A
A = qr(A); % Store R and Q in A
% Apply Q’ to B
B = Q’*B;
% Apply inverse of top of R to top of B
B(1:N,:) = R(1:N,:)\B(1:N,:);
% B now contains the solution X
% Compute error (AX – B)
Bcpy = Acpy*B
– Bcpy;
% Compute norm of error
norm(Bcpy,
‘fro’)