%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%      Compute all subspaces
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
function [Ar,Br,Cr,Jr,R,U,left_proj, right_proj] = ReducedMatrices(A,B,C,J)
%%  
[R, U] = reachUnobserv(A,B,C,J);
%%   Left- and right- projectors  
p=size(A,2);

for k=1:p
    [left_proj{k}, right_proj{k}] = KDSubspace(R{k}, U{k});
    
    Ar{k}= left_proj{k}*A{k}*right_proj{k};
    Br{k}= left_proj{k}*B{k};
    Cr{k}= C{k}*right_proj{k};
end

%%    reduced jump matrices
Jr{1}= left_proj{2}*J{1}*right_proj{1};
Jr{2}= left_proj{3}*J{2}*right_proj{2};
end




