Esempio n. 1
0
 /**
  * @param \Wandu\Math\LinearAlgebra\Matrix $other
  * @return \Wandu\Math\LinearAlgebra\Matrix
  */
 public function multiplyWithMatrix(Matrix $other)
 {
     if ($this->colSize !== $other->rowSize) {
         throw new InvalidArgumentException('cannot calculate, because of size.');
     }
     $newRowSize = $this->rowSize;
     $newColSize = $other->colSize;
     $newItems = [];
     for ($rowIndex = 0; $rowIndex < $newRowSize; $rowIndex++) {
         for ($colIndex = 0; $colIndex < $newColSize; $colIndex++) {
             $newItems[$rowIndex][$colIndex] = $this->getRowVector($rowIndex)->dot($other->getColVector($colIndex));
         }
     }
     return new static($this->rowSize, $other->colSize, $newItems);
 }
Esempio n. 2
0
 public function testEqual()
 {
     $this->assertEquals(matrix([[0, 0], [0, 0]]), Matrix::zeros(2, 2));
 }