/** * @covers NumbersPHP\Calculus::adaptiveSimpson */ public function testAdaptiveSimpson() { $testCalculusAdaptiveSimpsonTestFunc = function ($x) { return 2 * $x * $x; }; $this->assertTrue(\NumbersPHP\Basic::numbersEqual(\NumbersPHP\Calculus::adaptiveSimpson($testCalculusAdaptiveSimpsonTestFunc, 0, 100), 666666.6666699999, \NumbersPHP\Numbers::EPSILON)); /** * this does not work */ /* $this->assertEquals( 666666.666667, \NumbersPHP\Calculus::adaptiveSimpson($testCalculusAdaptiveSimpsonTestFunc, 0, 100), 'adaptive simpson should return an estimated definite integral of a function' ); */ }
/** * @covers NumbersPHP\Matrix::rotate */ public function testRotate() { $a = \NumbersPHP\Matrix::rotate(array(array(0), array(1)), 90, 'clockwise'); $this->assertTrue(\NumbersPHP\Basic::numbersEqual($a[0][0], 1) && \NumbersPHP\Basic::numbersEqual($a[1][0], 0)); }
public function testSum() { $result = Basic::sum(array(1, 2)); $this->assertEquals(3, $result); }
/** * @covers NumbersPHP\Basic::fallingFactorial * @expectedException \Exception */ public function testFallingFactorialException() { \NumbersPHP\Basic::fallingFactorial(-2, 5); }
/** * @covers NumbersPHP\Statistic::covariance */ public function testCovariance() { $this->assertTrue(\NumbersPHP\Basic::numbersEqual(\NumbersPHP\Statistic::covariance(array(-5, -4, -1, 0, 5, 100), array(-6, 5, 2, 5, 2, 6)), 66.05555555555556, \NumbersPHP\Numbers::EPSILON)); }
/** * @covers NumbersPHP\Complex::phase */ public function testPhase() { $a = new \NumbersPHP\Complex(3, 4); $this->assertTrue(\NumbersPHP\Basic::numbersEqual($a->phase(), 0.9272952180016122, \NumbersPHP\Numbers::EPSILON)); }