function [K, A_combined, LHS] = my_companion_form(A_core, A_periphery, Params)

A_combined = zeros(Params.p+Params.pp, (Params.p+Params.pp) * Params.k);
LHS = eye(Params.p+Params.pp);
for k_idx = 1:Params.k
    A_combined( 1:Params.p, (k_idx-1)*(Params.p+Params.pp) + (1:Params.p) ) = A_core( (k_idx-1) * Params.p + (1:Params.p) , 1:Params.p)';
end;
for p_idx=1:Params.pp
    LHS( Params.p + p_idx, 1:Params.p ) = -A_periphery( Params.k+ (1:Params.p) , p_idx)';
    for k_idx = 1:Params.k
        A_combined( Params.p + p_idx, (k_idx-1)*(Params.p+Params.pp) + (1:Params.p) ) = A_periphery( Params.k+ k_idx * Params.p + (1:Params.p) , p_idx)';
        A_combined( Params.p + p_idx, (k_idx-1)*(Params.p+Params.pp) + Params.p + p_idx ) = A_periphery( k_idx , p_idx);
    end;    
end;
% note that A_IV_combined is already transposed
K= [LHS\A_combined; eye( (Params.k-1) * (Params.p+Params.pp), Params.k*(Params.p+Params.pp))];