SpECTRE Documentation Coverage Report Current view: top level - NumericalAlgorithms/RootFinding - QuadraticEquation.hpp Hit Total Coverage Commit: cd74d65bdc718fd7e344eaec61dc6334dd4d366b Lines: 5 5 100.0 % Date: 2022-08-12 23:56:47 Legend: Lines: hit not hit  Line data Source code  1 1 : // Distributed under the MIT License. 2 : // See LICENSE.txt for details. 3 : 4 : /// \file 5 : /// Declares functions for solving quadratic equations 6 : 7 : #pragma once 8 : 9 : #include 10 : 11 : /*! 12 : * \ingroup NumericalAlgorithmsGroup 13 : * \brief Returns the positive root of a quadratic equation \f$ax^2 + 14 : * bx + c = 0\f$ 15 : * \returns The positive root of a quadratic equation. 16 : * \requires That there are two real roots, of which only one is positive. 17 : */ 18 1 : double positive_root(double a, double b, double c); 19 : 20 : /*! 21 : * \ingroup NumericalAlgorithmsGroup 22 : * \brief Returns the smallest root of a quadratic equation \f$ax^2 + 23 : * bx + c = 0\f$ that is greater than the given value, within roundoff. 24 : * \returns A root of a quadratic equation. 25 : * \requires That there are two real roots. 26 : * \requires At least one root is greater than the given value, to roundoff. 27 : */ 28 : template 29 1 : T smallest_root_greater_than_value_within_roundoff(const T& a, const T& b, 30 : const T& c, double value); 31 : /*! 32 : * \ingroup NumericalAlgorithmsGroup 33 : * \brief Returns the largest root of a quadratic equation 34 : * \f$ax^2 + bx + c = 0\f$ that is between min_value and max_value, 35 : * within roundoff. 36 : * \returns A root of a quadratic equation. 37 : * \requires That there are two real roots. 38 : * \requires At least one root is between min_value and max_value, to roundoff. 39 : */ 40 : template 41 1 : T largest_root_between_values_within_roundoff(const T& a, const T& b, 42 : const T& c, double min_value, 43 : double max_value); 44 : /*! 45 : * \ingroup NumericalAlgorithmsGroup 46 : * \brief Returns the two real roots of a quadratic equation \f$ax^2 + 47 : * bx + c = 0\f$ with the root closer to \f$-\infty\f$ first. 48 : * \returns An array of the roots of a quadratic equation 49 : * \requires That there are two real roots. 50 : */ 51 1 : std::array real_roots(double a, double b, double c); Generated by: LCOV version 1.14