首页 > 代码库 > Gram Shimidt QR Factorization Matlab version
Gram Shimidt QR Factorization Matlab version
function [Q,R] = gram_schmidt_qr(A) % Formation: A = QR % The implementation of QR Factorization(classical Gram-Schmidt method) % Q is orthonormal basis for R(A) % R is an upper-triangular matrix with positive diagonal entries. % Author: Zhenlin Du(Johnsondu) % Email: qlduzhlin@126.com % Time: 2014-11-27 22:00 A = double(A) [m, n] = size(A); Q = zeros(m, n); R = zeros(n, n); % for k = 1 u1 = A(:, 1); Q(:, 1) = u1 / (sqrt(dot(u1, u1))); R(1, 1) = (sqrt(dot(u1, u1))); % for k > 1 for i = 2 : n % take column i u = A(:, i); % compute R and u for j = 1: i - 1 R(j, i) = dot(Q(:, j), u); u = u - R(j, i) * Q(:, j); end % get R(i, i) R(i, i) = (sqrt(dot(u, u))); % normalize u = u / R(i, i); Q(:, i) = u; end
Gram Shimidt QR Factorization Matlab version
声明:以上内容来自用户投稿及互联网公开渠道收集整理发布,本网站不拥有所有权,未作人工编辑处理,也不承担相关法律责任,若内容有误或涉及侵权可进行投诉: 投诉/举报 工作人员会在5个工作日内联系你,一经查实,本站将立刻删除涉嫌侵权内容。