Question: Algorithm 6 . 1 procedure COMPACT _ SVD ( A ) , Vlarreig ( A H A ) l a r r 2 Calculate the

Algorithm 6.1
procedure COMPACT_SVD (A)
,Vlarreig(AHA)
larr2
Calculate the eigenvalues and eigenvectors of AHA.
Calculate the singular values of A.
larrsort(), Sort the singular values from greatest to least.
Vlarrsort(V), Sort the eigenvectors the same way as in the previous step.
rlarrcount(0), Count the number of nonzero singular values (the rank of A).
1larr:r, Keep only the positive singular values.
V1larrV:,:r, Keep only the corresponding eigenvectors.
U1larrAV11, Construct U with array broadcasting.
return U1,1,V1H
Problem 1. Write a function that accepts a matrix A and a small error tolerance tol. Use
Algorithm 6.1 to compute the compact SVD of A. In step 6, compute r by counting the number
of singular values that are greater than tol.
Consider the following tips for implementing the algorithm.
The Hermitian AH can be computed with A. conj(). T.
In step 4, the way that is sorted needs to be stored so that the columns of V can be
sorted the same way. Consider using np.argsort() and fancy indexing to do this, but
remember that by default it sorts from least to greatest (not greatest to least).
Step 9 can be done by looping over the columns of V, but it can be done more easily and
efficiently with array broadcasting.
Test your function by calculating the compact SVD for random matrices. Verify that U
and V are orthonormal, that UVH=A, and that the number of nonzero singular values is
the rank of A. You may also want to compre your results to SciPy's SVD algorithm.
 Algorithm 6.1 procedure COMPACT_SVD (A) ,Vlarreig(AHA) larr2 Calculate the eigenvalues and

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!