subtractMatrix() public method

public subtractMatrix ( self $value ) : self
$value self
return self
コード例 #1
0
 public function testSubtractMatrix()
 {
     $matrix1 = new Matrix([[1, 2, 3], [4, 5, 6], [7, 8, 9]]);
     $matrix2 = new Matrix([[4, 2, 6], [1, 7, 3], [7, 3, 2]]);
     $subtracted = $matrix1->subtractMatrix($matrix2);
     static::assertEquals(-3, $subtracted->get(0, 0));
     static::assertEquals(0, $subtracted->get(0, 1));
     static::assertEquals(-3, $subtracted->get(0, 2));
     static::assertEquals(3, $subtracted->get(1, 0));
     static::assertEquals(-2, $subtracted->get(1, 1));
     static::assertEquals(3, $subtracted->get(1, 2));
     static::assertEquals(0, $subtracted->get(2, 0));
     static::assertEquals(5, $subtracted->get(2, 1));
     static::assertEquals(7, $subtracted->get(2, 2));
 }