function [Z1,Z2]=circulant_embed_sample(c1)
% C.E. Powell, MATH64082
% Computes two samples Z1,Z2 from N(0, C_N) using circulant embedding + 
% DFT method if C_N is a TOEPLITZ covariance matrix. Only works if
% minimal circulant extension matrix C_tilde is a VALID covariance matrix. 
%
% input: 
%        c1  - first column vector of C_N, of length N
% outputs:
%        Z1, Z2 - two samples from N(0,C_N):

% create first column of circulant extension, C_tilde
tilde_c1=[c1; c1(end-1:-1:2)];    
% obtain 2 samples from N(0,C_tilde)
[Z1,Z2]=circ_cov_sample(tilde_c1); 
% extract samples from N(0,C_N)
N=length(c1); Z1=Z1(1:N); Z2=Z2(1:N); 

    
    
