Download the PHP package filmtools/polynomial without Composer
On this page you can find all versions of the php package filmtools/polynomial. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Informations about the package polynomial
FilmTools · Polynomial
Tools for working with simple polynomial models.
Installation
Upgrading from v1
From v2 on, this package now uses SplFixedArrays wherever possible. This will likely affect all your CoefficientProviderInterface implementations, as they now are required to return \SplFixedArray.
Wherever you calculate with FromCoefficientsInterpolator or MultipleInterpolator, you get \SplFixedArray results. When you rely on array results, just call $result->toArray()
as defined in SplFixedArray methods API.
What's in the package
Interfaces
CoefficientsProviderInterface: Returns the coefficients of the polynomial model.
public function getCoefficients(): \SplFixedArray;
InterpolatorInterface: Find an y value for a given x coordinate.
public function interpolate( float $x ): float;
XFinderInterface: Find an x for a given y, as opposite to InterpolatorInterface::interpolate
PolynomialModelInterface extends the above InterpolatorInterface, XFinderInterface, and CoefficientsProviderInterface
PolynomialModelProviderInterface returns a polynomial model interface instance.
public function getPolynomialModel(): PolynomialModelInterface;
FromCoefficientsInterpolator
This callable class interpolates a iterable with X values using the coefficients given on invokation:
You may also pass custom X values on invokation:
The interpolation method also accepts CoefficientsProviderInterface:
MultipleInterpolator
Interpolates iterables of X values using the same default coefficients. The interpolation method returns a SplFixedArray. The Constructor accepts a numbers iterable as well as CoefficientsProviderInterface:
DerivativeCoefficientsProvider
Calculates the coefficients for a derivative polynomial on a given a set of coefficients (either array or Provider).
The class itself implements CoefficientsProviderInterface, and thus works excellent in conjunction with MultipleInterpolator. Here an example using the above MyModel class:
Exceptions
The PolynomialModelException extends \Exception and implements PolynomialModelExceptionInterface.
The NotEnoughPointsException as well as XNotFoundException and YNotFoundException extend from PolynomialModelException. All these have PolynomialModelExceptionInterface in common. Use these whenever something fails.
All versions of polynomial with dependencies
dr-que/polynomial-regression Version v1.2.1.1
bentools/iterable-functions Version ^1.2