function [G,H] = BlockTriDiag(A,C)
% A is a length N cell array with symmetric m-by-m blocks
% C is a length N-1 cell array with m-by-m blocks
% Together, A and C represent an N-by-N symmetric block tridiagonal matrix
% Atilde that is positive definite. 
% G and H are cell arrays that encode Atilde's Cholesky factor.

N = length(A); G = cell(N); H = cell(N-1);
G{1} = chol(A{1})';
for i=1:N-1
    H{i} = (G{i}\C{i}')';                     
    G{i+1} = chol(A{i+1}-H{i}*H{i}')';
end