Bidiagonalization question, Golub-Kahan (lanczos)

For the following attempt at bidiagonalization during a test of A = magic(5), I get a matrix of NaN for B, and an entry in U lower right corner as NaN. Please help me understand why, I have followed the algorithm:
function [U,B,V]=bidiagonal_reduction(A)
[m n] = size(A);
U = zeros(m);
V = zeros(n);
for i = 1:n
x_col = A(i:m,i);
y_col = norm(x_col);
sizexc = size(x_col);
y_c = zeros(sizexc(1,1),1);
y_c(1) = y_col;
u = x_col-y_c;
U(i:m,i) = u;
usize = size(u);
A(i:m,i:n) = (eye(usize(1,1))-2*((u*u')/(u'*u)))*A(i:m,i:n);
x_row = A(i,i+1:n);
y_row = norm(x_row);
sizexr = size(x_row);
y_r = zeros(1,sizexr(1,2));
y_r(1) = y_row;
v = x_row-y_r;
V(i,i+1:n) = v;
vsize = size(v);
A(i:m,i+1:n) = A(i:m,i+1:n)*(eye(vsize(1,1)) - 2*((v'*v)/(v*v')));
end
B = U'*A*V;
end

Answers (0)

Asked:

on 12 Mar 2015

Edited:

on 13 Mar 2015

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!