Question: I need to convert this MATLAB function into C. MATLAB Code function [ Q, R ] = myqr(A); % QR factorization by the Gram-Schmidt Algorithm
I need to convert this MATLAB function into C.
MATLAB Code
function [ Q, R ] = myqr(A); % QR factorization by the Gram-Schmidt Algorithm
Q= zeros(size of(A));
R=zeros(size(A));
n= length(A);
for i = 1:1:n
Q(:,i)=A(:,i);
for j = 1:1:i-1
R(j,i) = Q(:,j)' * A(:,i);
Q(:,i) = Q(:,i) - R(j,i) * Q(:,j);
end
R(i,i) = norm(Q(:,i));
Q(:,i) = Q(:,i) / R(i,i);
end
C Code that I have
void qr_decomp( int n, double **A, double **Q, double **R)
int i, j, k:
for (i=0, i For the transpose in Matlab, what do i use in C? If you could translate the Matlab code to C that'd be awesome!
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
