From: Oluwa KuIse on
Hi,
How do I store the results of a vector in a matrix especially when the length of that vector changes at every step? I am solving the Householder QR factorization and need to store vk inside Qu. My algorithm is below:

function [Qu, R] = houseqr(A)
%This subroutine, houseqr, computes the QR factorization of A.
%It takes as input, matrix A and gives Qu and R as output. Qu is
%a matrix whose columns are Householder vectors u

[m n] = size(A); % m is the number of rows of A and n its column
Qu = zeros(size(A));
p = min(m-1,n);
for k=1:p
x = A(k:m,k);
vk = sign(x(1))*norm(x(:,1)) + x;
vk = vk/norm(vk);
A(k:m,k:n) = A(k:m,k:n)- 2*vk*(vk'*A(k:m,k:n));
%Qu(m-k+1,k) = vk; %% THIS IS WHERE I'M HAVING PROBLEM!!
end
R = A;

Thank you!
From: Bruno Luong on
There are too many problems in the Householder code that I can't guess your intention. You need to revise the algorithm.

Bruno
From: Rune Allnor on
On 9 apr, 08:34, "Oluwa KuIse" <wespeakfo...(a)yahoo.com> wrote:
> Hi,
> How do I store the results of a vector in a matrix especially when the length of that vector changes at every step?

You need to store the vectors in a matrix somewhere.
If you use the Householder for (bi)diagonalizing a
matrix, each Householder step will produce enough zeros
in the matrix that they can contain the elements of the
Householder vector.

Rune
 | 
Pages: 1
Prev: Filling an array
Next: Reply AODV