protected function _add(Matrix $other, $sign = 1)
    {
        $a1 = $this->toArray();
        $a2 = $other->toArray();

        $newMatrix = [];
        for ($i = 0; $i < $this->rows; ++$i) {
            for ($k = 0; $k < $this->columns; ++$k) {
                $newMatrix[$i][$k] = $a1[$i][$k] + $sign * $a2[$i][$k];
            }
        }

        return new self($newMatrix, false);
    }
protected function _add(Matrix $other, $sign = 1)
    {
        $a1 = $this->toArray();
        $a2 = $other->toArray();

        $newMatrix = [];
        for ($i = 0; $i < $this->rows; ++$i) {
            for ($k = 0; $k < $this->columns; ++$k) {
                $newMatrix[$i][$k] = $a1[$i][$k] + $sign * $a2[$i][$k];
            }
        }

        return new self($newMatrix, false);
    }
protected function _add ( Matrix $ other , $ sign = 1 ) { $ a1 = $ this -> toArray ( ) ; $ a2 = $ other -> toArray ( ) ; $ newMatrix = [ ] ; for ( $ i = 0 ; $ i < $ this -> rows ; ++ $ i ) { for ( $ k = 0 ; $ k < $ this -> columns ; ++ $ k ) { $ newMatrix [ $ i ] [ $ k ] = $ a1 [ $ i ] [ $ k ] + $ sign * $ a2 [ $ i ] [ $ k ] ; } } return new self ( $ newMatrix , false ) ; }
Element-wise addition or substraction depending on the given sign parameter

@param Matrix $other
@param int    $sign

@return Matrix
Element - wise addition or substraction depending on the given sign parameter