Core 1.0
|
Linear polynomials. More...
#include <linear.h>
Public Member Functions | |
Linear () | |
Empty. | |
Linear (const double &, const double &) | |
Creates a linear function. More... | |
Linear (const double &) | |
Creates a constant function. More... | |
~Linear () | |
Empty. | |
constexpr double & | operator[] (int) |
Access class components. | |
constexpr double | operator[] (int) const |
Overloaded. | |
Linear | operator- () const |
Unary. | |
Linear & | operator+= (const Linear &) |
Destructive sum of two linear polynomials. | |
Linear & | operator-= (const Linear &) |
Destructive difference of two linear polynomials. | |
Linear & | operator*= (const double &) |
Scale a linear polynomial by a double value. | |
Linear & | operator/= (const double &) |
Scales a linear polynomial by a double value. | |
constexpr double | operator() (const double &) const |
Evaluates the linear function. More... | |
int | Solve (double &) const |
Solve linear equations. More... | |
int | Solve (double &, const double &, const double &) const |
Search the roots of a linear equation over a given interval. More... | |
void | Range (double &, double &, const double &=0.0, const double &=1.0) const |
This function computes the range of values taken by a Linear over a given interval. More... | |
Static Public Member Functions | |
static double | Step (const double &, const double &, const double &) |
Create a linear step. More... | |
static double | Step (const double &, const double &, const double &, const double &, const double &) |
Create a linear step. More... | |
static double | Affine (const double &, const double &, const double &) |
Create the linear part of a linear step. More... | |
static double | Solve (const double &, const double &, const double &, const double &) |
Compute the root of a linear function such that f(a)=va and f(b)=vb. More... | |
static double | SolveAlpha (const double &, const double &, const double &, const double &) |
Compute the root of a linear function. More... | |
Protected Attributes | |
double | c [2] = { 0.0 } |
Array of coefficients. | |
Friends | |
Linear | operator+ (const Linear &, const Linear &) |
Overloaded. | |
Linear | operator- (const Linear &, const Linear &) |
Overloaded. | |
Linear | operator* (const Linear &, const double &) |
Multiply a polynomial by a scalar value. | |
Linear | operator* (const double &, const Linear &) |
Overloaded. | |
Linear | operator/ (const Linear &, const double &) |
Overloaded. | |
std::ostream & | operator<< (std::ostream &, const Linear &) |
Overloaded output-stream operator. More... | |
Linear polynomials.
When using constructors, the coefficients are given in descending order:
|
inlineexplicit |
Creates a linear function.
The function is defined as f(x) = a x + b.
a,b | Coefficients. |
|
inlineexplicit |
Creates a constant function.
a | Constant. |
|
inlinestatic |
Create the linear part of a linear step.
This function does not test limits.
x | Value |
a,b | Interval values. |
|
inlineconstexpr |
Evaluates the linear function.
x | Argument. |
void Linear::Range | ( | double & | x, |
double & | y, | ||
const double & | a = 0.0 , |
||
const double & | b = 1.0 |
||
) | const |
This function computes the range of values taken by a Linear over a given interval.
a,b | Interval. |
x,y | Returned range. |
|
inlinestatic |
Compute the root of a linear function such that f(a)=va and f(b)=vb.
Assuming that the root exists, this function reads easier than the following code, and avoids constructor and parameter computation.
int Linear::Solve | ( | double & | x | ) | const |
Solve linear equations.
This function store the root (ifit exists) in a double and returns the number of roots.
x | Solution. |
int Linear::Solve | ( | double & | x, |
const double & | a, | ||
const double & | b | ||
) | const |
Search the roots of a linear equation over a given interval.
x | Solution. |
a,b | Interval. |
|
static |
Compute the root of a linear function.
The linear function satisfies the constraints: f(a)=va and f(b)=vb; the function returns an interpolant t such that the root satisties r=(1-t) a+t b.
|
inlinestatic |
Create a linear step.
x | Value |
a,b | Interval values. |
|
inlinestatic |
Create a linear step.
This function is the same as coding:
x | Value |
a,b | Interval values. |
ya,yb | Output interval values. |