Question: WRITE THE CODE IN C++ Write a code that implements both the classical and the modified GramSchmidt orthogonalization to find the reduced QR factorization of

WRITE THE CODE IN C++

Write a code that implements both the classical and the modified GramSchmidt orthogonalization to find the reduced QR factorization of a given matrix A. Your code should detect if the columns are linearly dependent and abort with an appropriate message.

To detect linear dependence of the column vectors, it's sufficient to check for zero before normalizing vectors vj in the Classical Gramm-Schmidt (CGS), vi in the Modified Gramm-Schmidt (MGS) and vk in the Householder (H) methods, respectively. At least for CGS and MGS it should be clear that zero length of these vectors means that they are in the span of all previous q vectors. Recall that for each j=1:n, span{a1,..,aj} = span{q1,...,qj}. So in short, in CGS you have to stop the routine if rjj=0; likewise in MGS if rii=0; in H if norm(vk)=0.

 WRITE THE CODE IN C++ Write a code that implements both

the classical and the modified GramSchmidt orthogonalization to find the reduced QR

Classical Gram-Schmidt orthogonalization Let Aj, j = l, .. ., n be linearly independent vectors. for j=1,2, ,n for i = 1 , 2. ,j-1 end end Modified Gram-Schmidt orthogonalization Let AN = 1, , n be linearly independent vectors. for j =1,2, ,n for i = 1 , 2. . J-1 y = y-rijq end Classical Gram-Schmidt orthogonalization Let Aj, j = l, .. ., n be linearly independent vectors. for j=1,2, ,n for i = 1 , 2. ,j-1 end end Modified Gram-Schmidt orthogonalization Let AN = 1, , n be linearly independent vectors. for j =1,2, ,n for i = 1 , 2. . J-1 y = y-rijq end

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!