Home > NoiseTools > nt_lower_to_full.m

nt_lower_to_full

PURPOSE ^

b=nt_lower_to_full(a,ind) - transform lower diagonal to full covariance

SYNOPSIS ^

function b=nt_lower_to_full(a,ind,n)

DESCRIPTION ^

 b=nt_lower_to_full(a,ind) - transform lower diagonal to full  covariance

  b: full matrix

  a: matrix of lower diagonal terms
  ind: indices of lower diagonal terms
  n: covariance matrix is n*n

 Typically used to transform output of nt_xprod into a series of
 covariance matrices.

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SOURCE CODE ^

0001 function b=nt_lower_to_full(a,ind,n)
0002 % b=nt_lower_to_full(a,ind) - transform lower diagonal to full  covariance
0003 %
0004 %  b: full matrix
0005 %
0006 %  a: matrix of lower diagonal terms
0007 %  ind: indices of lower diagonal terms
0008 %  n: covariance matrix is n*n
0009 %
0010 % Typically used to transform output of nt_xprod into a series of
0011 % covariance matrices.
0012 %
0013 
0014 if nargin<2; error('!'); end
0015 if nargin<3; 
0016     % estimate based on on size of a (this fails if diagonal is not
0017     % present)
0018     n=floor(sqrt(2*size(a,2)));
0019 end
0020 
0021 b=zeros(size(a,1),n,n);
0022 
0023 [I,J]=ind2sub(n,ind);
0024 
0025 for k=1:numel(I)
0026     b(:,I(k),J(k))=a(:,k);
0027 end
0028 for k=1:numel(I)
0029     b(:,J(k),I(k))=a(:,k);
0030 end

Generated on Sat 29-Apr-2023 17:15:46 by m2html © 2005