public function testMatrixMultiplication() { $left = array(array(1, 2), array(3, 5), array(2, 4)); $right = array(array(4, 7, 5), array(3, 1, 4)); $this->assertEquals(MathUtils::getMmult($left, $right), array(array(10, 9, 13), array(27, 26, 35), array(20, 18, 26))); try { MathUtils::getMmult(array(), $right); $this->fail("Exception expected here"); } catch (WrongArgumentException $e) { } try { MathUtils::getMmult($left, array()); $this->fail("Exception expected here"); } catch (WrongArgumentException $e) { } }
/** * @return GoogleChartDataSet **/ private function calculateMax() { $maxValue = max($this->data); if ($this->base) { $maxValue = MathUtils::alignByBase($maxValue, $this->base, true); } if ($maxValue == 0) { if ($this->base) { $maxValue = $this->base; } else { $maxValue = 1; } } $this->minMax->setMax($maxValue); return $this; }
public function testCompareFloat() { $this->assertEquals(MathUtils::compareFloat(0.001, 0.001), 0); $this->assertEquals(MathUtils::compareFloat(0, 0.0001, 0.001), 0); $this->assertEquals(MathUtils::compareFloat(0.0001, 1.0E-5, 1.0E-6), 1); }