Get ellipse parameters from conic coefficient matrix

Here is an answer in Python language:

    if A*C <= 0 or B*B-4*A*C >= 0 or D*D + E*E <= 4*(A+C)*F:
        raise ValueError("These parameters do not define an ellipse.")
    Q = np.array([[2*A, B, D], [B, 2*C, E], [D, E, 2*F]])
    if np.linalg.det(Q) == 0:
        raise ValueError("These parameters do not define an ellipse.")
    M0 = np.array([F, D/2, E/2, D/2, A, B/2, E/2, B/2, C]).reshape((3,3))
    M = np.array([[A, B/2], [B/2, C]])
    eigvals = np.linalg.eigvals(M)
    detM0 = np.linalg.det(M0)
    detM = np.linalg.det(M)
    a = sqrt(-detM0 / (detM * eigvals[0]))
    b = sqrt(-detM0 / (detM * eigvals[1]))
    xy = np.array([B*E - 2*C*D, B*D - 2*A*E])
    phi = 0.0 if A == C else (atan(B/(A-C))/2 if abs(C) > abs(A) else pi/2 - atan(-B/(A-C))/2)
    center = xy/(4*A*C - B*B)
    major_radius = max(a, b)
    minor_radius = min(a, b)
    angle = phi % pi