/** * @return array */ public function run() { $result = []; for ($i = 100; $i <= 1000; $i += 100) { $numArray = NumPHP::ones($i, $i); $time = microtime(true); $numArray->abs(); $timeDiff = microtime(true) - $time; $result[$i] = new TestRun($i, $timeDiff); } return $result; }
/** * Tests NumArray::getSize on scalar */ public function testGetSize() { $numArray = NumPHP::ones(); $this->assertSame(1, $numArray->getSize()); }
/** * Tests if InvalidArgumentException will be thrown, when using LinAlg::solve with not align matrix and vector * * @expectedException \NumPHP\LinAlg\Exception\InvalidArgumentException * @expectedExceptionMessage Can not solve a linear system with matrix (4, 4) and matrix (3) */ public function testSolveNotAlign() { $matrix = NumPHP::identity(4); $vector = NumPHP::ones(3); LinAlg::solve($matrix, $vector); }
/** * Tests if Helper::isSquareMatrix works with invalid square matrix */ public function testCheckSquareMatrixInvalid() { $numArray = NumPHP::ones(2, 3); $this->assertFalse(Helper::isSquareMatrix($numArray)); }
/** * Tests NumPHP::eye with argument 1 */ public function testEye1() { $numArray = NumPHP::eye(1); $expectedNumArray = NumPHP::ones(1, 1); $this->assertNumArrayEquals($expectedNumArray, $numArray); }
/** * Tests if InvalidArgumentException will be thrown, when using NumArray::reshape * with wrong size * * @expectedException \NumPHP\Core\Exception\InvalidArgumentException * @expectedExceptionMessage Total size of new array must be unchanged */ public function testReshapeInvalidArgumentException() { $numArray = NumPHP::ones(2, 3); $numArray->reshape(2, 2); }
/** * Tests NumPHP::onesLike with 3x2 matrix */ public function testOnesLike() { $numArray = new NumArray([[1, 1], [1, 1], [1, 1]]); $expectedNumArray = NumPHP::ones(3, 2); $this->assertNumArrayEquals($expectedNumArray, NumPHP::onesLike($numArray)); }