src/Vector.php
public function dotProduct(self $b)
    {
        $this->_checkVectorSpace($b);

        $bComponents = $b->components();
        $product = 0;
        foreach ($this->components() as $i => $component) {
            $product += $component * $bComponents[$i];
        }

        return $product;
    }
public function dotProduct(self $b)
    {
        $this->_checkVectorSpace($b);

        $bComponents = $b->components();
        $product = 0;
        foreach ($this->components() as $i => $component) {
            $product += $component * $bComponents[$i];
        }

        return $product;
    }
public function dotProduct ( self $ b ) { $ this -> _checkVectorSpace ( $ b ) ; $ bComponents = $ b -> components ( ) ; $ product = 0 ; foreach ( $ this -> components ( ) as $ i => $ component ) { $ product += $ component * $ bComponents [ $ i ] ; } return $ product ; }
Computes the dot product, or scalar product, of two vectors.

@api
@param self $b The vector to multiply with.
@return int|float The dot product of the two vectors.
@throws Exception if the vectors are not in the same vector space.
@see self::_checkVectorSpace() For exception information.
Computes the dot product or scalar product of two vectors .