π Geometric Computer Vision Library for Spatial AI
Python artificial-intelligencecomputer-visiondeep-learninghacktoberfestimage-processingmachine-learningneural-networkpythonpytorchroboticsspatial-ai
kornia.geometry.solvers (polynomial_solvers) docs (#2484)
Anandhu9e89dfb759d2
diff --git a/docs/source/geometry.rst b/docs/source/geometry.rstindex eb3163e28..d1aff9193 100644--- a/docs/source/geometry.rst+++ b/docs/source/geometry.rst@@ -57,6 +57,7 @@ transforms, camera, conversions, linalg and depth. We next describe each of themgeometry.linalggeometry.linegeometry.quaternion+ geometry.solversgeometry.subpixgeometry.transformgeometry.ransacdiff --git a/docs/source/geometry.solvers.rst b/docs/source/geometry.solvers.rstnew file mode 100644index 000000000..bad03b22c--- /dev/null+++ b/docs/source/geometry.solvers.rst@@ -0,0 +1,12 @@+kornia.geometry.solvers+=======================++.. currentmodule:: kornia.geometry.solvers++Module containing various geometrical solvers/optimizers.++Polynomial Solvers+------------------++.. autofunction:: solve_quadratic+.. autofunction:: solve_cubicdiff --git a/kornia/geometry/solvers/polynomial_solver.py b/kornia/geometry/solvers/polynomial_solver.pyindex ca02709ac..4d4caee0f 100644--- a/kornia/geometry/solvers/polynomial_solver.py+++ b/kornia/geometry/solvers/polynomial_solver.py@@ -11,13 +11,24 @@ from kornia.core.check import KORNIA_CHECK_SHAPEdef solve_quadratic(coeffs: Tensor) -> Tensor:r"""Solve given quadratic equation.- The function takes the coefficients of quadratic equation and returns the solutions.+ The function takes the coefficients of quadratic equation and returns the real roots.++ .. math:: coeffs[0]x^2 + coeffs[1]x + coeffs[2] = 0Args:coeffs : The coefficients of quadratic equation :`(B, 3)`Returns:- A tensor of shape `(B, 2)` containing the solutions to the quadratic equation.+ A tensor of shape `(B, 2)` containing the real roots to the quadratic equation.++ Example:+ >>> coeffs = torch.tensor([[1., 4., 4.]])+ >>> roots = solve_quadratic(coeffs)++ .. 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_CHECK_SHAPE(coeffs, ['B', '3'])@@ -62,13 +73,24 @@ def solve_cubic(coeffs: Tensor) -> Tensor:r"""Solve given cubic equation.The function takes the coefficients of cubic equation and returns- the solutions.+ the real roots.++ .. math:: coeffs[0]x^3 + coeffs[1]x^2 + coeffs[2]x + coeffs[3] = 0Args:coeffs : The coefficients cubic equation : `(B, 4)`Returns:- A tensor of shape `(B, 3)` containing the solutions to the cubic equation.+ 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]."""KORNIA_CHECK_SHAPE(coeffs, ['B', '4'])