Returns True if expression is linear (a polynomial with degree 1 or 0) (read-only).
774343
def is_Linear(self):
        """"""
        coeff_dict = self.expression.as_coefficients_dict()
        for key in coeff_dict.keys():
            if len(key.free_symbols) < 2 and (key.is_Add or key.is_Mul or key.is_Atom):
                pass
            else:
                return False
            if key.is_Pow and key.args[1] != 1:
                return False
        else:
            return True
1258031
def _check_ising_linear_ranges(linear_ranges, graph):
        """"""
        if linear_ranges is None:
            linear_ranges = {}

        for v in graph:
            if v in linear_ranges:
                # check
                linear_ranges[v] = Specification._check_range(linear_ranges[v])
            else:
                # set default
                linear_ranges[v] = [-2, 2]

        return linear_ranges
297720
function linear (a, b) {
  if (!is.defined(a)) {
    this.options.linearA = 1.0;
  } else if (is.number(a)) {
    this.options.linearA = a;
  } else {
    throw new Error('Invalid linear transform multiplier ' + a);
  }

  if (!is.defined(b)) {
    this.options.linearB = 0.0;
  } else if (is.number(b)) {
    this.options.linearB = b;
  } else {
    throw new Error('Invalid linear transform offset ' + b);
  }

  return this;
}
149480
def interpolation_linear(x, x1, x2, y1, y2):
    
    m = (y2 - y1) / (x2 - x1)
    t = (x - x1)
    return m * t + y1
257756
public static boolean isZeros(DMatrixD1 m , double tol )
    {
        int length = m.getNumElements();

        for( int i = 0; i < length; i++ ) {
            if( Math.abs(m.get(i)) > tol )
                return false;
        }
        return true;
    }
126368
function canMultiplyLikeTermPolynomialNodes(node) {
  if (!Node.Type.isOperator(node) || node.op !== '*') {
    return false;
  }
  const args = node.args;
  if (!args.every(n => Node.PolynomialTerm.isPolynomialTerm(n))) {
    return false;
  }
  if (args.length === 1) {
    return false;
  }

  const polynomialTermList = node.args.map(n => new Node.PolynomialTerm(n));
  if (!polynomialTermList.every(polyTerm => !polyTerm.hasCoeff())) {
    return false;
  }

  const firstTerm = polynomialTermList[0];
  const restTerms = polynomialTermList.slice(1);
  // they're considered like terms if they have the same symbol name
  return restTerms.every(term => firstTerm.getSymbolName() === term.getSymbolName());
}
91354
def iscomplex(polynomial):
    
    if isinstance(polynomial, (int, float)):
        return False
    if isinstance(polynomial, complex):
        return True
    polynomial = polynomial.expand()
    for monomial in polynomial.as_coefficients_dict():
        for variable in monomial.as_coeff_mul()[1]:
            if isinstance(variable, complex) or variable == I:
                return True
    return False
191952
protected boolean bracket() {
//		System.out.println("------------- bracket");
		// the value of alpha was passed in
		function.setInput(stp);
		if( mode != 0 ) {
			fp = function.computeFunction();
			gp = Double.NaN;
		} else {
			mode = 1;
		}

		// check for upper bounds
		if( fp > valueZero + ftol * stp *derivZero ) {
			setModeToSection(stprev, fprev, stp);
			return false;
		}
		if( fp >= fprev) {
			setModeToSection(stprev, fprev, stp);
			return false;
		}

		gp = function.computeDerivative();
		if( Math.abs(gp) <= -gtol *derivZero ) {
			return true;
		}

		// if the derivative is positive it is on the other side of the dip and has
		// been bracketed
		if( gp >= 0 ) {
			setModeToSection(stp, fp, stprev);
			return false;
		}
		
		if( stmax <= 2*stp - stprev ) {
			stprev = stp;
			gprev = gp;
			fprev = fp;
			stp = stmax;
			updated = true;
		} else {
			// use interpolation to pick the next sample point
			double temp = stp;
			stp = interpolate(2*stp - stprev, Math.min(stpmax, stp +t1*(stp - stprev)));
			stprev = temp;
			gprev = gp;
			fprev = fp;
			updated = true;
		}

		// see if it is taking significant steps
		if( checkSmallStep() ) {
			if( verbose != null )
				verbose.println("WARNING: Small steps");
			return true;
		}

		return false;
	}
