summaryrefslogtreecommitdiffstats
path: root/tests/dataset_average_test.php
diff options
context:
space:
mode:
authorKore Nordmann <github@kore-nordmann.de>2006-11-30 13:59:55 +0000
committerKore Nordmann <github@kore-nordmann.de>2006-11-30 13:59:55 +0000
commita7df5bda8d5f00fee28a288fb078d936787fe524 (patch)
treecd2ec9003034b5e1e801668b893eccdce4cb2051 /tests/dataset_average_test.php
parent94182972f32db9770cc9bbe158e4a05aa3860c42 (diff)
downloadzetacomponents-graph-a7df5bda8d5f00fee28a288fb078d936787fe524.zip
zetacomponents-graph-a7df5bda8d5f00fee28a288fb078d936787fe524.tar.gz
- Fixed: Bug #9588 (Wrong polynoms build from data)
Diffstat (limited to 'tests/dataset_average_test.php')
-rw-r--r--tests/dataset_average_test.php38
1 files changed, 38 insertions, 0 deletions
diff --git a/tests/dataset_average_test.php b/tests/dataset_average_test.php
index 6ab21c6..c5a7695 100644
--- a/tests/dataset_average_test.php
+++ b/tests/dataset_average_test.php
@@ -120,6 +120,44 @@ class ezcGraphDataSetAverageTest extends ezcTestCase
);
}
+ public function testCreateDatasetFromDataset4()
+ {
+ $points = array();
+ for ( $x = -1; $x <= 5; ++$x )
+ {
+ $points[$x] = pow( $x - 2, 3 ) - .21 * pow( $x - 2, 2 ) + .2 * ( $x - 2 ) - 2.45;
+ }
+
+ $arrayDataSet = new ezcGraphArrayDataSet( $points );
+
+ $averageDataSet = new ezcGraphDataSetAveragePolynom( $arrayDataSet, 3 );
+ $polynom = $averageDataSet->getPolynom();
+
+ $this->assertEquals(
+ '1.00 * x^3 + -6.21 * x^2 + 13.04 * x + -11.69',
+ $polynom->__toString()
+ );
+ }
+
+ public function testCreateDatasetFromDataset5()
+ {
+ $points = array();
+ for ( $x = -3; $x <= 3; ++$x )
+ {
+ $points[$x] = pow( $x, 3 ) - .21 * pow( $x, 2 ) + .2 * $x - 2.45;
+ }
+
+ $arrayDataSet = new ezcGraphArrayDataSet( $points );
+
+ $averageDataSet = new ezcGraphDataSetAveragePolynom( $arrayDataSet, 3 );
+ $polynom = $averageDataSet->getPolynom();
+
+ $this->assertEquals(
+ 'x^3 + -0.21 * x^2 + 0.20 * x + -2.45',
+ $polynom->__toString()
+ );
+ }
+
public function testCreateDatasetFromDatasetLowOrder()
{
$arrayDataSet = new ezcGraphArrayDataSet( array( -1 => 2, 1 => 2, 3 => 10 ) );
OpenPOWER on IntegriCloud