Evaluate given mathematical binary operation with given operands.
180807
def evaluate_binop_math(self, operation, left, right, **kwargs):
        
        if not operation in self.binops_math:
            raise ValueError("Invalid math binary operation '{}'".format(operation))
        if left is None or right is None:
            return None
        if not isinstance(left, (list, ListIP)):
            left = [left]
        if not isinstance(right, (list, ListIP)):
            right = [right]
        if not left or not right:
            return None
        try:
            vect = self._calculate_vector(operation, left, right)
            if len(vect) > 1:
                return vect
            return vect[0]
        except:
            return None
1021648
def _evaluate_standard(op, op_str, a, b, **eval_kwargs):
    
    if _TEST_MODE:
        _store_test_result(False)
    with np.errstate(all='ignore'):
        return op(a, b)
763603
def evaluate(self,n, features, stack_float, stack_bool,labels=None):
        """"""
        np.seterr(all='ignore')
        if len(stack_float) >= n.arity['f'] and len(stack_bool) >= n.arity['b']:
            if n.out_type == 'f':
                stack_float.append(
                    self.safe(self.eval_dict[n.name](n,features,stack_float,
                                                     stack_bool,labels)))
                if (np.isnan(stack_float[-1]).any() or
                    np.isinf(stack_float[-1]).any()):
                    print("problem operator:",n)
            else:
                stack_bool.append(self.safe(self.eval_dict[n.name](n,features,
                                                                   stack_float,
                                                                   stack_bool,
                                                                   labels)))
                if np.isnan(stack_bool[-1]).any() or np.isinf(stack_bool[-1]).any():
                    print("problem operator:",n)
281416
def eval(e, amplitude, e_0, e_break, alpha_1, alpha_2, e_cutoff, beta):
        """"""
        K = np.where(e < e_break, 1, (e_break / e_0) ** (alpha_2 - alpha_1))
        alpha = np.where(e < e_break, alpha_1, alpha_2)
        ee2 = e / e_cutoff
        return amplitude * K * (e / e_0) ** -alpha * np.exp(-(ee2 ** beta))
