function [User, Total_Ant,Per_BS_Coop,Per_BS_ServAnt]= Compute_Coop_Link(Num_Cell,User,Cells, Num_TxAnt_Macro,Num_TxAnt_Pico,L_Macro,L_Pico)
%%
Total_BS = L_Macro+L_Pico;
Total_Ant = 0;
%compute parameters for cvx solver to compute Tx BF
for m = 1:Num_Cell
    for l = 1:Total_BS
        Per_BS_Coop(m,l).Coop_Matrix = [];
        Per_BS_ServAnt(m,l).index = [];
    end
end

usr_idx = 0;

for l = 1:Num_Cell   
    for ik = 1:length(Cells(l).Scheduled_User)
        
        usr_idx = usr_idx + 1;
        
        k = Cells(l).Scheduled_User(ik);

       % Total_Scd_User = Total_Scd_User + length(Cells(l).Scheduled_User);
       % User(l,k).Kz_Per_Cluster_diag = [];
        
        ant_head = 1;        
        Ant_idx = [Total_Ant+1 : Total_Ant+User(l,k).ServingAnt]; %ant index serving user (l,k)       
        User(l,k).ServingAntIdx = Ant_idx;
  
        for iBS = 1:size(User(l,k).ServingCluster,1)
            curr_cell = User(l,k).ServingCluster(iBS,1);
            curr_BS = User(l,k).ServingCluster(iBS,2);
                                 
            if curr_BS <= L_Macro %Macro BS
                Per_BS_ServAnt(curr_cell,curr_BS).index = [Per_BS_ServAnt(curr_cell,curr_BS).index (Total_Ant+ant_head):(Total_Ant+ant_head+Num_TxAnt_Macro-1)];
                Per_BS_Coop(curr_cell,curr_BS).Coop_Matrix = blkdiag(Per_BS_Coop(curr_cell,curr_BS).Coop_Matrix, eye(Num_TxAnt_Macro));
                
                ant_head = ant_head + Num_TxAnt_Macro;
            else    %Pico BS
                Per_BS_ServAnt(curr_cell,curr_BS).index = [Per_BS_ServAnt(curr_cell,curr_BS).index (Total_Ant+ant_head):(Total_Ant+ant_head+Num_TxAnt_Pico-1)];
                Per_BS_Coop(curr_cell,curr_BS).Coop_Matrix = blkdiag(Per_BS_Coop(curr_cell,curr_BS).Coop_Matrix, eye(Num_TxAnt_Pico));
                 
                ant_head = ant_head + Num_TxAnt_Pico;
            end
        end
        
        Total_Ant = Total_Ant + User(l,k).ServingAnt;
        
    end 
end