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

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

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

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

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

        return $c;
    }
387999
protected function compare($a, $b, $operator)
    {
        settype($a, 'array');
        settype($b, 'array');

        if (in_array($operator, array('>=', '<=', '>', '<'))) {
            $a = reset($a);
            $b = reset($b);
        }

        switch ($operator) {
            case '>=':
                return $a >= $b;
            case '<=':
                return $a <= $b;
            case '>':
                return $a > $b;
            case '<':
                return $a < $b;
            case '=':
                return count(array_intersect($a, $b)) > 0;
            case '!=':
                return count(array_intersect($a, $b)) == 0;
        }

        return false;
    }
1226921
protected function subtractVector(Vector $b) : self
    {
        if ($this->n !== $b->size()) {
            throw new DimensionalityMismatchException('Vector A requires'
                . " $this->n elements but Vector B has {$b->size()}.");
        }

        $c = [];

        foreach ($this->a as $i => $value) {
            $c[] = $value - $b[$i];
        }

        return static::quick($c);
    }
502830
public function compare(PersistentObject $a, PersistentObject $b) {
    // we compare for each criteria and sum the results for $a, $b
    // afterwards we compare the sums and return -1,0,1 appropriate
    $sumA = 0;
    $sumB = 0;
    $maxWeight = sizeOf($this->sortCriteria);
    $i = 0;
    foreach ($this->sortCriteria as $criteria => $sortType) {
      $weightedValue = ($maxWeight-$i)*($maxWeight-$i);
      $aGreaterB = 0;
      // sort by id
      if ($criteria == self::ATTRIB_OID) {
        if ($a->getOID() != $b->getOID()) {
          ($a->getOID() > $b->getOID()) ? $aGreaterB = 1 : $aGreaterB = -1;
        }
      }
      // sort by type
      else if ($criteria == self::ATTRIB_TYPE) {
        if ($a->getType() != $b->getType()) {
          ($a->getType() > $b->getType()) ? $aGreaterB = 1 : $aGreaterB = -1;
        }
      }
      // sort by value
      else if($a->getValue($criteria) != null || $b->getValue($criteria) != null) {
        $aValue = strToLower($a->getValue($criteria));
        $bValue = strToLower($b->getValue($criteria));
        if ($aValue != $bValue) {
          ($aValue > $bValue) ? $aGreaterB = 1 : $aGreaterB = -1;
        }
      }
      // sort by property
      else if($a->getProperty($criteria) != null || $b->getProperty($criteria) != null) {
        $aProperty = strToLower($a->getProperty($criteria));
        $bProperty = strToLower($b->getProperty($criteria));
        if ($aProperty != $bProperty) {
          ($aProperty > $bProperty) ? $aGreaterB = 1 : $aGreaterB = -1;
        }
      }
      // calculate result of current criteria depending on current sorttype
      if ($sortType == self::SORTTYPE_ASC) {
        if ($aGreaterB == 1) { $sumA += $weightedValue; }
        else if ($aGreaterB == -1) { $sumB += $weightedValue; }
      }
      else if ($sortType == self::SORTTYPE_DESC) {
        if ($aGreaterB == 1) { $sumB += $weightedValue; }
        else if ($aGreaterB == -1) { $sumA += $weightedValue; }
      }
      else {
        throw new IllegalArgumentException("Unknown SORTTYPE.");
      }
      $i++;
    }
    if ($sumA == $sumB) { return 0; }
    return ($sumA > $sumB) ? 1 : -1;
  }
93938
public static function equal( $a, $b, int $precision = 0 ): bool {
    return self::write( $a, $precision ) === self::write( $b, $precision );
  }
802959
public function compare(Node $a, Node $b) {
    $valA = $this->getSortkeyValue($a);
    $valB = $this->getSortkeyValue($b);
    if ($valA == $valB) { return 0; }
    return ($valA > $valB) ? 1 : -1;
  }
561339
protected function valueEquals($left, $right)
    {
        if ($left instanceof EqualityComparable) {
            return $left->isEqualTo($right, $this);
        } elseif ($right instanceof EqualityComparable) {
            return $right->isEqualTo($left, $this);
        }

        switch (gettype($left)) {
            case 'array':
                return $this->arrayEquals($left, $right);
            case 'object':
                return $this->objectEquals($left, $right);
        }

        return $left === $right;
    }
1250584
protected function multiplyVector(Vector $b) : self
    {
        if ($b->n() !== $this->n) {
            throw new DimensionalityMismatchException('Matrix A requires'
                . " $this->n columns but Vector B has {$b->n()}.");
        }

        $c = [];

        foreach ($this->a as $row) {
            $temp = [];

            foreach ($row as $j => $value) {
                $temp[] = $value * $b[$j];
            }

            $c[] = $temp;
        }

        return self::quick($c);
    }
366479
public function pow($b)
    {
        switch (true) {
            case $b instanceof Vector:
                $c = $this->powVector($b);
                break;

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

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

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

        return $c;
    }
696815
public function versionCompare($a, $b, $operator, $compareBranches = false)
    {
        if (!isset(self::$transOpStr[$operator])) {
            throw new \InvalidArgumentException(sprintf(
                'Invalid operator "%s" given, expected one of: %s',
                $operator,
                implode(', ', self::getSupportedOperators())
            ));
        }

        $aIsBranch = 'dev-' === substr($a, 0, 4);
        $bIsBranch = 'dev-' === substr($b, 0, 4);

        if ($aIsBranch && $bIsBranch) {
            return $operator === '==' && $a === $b;
        }

        // when branches are not comparable, we make sure dev branches never match anything
        if (!$compareBranches && ($aIsBranch || $bIsBranch)) {
            return false;
        }

        return version_compare($a, $b, $operator);
    }
288243
public static function CodepointEqual( $a, $b )
	{
		if ( $a instanceof Undefined || $b instanceof Undefined )
		{
			return Undefined::getValue();
		}

	    $s1 = $a . "";
	    $s2 = $b . "";
		return strcmp( $s1, $s2 ) == 0;
	}
319084
public static function compare(array $a, array $b)
    {
        if ($a['quality'] !== $b['quality']) {
            return $a['quality'] > $b['quality'] ? -1 : 1;
        }

        if ($a['index'] !== $b['index']) {
            return $a['index'] > $b['index'] ? 1 : -1;
        }

        return 0;
    }
1294275
private function zeroCompare($a, $b)
    {
        return ($this->math->comp($a, '0') <= 0 || $this->math->comp($b, '0') <= 0);
    }
39482
public static function isEqual($a, $b)
    {
        if ($a === $b) {
            return true;
        } elseif ($a instanceof \stdClass) {
            return self::isEqual((array) $a, $b);
        } elseif ($b instanceof \stdClass) {
            return self::isEqual($a, (array) $b);
        } else {
            return false;
        }
    }
349467
public function Compare($a, $b)
    {
        $this->preOpMethodParamsCheck(array($a, $b));

        return $this->math->comp($a, $b);
    }
557603
private function compare(int $a, int $b)
    {
        $x = $this->heap[$a];
        $y = $this->heap[$b];

        // Compare priority, using insertion stamp as fallback.
        return ($x->priority <=> $y->priority) ?: ($y->stamp <=> $x->stamp);
    }
1172008
private function compareOptions($a, $b)
    {
        $comparison = $b['priority'] - $a['priority'];

        if ($comparison == 0) {
            return strcasecmp($a['path'], $b['path']);
        }

        return $comparison;
    }