Adapt the bias according to the current code point and position
@param int $delta
@param int $nPoints
@param int $isFirst
@return int
5562
protected function adapt($delta, $nPoints, $isFirst): int
    {
        $delta = intval($isFirst ? ($delta / self::damp) : ($delta / 2));
        $delta += intval($delta / $nPoints);
        for ($k = 0; $delta > ((self::base - self::tMin) * self::tMax) / 2; $k += self::base) {
            $delta = intval($delta / (self::base - self::tMin));
        }

        return intval($k + (self::base - self::tMin + 1) * $delta / ($delta + self::skew));
    }
682640
public boolean equalsDelta(Coordinate coordinate, double delta) {
		return null != coordinate &&
				(Math.abs(this.x - coordinate.x) < delta && Math.abs(this.y - coordinate.y) < delta);
	}
750423
public MultiPoint toMultiPoint(List<LatLng> latLngs, boolean hasZ,
                                   boolean hasM) {

        MultiPoint multiPoint = new MultiPoint(hasZ, hasM);

        for (LatLng latLng : latLngs) {
            Point point = toPoint(latLng);
            multiPoint.addPoint(point);
        }

        return multiPoint;
    }
1292264
public boolean eq(IntDoubleSortedVector other, double delta) {
        // This is slow, but correct.
        IntDoubleSortedVector v1 = IntDoubleSortedVector.getWithNoZeroValues(this, delta);
        IntDoubleSortedVector v2 = IntDoubleSortedVector.getWithNoZeroValues(other, delta);
                
        if (v2.size() != v1.size()) {
            return false;
        }

        for (IntDoubleEntry ve : v1) {
            if (!Primitives.equals(ve.get(), v2.get(ve.index()), delta)) {
                return false;
            }
        }
        for (IntDoubleEntry ve : v2) {
            if (!Primitives.equals(ve.get(), v1.get(ve.index()), delta)) {
                return false;
            }
        }
        return true;
    }
1031560
private function combineSumPoints($points1, $points2) {
        $pointsCount = count($points1);
        $currPoint = 0;
        foreach ($points2 as $point2) {
            $pointFound = false;
            //leverage the fact that points are sorted and improve O(n^2)
            while ($currPoint < $pointsCount) {
                $point1 = $points1[$currPoint];
                if ($point1['time'] == $point2['time']) {
                    $points1[$currPoint]['sum'] += $point2['sum'];
                    $currPoint++;
                    $pointFound = true;
                    break;
                }
                $currPoint++;
            }
            //point not found in downsampled array, then just append
            if (!$pointFound) {
                $points1[] = $point2;
            }
        }

        return $points1;
    }
807510
void findInsertPointInRight(
    Object           new1,
    NodeInsertPoint  point)
  {
    int r = rightMostIndex();
    int m = midPoint();
    if (r <= m)
      {
        String x =
         "Erroneous call to findInsertPointInRight(). "  +
         "rightMostIndex() = " + r +
         ", midPoint() = "     + m + ".";
        throw new OptimisticDepthException(x);
      }
    findIndex(m+1 , r, new1, point);
  }
1191034
def shift_output_offsets(delta)
      return if delta == 0
      @data.each do |m|
        break if m.output.start_pos.line > 1
        m.output.start_pos.offset += delta
        m.output.end_pos.offset += delta if m.output.end_pos.line > 1
      end
    end
242876
public function adapt($delta, $numPoints, $firstTime)
    {
        $k = 0;
        $delta = $firstTime ? floor($delta / self::DAMP) : $delta >> 1;
        $delta += floor($delta / $numPoints);
        for (/* no initialization */; $delta > self::BASE_MINUS_T_MIN * self::T_MAX >> 1; $k += self::BASE) {
            $delta = floor($delta / self::BASE_MINUS_T_MIN);
        }
        return floor($k + (self::BASE_MINUS_T_MIN + 1) * $delta / ($delta + self::SKEW));
    }
890863
public static IntSupplier topAlignedTo(IPositioned other, int offset)
	{
		checkNotNull(other);
		return () -> {
			return other.position().y() + offset;
		};

	}
31656
def _first_fill_value_loc(self):
        
        if len(self) == 0 or self.sp_index.npoints == len(self):
            return -1

        indices = self.sp_index.to_int_index().indices
        if not len(indices) or indices[0] > 0:
            return 0

        diff = indices[1:] - indices[:-1]
        return np.searchsorted(diff, 2) + 1
279238
private static void updateNearestCenter(double inverseSimilarities[], Matrix dataPoints,
                                            int newlyChosen, 
                                            SimilarityFunction simFunc) {
        
        DoubleVector chosenVec = dataPoints.getRowVector(newlyChosen);
	for (int i = 0; i < inverseSimilarities.length; i++) {
            double sim = simFunc.sim(dataPoints.getRowVector(i), chosenVec);
            sim = invertSim(sim);
            inverseSimilarities[i] = Math.min(inverseSimilarities[i], sim);
        }
    }