305165
def get_support(variables, polynomial):
    
    support = []
    if is_number_type(polynomial):
        support.append([0] * len(variables))
        return support
    for monomial in polynomial.expand().as_coefficients_dict():
        tmp_support = [0] * len(variables)
        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()
                tmp_support[variables.index(base)] = s.exp
            elif is_adjoint(s):
                tmp_support[variables.index(s.adjoint())] = 1
            elif isinstance(s, (Operator, Symbol)):
                tmp_support[variables.index(s)] = 1
        support.append(tmp_support)
    return support
783628
public static boolean isDiagonalPositive( DMatrixRMaj a ) {
        for( int i = 0; i < a.numRows; i++ ) {
            if( !(a.get(i,i) >= 0) )
                return false;
        }
        return true;
    }
640264
def _is_molecule_linear(self, mol):
        
        if mol.NumAtoms() < 3:
            return True
        a1 = mol.GetAtom(1)
        a2 = mol.GetAtom(2)
        for i in range(3, mol.NumAtoms()+1):
            angle = float(mol.GetAtom(i).GetAngle(a2, a1))
            if angle < 0.0:
                angle = -angle
            if angle > 90.0:
                angle = 180.0 - angle
            if angle > self._angle_tolerance:
                return False
        return True
407827
private static StaticAnalysisResult isListExpressionEmpty(ForNode node) {
    Optional<RangeArgs> rangeArgs = RangeArgs.createFromNode(node);
    if (rangeArgs.isPresent()) {
      return isRangeExpressionEmpty(rangeArgs.get());
    }
    ExprNode expr = node.getExpr().getRoot();
    if (expr instanceof ListLiteralNode) {
      return ((ListLiteralNode) expr).numChildren() > 0
          ? StaticAnalysisResult.FALSE
          : StaticAnalysisResult.TRUE;
    }
    return StaticAnalysisResult.UNKNOWN;
  }
910166
def pwl_to_poly(self):
        
        if self.pcost_model == PW_LINEAR:
            x0 = self.p_cost[0][0]
            y0 = self.p_cost[0][1]
            x1 = self.p_cost[1][0]
            y1 = self.p_cost[1][1]
            m = (y1 - y0) / (x1 - x0)
            c = y0 - m * x0

            self.pcost_model = POLYNOMIAL
            self.p_cost = (m, c)
        else:
            return
3142
function iszero(x, tolerance) {
    if (tolerance === void 0) { tolerance = constants_1.EPSILON; }
    // the 'less-than-equal' comparision is necessary for correct result
    // when tolerance = 0
    return Math.abs(x) <= tolerance;
}
138079
public static boolean isZero(long[] v) {
    for(int i = 0; i < v.length; i++) {
      if(v[i] != 0) {
        return false;
      }
    }
    return true;
  }
599835
def linear(self, limits=None, k=5):
        """"""
        start, stop = limits or (self.minval, self.maxval)
        return np.linspace(start, stop, k)
34442
function multiplyLikeTerms(node, polynomialOnly=false) {
  if (!Node.Type.isOperator(node)) {
    return Node.Status.noChange(node);
  }
  let status;

  if (!polynomialOnly) {
    status = arithmeticSearch(node);
    if (status.hasChanged()) {
      status.changeType = ChangeTypes.MULTIPLY_COEFFICIENTS;
      return status;
    }

    status = multiplyFractionsSearch(node);
    if (status.hasChanged()) {
      status.changeType = ChangeTypes.MULTIPLY_COEFFICIENTS;
      return status;
    }
  }

  status = multiplyPolynomialTerms(node);
  if (status.hasChanged()) {
    status.changeType = ChangeTypes.MULTIPLY_COEFFICIENTS;
    return status;
  }

  return Node.Status.noChange(node);
}