# kornia.geometry.solvers#

Module containing various geometrical solvers/optimizers.

## Polynomial Solvers#

The function takes the coefficients of quadratic equation and returns the real roots.

$coeffsx^2 + coeffsx + coeffs = 0$
Parameters:

coeffs (Tensor) – The coefficients of quadratic equation :(B, 3)

Return type:

Tensor

Returns:

A tensor of shape (B, 2) containing the real roots to the quadratic equation.

Example

>>> coeffs = torch.tensor([[1., 4., 4.]])


Note

In cases where a quadratic polynomial has only one real root, the output will be in the format [real_root, 0]. And for the complex roots should be represented as 0. This is done to maintain a consistent output shape for all cases.

kornia.geometry.solvers.solve_cubic(coeffs)[source]#

Solve given cubic equation.

The function takes the coefficients of cubic equation and returns the real roots.

$coeffsx^3 + coeffsx^2 + coeffsx + coeffs = 0$
Parameters:

coeffs (Tensor) – The coefficients cubic equation : (B, 4)

Return type:

Tensor

Returns:

A tensor of shape (B, 3) containing the real roots to the cubic equation.

Example

>>> coeffs = torch.tensor([[32., 3., -11., -6.]])
>>> roots = solve_cubic(coeffs)


Note

In cases where a cubic polynomial has only one or two real roots, the output for the non-real roots should be represented as 0. Thus, the output for a single real root should be in the format [real_root, 0, 0], and for two real roots, it should be [real_root_1, real_root_2, 0].