当前位置: 首页>>代码示例>>Python>>正文


Python cgutils.guard_zero函数代码示例

本文整理汇总了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)
开发者ID:whalen53,项目名称:numba,代码行数:7,代码来源:builtins.py

示例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()
开发者ID:whalen53,项目名称:numba,代码行数:31,代码来源:builtins.py

示例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
开发者ID:whalen53,项目名称:numba,代码行数:8,代码来源:builtins.py

示例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
开发者ID:maartenscholl,项目名称:numba,代码行数:9,代码来源:listobj.py

示例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)
开发者ID:cpcloud,项目名称:numba,代码行数:12,代码来源:listobj.py

示例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
开发者ID:whalen53,项目名称:numba,代码行数:5,代码来源:builtins.py

示例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
开发者ID:whalen53,项目名称:numba,代码行数:5,代码来源:builtins.py

示例8: real_div_impl

def real_div_impl(context, builder, sig, args):
    cgutils.guard_zero(context, builder, args[1])
    return builder.fdiv(*args)
开发者ID:whalen53,项目名称:numba,代码行数:3,代码来源:builtins.py

示例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
开发者ID:whalen53,项目名称:numba,代码行数:5,代码来源:builtins.py

示例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)
开发者ID:whalen53,项目名称:numba,代码行数:4,代码来源:builtins.py

示例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)
开发者ID:whalen53,项目名称:numba,代码行数:6,代码来源:builtins.py


注:本文中的numba.cgutils.guard_zero函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。