Factor out coefficients of all factors.
773349
def factor_coeff(cls, ops, kwargs):
    """"""
    coeffs, nops = zip(*map(_coeff_term, ops))
    coeff = 1
    for c in coeffs:
        coeff *= c
    if coeff == 1:
        return nops, coeffs
    else:
        return coeff * cls.create(*nops, **kwargs)
614842
public Factor getFactorByName(String name) {
    int index = getFactorIndexByName(name);
    if (index == -1) {
      return null;
    }
    return factors[index];
  }
864864
function factorMultiplicands(node) {
  const newNode = clone(node);
  const radicandNode = getRadicandNode(node);

  let children = [];
  let factored = false;
  radicandNode.args.forEach(child => {
    if (Node.PolynomialTerm.isPolynomialTerm(child)) {
      const polyTerm = new Node.PolynomialTerm(child);
      const coeffNode = polyTerm.getCoeffNode();
      const polyTermNoCoeff = Node.Creator.polynomialTerm(
        polyTerm.getSymbolNode(), polyTerm.getExponentNode(), null);
      if (coeffNode) {
        const factorNodes = getFactorNodes(coeffNode);
        if (factorNodes.length > 1) {
          factored = true;
        }
        children = children.concat(factorNodes);
      }
      children.push(polyTermNoCoeff);
    }
    else {
      const factorNodes = getFactorNodes(child);
      if (factorNodes.length > 1) {
        factored = true;
      }
      children = children.concat(factorNodes);
    }
  });

  if (factored) {
    newNode.args[0] = Node.Creator.operator('*', children);
    return Node.Status.nodeChanged(
      ChangeTypes.FACTOR_INTO_PRIMES, node, newNode);
  }

  return Node.Status.noChange(node);
}
760169
def factorize_and_solve(self, A, b):
        

        self.factorize(A)

        return self.solve(b)
827292
public static List<DiscreteFactor> coerceToDiscrete(Collection<Factor> factors) {
    List<DiscreteFactor> returnFactors = Lists.newArrayList();
    for (Factor factor : factors) {
      returnFactors.add(factor.coerceToDiscrete());
    }
    return returnFactors;
  }
1339980
function factorizeArray(n) {
    let factors = [];
    factorize(n, factor => {
        factors.push(factor);
    });
    return factors;
}
634782
def majorize(values):
    """"""
    sorted_values = sorted(values)
    if len(values) <= 3 or (
            abs(2 * sorted_values[1] - sorted_values[0] - sorted_values[2]) >
            abs(1.5 * (sorted_values[1] - sorted_values[0]))):
        return []
    values_step = sorted_values[1] - sorted_values[0]
    full_range = sorted_values[-1] - sorted_values[0]
    step = 10**int(log10(full_range))
    if step == values_step:
        step *= 10
    step_factor = 10**(int(log10(step)) + 1)
    if round(step * step_factor) % (round(values_step * step_factor) or 1):
        # TODO: Find lower common multiple instead
        step *= values_step
    if full_range <= 2 * step:
        step *= .5
    elif full_range >= 5 * step:
        step *= 5
    major_values = [
        value for value in values if value / step == round(value / step)
    ]
    return [value for value in sorted_values if value in major_values]
27978
def factorize(self, A):
        
        
        A = csc_matrix(A)
        if self.prop == self.SYMMETRIC:
            A = (A + A.T) - triu(A)

        self.lu = self.umfpack.splu(A)
852039
def calculate_columns(self):
        """"""

        self.cols = int(math.ceil(len(self.elements) / float(self.rows)))
1075994
def get_factors_iterative2(n):
    

    ans, stack, x = [], [], 2
    while True:
        if x > n // x:
            if not stack:
                return ans
            ans.append(stack + [n])
            x = stack.pop()
            n *= x
            x += 1
        elif n % x == 0:
            stack.append(x)
            n //= x
        else:
            x += 1
342838
def upsample(self, factor):
        """"""
        self.command.append("upsample")
        self.command.append(factor)
        return self
724666
private static int[] getFactors(int _value, int _max) {
      final int factors[] = new int[MAX_GROUP_SIZE];
      int factorIdx = 0;

      for (int possibleFactor = 1; possibleFactor <= _max; possibleFactor++) {
         if ((_value % possibleFactor) == 0) {
            factors[factorIdx++] = possibleFactor;
         }
      }

      return (Arrays.copyOf(factors, factorIdx));
   }
1016547
def _get_factors(self, element):
        
        gdim = None
        sdim = None
        if element.ndims == 1:
            pass
        elif not (self.stacked or self.stack_index):
            gdim = element.get_dimension(1)
        else:
            sdim = element.get_dimension(1)

        xdim, ydim = element.dimensions()[:2]
        xvals = element.dimension_values(0, False)
        xvals = [x if xvals.dtype.kind in 'SU' else xdim.pprint_value(x)
                 for x in xvals]
        if gdim and not sdim:
            gvals = element.dimension_values(gdim, False)
            xvals = sorted([(x, g) for x in xvals for g in gvals])
            is_str = gvals.dtype.kind in 'SU'
            xvals = [(x, g if is_str else gdim.pprint_value(g)) for (x, g) in xvals]
        coords = xvals, []
        if self.invert_axes: coords = coords[::-1]
        return coords
847049
function factorizeHash(n) {
    let factors = {};
    factorize(n, factor => {
        if (factors[factor]) {
            factors[factor] += 1;
        } else {
            factors[factor] = 1;
        }
    });
    return factors;
}
8486
def phi( n ):
  """"""

  assert isinstance( n, integer_types )

  if n < 3: return 1

  result = 1
  ff = factorization( n )
  for f in ff:
    e = f[1]
    if e > 1:
      result = result * f[0] ** (e-1) * ( f[0] - 1 )
    else:
      result = result * ( f[0] - 1 )
  return result
176879
def factors(self, rank):
        
        self._check_rank(rank)
        return [result.factors for result in self.results[rank]]
866793
def _compute_f1_factor(self, rrup):
        
        # f1 = min(log10(rrup),log10(R1))
        f1 = np.log10(rrup)
        logR1 = np.log10(self.COEFFS_IMT_INDEPENDENT['R1'])
        f1[f1 > logR1] = logR1

        return f1