math-php
Static Public Member Functions | Public Attributes | Static Protected Member Functions | List of all members
MathPHP\NumericalAnalysis\Interpolation\Interpolation Class Reference

Base class for interpolation techniques. More...

Inheritance diagram for MathPHP\NumericalAnalysis\Interpolation\Interpolation:
Inheritance graph
[legend]

Static Public Member Functions

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...
 

Public Attributes

const X = 0
 
const Y = 1
 

Static Protected Member Functions

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...
 

Detailed Description

Base class for interpolation techniques.

Member Function Documentation

◆ 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$functionf(x) callback function
number$startthe start of the interval
number$endthe end of the interval
number$nthe 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$sourceThe source of our approximation. Should be either a callback function or a set of arrays.
array$argsThe 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
Exception

◆ 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
array$points
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$pointsArray of arrays (points)
number$degreeThe miminum number of input arrays
Returns
bool
Exceptions
Exceptionif there are less than two points
Exceptionif any point does not contain two numbers
Exceptionif two points share the same first number (x-component)

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