Creates the generator function with the specified polynomial degree. The generator function is composed
of factors of (x-a_n) where a_n is a power of 2.<br>

g<sub>4</sub>(x) = (x - α0) (x - α1) (x - α2) (x - α3) = 01 x4 + 0f x3 + 36 x2 + 78 x + 40
198168
void generator( int degree ) {
		// initialize to a polynomial = 1
		initToOne(generator,degree+1);

		// (1*x - a[i])
		tmp1.resize(2);
		tmp1.data[0] = 1;
		for (int i = 0; i < degree; i++) {
			tmp1.data[1] = (byte)math.power(2,i);
			math.polyMult(generator,tmp1,tmp0);
			generator.setTo(tmp0);
		}
	}
113064
function pmf( x, p ) {
	var q;
	if ( x !== x) {
		return NaN;
	}
	if ( isNonNegativeInteger( x ) ) {
		q = 1 - p;
		return p * pow( q, x );
	}
	return 0;
}
888940
def _hensel_lift(g0, f0, _char, height, where)
      # self in MPolynomial/ZorZp
      # g0 in Polyomial/ZorZp, candidate of factor of f0
      # f0 in Polyomial/ZoZzp, one variable reduction of self

      ring = self.class
      ring_one = g0.class

      h0, r0 = f0.divmod g0
      raise 'each_product does not work well' unless r0.zero?

      #    where = 0
      ary = [g0, h0]
      cofacts = mk_cofacts(ary)
      fk = ary.collect { |fx| fx.value_on_one(ring, where) } # MPolynomial

      height.times do |k|
        c = self - fk[0] * fk[1]
        h = c.annihilate_away_from(where, k + 1)
        h_alpha0 = h.collect_away_from(where, ring_one) # Hash: ind0=>Polynomial
        h_alpha = {}

        h_alpha0.each do |ind, ha|
          h_alpha[ind] = yield(ha, ary, cofacts)
        end

        hias = ary.collect { {} }
        h_alpha.each do |ind, ha_i|
          ha_i.each_with_index do |fx, i|
            next if fx.zero?
            hias[i][ind] = fx
          end
        end

        hi = hias.collect do |hia|
          e = ring.zero
          hia.each do |ind, fx|
            e += ring.monomial(ind) * fx.value_on_one(ring, where)
          end
          e
        end
        fk_new = []
        hi.each_with_index do |fx, i|
          fk_new.push fk[i] + fx
        end
        fk = fk_new
      end
      fk
    end
830531
def next_power_of_2(x):
    

    power_of_2 = 1 if x == 0 else 2 ** np.ceil(np.log2(x))
    return power_of_2
344534
def mul_at(self, other, k):
        ''''''
        if k > (self.degree + other.degree) or k > self.degree: return 0 # optimization: if the required coefficient is above the maximum coefficient of the resulting polynomial, we can already predict that and just return 0

        term = 0

        for i in _range(min(len(self), len(other))):
            coef1 = self.coefficients[-(k-i+1)]
            coef2 = other.coefficients[-(i+1)]
            if coef1 == 0 or coef2 == 0: continue # log(0) is undefined, skip (and in addition it's a nice optimization)
            term += coef1 * coef2
        return term
1233353
def polynomial(img, mask, inplace=False, replace_all=False,
               max_dev=1e-5, max_iter=20, order=2):
    '''
    
    '''
    if inplace:
        out = img
    else:
        out = img.copy()
    lastm = 0
    for _ in range(max_iter):
        out2 = polyfit2dGrid(out, mask, order=order, copy=not inplace,
                             replace_all=replace_all)
        if replace_all:
            out = out2
            break
        res = (np.abs(out2 - out)).mean()
        print('residuum: ', res)
        if res < max_dev:
            out = out2
            break
        out = out2
        mask = _highGrad(out)

        m = mask.sum()
        if m == lastm or m == img.size:
            break
        lastm = m
    out = np.clip(out, 0, 1, out=out)  # if inplace else None)
    return out
253398
def rs_generator_poly(nsym, fcr=0, generator=2):
    ''''''
    g = bytearray([1])
    for i in xrange(nsym):
        g = gf_poly_mul(g, [1, gf_pow(generator, i+fcr)])
    return g