404979
private int trPivot(int ISAd, int first, int last) {
        int middle;
        int t;

        t = last - first;
        middle = first + t / 2;

        if (t <= 512) {
            if (t <= 32) {
                return trMedian3(ISAd, first, middle, last - 1);
            } else {
                t >>= 2;
                return trMedian5(ISAd, first, first + t, middle, last - 1 - t, last - 1);
            }
        }
        t >>= 3;
        first = trMedian3(ISAd, first, first + t, first + (t << 1));
        middle = trMedian3(ISAd, middle - t, middle, middle + t);
        last = trMedian3(ISAd, last - 1 - (t << 1), last - 1 - t, last - 1);
        return trMedian3(ISAd, first, middle, last);
    }
710560
def update_coordinates(self, coordinates=None):
        
        if coordinates is not None:
            self.coordinates = coordinates
        self.numc = len(self.coordinates)
        self.distances = np.zeros((self.numc, self.numc), float)
        self.deltas = np.zeros((self.numc, self.numc, 3), float)
        self.directions = np.zeros((self.numc, self.numc, 3), float)
        self.dirouters = np.zeros((self.numc, self.numc, 3, 3), float)
        for index1, coordinate1 in enumerate(self.coordinates):
            for index2, coordinate2 in enumerate(self.coordinates):
                delta = coordinate1 - coordinate2
                self.deltas[index1, index2] = delta
                distance = np.linalg.norm(delta)
                self.distances[index1, index2] = distance
                if index1 != index2:
                    tmp = delta/distance
                    self.directions[index1, index2] = tmp
                    self.dirouters[index1, index2] = np.outer(tmp, tmp)
192261
public function updateRightValues($first, $last, $delta, $rootVal=null)
    {
        $hasManyRoots = $this->getConfiguration()->hasManyRoots();

        foreach($this->wrappers as $wrapper)
        {
            if(!$hasManyRoots || ($wrapper->getRootValue() == $rootVal))
            {
                if($wrapper->getRightValue() >= $first && ($last === 0 || $wrapper->getRightValue() <= $last))
                {
                    $wrapper->setRightValue($wrapper->getRightValue() + $delta);
                    $wrapper->invalidate();
                }
            }
        }
    }
888448
public static void calcPoints(final double lat1, final double lon1,
                                  final double lat2, final double lon2,
                                  final PointEmitter emitter,
                                  final double offsetLat, final double offsetLon,
                                  final double deltaLat, final double deltaLon) {
        // round to make results of bresenham closer to correct solution
        int y1 = (int) ((lat1 - offsetLat) / deltaLat);
        int x1 = (int) ((lon1 - offsetLon) / deltaLon);
        int y2 = (int) ((lat2 - offsetLat) / deltaLat);
        int x2 = (int) ((lon2 - offsetLon) / deltaLon);
        bresenham(y1, x1, y2, x2, new PointEmitter() {
            @Override
            public void set(double lat, double lon) {
                // +.1 to move more near the center of the tile
                emitter.set((lat + .1) * deltaLat + offsetLat, (lon + .1) * deltaLon + offsetLon);
            }
        });
    }
241043
protected static function adapt($delta, $numpoints, $firsttime) {
#	function adapt(delta,numpoints,firsttime):
#		if firsttime then let delta = delta div damp
		if ($firsttime) {
			$delta = floor($delta / self::BOOTSTRAP_DAMP);
		}
#		else let delta = delta div 2
		else {
			$delta = floor($delta / 2);
		}
#		let delta = delta + (delta div numpoints)
		$delta += floor($delta / $numpoints);
#		let k = 0
		$k = 0;
#		while delta > ((base - tmin) * tmax) div 2 do begin
		$max = floor(((self::BOOTSTRAP_BASE - self::BOOTSTRAP_TMIN) * self::BOOTSTRAP_TMAX) / 2);
		while ($delta > $max) {
#			let delta = delta div (base - tmin)
			$delta = floor($delta / (self::BOOTSTRAP_BASE - self::BOOTSTRAP_TMIN));
#			let k = k + base
			$k += self::BOOTSTRAP_BASE;
#		end
		}
#		return k + (((base - tmin + 1) * delta) div (delta + skew))
		return $k + floor(((self::BOOTSTRAP_BASE - self::BOOTSTRAP_TMIN + 1) * $delta) / ($delta + self::BOOTSTRAP_SKEW));
	}
982328
public function podiumEdit($isFirstPost = false)
    {
        $transaction = static::getDb()->beginTransaction();
        try {
            $this->edited = 1;
            $this->touch('edited_at');
            if (!$this->save()) {
                throw new Exception('Post saving error!');
            }
            if ($isFirstPost) {
                $this->thread->name = $this->topic;
                if (!$this->thread->save()) {
                    throw new Exception('Thread saving error!');
                }
            }
            $this->markSeen();
            $this->thread->touch('edited_post_at');

            $transaction->commit();
            Log::info('Post updated', $this->id, __METHOD__);
            return true;
        } catch (Exception $e) {
            $transaction->rollBack();
            Log::error($e->getMessage(), null, __METHOD__);
        }
        return false;
    }