Reduce points with Opheim algorithm.

@param mixed $tolerance Defined threshold to reduce by

@return array Reduced set of points
772560
public function reduce( $tolerance )
    {
        $key = 0;
        while ( $key < $this->lastKey(-3) ) {
            $out = $key + 2;
            $pd = $this->shortestDistanceToSegment(
                $this->points[$out],
                $this->points[$key],
                $this->points[$key + 1]
            );
            while ( $out < $this->lastKey() && $pd < $tolerance ) {
                $pd = $this->shortestDistanceToSegment(
                    $this->points[++$out],
                    $this->points[$key],
                    $this->points[$key + 1]
                );
            }
            for ( $i = $key+1, $l = $out - 1; $i < $l; $i++ ) {
                unset($this->points[$i]);
            }
            $this->reindex();
            $key++;
        }
        return $this->points;
    }
146018
public function getDeletedExtensions()
    {
        $oModuleValidatorFactory = $this->getModuleValidatorFactory();
        $oModuleMetadataValidator = $oModuleValidatorFactory->getModuleMetadataValidator();
        $aModulesIds = $this->getModuleIds();
        $oModule = $this->getModule();
        $aDeletedExt = [];

        foreach ($aModulesIds as $sModuleId) {
            $oModule->setModuleData(['id' => $sModuleId]);
            if (!$oModuleMetadataValidator->validate($oModule)) {
                $aDeletedExt[$sModuleId]['files'] = [$sModuleId . '/metadata.php'];
            } else {
                $aInvalidExtensions = $this->_getInvalidExtensions($sModuleId);
                if ($aInvalidExtensions) {
                    $aDeletedExt[$sModuleId]['extensions'] = $aInvalidExtensions;
                }
            }
        }

        return $aDeletedExt;
    }
42491
public function reduce(Callable $f, $initial = null) {
        return array_reduce($this->items, $f, $initial);
    }
891443
private function reduceCursorForGroups()
    {
        $reduceForGroups = $groupKeys = [];
        $index = 0;
        foreach ($this->collectionCursor as $model) {
            $groupKey = $this->getGroupKeyForModel($model);
            if ($groupKey != '') {
                if (!in_array($groupKey, $groupKeys)) {
                    $groupKeys[] = $groupKey;
                } else {
                    $reduceForGroups[] = $index;
                }
            }
            $index++;
        }

        if (count($reduceForGroups) > 0) {
            $this->collectionCursor->filterModelsByIndex($reduceForGroups);
        }
    }
770310
public function get($severity)
    {
        $severity = $this->mapSeverity($severity);
        if (!isset($this->violations[$severity])) {
            return array();
        }

        return $this->violations[$severity];
    }
657388
public function slice($offset, $limit=null) {
		$this->rewind();
		$i=0;
		$del=array();
		while ($this->valid()) {
			if ($i < $offset)
				$del[]=$this->key();
			elseif ($i >= $offset && $limit && $i >= ($offset+$limit))
				$del[]=$this->key();
			$i++;
			$this->next();
		}
		foreach ($del as $ii)
			unset($this[$ii]);
	}
1082975
protected function reduce(array $data): array
    {
        $m1 = new Matrix($data);
        $m2 = new Matrix($this->eigVectors);

        return $m1->multiply($m2->transpose())->toArray();
    }
1342895
public function getClosest(array $points)
    {
        foreach ($points as $point) {
            $distance = $this->getDistanceWith($point, false);

            if (!isset($minDistance)) {
                $minDistance = $distance;
                $minPoint = $point;
                continue;
            }

            if ($distance < $minDistance) {
                $minDistance = $distance;
                $minPoint = $point;
            }
        }

        return $minPoint;
    }
282940
public function isExpired(int $tolerance) : bool
    {
        $timestamp = $this->headers->get('X-SIGNED-TIMESTAMP', '1901-01-01 12:00:00');
        $issuedAt = Carbon::parse($timestamp);

        $isValid = Helpers::verifyDateTime($timestamp, 'Y-m-d H:i:s');

        return !$isValid || Carbon::now()->diffInSeconds($issuedAt) > $tolerance;
    }
83853
public static function risMatch($collection, $needle, $tolerance)
    {
        return WURFL_Handlers_Matcher_RISMatcher::INSTANCE()->match($collection, $needle, $tolerance);
    }
33318
public static function adjust_lon($x)
    {
        return (abs($x) < M_PI)
            ? $x
            : ($x - (static::sign($x) * static::TWO_PI));
    }
678029
public function trim(int $start, int $stop): array
    {
        return $this->handle->lTrim($this->name, $start, $stop);
    }
817183
public function range($stop=null) {
    $args = self::_wrapArgs(func_get_args(), 1);
    
    $__ = new self;
    $args = $__->reject($args, function($val) {
      return is_null($val);
    });
    
    $num_args = count($args);
    switch($num_args) {
      case 1: 
        list($start, $stop, $step) = array(0, $args[0], 1);
        break;
      case 2:
        list($start, $stop, $step) = array($args[0], $args[1], 1);
        if($stop < $start) return self::_wrap(array());
        break;
      default:
        list($start, $stop, $step) = array($args[0], $args[1], $args[2]);
        if($step > 0 && $step > $stop) return self::_wrap(array($start));
    }
    $results = range($start, $stop, $step);
    
    // Switch inclusive to exclusive
    if($step > 0 && $__->last($results) >= $stop) array_pop($results);
    elseif($step < 0 && $__->last($results) <= $stop) array_pop($results);
    
    return self::_wrap($results);
  }
174172
public static MultiPolygon removeDuplicateCoordinates(MultiPolygon multiPolygon, double tolerance) throws SQLException {
        ArrayList<Polygon> polys = new ArrayList<Polygon>();
        for (int i = 0; i < multiPolygon.getNumGeometries(); i++) {
            Polygon poly = (Polygon) multiPolygon.getGeometryN(i);
            polys.add(removeDuplicateCoordinates(poly, tolerance));
        }
        return FACTORY.createMultiPolygon(GeometryFactory.toPolygonArray(polys));
    }
1357757
private function _adjustPoint($point)
    {
        $type = $this->shapeType / 10;
        if ($type >= 2) {
            $point = $this->_fixPoint($point, 'm');
        } elseif ($type >= 1) {
            $point = $this->_fixPoint($point, 'z');
            $point = $this->_fixPoint($point, 'm');
        }

        return $point;
    }
126524
function(coords) {
        var tolerance = this.options.tolerance || 0.8;
        var enableHighQuality = !!this.options.highQuality;
        var points = GeometryUtils.simplify(coords, tolerance,
                enableHighQuality);
        return points;
    }
890387
public function getPpmDelta($mass)
    {
        if ($this->unit == Tolerance::PPM) {
            return $this->tolerance;
        }

        $toleranceRatio = $this->tolerance / $mass;

        return $toleranceRatio * 1000000;
    }