function G = CholBlock(A,p);
%
%  Pre:  A is an n-by-n symmetric and positive definite matrix
%        and p is an integer that divides n.
%
%  Post: G is lower triangular and A = G*G'.
   
   [n,n] = size(A);
   m = n/p;
   G = zeros(n,n);
   for i=1:m
      ivec = ((i-1)*p+1):(i*p);
      for j=1:i
	     jvec = ((j-1)*p+1):(j*p);
		 %Find the (i,j) block of G, i.e., G(ivec,jvec).
	     S = A(ivec,jvec);
		 for k=1:j-1
		    kvec = ((k-1)*p+1):(k*p);
		    S = S - G(ivec,kvec)*G(jvec,kvec)';
		 end
		 if j<i 
			for q=1:p
			   G(q+(i-1)*p,jvec)= (LTriSol(G(jvec,jvec),S(q,:)'))';
		    end 
		 else
		    G(ivec,ivec) = CholScalar(S);
		 end
	  end
   end
   
   
