def RcompUnits_mult_lowersets_continuous(A, a, B, b, C): """ Multiplication on Rcompunits, extended for top, so that top*0 = Top """ from mcdp_posets.poset import is_top if is_top(A, a) or is_top(B, b): return C.get_top() mcdp_dev_warning('catch overflow') return a * b
def _call(self, x): if is_top(self.dom, x): return self.cod.get_top() assert isinstance(x, float) # XXX: overflow? r = int(math.ceil(x)) return r
def _call(self, x): if is_top(self.dom, x): return self.cod.get_top() r = int(x) if r != x: msg = 'We cannot just coerce %r into an int.' % x raise MapNotDefinedHere(msg) return r
def _call(self, x): if is_top(self.dom, x): return self.cod.get_top() try: return float(x) except BaseException as e: msg = 'Internal error in PromoteToFloat.' raise_wrapped(DPInternalError, e, msg, x=x)
def Nat_mult_lowersets_continuous(a, b): """ Multiplication on Nat, extended for top, so that top*0 = Top """ from mcdp_posets.poset import is_top N = Nat_add_Nat if is_top(N, a) or is_top(N, b): return Nat_add_top assert isinstance(a, int), (a, type(a)) assert isinstance(b, int), (b, type(b)) res = a * b if res > sys.maxint: return N.get_top() assert isinstance(res, int), (res, type(res)) return res
def Nat_add(a, b): """ Addition on Nat, extended for top """ from mcdp_posets.poset import is_top N = Nat_add_Nat if is_top(N, a) or is_top(N, b): return Nat_add_top mcdp_dev_warning('catch overflow') assert isinstance(a, int), (a, type(a)) assert isinstance(b, int), (b, type(b)) res = a + b if res > sys.maxint: return N.get_top() assert isinstance(res, int), (res, type(res)) return res
def _call(self, x): if is_top(self.dom, x): return self.cod.get_top() if np.isinf(x): return self.cod.get_top() y = self.op(x) if np.isinf(y): return self.cod.get_top() return y
def Nat_mult_uppersets_continuous(a, b): """ Multiplication on Nat, extended for top, so that top*0 = 0 """ from mcdp_posets.poset import is_top N = Nat_add_Nat a_is_zero = a == 0 b_is_zero = b == 0 if a_is_zero or b_is_zero: return 0 if is_top(N, a) or is_top(N, b): return Nat_add_top mcdp_dev_warning('catch overflow') assert isinstance(a, int), (a, type(a)) assert isinstance(b, int), (b, type(b)) res = a * b if res > sys.maxint: return N.get_top() assert isinstance(res, int), (res, type(res)) return res
def solve(self, f): n = self.n Fbot = self.Fbot if is_bottom(self.F, f): return self.R.U(self.R.get_bottom()) elif is_top(self.F, f): return self.R.U(self.R.get_top()) else: minimals = set() for i in range(n): tops = [Fbot] * n tops[i] = f minimals.add(tuple(tops)) return self.R.Us(minimals)
def solve_r(self, r): Rtop = self.Rtop n = self.n if is_top(self.R, r): return self.F.L(self.F.get_top()) elif is_bottom(self.R, r): return self.F.L(self.F.get_bottom()) else: maximals = set() for i in range(n): tops = [Rtop] * n tops[i] = r maximals.add(tuple(tops)) return self.F.Ls(maximals)