741166
function bgrat(a, b, x) {
      var T, fTs, u, logH, logM, lnx2s, lnx2sn, ps, cs, j, ser;

      T = a + 0.5 * (b - 1);
      fTs = 1 / (4 * T * T);
      u = -T * Math.log(x);
      logH = Math.log(b) + log1p(gam1(b)) + b * Math.log(u) - u;
      logM = logH - (algdiv(b, a) + b * Math.log(T));
      cs = [1];   // cs[n] = 1 / (2n + 1)!
      ps = [1];   // ps[n] = p_n in (9.3)
      lnx2s = Math.log(x) * 0.5;   // (ln(x) / 2) ^ 2
      lnx2s *= lnx2s;
      lnx2sn = 1;   // lnx2s ^ n
      j = gratR(b, u, logH);
      ser =
      Math.log(
         series(function(n) {
            var mbmn; // holds m*b - n

            mbmn = -n;
            if (n > 0) {
               j = (b + 2 * n - 2) * (b + 2 * n - 2 + 1) * j +
                     (u + b + 2 * n - 2 + 1) * lnx2sn;
               j *= fTs;
               cs[n] = cs[n - 1] / (2 * n) / (2 * n + 1);
               ps[n] = (b - 1) * cs[n] + 1 / n * series(function(m) {
                  if (m === 0) { return 0; }
                  mbmn += b;
                  return mbmn * cs[m] * ps[n - m];
               }, n);
               lnx2sn *= lnx2s;
            }
            return ps[n] * j;
         })
      );
      return logM + ser;
   }
114145
private static double gCf(double x, double A) {
       // Good for X>A+1
       double A0=0;
       double B0=1;
       double A1=1;
       double B1=x;
       double AOLD=0;
       double N=0;
       while (Math.abs((A1-AOLD)/A1)>.00001) {
           AOLD=A1;
           N=N+1;
           A0=A1+(N-A)*A0;
           B0=B1+(N-A)*B0;
           A1=x*A0+N*A1;
           B1=x*B0+N*B1;
           A0=A0/B1;
           B0=B0/B1;
           A1=A1/B1;
           B1=1;
       }
       double Prob=Math.exp(A*Math.log(x)-x-logGamma(A))*A1;

       return 1.0-Prob;
    }
423595
function calc_crc8(buf, len)
{
    var dataandcrc;
    // Generator polynomial: x**8 + x**5 + x**4 + 1 = 1001 1000 1
    var poly = 0x98800000;
    var i;

    if (len === null) return -1;
    if (len != 3) return -1;
    if (buf === null) return -1;

    // Justify the data on the MSB side. Note the poly is also
    // justified the same way.
    dataandcrc = (buf[0] << 24) | (buf[1] << 16) | (buf[2] << 8);
    for (i = 0; i < 24; i++) {
        if (dataandcrc & 0x80000000)
            dataandcrc ^= poly;
        dataandcrc <<= 1;
    }
    return (dataandcrc === 0);
}
823321
def make_polynomial(degree=3, n_samples=100, bias=0.0, noise=0.0,
                    return_coefs=False, random_state=None):
    
    generator = check_random_state(random_state)

    # TODO: Add arguments to support other priors
    coefs = generator.randn(degree + 1)
    pows = np.arange(degree + 1)
    poly = np.vectorize(lambda x: np.sum(coefs * x ** pows))
    X, y = make_regression(poly, n_samples=n_samples, bias=bias, noise=noise,
                           random_state=random_state)
    if return_coefs:
        return X, y, coefs

    return X, y
152239
def get_support_variables(polynomial):
    
    support = []
    if is_number_type(polynomial):
        return support
    for monomial in polynomial.expand().as_coefficients_dict():
        mon, _ = __separate_scalar_factor(monomial)
        symbolic_support = flatten(split_commutative_parts(mon))
        for s in symbolic_support:
            if isinstance(s, Pow):
                base = s.base
                if is_adjoint(base):
                    base = base.adjoint()
                support.append(base)
            elif is_adjoint(s):
                support.append(s.adjoint())
            elif isinstance(s, Operator):
                support.append(s)
    return support
