Base class for interpolation techniques.
More...
|
static | getPoints ($source, array $args=[]) |
| Determine where the input $source argument is a callback function, a set of arrays, or neither. More...
|
|
static | validate (array $points, $degree=2) |
| Validate that there are enough input arrays (points), that each point array has precisely two numbers, and that no two points share the same first number (x-component) More...
|
|
|
static | functionToPoints (callable $function, $start, $end, $n) |
| Evaluate our callback function at n evenly spaced points on the interval between start and end. More...
|
|
static | sort (array $points) |
| Sorts our coordinates (arrays) by their x-component (first number) such that consecutive coordinates have an increasing x-component. More...
|
|
Base class for interpolation techniques.
◆ functionToPoints()
static MathPHP\NumericalAnalysis\Interpolation\Interpolation::functionToPoints |
( |
callable |
$function, |
|
|
|
$start, |
|
|
|
$end, |
|
|
|
$n |
|
) |
| |
|
staticprotected |
Evaluate our callback function at n evenly spaced points on the interval between start and end.
- Parameters
-
callable | $function | f(x) callback function |
number | $start | the start of the interval |
number | $end | the end of the interval |
number | $n | the number of function evaluations |
- Returns
- array
◆ getPoints()
static MathPHP\NumericalAnalysis\Interpolation\Interpolation::getPoints |
( |
|
$source, |
|
|
array |
$args = [] |
|
) |
| |
|
static |
Determine where the input $source argument is a callback function, a set of arrays, or neither.
If $source is a callback function, run it through the functionToPoints() method with the input $args, and set $points to output array. If $source is a set of arrays, simply set $points to $source. If $source is neither, throw an Exception.
- Todo:
Add method to verify function is continuous on our interval
Add method to verify input arguments are valid. Verify $start and $end are numbers, $end > $start, and $points is an integer > 1
- Parameters
-
callable | array | $source | The source of our approximation. Should be either a callback function or a set of arrays. |
array | $args | The arguments of our callback function: start, end, and n. Example: [0, 8, 5]. If $source is a set of arrays, $args will default to []. |
- Returns
- array
- Exceptions
-
◆ sort()
static MathPHP\NumericalAnalysis\Interpolation\Interpolation::sort |
( |
array |
$points | ) |
|
|
staticprotected |
Sorts our coordinates (arrays) by their x-component (first number) such that consecutive coordinates have an increasing x-component.
- Parameters
-
- Returns
- array
◆ validate()
static MathPHP\NumericalAnalysis\Interpolation\Interpolation::validate |
( |
array |
$points, |
|
|
|
$degree = 2 |
|
) |
| |
|
static |
Validate that there are enough input arrays (points), that each point array has precisely two numbers, and that no two points share the same first number (x-component)
- Parameters
-
array | $points | Array of arrays (points) |
number | $degree | The miminum number of input arrays |
- Returns
- bool
- Exceptions
-
Exception | if there are less than two points |
Exception | if any point does not contain two numbers |
Exception | if two points share the same first number (x-component) |
The documentation for this class was generated from the following file:
- src/NumericalAnalysis/Interpolation/Interpolation.php