function info = extract_info_connection_matrix(IDS)
% Extract the following information from pf_active and connection
% matrix and add them to the IDS structure

% -------------------------------------------
% Which coils belong to a specific circuit added to
% pf_active.circuit{i}.coils_belonging_to_circuit

% Which power supply belongs  to a spefic circuit added to
% pf_active.circuit{i}.supplies_belonging_to_circuit

% Which circuit does a given coil belong to added to 
% pf_active.coil{i}.belonged_circuit

% Which circuit does a given power supply belong to
% pf_active.supply{i}.belonged_circuit

info = IDS;

info.ntotcoils = numel(IDS.pf_active.coil);
info.ntotcircuits = numel(IDS.pf_active.circuit);
info.ntotsupplies = numel(IDS.pf_active.supply);
info.ntotelements = info.ntotcoils + info.ntotsupplies;

for ii = 1:info.ntotcircuits
    
    % Supplies belonging to the circuit
    supplies_of_circuit = {};
    supplies_of_circuit_ind = [];
    counter = 0;
    for jj=1:info.ntotsupplies
        index = (2*(jj-1) + 1);
        if sum(IDS.pf_active.circuit{ii}.connections(:,index)) == 1
            counter = counter +1;
            supplies_of_circuit{counter} = IDS.pf_active.supply{jj}.name;
            supplies_of_circuit_ind(counter) = jj;
        end
    end
    info.pf_active.circuit{ii}.supplies_belonging_to_circuit = supplies_of_circuit;
    info.pf_active.circuit{ii}.supplies_ind_belonging_to_circuit = supplies_of_circuit_ind;
    
    % Find to which circuit each supply belongs to
    for jj=supplies_of_circuit_ind
        info.pf_active.supply{jj}.belonged_circuit = IDS.pf_active.circuit{ii}.name;
        info.pf_active.supply{jj}.belonged_circuit_ind  = ii;
    end
    
    
    % Coils belonging to the circuit
    coils_of_circuit = {};
    coils_of_circuit_ind = [];
    counter = 0;
    for jj=1:info.ntotcoils
        index = (2*(jj-1) + 1 + 2*info.ntotsupplies);
        if sum(IDS.pf_active.circuit{ii}.connections(:,index)) == 1
            counter = counter +1;
            coils_of_circuit{counter} = IDS.pf_active.coil{jj}.name;
            coils_of_circuit_ind(counter) = jj;
        end
    end
    info.pf_active.circuit{ii}.coils_belonging_to_circuit = coils_of_circuit;
    info.pf_active.circuit{ii}.coils_ind_belonging_to_circuit = coils_of_circuit_ind;
    
    % Find to which circuit each coil belongs to
    for jj=coils_of_circuit_ind 
        info.pf_active.coil{jj}.belonged_circuit = IDS.pf_active.circuit{ii}.name;
        info.pf_active.coil{jj}.belonged_circuit_ind  = ii;
    end

    
    
end



    