23777
function() { 
            var a = this.clone(),
                i = 1,
                b = a.clone().diff(),
                c = a.clone().gcd(b),
                w = a.divide(c)[0];
            var output = Polynomial.fromArray([new Frac(1)], a.variable);
            while(!c.equalsNumber(1)) { 
                var y = w.gcd(c); 
                var z = w.divide(y)[0];
                //one of the factors may have shown up since it's square but smaller than the 
                //one where finding
                if(!z.equalsNumber(1) && i>1) {
                    var t = z.clone();
                    for(var j=1; j<i; j++)
                        t.multiply(z.clone());
                    z = t;
                }
                output = output.multiply(z); 
                i++;
                w = y;
                c = c.divide(y)[0];
            }
            return [output, w, i];
        }
187349
def _to_binpoly(x):
        ''''''
        if x <= 0: return "0"
        b = 1 # init to 2^0 = 1
        c = [] # stores the degrees of each term of the polynomials
        i = 0 # counter for b = 2^i
        while x > 0:
            b = (1 << i) # generate a number power of 2: 2^0, 2^1, 2^2, ..., 2^i. Equivalent to b = 2^i
            if x & b : # then check if x is divisible by the power of 2. Equivalent to x % 2^i == 0
                # If yes, then...
                c.append(i) # append this power (i, the exponent, gives us the coefficient)
                x ^= b # and compute the remainder of x / b
            i = i+1 # increment to compute the next power of 2
        return " + ".join(["x^%i" % y for y in c[::-1]])
265714
function _exponentiate($x)
    {
        switch (true) {
            case empty($this->primes):
            case $this->primes[1]->equals($this->zero):
            case empty($this->coefficients):
            case $this->coefficients[2]->equals($this->zero):
            case empty($this->exponents):
            case $this->exponents[1]->equals($this->zero):
                return $x->modPow($this->exponent, $this->modulus);
        }

        $num_primes = count($this->primes);

        if (defined('CRYPT_RSA_DISABLE_BLINDING')) {
            $m_i = array(
                1 => $x->modPow($this->exponents[1], $this->primes[1]),
                2 => $x->modPow($this->exponents[2], $this->primes[2])
            );
            $h = $m_i[1]->subtract($m_i[2]);
            $h = $h->multiply($this->coefficients[2]);
            list(, $h) = $h->divide($this->primes[1]);
            $m = $m_i[2]->add($h->multiply($this->primes[2]));

            $r = $this->primes[1];
            for ($i = 3; $i <= $num_primes; $i++) {
                $m_i = $x->modPow($this->exponents[$i], $this->primes[$i]);

                $r = $r->multiply($this->primes[$i - 1]);

                $h = $m_i->subtract($m);
                $h = $h->multiply($this->coefficients[$i]);
                list(, $h) = $h->divide($this->primes[$i]);

                $m = $m->add($r->multiply($h));
            }
        } else {
            $smallest = $this->primes[1];
            for ($i = 2; $i <= $num_primes; $i++) {
                if ($smallest->compare($this->primes[$i]) > 0) {
                    $smallest = $this->primes[$i];
                }
            }

            $one = new Math_BigInteger(1);

            $r = $one->random($one, $smallest->subtract($one));

            $m_i = array(
                1 => $this->_blind($x, $r, 1),
                2 => $this->_blind($x, $r, 2)
            );
            $h = $m_i[1]->subtract($m_i[2]);
            $h = $h->multiply($this->coefficients[2]);
            list(, $h) = $h->divide($this->primes[1]);
            $m = $m_i[2]->add($h->multiply($this->primes[2]));

            $r = $this->primes[1];
            for ($i = 3; $i <= $num_primes; $i++) {
                $m_i = $this->_blind($x, $r, $i);

                $r = $r->multiply($this->primes[$i - 1]);

                $h = $m_i->subtract($m);
                $h = $h->multiply($this->coefficients[$i]);
                list(, $h) = $h->divide($this->primes[$i]);

                $m = $m->add($r->multiply($h));
            }
        }

        return $m;
    }
953618
def factorial(n):
    
    f = 1
    while (n > 0):
        f = f * n
        n = n - 1
    return f
213248
def create_factor_general(self, *args, **kwargs):
        
        try:
            return self.create_factor(*args, **kwargs)
        except TypeError:
            pass
        try:
            return self.create_multi_output_factor(*args, **kwargs)
        except TypeError:
            pass
        try:
            return self.create_node_creation_factor(*args, **kwargs)
        except TypeError:
            pass
        raise FactorDefinitionError("Could not find a matching signature")