/* For another derivation of the same result, using Singular Value Decomposition, see doc/tutorial/src/singular.c.  */
double _cairo_matrix_transformed_circle_major_axis(const cairo_matrix_t *matrix, double radius)
/* For another derivation of the same result, using Singular Value Decomposition, see doc/tutorial/src/singular.c.  */
double _cairo_matrix_transformed_circle_major_axis(const cairo_matrix_t *matrix, double radius)
{
    double  a, b, c, d, f, g, h, i, j;
    if (_cairo_matrix_has_unity_scale (matrix))
	return radius;
    _cairo_matrix_get_affine (matrix,
                              &a, &b,
                              &c, &d,
                              NULL, NULL);
    i = a*a + b*b;
    j = c*c + d*d;
    f = 0.5 * (i + j);
    g = 0.5 * (i - j);
    h = a*c + b*d;
    return radius * sqrt (f + hypot (g, h));
}