本文整理汇总了Python中numba.cgutils.guard_zero函数的典型用法代码示例。如果您正苦于以下问题:Python guard_zero函数的具体用法?Python guard_zero怎么用?Python guard_zero使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了guard_zero函数的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: int_udiv_impl
def int_udiv_impl(context, builder, sig, args):
[va, vb] = args
[ta, tb] = sig.args
a = context.cast(builder, va, ta, sig.return_type)
b = context.cast(builder, vb, tb, sig.return_type)
cgutils.guard_zero(context, builder, b)
return builder.udiv(a, b)
示例2: complex_div_impl
def complex_div_impl(context, builder, sig, args):
"""
z = c^2 + d^2
(a+bi)/(c+di) = (ac + bd) / z, (bc - ad) / z
"""
[cx, cy] = args
complexClass = context.make_complex(sig.args[0])
x = complexClass(context, builder, value=cx)
y = complexClass(context, builder, value=cy)
z = complexClass(context, builder)
a = x.real
b = x.imag
c = y.real
d = y.imag
ac = builder.fmul(a, c)
bd = builder.fmul(b, d)
ad = builder.fmul(a, d)
bc = builder.fmul(b, c)
cc = builder.fmul(c, c)
dd = builder.fmul(d, d)
zz = builder.fadd(cc, dd)
ac_bd = builder.fadd(ac, bd)
bc_ad = builder.fsub(bc, ad)
cgutils.guard_zero(context, builder, zz)
z.real = builder.fdiv(ac_bd, zz)
z.imag = builder.fdiv(bc_ad, zz)
return z._getvalue()
示例3: int_sdiv_impl
def int_sdiv_impl(context, builder, sig, args):
[va, vb] = args
[ta, tb] = sig.args
a = context.cast(builder, va, ta, sig.return_type)
b = context.cast(builder, vb, tb, sig.return_type)
cgutils.guard_zero(context, builder, b)
div, _ = int_divmod(context, builder, a, b)
return div
示例4: list_pop
def list_pop(context, builder, sig, args):
inst = ListInstance(context, builder, sig.args[0], args[0])
n = inst.size
cgutils.guard_zero(context, builder, n, (IndexError, "pop from empty list"))
n = builder.sub(n, ir.Constant(n.type, 1))
res = inst.getitem(n)
inst.resize(n)
return res
示例5: list_pop
def list_pop(context, builder, sig, args):
inst = ListInstance(context, builder, sig.args[0], args[0])
n = inst.size
cgutils.guard_zero(context, builder, n,
(IndexError, "pop from empty list"))
n = builder.sub(n, ir.Constant(n.type, 1))
res = inst.getitem(n)
inst.incref_value(res) # incref the pop'ed element
inst.clear_value(n) # clear the storage space
inst.resize(n)
return impl_ret_new_ref(context, builder, sig.return_type, res)
示例6: real_floordiv_impl
def real_floordiv_impl(context, builder, sig, args):
x, y = args
cgutils.guard_zero(context, builder, y)
quot, _ = real_divmod(context, builder, x, y)
return quot
示例7: real_mod_impl
def real_mod_impl(context, builder, sig, args):
x, y = args
cgutils.guard_zero(context, builder, y)
_, rem = real_divmod(context, builder, x, y)
return rem
示例8: real_div_impl
def real_div_impl(context, builder, sig, args):
cgutils.guard_zero(context, builder, args[1])
return builder.fdiv(*args)
示例9: int_srem_impl
def int_srem_impl(context, builder, sig, args):
x, y = args
cgutils.guard_zero(context, builder, y)
_, rem = int_divmod(context, builder, x, y)
return rem
示例10: int_ufloordiv_impl
def int_ufloordiv_impl(context, builder, sig, args):
x, y = args
cgutils.guard_zero(context, builder, y)
return builder.udiv(x, y)
示例11: int_utruediv_impl
def int_utruediv_impl(context, builder, sig, args):
x, y = args
fx = builder.uitofp(x, Type.double())
fy = builder.uitofp(y, Type.double())
cgutils.guard_zero(context, builder, y)
return builder.fdiv(fx, fy)