MatrixPropertiesTest.php 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  1. <?php
  2. namespace MathPHP\Tests\LinearAlgebra\Matrix\Base;
  3. use MathPHP\LinearAlgebra\MatrixFactory;
  4. use MathPHP\LinearAlgebra\NumericMatrix;
  5. class MatrixPropertiesTest extends \PHPUnit\Framework\TestCase
  6. {
  7. use \MathPHP\Tests\LinearAlgebra\Fixture\MatrixDataProvider;
  8. /**
  9. * @test isSquare returns true for square matrices.
  10. * @dataProvider dataProviderForSquareMatrix
  11. * @param array $A
  12. * @throws \Exception
  13. */
  14. public function testIsSquare(array $A)
  15. {
  16. // Given
  17. $A = MatrixFactory::create($A);
  18. // Then
  19. $this->assertTrue($A->isSquare());
  20. }
  21. /**
  22. * @test isSquare returns false for nonsquare matrices.
  23. * @dataProvider dataProviderForNotSquareMatrix
  24. * @param array $A
  25. * @throws \Exception
  26. */
  27. public function testIsSquareFalseNonSquareMatrix(array $A)
  28. {
  29. // Given
  30. $A = MatrixFactory::create($A);
  31. // Then
  32. $this->assertFalse($A->isSquare());
  33. }
  34. /**
  35. * @test isNotSquare returns true for nonsquare matrices.
  36. * @dataProvider dataProviderForNotSquareMatrix
  37. * @param array $A
  38. * @throws \Exception
  39. */
  40. public function testIsNotSquare(array $A)
  41. {
  42. // Given
  43. $A = MatrixFactory::create($A);
  44. // Then
  45. $this->assertFalse($A->isSquare());
  46. }
  47. /**
  48. * @test isRectangularDiagonal returns true appropriately
  49. * @dataProvider dataProviderForRectangularDiagonalMatrix
  50. * @param array $D
  51. * @throws \Exception
  52. */
  53. public function testIsRectangularDiagonal(array $D)
  54. {
  55. // Given
  56. $D = MatrixFactory::create($D);
  57. // Then
  58. $this->assertTrue($D->isRectangularDiagonal());
  59. }
  60. }