ATLAS Offline Software
Loading...
Searching...
No Matches
TrkExtrapolation/TrkExUtils/TrkExUtils/RealQuadraticEquation.h
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2021 CERN for the benefit of the ATLAS collaboration
3*/
4
6// RealQuadraticEquation.h, (c) ATLAS Detector software
8
9#ifndef TRKEXUTILS_REALQUADRATICEQUATION_H
10#define TRKEXUTILS_REALQUADRATICEQUATION_H
11
12#include <cmath>
13#include <utility>
14
15namespace Trk {
18
20{
21 none = 0,
22 one = 1,
23 two = 2
24};
25
52
53struct RealQuadraticEquation
54{
55
56 double first;
57 double second;
59
60 RealQuadraticEquation(double alpha, double beta, double gamma)
61 : first{}
62 , second{}
63 {
64 double discriminant = beta * beta - 4 * alpha * gamma;
65 if (discriminant < 0)
67 else {
68 solutions = (discriminant == 0) ? one : two;
69 double q =
70 -0.5 * (beta + (beta > 0 ? sqrt(discriminant) : -sqrt(discriminant)));
71 first = q / alpha;
72 second = gamma / q;
73 }
74 }
75};
76
77} // end of namespace
78
79#endif // TRKEXUTILS_REALQUADRATICEQUATION_H
80
Ensure that the ATLAS eigen extensions are properly loaded.