def normalizeMatrix(M, axis):
    if (axis == 1):
        norm = np.sum(M, axis=axis)
        norm = np.broadcast_to(norm, M.T.shape)
        norm = norm.T
    else:
        norm = np.sum(M, axis=axis)
        norm = np.broadcast_to(norm, M.shape)
    return norm
def normalizeMatrix(M, axis):
    if (axis == 1):
        norm = np.sum(M, axis=axis)
        norm = np.broadcast_to(norm, M.T.shape)
        norm = norm.T
    else:
        norm = np.sum(M, axis=axis)
        norm = np.broadcast_to(norm, M.shape)
    return norm