def cov2cor(v):
    '''
    Converts a symmetric positive definite matrix to a correlation matrix by 
    normalizing by the diagonal.
    '''
    r,c = v.shape
    assert r == c
    s = 1.0/np.sqrt(np.diag(v))
    v *= s.reshape(r,1)
    v *= s.reshape(1,c)
    return v
dataset/ETHPy150Open bolme/pyvision/src/pyvision/analysis/stats.py/cov2cor/original