My Project
PolynomialUtils.hpp File Reference

Provides free functions to invert polynomials of degree 1, 2 and 3. More...

#include <cmath>
#include <algorithm>
#include <opm/material/common/MathToolbox.hpp>

Go to the source code of this file.

Functions

template<class Scalar , class SolContainer >
unsigned Opm::invertLinearPolynomial (SolContainer &sol, Scalar a, Scalar b)
 Invert a linear polynomial analytically. More...
 
template<class Scalar , class SolContainer >
unsigned Opm::invertQuadraticPolynomial (SolContainer &sol, Scalar a, Scalar b, Scalar c)
 Invert a quadratic polynomial analytically. More...
 
template<class Scalar , class SolContainer >
unsigned Opm::invertCubicPolynomial (SolContainer *sol, Scalar a, Scalar b, Scalar c, Scalar d)
 Invert a cubic polynomial analytically. More...
 
template<class Scalar , class SolContainer >
unsigned Opm::cubicRoots (SolContainer *sol, Scalar a, Scalar b, Scalar c, Scalar d)
 Invert a cubic polynomial analytically. More...
 

Detailed Description

Provides free functions to invert polynomials of degree 1, 2 and 3.

Function Documentation

◆ cubicRoots()

template<class Scalar , class SolContainer >
unsigned Opm::cubicRoots ( SolContainer *  sol,
Scalar  a,
Scalar  b,
Scalar  c,
Scalar  d 
)

Invert a cubic polynomial analytically.

The polynomial is defined as

\[ p(x) = a\; x^3 + + b\;x^3 + c\;x + d \]

This method returns the number of solutions which are in the real numbers. The "sol" argument contains the real roots of the cubic polynomial in order with the smallest root first.

Parameters
solContainer into which the solutions are written
aThe coefficient for the cubic term
bThe coefficient for the quadratic term
cThe coefficient for the linear term
dThe coefficient for the constant term

◆ invertCubicPolynomial()

template<class Scalar , class SolContainer >
unsigned Opm::invertCubicPolynomial ( SolContainer *  sol,
Scalar  a,
Scalar  b,
Scalar  c,
Scalar  d 
)

Invert a cubic polynomial analytically.

The polynomial is defined as

\[ p(x) = a\; x^3 + + b\;x^3 + c\;x + d \]

This method teturns the number of solutions which are in the real numbers. The "sol" argument contains the real roots of the cubic polynomial in order with the smallest root first.

Parameters
solContainer into which the solutions are written
aThe coefficient for the cubic term
bThe coefficient for the quadratic term
cThe coefficient for the linear term
dThe coefficient for the constant term

◆ invertLinearPolynomial()

template<class Scalar , class SolContainer >
unsigned Opm::invertLinearPolynomial ( SolContainer &  sol,
Scalar  a,
Scalar  b 
)

Invert a linear polynomial analytically.

The polynomial is defined as

\[ p(x) = a\; x + b \]

This method Returns the number of solutions which are in the real numbers, i.e. 1 except if the slope of the line is 0.

Parameters
solContainer into which the solutions are written
aThe coefficient for the linear term
bThe coefficient for the constant term

◆ invertQuadraticPolynomial()

template<class Scalar , class SolContainer >
unsigned Opm::invertQuadraticPolynomial ( SolContainer &  sol,
Scalar  a,
Scalar  b,
Scalar  c 
)

Invert a quadratic polynomial analytically.

The polynomial is defined as

\[ p(x) = a\; x^2 + + b\;x + c \]

This method teturns the number of solutions which are in the real numbers. The "sol" argument contains the real roots of the parabola in order with the smallest root first.

Parameters
solContainer into which the solutions are written
aThe coefficient for the quadratic term
bThe coefficient for the linear term
cThe coefficient for the constant term