Zeta Components Manual :: Docs For Class ezcGraphPolynom
Graph::ezcGraphPolynom
Class ezcGraphPolynom
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:
- // Equivalent to: x^2 + .5
- // Calculate result for x = 1, echos: 1.5
- // Build the sum with another polynom
- // Print polynom, echos:
- // x^2 + x + 5.00e-1
- echo $polynom, PHP_EOL;
Source for this file: /Graph/src/math/polynom.php
Version: | //autogentag// |
Member Variables
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, ) |
Method Summary
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 |
Methods
__construct
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, )
Parameters:
Name | Type | Description |
---|---|---|
$values |
array | Array with values |
add
Adds polynom to current polynom
Parameters:
Name | Type | Description |
---|---|---|
$polynom |
ezcGraphPolynom | Polynom to add |
evaluate
Evaluate Polynom with a given value
Parameters:
Name | Type | Description |
---|---|---|
$x |
float | Value |
get
Return factor for one exponent
Parameters:
Name | Type | Description |
---|---|---|
$exponent |
int | Exponent |
getOrder
Returns the order of the polynom
init
Initialise a polygon
Initialise a polygon of the given order. Sets all factors to 0.
Parameters:
Name | Type | Description |
---|---|---|
$order |
int | Order of polygon |
set
Set the factor for one exponent
Parameters:
Name | Type | Description |
---|---|---|
$exponent |
int | Exponent |
$factor |
float | Factor |
__toString
Returns a string represenation of the polynom