pocketmine\math\Matrix::add PHP Method

add() public method

public add ( Matrix $matrix )
$matrix Matrix
    public function add(Matrix $matrix)
    {
        if ($this->rows !== $matrix->getRows() or $this->columns !== $matrix->getColumns()) {
            return false;
        }
        $result = new Matrix($this->rows, $this->columns);
        for ($r = 0; $r < $this->rows; ++$r) {
            for ($c = 0; $c < $this->columns; ++$c) {
                $result->setElement($r, $c, $this->matrix[$r][$c] + $matrix->getElement($r, $c));
            }
        }
        return $result;
    }