A universal function to compute the greater than comparison of
this vector and another tensor element-wise.

@param mixed $b
@throws \InvalidArgumentException
@return mixed
961051
public function greater($b)
    {
        switch (true) {
            case $b instanceof Vector:
                $c = $this->greaterVector($b);
                break;

            case $b instanceof Matrix:
                $c = $this->greaterMatrix($b);
                break;

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

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

        return $c;
    }
290626
public function compare($a, $b)
    {
        return strcoll(Horde_String::lower($a[$this->key], true, 'UTF-8'), Horde_String::lower($b[$this->key], true, 'UTF-8'));
    }
261487
public function similarity(&$A, &$B)
    {
        $alpha = $this->alpha;
        $beta = $this->beta;

        $a = array_fill_keys($A,1);
        $b = array_fill_keys($B,1);

        $min = min(count(array_diff_key($a,$b)),count(array_diff_key($b, $a)));
        $max = max(count(array_diff_key($a,$b)),count(array_diff_key($b, $a)));

        $intersect = count(array_intersect_key($a,$b));

        return $intersect/($intersect + ($beta * ($alpha * $min + $max*(1-$alpha)) ));
    }
38794
public function convolve(Vector $b, int $stride = 1) : self
    {
        if ($b->size() > $this->n) {
            throw new InvalidArgumentException('Vector B cannot be'
                . ' longer than Vector A.');
        }

        if ($stride < 1) {
            throw new InvalidArgumentException('Stride cannot be'
                . " less than 1, $stride given.");
        }

        $c = [];

        for ($i = 0; $i < $this->n; $i += $stride) {
            $sigma = 0;

            foreach ($b as $j => $valueB) {
                $sigma += ($this->a[$i - (int) $j] ?? 0) * $valueB;
            }

            $c[] = $sigma;
        }

        return static::quick($c);
    }
697251
public function Multiply($a, $b)
    {
        $this->preOpMethodParamsCheck(array($a, $b));

        return $this->math->mul($a, $b);
    }
633558
private static function defaultCompareWrapper( $a, $b ) {
			if ( $a === $b ) {
				return 0;
			} else {

				if ( is_string( $a ) ) {
					return strcmp( $a, $b . '' );
				} else
				if ( is_int( $a ) || is_float( $b ) ) {
					return (float)$a - $b;
				} else 
				return -1;

			}
		}
1118857
public function compute(array $a, array $b) : float
    {
        $distance = $min = $max = 0.;

        foreach ($a as $i => $valueA) {
            $valueB = $b[$i];

            $min += min($valueA, $valueB);
            $max += max($valueA, $valueB);
        }

        return 1. - ($min / ($max ?: EPSILON));
    }
30335
final protected function _mboxCompare($a, $b)
    {
        /* Always return INBOX as "smaller". */
        if ($this->_sortinbox) {
            if (strcasecmp($a, 'INBOX') === 0) {
                return -1;
            } elseif (strcasecmp($b, 'INBOX') === 0) {
                return 1;
            }
        }

        $a_parts = explode($this->_delimiter, $a);
        $b_parts = explode($this->_delimiter, $b);

        $a_count = count($a_parts);
        $b_count = count($b_parts);

        for ($i = 0, $iMax = min($a_count, $b_count); $i < $iMax; ++$i) {
            if ($a_parts[$i] != $b_parts[$i]) {
                /* If only one of the folders is under INBOX, return it as
                 * "smaller". */
                if ($this->_sortinbox && ($i === 0)) {
                    $a_base = (strcasecmp($a_parts[0], 'INBOX') === 0);
                    $b_base = (strcasecmp($b_parts[0], 'INBOX') === 0);
                    if ($a_base && !$b_base) {
                        return -1;
                    } elseif (!$a_base && $b_base) {
                        return 1;
                    }
                }

                $cmp = strnatcasecmp($a_parts[$i], $b_parts[$i]);
                return ($cmp === 0)
                    ? strcmp($a_parts[$i], $b_parts[$i])
                    : $cmp;
            } elseif ($a_parts[$i] !== $b_parts[$i]) {
                return strlen($a_parts[$i]) - strlen($b_parts[$i]);
            }
        }

        return ($a_count - $b_count);
    }
1373987
private function valuesAreEqual($a, $b)
    {
        if (is_array($a) && is_array($b)) {
            ksort($a);
            ksort($b);
        }

        return $a === $b;
    }
1202898
protected function compare(string $a, string $b): int
    {
        global $sortOrder;

        $aIndex = array_search($a, $sortOrder);
        $bIndex = array_search($b, $sortOrder);
        if ($aIndex === false) {
            return -1;
        }

        if ($bIndex === false) {
            return 1;
        }

        return $aIndex - $bIndex;
    }
454790
public function lessEqual($b)
    {
        switch (true) {
            case $b instanceof Matrix:
                $c = $this->lessEqualMatrix($b);
                break;

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

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

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

        return $c;
    }
633641
public function greaterThan($other)
    {
        $this->doCheck(function ($value) use ($other) {
            $this->throwExceptionIfFalse(
                $value > $other,
                'Failed assertion that %s is greater than %s', $value, $other
            );
        });

        return $this;
    }
1080633
public function lt($other)
    {
        if (!($other instanceof self)) {
            $other = new BigInt($other);
        }
        return ($this->compare($other) < 0);
    }
900217
public static function getResultComparisonTypeValue($comparisonType)
    {
        $comparisonTypeValue = array_search($comparisonType, self::getResultComparisonTypes());

        if (false === $comparisonTypeValue) {
            throw new \InvalidArgumentException("Unknow comparison type.");
        }

        return $comparisonTypeValue;
    }
675014
public function multiply($b)
    {
        switch (true) {
            case $b instanceof Vector:
                $c = $this->multiplyVector($b);
                break;

            case $b instanceof Matrix:
                $c = $this->multiplyMatrix($b);
                break;

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

            default:
                throw new InvalidArgumentException('Cannot multiply vector'
                    . ' with a ' . gettype($b) . '.');
        }

        return $c;
    }
576655
public static function compare(Symbol $a, Symbol $b): int
    {
        return ($a->isTerminal - $b->isTerminal)
            ?: strcmp($a->name, $b->name);
    }
717276
public function computeWithoutBcMath(DecimalNumber $a, DecimalNumber $b)
    {
        if ($a->isNegative()) {
            if ($b->isNegative()) {
                // if both numbers are negative,
                // we can just add them as positive numbers and then invert the sign
                // f(x, y) = -(|x| + |y|)
                // eg. f(-1, -2) = -(|-1| + |-2|) = -3
                // eg. f(-2, -1) = -(|-2| + |-1|) = -3
                return $this
                    ->computeWithoutBcMath($a->toPositive(), $b->toPositive())
                    ->invert();
            }
            // if the number is negative and the addend positive,
            // perform an inverse subtraction by inverting the terms
            // f(x, y) = y - |x|
            // eg. f(-2, 1) = 1 - |-2| = -1
            // eg. f(-1, 2) = 2 - |-1| = 1
            // eg. f(-1, 1) = 1 - |-1| = 0
            return $b->minus(
                $a->toPositive()
            );
        }

        if ($b->isNegative()) {
            // if the number is positive and the addend is negative
            // perform subtraction instead: 2 - 1
            // f(x, y) = x - |y|
            // f(2, -1) = 2 - |-1| = 1
            // f(1, -2) = 1 - |-2| = -1
            // f(1, -1) = 1 - |-1| = 0
            return $a->minus(
                $b->toPositive()
            );
        }

        // optimization: 0 + x = x
        if ('0' === (string) $a) {
            return $b;
        }

        // optimization: x + 0 = x
        if ('0' === (string) $b) {
            return $a;
        }

        // pad coefficients with leading/trailing zeroes
        list($coeff1, $coeff2) = $this->normalizeCoefficients($a, $b);

        // compute the coefficient sum
        $sum = $this->addStrings($coeff1, $coeff2);

        // both signs are equal, so we can use either
        $sign = $a->getSign();

        // keep the bigger exponent
        $exponent = max($a->getExponent(), $b->getExponent());

        return new DecimalNumber($sign . $sum, $exponent);
    }