From a7df5bda8d5f00fee28a288fb078d936787fe524 Mon Sep 17 00:00:00 2001 From: Kore Nordmann Date: Thu, 30 Nov 2006 13:59:55 +0000 Subject: - Fixed: Bug #9588 (Wrong polynoms build from data) --- tests/dataset_average_test.php | 38 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 38 insertions(+) (limited to 'tests/dataset_average_test.php') 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 ) ); -- cgit v1.1