function []=Display_Distance_Spectra(F,M,N)
%
% This function displays the distance spectra of a Grassmannian codebook
% F of N codewords of size M_t x M. 
%
% Note that we have presumed that the user has chosen M and N
% in a way that is compatible with the codebook F. In particular,
% we presume that F is of size M_t x (MN), and that M and N are integers
% with M >= 1 and N > 1. 
%
ddd=[];
ccc=[];
ppp=[];
Qpre=N; %for compatibility with previous notation
for ii=1:(Qpre-1)
    for jj=(ii+1):Qpre
        f1=F(:,(ii-1)*M+1:ii*M);
        f2=F(:,(jj-1)*M+1:jj*M);
        d=abs(det(f2'*f1));
        d=acos(d);
        ddd=[ddd d];
        ccc=[ccc 1/sqrt(2)*norm((f1*f1'-f2*f2'),'fro')];
        ppp=[ppp norm((f1*f1'-f2*f2'),2)];
     end
end
fsmin=min(ddd);
chmin=min(ccc);
pnmin=min(ppp);
disp(['Minimum Fubini Study distance = ',num2str(fsmin)])
disp(['Minimum Chordal distance = ',num2str(chmin)])
disp(['Minimum Projection two norm distance = ',num2str(pnmin)])
figure
subplot(3,1,1)
hist((ddd))
xlabel('Fubini Study distances ')
ylabel('Distance Distribution')
subplot(3,1,2)
hist((ccc))
xlabel('Chordal distances ')
ylabel('Distance Distribution')
subplot(3,1,3)
hist((ppp))
xlabel('Projection two norm distances ')
ylabel('Distance Distribution')