summaryrefslogtreecommitdiffstats
path: root/tests/polynom_test.php
diff options
context:
space:
mode:
authorKore Nordmann <github@kore-nordmann.de>2006-08-16 12:59:26 +0000
committerKore Nordmann <github@kore-nordmann.de>2006-08-16 12:59:26 +0000
commitbb028918891c1840d200530a0cb458db9a07cf95 (patch)
tree7f98afbf839f41a2e4ad27bb1fb9179f4ce96ee2 /tests/polynom_test.php
parentae311d59bf94eb135dfaa1c09dd93e1ebea4ee05 (diff)
downloadzetacomponents-graph-bb028918891c1840d200530a0cb458db9a07cf95.zip
zetacomponents-graph-bb028918891c1840d200530a0cb458db9a07cf95.tar.gz
- Added matrix and polynom classes for future use in statistical datasets
Diffstat (limited to 'tests/polynom_test.php')
-rw-r--r--tests/polynom_test.php122
1 files changed, 122 insertions, 0 deletions
diff --git a/tests/polynom_test.php b/tests/polynom_test.php
new file mode 100644
index 0000000..c46d8c5
--- /dev/null
+++ b/tests/polynom_test.php
@@ -0,0 +1,122 @@
+<?php
+/**
+ * ezcGraphPolynomTest
+ *
+ * @package Graph
+ * @version //autogen//
+ * @subpackage Tests
+ * @copyright Copyright (C) 2005, 2006 eZ systems as. All rights reserved.
+ * @license http://ez.no/licenses/new_bsd New BSD License
+ */
+
+/**
+ * Tests for ezcGraph class.
+ *
+ * @package ImageAnalysis
+ * @subpackage Tests
+ */
+class ezcGraphPolynomTest extends ezcTestCase
+{
+
+ public static function suite()
+ {
+ return new ezcTestSuite( "ezcGraphPolynomTest" );
+ }
+
+ /**
+ * setUp
+ *
+ * @access public
+ */
+ public function setUp()
+ {
+ }
+
+ /**
+ * tearDown
+ *
+ * @access public
+ */
+ public function tearDown()
+ {
+ }
+
+ public function testCreatePolynom()
+ {
+ $polynom = new ezcGraphPolynom( array( 2 => 1 ) );
+
+ $this->assertEquals(
+ 'x^2',
+ $polynom->__to_string()
+ );
+ }
+
+ public function testCreatePolynom2()
+ {
+ $polynom = new ezcGraphPolynom( array( 2 => .5, 1 => 3, 0 => -4.5 ) );
+
+ $this->assertEquals(
+ '0.50 * x^2 + 3.00 * x + -4.50',
+ $polynom->__to_string()
+ );
+ }
+
+ public function testPolynomGetOrder()
+ {
+ $polynom = new ezcGraphPolynom( array( 2 => .5, 1 => 3, 0 => -4.5 ) );
+
+ $this->assertEquals(
+ 2,
+ $polynom->getOrder()
+ );
+ }
+
+ public function testAddPolynom()
+ {
+ $polynom = new ezcGraphPolynom( array( 2 => .5, 1 => 3, 0 => -4.5 ) );
+ $polynom->add( new ezcGraphPolynom( array( 2 => 1 ) ) );
+
+ $this->assertEquals(
+ '1.50 * x^2 + 3.00 * x + -4.50',
+ $polynom->__to_string()
+ );
+ }
+
+ public function testEvaluatePolynom()
+ {
+ $polynom = new ezcGraphPolynom( array( 2 => 1 ) );
+
+ $this->assertEquals(
+ 4.,
+ $polynom->evaluate( 2 ),
+ 'Calculated wrong value',
+ .1
+ );
+ }
+
+ public function testEvaluatePolynomNegativeValue()
+ {
+ $polynom = new ezcGraphPolynom( array( 2 => 1 ) );
+
+ $this->assertEquals(
+ 4.,
+ $polynom->evaluate( -2 ),
+ 'Calculated wrong value',
+ .1
+ );
+ }
+
+ public function testEvaluateComplexPolynom()
+ {
+ $polynom = new ezcGraphPolynom( array( 2 => .5, 1 => 3, 0 => -4.5 ) );
+
+ $this->assertEquals(
+ 9.,
+ $polynom->evaluate( 3 ),
+ 'Calculated wrong value',
+ .1
+ );
+ }
+}
+
+?>
OpenPOWER on IntegriCloud