public function add($b)
    {
        switch (true) {
            case $b instanceof Matrix:
                $c = $this->addMatrix($b);
                break;

            case $b instanceof ColumnVector:
                $c = $this->addColumnVector($b);
                break;
            
            case $b instanceof Vector:
                $c = $this->addVector($b);
                break;

            case is_int($b) or is_float($b):
                $c = $this->addScalar($b);
                break;

            default:
                throw new InvalidArgumentException('Cannot add matrix'
                    . ' to a ' . gettype($b) . '.');
        }

        return $c;
    }
public function add($b)
    {
        switch (true) {
            case $b instanceof Matrix:
                $c = $this->addMatrix($b);
                break;

            case $b instanceof ColumnVector:
                $c = $this->addColumnVector($b);
                break;
            
            case $b instanceof Vector:
                $c = $this->addVector($b);
                break;

            case is_int($b) or is_float($b):
                $c = $this->addScalar($b);
                break;

            default:
                throw new InvalidArgumentException('Cannot add matrix'
                    . ' to a ' . gettype($b) . '.');
        }

        return $c;
    }
public function add ( $ b ) { switch ( true ) { case $ b instanceof Matrix : $ c = $ this -> addMatrix ( $ b ) ; break ; case $ b instanceof ColumnVector : $ c = $ this -> addColumnVector ( $ b ) ; break ; case $ b instanceof Vector : $ c = $ this -> addVector ( $ b ) ; break ; case is_int ( $ b ) or is_float ( $ b ) : $ c = $ this -> addScalar ( $ b ) ; break ; default : throw new InvalidArgumentException ( 'Cannot add matrix' . ' to a ' . gettype ( $ b ) . '.' ) ; } return $ c ; }
A universal function to add this matrix with another tensor
element-wise.

@param mixed $b
@throws \InvalidArgumentException
@return mixed
A universal function to add this matrix with another tensor element - wise .