% P3
% Example 1
clc
randn('seed',0)
n = 10;
u = randn(n,1);
g = CholDiag(u);
R = chol(eye(n,n)+u*u');
format long 
TwoDiags = [g diag(R)]

% Example 2
disp(' ')
n = 100000;
u = randn(n,1);
g = CholDiag(u);
Snapshot = g(1:10000:100000)