function CC = normalize(CC)

% determine size of arrays
[M,K] = size(CC);

% compute norms of principle directions
CCnorm = sqrt(sum(CC.*CC,1));

% Mask out vectors that are zero
mask = CCnorm==0;

% make sure that principle directions are normal
CC = CC.*repmat(1./(CCnorm+mask),[M,1]);

