Provides a class for generic operations on polynoms
This class is mainly used for internal representation of polynoms in the average dataset ezcGraphDataSetAveragePolynom.
It provides only very basic mechanisms to work with polynoms, like adding of polynomes and evaluating the polynom with a given number, to calculate a point in the chart for a given value on the x axis.
Beside this the __toString implementation may be used to echo the polynoms calculated by the least squares mechanism in the above mentioned average datasets. The class does not provide any options to customize the output.
The class can be used like:
Source for this file: /Graph/src/math/polynom.php
Version: | //autogentag// |
protected array |
$values
Factors of the polynom An example: Polynom: 2 * x^3 + .5 * x - 3 Array: array ( (int) 3 => (float) 2, (int) 1 => (float) .5, (int) 0 => (float) -3, ) |
public ezcGraphPolynom |
__construct(
[ $values
= array()] )
Constructor |
public ezcGraphPolynom |
add(
$polynom
)
Adds polynom to current polynom |
public float |
evaluate(
$x
)
Evaluate Polynom with a given value |
public float |
get(
$exponent
)
Return factor for one exponent |
public int |
getOrder(
)
Returns the order of the polynom |
public ezcGraphPolynom |
init(
$order
)
Initialise a polygon |
public ezcGraphPolynom |
set(
$exponent
, $factor
)
Set the factor for one exponent |
public string |
__toString(
)
Returns a string represenation of the polynom |
Constructor
Constructs a polynom object from given array, where the key is the exponent and the value the factor. An example: Polynom: 2 * x^3 + .5 * x - 3 Array: array ( (int) 3 => (float) 2, (int) 1 => (float) .5, (int) 0 => (float) -3, )
Name | Type | Description |
---|---|---|
$values |
array | Array with values |
Adds polynom to current polynom
Name | Type | Description |
---|---|---|
$polynom |
ezcGraphPolynom | Polynom to add |
Evaluate Polynom with a given value
Name | Type | Description |
---|---|---|
$x |
float | Value |
Return factor for one exponent
Name | Type | Description |
---|---|---|
$exponent |
int | Exponent |
Returns the order of the polynom
Initialise a polygon
Initialise a polygon of the given order. Sets all factors to 0.
Name | Type | Description |
---|---|---|
$order |
int | Order of polygon |
Set the factor for one exponent
Name | Type | Description |
---|---|---|
$exponent |
int | Exponent |
$factor |
float | Factor |
Returns a string represenation of the polynom