📄 mcud.m
字号:
% mcud.m
% Scope: This MATLAB macro computes the real symmetric matrix
% P = U*D*U**(Transpose), when its U-D factors are given, where U
% is a real unit upper triangular matrix and D is a real diagonal
% matrix. Only the upper triangular part (columnwise) of the pair
% U-D and matrix P are stored.
% Usage: p = mcud(n,ud)
% ud = mcud(n,ud) , when the input matrix ud is destroyed
% Description of parameters:
% n - input, real scalar, number of rows and columns in matrices
% U , D and P
% ud - input, real array of length n*(n+1)/2, storing the
% upper triangular part of the pair U-D ; the elements of
% the diagonal matrix D are stored on diagonal locations
% of the unit upper triangular matrix U
% p - output, real array of length n*(n+1)/2, storing the
% upper triangular part of the resultant matrix P
% Remark: The computation can be used to determine the covariance matrix
% from its U-D factors.
% Last update: 06/29/00
% Copyright (C) 1996-00 by LL Consulting. All Rights Reserved.
function p = mcud(n,ud)
nn1 = n*(n+1)/2;
p = zeros(nn1,1);
p(1) = ud(1);
if n == 1
return
end
jj = 1;
for j = 2:n
jjp = jj;
jj = jj + j;
p(jj) = ud(jj);
s = p(jj);
ii = 0;
jm1 = j - 1;
for i = 1:jm1
ii = ii + i;
temp = s * ud(jjp + i);
ik = ii;
for k = i:jm1
p(ik) = p(ik) + temp * ud(jjp + k);
ik = ik + k;
end
p(jjp + i) = temp;
end
end
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -