src/Chippyash/Math/Type/Comparator/Native.php
protected function complexCompare(ComplexType $a, ComplexType $b)
    {
        if ($a->isReal() && $b->isReal()) {
            return $this->rationalCompare($a->r(), $b->r());
        }

        //hack to get around native php integer limitations
        //what we should be doing here is to return $this->rationalCompare($a->modulus(), $b->modulus())
        //but this blows up because of the big rationals it produces
        $am = $a->modulus()->asFloatType()->get();
        $bm = $b->modulus()->asFloatType()->get();

        if ($am == $bm) {
            return 0;
        }
        if ($am < $bm) {
            return -1;
        }
        return 1;
    }
protected function complexCompare(ComplexType $a, ComplexType $b)
    {
        if ($a->isReal() && $b->isReal()) {
            return $this->rationalCompare($a->r(), $b->r());
        }

        //hack to get around native php integer limitations
        //what we should be doing here is to return $this->rationalCompare($a->modulus(), $b->modulus())
        //but this blows up because of the big rationals it produces
        $am = $a->modulus()->asFloatType()->get();
        $bm = $b->modulus()->asFloatType()->get();

        if ($am == $bm) {
            return 0;
        }
        if ($am < $bm) {
            return -1;
        }
        return 1;
    }
protected function complexCompare ( ComplexType $ a , ComplexType $ b ) { if ( $ a -> isReal ( ) && $ b -> isReal ( ) ) { return $ this -> rationalCompare ( $ a -> r ( ) , $ b -> r ( ) ) ; } //hack to get around native php integer limitations //what we should be doing here is to return $this->rationalCompare($a->modulus(), $b->modulus()) //but this blows up because of the big rationals it produces $ am = $ a -> modulus ( ) -> asFloatType ( ) -> get ( ) ; $ bm = $ b -> modulus ( ) -> asFloatType ( ) -> get ( ) ; if ( $ am == $ bm ) { return 0 ; } if ( $ am < $ bm ) { return - 1 ; } return 1 ; }
Compare complex numbers.
If both operands are real then compare the real parts
else compare the modulii of the two numbers

@param ComplexType $a
@param ComplexType $b

@return boolean
Compare complex numbers . If both operands are real then compare the real parts else compare the modulii of the two numbers