码迷,mamicode.com
首页 > 其他好文 > 详细

Householder Reduction Matlab Version

时间:2014-11-30 23:18:18      阅读:221      评论:0      收藏:0      [点我收藏+]

标签:blog   io   ar   for   on   2014   log   cti   ef   

function [T, P] = householder(A)
% Formations: RA = T, where A is original matrix
% The implementation of Householder Reduction
% R is constructed as a product of elementary reflector
% T is upper triangular matrix

% Author: Zhenlin Du(Johnsondu)
% Email:  qlduzhlin@126.com
% Time:   2014-11-28 14:00

A = double(A)
[m, n] = size(A); % m- number of rows, n- number of columns

iter = 0;
if m > n
    iter = n;
else
    iter = m - 1;
end

T = A;
P = eye(m);

for i = 1 : iter
    % take the first column
    u = T(i:m, i);
    % construct identity matrix
    I = eye(m-i+1);
    e1 = I (:, 1);
    % u is elementary relector.
    u = u - norm(u) * e1;
    R11 = eye(m-i+1) - 2 * (u * u') / (u' * u);
    R1 = eye(m);
    for j = i: m
        R1(j, i: m) = R11(j-i+1, :);
    end
    T = R1 * T;
    P = R1 * P;
end


Householder Reduction Matlab Version

标签:blog   io   ar   for   on   2014   log   cti   ef   

原文地址:http://blog.csdn.net/zone_programming/article/details/41630409

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!