def calc_vecp(l,C_l_hat,C_fl, C_l):

    C_fl_12 = sqrtm(C_fl[l])
    C_l_inv = LA.inv(C_l[l])
    C_l_inv_12= sqrtm(C_l_inv)
    # the order is inverted compared to matlab hamimeche_lewis_likelihood.m line 19

    # line 20 of hamimeche_lewis_likelihood.m
    res = np.dot(C_l_inv_12, np.dot(C_l_hat[l], C_l_inv_12))
    [d, u] = LA.eigh(res)
    d = np.diag(d)  # noticed that python returns the eigenvalues as a vector, not a matrix
    #np. dot( u, np.dot( np.diag(d), LA.inv(u))) should be equals to res
    # real symmetric matrices are diagnalized by orthogonal matrices (M^t M = 1)

    # this makes a diagonal matrix by applying g(x) to the eigenvalues, equation 10 in Barkats et al
    gd = np.sign(np.diag(d) - 1) * np.sqrt(2 * (np.diag(d) - 1 - np.log(np.diag(d))))
    gd = np.diag(gd)
    # Argument of vecp in equation 8; multiplying from right to left
    X = np.dot(np.transpose(u), C_fl_12)
    X = np.dot(gd, X)
    X = np.dot(u, X)
    X = np.dot(C_fl_12, X)
    # This is the vector of equation 7
    X = vecp(X)

    return X


#def g(x):
#    #  sign(x-1) \sqrt{ 2(x-ln(x) -1 }
#    return np.sign(x-1) * np.sqrt( 2* (x - np.log(x) -1) )
dataset/ETHPy150Open baudren/montepython_public/montepython/likelihoods/bicep2/bicep_util.py/calc_vecp/swapped operands of `-`