function [a_now, iter_mat, values_mat] = cv_vectorized(v1v2, cvfact, m1m2)

    % This function implements a 
    % vectorized version of the CVE
    % as a fixed point algorithm

    % Outputs:
    % 'a_now': The converged MLE 
    % 'iter_mat':  A vector that records 
    % the number of iterations before 
    % convergence

    TOL = 0.0001;
    tot_size = length(v1v2);
    a_now = v1v2;
    prev_prob = a_now;
    len_anow = tot_size;
    values_mat = nan(11,100);
    values_mat(1,:) = v1v2;    
    iter_mat = zeros(1, len_anow);
    
    a_prev = zeros(1, len_anow);
    
    % Terminate also when no more elements to iterate
    is_term = tot_size;
    
    % Check number of idxes to go ; we stop iterating an element when TOL is met
    idx_to_go = 1:len_anow;
    
    iter = 0;

    while is_term > 0 && iter < 10

        iter_mat(idx_to_go) = iter_mat(idx_to_go) + 1;
        iter = iter + 1;
        
        % Update the indexes where we need 
        % to continue doing iterating
        a_prev(idx_to_go) = a_now(idx_to_go);
        
        % Update steps
        a_now(idx_to_go) = v1v2(idx_to_go) - (cvfact(idx_to_go)).*a_now(idx_to_go)./(a_now(idx_to_go).^2 + m1m2);
        values_mat(iter+1,idx_to_go) = a_now(idx_to_go);
        % check which points to still iterate on    
        idx_to_go = idx_to_go(abs(a_now(idx_to_go) - a_prev(idx_to_go)) > TOL);
        is_term = length(idx_to_go);

    end

    % In case there is no convergence, we 
    % set this to the initial estimate 
    a_now(idx_to_go) = prev_prob(idx_to_go);

    % If there is convergence past the inner 
    % product bounds (via cosine rule), then 
    % set the MLE estimate to be the
    % upper (or corresponding) lower bound
    a_now(a_now > sqrt(m1m2)) = sqrt(m1m2);
    a_now(a_now < -sqrt(m1m2)) = -sqrt(m1m2);
end
