예제 #1
0
 /**
  * @dataProvider dataProviderForConstructor
  */
 public function testConstructor(array $M, array $V)
 {
     $R = new RowVector($M);
     $V = new Matrix($V);
     $this->assertInstanceOf('MathPHP\\LinearAlgebra\\RowVector', $R);
     $this->assertInstanceOf('MathPHP\\LinearAlgebra\\Matrix', $R);
     $this->assertEquals($V[0], $R[0]);
     $this->assertEquals(1, $V->getM());
     $this->assertEquals(count($M), $V->getN());
 }
예제 #2
0
 /**
  * @dataProvider dataProviderForConstructor
  */
 public function testConstructor(array $M, array $V)
 {
     $C = new ColumnVector($M);
     $V = new Matrix($V);
     $this->assertInstanceOf('MathPHP\\LinearAlgebra\\ColumnVector', $C);
     $this->assertInstanceOf('MathPHP\\LinearAlgebra\\Matrix', $C);
     foreach ($M as $row => $value) {
         $this->assertEquals($value, $V[$row][0]);
     }
     $this->assertEquals(count($M), $V->getM());
     $this->assertEquals(1, $V->getN());
 }
예제 #3
0
 /**
  * @dataProvider dataProviderMulti
  */
 public function testConstructor(array $A, array $R)
 {
     $D = new DiagonalMatrix($A);
     $R = new Matrix($R);
     $this->assertInstanceOf('MathPHP\\LinearAlgebra\\DiagonalMatrix', $D);
     $this->assertInstanceOf('MathPHP\\LinearAlgebra\\Matrix', $D);
     $m = $D->getM();
     for ($i = 0; $i < $m; $i++) {
         $this->assertEquals($R[$i], $D[$i]);
     }
     $m = $R->getM();
     for ($i = 0; $i < $m; $i++) {
         $this->assertEquals($R[$i], $D[$i]);
     }
 }
예제 #4
0
 /**
  * @dataProvider dataProviderMulti
  */
 public function testConstructor(array $A)
 {
     $S = new SquareMatrix($A);
     $M = new Matrix($A);
     $this->assertInstanceOf('MathPHP\\LinearAlgebra\\SquareMatrix', $S);
     $this->assertInstanceOf('MathPHP\\LinearAlgebra\\Matrix', $S);
     $m = $S->getM();
     for ($i = 0; $i < $m; $i++) {
         $this->assertEquals($M[$i], $S[$i]);
     }
     $m = $M->getM();
     for ($i = 0; $i < $m; $i++) {
         $this->assertEquals($M[$i], $S[$i]);
     }
 }
 /**
  * @dataProvider dataProviderForTestConstructor
  */
 public function testConstructor($M, int $n, $V)
 {
     $M = new VandermondeMatrix($M, $n);
     $V = new Matrix($V);
     $this->assertInstanceOf('MathPHP\\LinearAlgebra\\VandermondeMatrix', $M);
     $this->assertInstanceOf('MathPHP\\LinearAlgebra\\Matrix', $M);
     $m = $V->getM();
     for ($i = 0; $i < $m; $i++) {
         $this->assertEquals($V[$i], $M[$i]);
     }
     $m = $M->getM();
     for ($i = 0; $i < $m; $i++) {
         $this->assertEquals($V[$i], $M[$i]);
     }
 }