The SKIRT project
advanced radiative transfer for astrophysics
Static Public Member Functions | List of all members
Quadratic Class Reference

#include <Quadratic.hpp>

Static Public Member Functions

static void distinctSolutions (double b, double c, double &x1, double &x2)
 
static double smallestPositiveSolution (double b, double c)
 

Detailed Description

This static class offers functions that solve quadratic equations using a numerically stable technique. Specifically, consider a quadratic equation of the form

x2+2bx+c=0.

If b2c, this equation has solutions described by

x1=bb2cx2=b+b2cs1s2=c.

To avoid loss of significance in case the solutions have a different order of magnitude, the functions in this class use the first and third equations if b>0 and the second and third equations otherwise.

Member Function Documentation

◆ distinctSolutions()

static void Quadratic::distinctSolutions ( double  b,
double  c,
double &  x1,
double &  x2 
)
inlinestatic

This function determines the solutions of x2+2bx+c=0. If there are two distinct real solutions, they are stored in the arguments x1 and x2. Otherwise, i.e. if there are no solutions or there is just one real solution, x1 and x2 remain unchanged.

◆ smallestPositiveSolution()

static double Quadratic::smallestPositiveSolution ( double  b,
double  c 
)
inlinestatic

This function returns the smallest positive solution of x2+2bx+c=0, or zero if there is no positive solution.


The documentation for this class was generated from the following file: