Linear mapping from range <a1, a2> to range <b1, b2>
17453
function ( x, a1, a2, b1, b2 ) {

		return b1 + ( x - a1 ) * ( b2 - b1 ) / ( a2 - a1 );

	}
443833
def interp(mapping, x):
    
    mapping = sorted(mapping)
    if len(mapping) == 1:
        xa, ya = mapping[0]
        if xa == x:
            return ya
        return x
    for (xa, ya), (xb, yb) in zip(mapping[:-1], mapping[1:]):
        if xa <= x <= xb:
            return ya + float(x - xa) / (xb - xa) * (yb - ya)
    return x
228291
def sRGB1_to_sRGB1_linear(sRGB1):
    """"""
    sRGB1 = np.asarray(sRGB1, dtype=float)
    sRGB1_linear = C_linear(sRGB1)
    return sRGB1_linear
524214
def array_to_ranges(ar)
      prev = ar[0]

      ranges = ar.slice_before do |e|
        prev2 = prev
        prev = e
        prev2 + 1 != e
      end.map { |a| a[0]..a[-1] }

      ranges
    end
599835
def linear(self, limits=None, k=5):
        """"""
        start, stop = limits or (self.minval, self.maxval)
        return np.linspace(start, stop, k)
8822
def _adjust(a, a_offset, b):
    
    x = (b[-1] & 0xFF) + (a[a_offset + len(b) - 1] & 0xFF) + 1
    a[a_offset + len(b) - 1] = ctypes.c_ubyte(x).value
    x >>= 8

    for i in range(len(b)-2, -1, -1):
        x += (b[i] & 0xFF) + (a[a_offset + i] & 0xFF)
        a[a_offset + i] = ctypes.c_ubyte(x).value
        x >>= 8
700102
def _map(value, istart, istop, ostart, ostop):
    
    return ostart + (ostop - ostart) * ((value - istart) / (istop - istart))
145574
def linear(arr1, arr2):
    
    n = N.shape(arr1)[0]
    try:
        channels = N.shape(arr1)[1]
    except:
        channels = 1

    f_in = N.linspace(0, 1, num=n)
    f_out = N.linspace(1, 0, num=n)

    # f_in = N.arange(n) / float(n - 1)
    # f_out = N.arange(n - 1, -1, -1) / float(n)

    if channels > 1:
        f_in = N.tile(f_in, (channels, 1)).T
        f_out = N.tile(f_out, (channels, 1)).T

    vals = f_out * arr1 + f_in * arr2
    return vals
343128
private void linearScan(Relation<? extends O> relation, DBIDIter iter, O obj, double range, ModifiableDoubleDBIDList result) {
    final PrimitiveDistanceFunction<? super O> rawdist = this.rawdist;
    while(iter.valid()) {
      final double distance = rawdist.distance(obj, relation.get(iter));
      if(distance <= range) {
        result.add(distance, iter);
      }
      iter.advance();
    }
  }
509200
def _range(self, xloc, cache):
        
        uloc = numpy.zeros((2, len(self)))
        for dist in evaluation.sorted_dependencies(self, reverse=True):
            if dist not in self.inverse_map:
                continue
            idx = self.inverse_map[dist]
            xloc_ = xloc[idx].reshape(1, -1)
            uloc[:, idx] = evaluation.evaluate_bound(
                dist, xloc_, cache=cache).flatten()
        return uloc
697901
private void linearScan(Relation<? extends O> relation, DBIDIter iter, O obj, double range, ModifiableDoubleDBIDList result) {
    while(iter.valid()) {
      final double similarity = rawsim.similarity(obj, relation.get(iter));
      if(similarity >= range) {
        result.add(similarity, iter);
      }
      iter.advance();
    }
  }
1015852
function regualizedBeta(x, a, b) {
	if(x < 0 || x > 1) {
    throw new RangeError('First argument must be between 0 and 1.');
	}

  // Special cases, there can make trouble otherwise
  else if (a === 1 && b === 1) return x;
  else if (x === 0) return 0;
  else if (x === 1) return 1;
  else if (a === 0) return 1;
  else if (b === 0) return 0;

  else {
    var bt =
      Math.exp(gammaCollection.logGamma(a + b) -
      gammaCollection.logGamma(a) -
      gammaCollection.logGamma(b) +
      a * Math.log(x) +
      b * log1p(-x));

    // Use continued fraction directly.
    if (x < (a + 1) / (a + b + 2)) return bt * betacf(x, a, b) / a;
    // else use continued fraction after making the symmetry transformation.
    else return 1 - bt * betacf(1 - x, b, a) / b;
  }
}
1201372
private static double cross(Coordinate a1, Coordinate a2, Coordinate b1, Coordinate b2) {
		return (a2.getX() - a1.getX()) * (b2.getY() - b1.getY()) - (a2.getY() - a1.getY()) * (b2.getX() - b1.getX());
	}
329155
def array_map(f, ar):
    ""
    flat_ar = ravel(ar)
    out = zeros(len(flat_ar), flat_ar.typecode())
    for i in range(len(flat_ar)):
        out[i] = f(flat_ar[i])
    out.shape = ar.shape
    return out
297166
def nmap(a, b, c, d, curvefn=None, normfn=None):
    
    if not curvefn:
        curvefn = lambda x: x

    def map(n):
        r = 1.0 * (n - a) / (b - a)
        out = curvefn(r) * (d - c) + c
        if not normfn:
            return out
        return normfn(out)
    return map
1021077
private static final void mont_dbl(long10 t1, long10 t2, long10 t3, long10 t4,long10 bx, long10 bz) {
		sqr(t1, t3);
		sqr(t2, t4);
		mul(bx, t1, t2);
		sub(t2, t1, t2);
		mul_small(bz, t2, 121665);
		add(t1, t1, bz);
		mul(bz, t1, t2);
	}
111929
def t_seg(p1, p2, t, align=0):
    
    v = vector(p1, p2)
    result = {
        1: lambda a, b: (a, translate(b, scale(v, -t))),
        2: lambda a, b: (translate(a, scale(v, t)), b),
        0: lambda a, b: (translate(a, scale(v, t / 2)),
                         translate(b, scale(v, -t / 2)))
    }
    return result[align](p1, p2)