1132900
def _match_replace_binary(cls, ops: list) -> list:
    """"""
    n = len(ops)
    if n <= 1:
        return ops
    ops_left = ops[:n // 2]
    ops_right = ops[n // 2:]
    return _match_replace_binary_combine(
        cls,
        _match_replace_binary(cls, ops_left),
        _match_replace_binary(cls, ops_right))
23311
def multiply(self, other):
        """"""
        return self.operation(other, lambda x, y: x * y)
997398
public static function doBinaryOperation($left, $operator, $right)
    {
        if (self::$binaryOperations === null) {
            self::$binaryOperations = [
                    self::BITWISE_AND              => function ($l, $r) { return $l & $r; },
                    self::BITWISE_OR               => function ($l, $r) { return $l | $r; },
                    self::BITWISE_XOR              => function ($l, $r) { return $l ^ $r; },
                    self::SHIFT_LEFT               => function ($l, $r) { return $l << $r; },
                    self::SHIFT_RIGHT              => function ($l, $r) { return $l >> $r; },
                    self::LOGICAL_AND              => function ($l, $r) { return $l && $r; },
                    self::LOGICAL_OR               => function ($l, $r) { return $l || $r; },
                    self::ADDITION                 => function ($l, $r) { return $l + $r; },
                    self::SUBTRACTION              => function ($l, $r) { return $l - $r; },
                    self::MULTIPLICATION           => function ($l, $r) { return $l * $r; },
                    self::DIVISION                 => function ($l, $r) { return $l / $r; },
                    self::MODULUS                  => function ($l, $r) { return $l % $r; },
                    //Compatible with < PHP 5.6
                    self::POWER                    => function ($l, $r) { return pow($l, $r); },
                    self::CONCATENATION            => function ($l, $r) { return $l . $r; },
                    self::IS_INSTANCE_OF           => function ($l, $r) { return $l instanceof $r; },
                    self::EQUALITY                 => function ($l, $r) { return $l == $r; },
                    self::IDENTITY                 => function ($l, $r) { return $l === $r; },
                    self::INEQUALITY               => function ($l, $r) { return $l != $r; },
                    self::NOT_IDENTICAL            => function ($l, $r) { return $l !== $r; },
                    self::LESS_THAN                => function ($l, $r) { return $l < $r; },
                    self::LESS_THAN_OR_EQUAL_TO    => function ($l, $r) { return $l <= $r; },
                    self::GREATER_THAN             => function ($l, $r) { return $l > $r; },
                    self::GREATER_THAN_OR_EQUAL_TO => function ($l, $r) { return $l >= $r; },
            ];
        }

        if (!isset(self::$binaryOperations[$operator])) {
            throw new PinqException('Binary operator \'%s\' is not supported', $operator);
        }

        $operation = self::$binaryOperations[$operator];

        return $operation($left, $right);
    }
423990
private function _executeNumericBinaryOperation($cellID,$operand1,$operand2,$operation,$matrixFunction,&$stack) {
		//	Validate the two operands
		if (!$this->_validateBinaryOperand($cellID,$operand1,$stack)) return FALSE;
		if (!$this->_validateBinaryOperand($cellID,$operand2,$stack)) return FALSE;

		$executeMatrixOperation = FALSE;
		//	If either of the operands is a matrix, we need to treat them both as matrices
		//		(converting the other operand to a matrix if need be); then perform the required
		//		matrix operation
		if ((is_array($operand1)) || (is_array($operand2))) {
			//	Ensure that both operands are arrays/matrices
			$executeMatrixOperation = TRUE;
			$mSize = array();
			list($mSize[],$mSize[],$mSize[],$mSize[]) = self::_checkMatrixOperands($operand1,$operand2,2);

			//	But if they're both single cell matrices, then we can treat them as simple values
			if (array_sum($mSize) == 4) {
				$executeMatrixOperation = FALSE;
				$operand1 = $operand1[0][0];
				$operand2 = $operand2[0][0];
			}
		}

		if ($executeMatrixOperation) {
			try {
				//	Convert operand 1 from a PHP array to a matrix
				$matrix = new PHPExcel_Shared_JAMA_Matrix($operand1);
				//	Perform the required operation against the operand 1 matrix, passing in operand 2
				$matrixResult = $matrix->$matrixFunction($operand2);
				$result = $matrixResult->getArray();
			} catch (PHPExcel_Exception $ex) {
				$this->_debugLog->writeDebugLog('JAMA Matrix Exception: ', $ex->getMessage());
				$result = '#VALUE!';
			}
		} else {
			if ((PHPExcel_Calculation_Functions::getCompatibilityMode() != PHPExcel_Calculation_Functions::COMPATIBILITY_OPENOFFICE) &&
				((is_string($operand1) && !is_numeric($operand1)) || (is_string($operand2) && !is_numeric($operand2)))) {
				$result = PHPExcel_Calculation_Functions::VALUE();
			} else {
				//	If we're dealing with non-matrix operations, execute the necessary operation
				switch ($operation) {
					//	Addition
					case '+':
						$result = $operand1+$operand2;
						break;
					//	Subtraction
					case '-':
						$result = $operand1-$operand2;
						break;
					//	Multiplication
					case '*':
						$result = $operand1*$operand2;
						break;
					//	Division
					case '/':
						if ($operand2 == 0) {
							//	Trap for Divide by Zero error
							$stack->push('Value','#DIV/0!');
							$this->_debugLog->writeDebugLog('Evaluation Result is ', $this->_showTypeDetails('#DIV/0!'));
							return FALSE;
						} else {
							$result = $operand1/$operand2;
						}
						break;
					//	Power
					case '^':
						$result = pow($operand1,$operand2);
						break;
				}
			}
		}

		//	Log the result details
		$this->_debugLog->writeDebugLog('Evaluation Result is ', $this->_showTypeDetails($result));
		//	And push the result onto the stack
		$stack->push('Value',$result);
		return TRUE;
	}
931314
def bitwise_or(self, t):
        
        """
        This implementation combines the approaches used by 'WYSINWYX: what you see is not what you execute'
        paper and 'Signedness-Agnostic Program Analysis: Precise Integer Bounds for Low-Level Code'. The
        first paper provides an sound way to approximate the stride, whereas the second provides a way
        to calculate the or operation using wrapping intervals.
        Note that, even though according Warren's work 'Hacker's delight', one should follow different
        approaches to calculate the minimun/maximum values of an or operations according on the type
        of the operands (signed/unsigned). On the other other hand, by splitting the wrapping-intervals
        at the south pole, we can safely and soundly only use the Warren's functions for unsigned
        integers.
        """
        s = self
        result_interval = list()

        for u in s._ssplit():
            for v in t._ssplit():
                w = u.bits
                # u |w v
                if u.is_integer:
                    s_t = StridedInterval._ntz(v.stride)
                elif v.is_integer:
                    s_t = StridedInterval._ntz(u.stride)
                else:
                    s_t = min(StridedInterval._ntz(u.stride), StridedInterval._ntz(v.stride))

                if u.is_integer and u.lower_bound == 0:
                    new_stride = v.stride
                elif v.is_integer and v.lower_bound == 0:
                    new_stride = u.stride
                else:
                    new_stride = 2 ** s_t
                mask = (1 << s_t) - 1
                r = (u.lower_bound & mask) | (v.lower_bound & mask)
                m = (2 ** w) - 1
                low_bound = WarrenMethods.min_or(u.lower_bound & (~mask & m), u.upper_bound & (~mask & m), v.lower_bound & (~mask & m), v.upper_bound & (~mask & m), w)
                upper_bound = WarrenMethods.max_or(u.lower_bound & (~mask & m), u.upper_bound & (~mask & m), v.lower_bound & (~mask & m), v.upper_bound & (~mask & m), w)
                if low_bound == upper_bound:
                    new_stride = 0

                new_interval = StridedInterval(lower_bound=((low_bound & (~mask & m)) | r), upper_bound=((upper_bound & (~mask & m)) | r), bits=w, stride=new_stride)
                result_interval.append(new_interval)

        return StridedInterval.least_upper_bound(*result_interval).normalize()
219046
def evaluate(self):
        """"""

        if self.opt['AccurateDFid']:
            DX = self.reconstruct()
            S = self.xstep.S
            dfd = (np.linalg.norm(self.xstep.W * (DX - S))**2) / 2.0
            if self.xmethod == 'fista':
                X = self.xstep.getcoef()
            else:
                X = self.xstep.var_y1()
            rl1 = np.sum(np.abs(X))
            return dict(DFid=dfd, RegL1=rl1,
                        ObjFun=dfd + self.xstep.lmbda * rl1)
        else:
            return None
275807
def arithmetic(self, operation, operand1, operand2, operand3 = None):
        
        if isinstance(operand1, int):
            output_type = self.symtab.get_type(operand1)
            self.free_if_register(operand1)
        else:
            output_type = None
        if isinstance(operand2, int):
            output_type = self.symtab.get_type(operand2) if output_type == None else output_type
            self.free_if_register(operand2)
        else:
            output_type = SharedData.TYPES.NO_TYPE if output_type == None else output_type
        #if operand3 is not defined, reserve one free register for it
        output = self.take_register(output_type) if operand3 == None else operand3
        mnemonic = self.arithmetic_mnemonic(operation, output_type)
        self.newline_text("{0}\t{1},{2},{3}".format(mnemonic, self.symbol(operand1), self.symbol(operand2), self.symbol(output)), True)
        return output
463052
def from_bin(cls, value):
        """"""
        value = value.lstrip('b')
        if len(value) == 32:
            return cls(int(value, 2))
        elif len(value) == 128:
            return cls(int(value, 2))
        else:
            return ValueError('%r: invalid binary notation' % (value,))
1282775
def binary_op(data, op, other, blen=None, storage=None, create='array',
              **kwargs):
    """"""

    # normalise scalars
    if hasattr(other, 'shape') and len(other.shape) == 0:
        other = other[()]

    if np.isscalar(other):
        def f(block):
            return op(block, other)
        return map_blocks(data, f, blen=blen, storage=storage, create=create, **kwargs)

    elif len(data) == len(other):
        def f(a, b):
            return op(a, b)
        return map_blocks((data, other), f, blen=blen, storage=storage, create=create,
                          **kwargs)

    else:
        raise NotImplementedError('argument type not supported')
400369
def _eval_unaryop(self, node):
        
        return self.operators[type(node.op)](self._eval(node.operand))
487108
def eval_proxop(self, V):
        """"""

        return np.asarray(sp.prox_l1(V, (self.lmbda / self.L) * self.wl1),
                          dtype=self.dtype)
127032
def operator_is(u):
    """"""
    global _aux
    if np.ndim(u) == 2:
        P = _P2
    elif np.ndim(u) == 3:
        P = _P3
    else:
        raise ValueError("u has an invalid number of dimensions "
                         "(should be 2 or 3)")
    
    if u.shape != _aux.shape[1:]:
        _aux = np.zeros((len(P),) + u.shape)
    
    for _aux_i, P_i in zip(_aux, P):
        _aux_i[:] = binary_dilation(u, P_i)
    
    return _aux.min(0)
617632
def is_binary_operator(oper):
    """"""
    # definition:
    # member in class
    # ret-type operator symbol(arg)
    # globally
    # ret-type operator symbol( arg1, arg2 )
    symbols = [
        ',', '()', '[]', '!=', '%', '%=', '&', '&&', '&=', '*', '*=', '+',
        '+=', '-', '-=', '->', '->*', '/', '/=', '<', '<<', '<<=', '<=', '=',
        '==', '>', '>=', '>>', '>>=', '^', '^=', '|', '|=', '||']
    if not isinstance(oper, calldef_members.operator_t):
        return False
    if oper.symbol not in symbols:
        return False

    if isinstance(oper, calldef_members.member_operator_t):
        if len(oper.arguments) == 1:
            return True
        return False

    if len(oper.arguments) == 2:
        return True
    return False