Function solve_cubic

Source
pub fn solve_cubic(
    coeffs: &impl ToInputArray,
    roots: &mut impl ToOutputArray,
) -> Result<i32>
Expand description

Finds the real roots of a cubic equation.

The function solveCubic finds the real roots of a cubic equation:

  • if coeffs is a 4-element vector: block formula
  • if coeffs is a 3-element vector: block formula

The roots are stored in the roots array.

§Parameters

  • coeffs: equation coefficients, an array of 3 or 4 elements.
  • roots: output array of real roots that has 1 or 3 elements.

§Returns

number of real roots. It can be 0, 1 or 2.