PHP 클래스 MathPHP\NumericalAnalysis\Interpolation\ClampedCubicSpline

In numerical analysis, cubic splines are used for polynomial interpolation. A cubic spline is a spline constructed of piecewise third-order polynomials which pass through a set of m control points." In the case of the Clamped cubic spline, the first derivative of piecewise polynomial is set to equal the first derivative of our input at the endpoints. Cubic spline interpolation belongs to a collection of techniques that interpolate a function or a set of values, producing a continuous polynomial. In the case of the cubic spline, a piecewise function (polynomial) is produced. We can either directly supply a set of inputs and their corresponding outputs for said function, or if we explicitly know the function, we can define it as a callback function and then generate a set of points by evaluating that function at n points between a start and end point. We then use these values to interpolate our piecewise polynomial. https://en.wikipedia.org/wiki/Spline_interpolation http://mathworld.wolfram.com/CubicSpline.html
상속: extends Interpolation
파일 보기 프로젝트 열기: markrogoyski/math-php 1 사용 예제들

공개 메소드들

메소드 설명
getSplinePoints ( $source, array $args = [] ) : array 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.
interpolate ( $source, $args ) : Piecewise Interpolate
validateSpline ( array $points, number $degree = 2 ) : boolean Validate that there are enough input arrays (points), that each point array has precisely three numbers, and that no two points share the same first number (x-component)

보호된 메소드들

메소드 설명
functionToSplinePoints ( callable $function, callable $derivative, number $start, number $end, number $n ) : array Evaluate our callback function and derivative at n evenly spaced points on the interval between start and end

메소드 상세

functionToSplinePoints() 보호된 정적인 메소드

Evaluate our callback function and derivative at n evenly spaced points on the interval between start and end
protected static functionToSplinePoints ( callable $function, callable $derivative, number $start, number $end, number $n ) : array
$function callable f(x) callback function
$derivative callable f'(x) callback function
$start number the start of the interval
$end number the end of the interval
$n number the number of function evaluations
리턴 array

getSplinePoints() 공개 정적인 메소드

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.
public static getSplinePoints ( $source, array $args = [] ) : array
$source The source of our approximation. Should be either a callback function or a set of arrays.
$args array The arguments of our callback function: derivative, start, end, and n. Example: [$derivative, 0, 8, 5]. If $source is a set of arrays, $args will default to [].
리턴 array

interpolate() 공개 정적인 메소드

Interpolate
public static interpolate ( $source, $args ) : Piecewise
$source The source of our approximation. Should be either a callback function or a set of arrays. Each array (point) contains precisely three numbers: x, y, and y' Example array: [[1,2,1], [2,3,0], [3,4,2]]. Example callback: function($x) {return $x**2;}
리턴 MathPHP\Functions\Piecewise The interpolting (piecewise) polynomial, as an instance of Piecewise.

validateSpline() 공개 정적인 메소드

Validate that there are enough input arrays (points), that each point array has precisely three numbers, and that no two points share the same first number (x-component)
public static validateSpline ( array $points, number $degree = 2 ) : boolean
$points array Array of arrays (points)
$degree number The miminum number of input arrays
리턴 boolean