ACTS
Experiment-independent tracking
Loading...
Searching...
No Matches
detray::detail::quadratic_equation< scalar_t > Class Template Reference

Class to solve a quadratic equation of type a * x^2 + b * x + c = 0. More...

#include <detray/utils/quadratic_equation.hpp>

Inheritance diagram for detray::detail::quadratic_equation< scalar_t >:
[legend]
Collaboration diagram for detray::detail::quadratic_equation< scalar_t >:
[legend]

Public Member Functions

constexpr quadratic_equation (const scalar_t &a, const scalar_t &b, const scalar_t &c, const scalar_t &tolerance=1e-6f)
 Solve the equation a*x^2 + b*x + c = 0 for SIMD coefficients.
constexpr quadratic_equation (const scalar_t a, const scalar_t b, const scalar_t c, const scalar_t tolerance=std::numeric_limits< scalar_t >::epsilon())
 Solve the equation a*x^2 + b*x + c = 0 for arithmetic coefficients.
constexpr int solutions () const
 Getters for the solution(s).
constexpr scalar_t smaller () const
constexpr scalar_t larger () const
constexpr const auto & solutions () const
 Getters for the solution(s).
constexpr const scalar_t & smaller () const
constexpr const scalar_t & larger () const

Detailed Description

template<concepts::scalar scalar_t>
requires std::is_arithmetic_v<scalar_t>
class detray::detail::quadratic_equation< scalar_t >

Class to solve a quadratic equation of type a * x^2 + b * x + c = 0.

Note
If there are no real solutions, the result is undefined
The solutions are sorted by default. If there is only one solution, the larger value is undefined.

Constructor & Destructor Documentation

◆ quadratic_equation() [1/2]

template<concepts::scalar scalar_t>
detray::detail::quadratic_equation< scalar_t >::quadratic_equation ( const scalar_t a,
const scalar_t b,
const scalar_t c,
const scalar_t tolerance = std::numeric_limits<scalar_t>::epsilon() )
constexpr

Solve the equation a*x^2 + b*x + c = 0 for arithmetic coefficients.

Parameters
aQuadratic coefficient.
bLinear coefficient.
cConstant coefficient.
tolerancethreshold to compare the discrimant against to decide if we have two separate solutions.

◆ quadratic_equation() [2/2]

template<concepts::scalar scalar_t>
detray::detail::quadratic_equation< scalar_t >::quadratic_equation ( const scalar_t & a,
const scalar_t & b,
const scalar_t & c,
const scalar_t & tolerance = 1e-6f )
constexpr

Solve the equation a*x^2 + b*x + c = 0 for SIMD coefficients.

Parameters
aQuadratic coefficient for each lane.
bLinear coefficient for each lane.
cConstant coefficient for each lane.
toleranceThreshold used to classify the discriminant per lane.

Member Function Documentation

◆ larger() [1/2]

template<concepts::scalar scalar_t>
const scalar_t & detray::detail::quadratic_equation< scalar_t >::larger ( ) const
constexpr
Returns
Larger solution in each lane; undefined unless there are two.

◆ larger() [2/2]

template<concepts::scalar scalar_t>
scalar_t detray::detail::quadratic_equation< scalar_t >::larger ( ) const
constexpr
Returns
Larger solution; undefined unless there are two solutions.

◆ smaller() [1/2]

template<concepts::scalar scalar_t>
const scalar_t & detray::detail::quadratic_equation< scalar_t >::smaller ( ) const
constexpr
Returns
Smaller solution in each lane.

◆ smaller() [2/2]

template<concepts::scalar scalar_t>
scalar_t detray::detail::quadratic_equation< scalar_t >::smaller ( ) const
constexpr
Returns
Smaller solution; undefined when there are no solutions.

◆ solutions() [1/2]

template<concepts::scalar scalar_t>
const auto & detray::detail::quadratic_equation< scalar_t >::solutions ( ) const
constexpr

Getters for the solution(s).

Returns
Number of real solutions in each lane.

◆ solutions() [2/2]

template<concepts::scalar scalar_t>
int detray::detail::quadratic_equation< scalar_t >::solutions ( ) const
constexpr

Getters for the solution(s).

Returns
Number of real solutions found.