(ctx, mpf_f, mpc_f=None, mpi_f=None, doc="<no doc>")
return f
Given a low-level mpf_ function, and optionally similar functions
        for mpc_ and mpi_, defines the function as a context method.

        It is assumed that the return type is the same as that of
        the input; the exception is that propagation from mpf to mpc is possible
        by raising ComplexResult.
Given a low-level mpf_ function, and optionally similar functions
        for mpc_ and mpi_, defines the function as a context method.
Given a low - level mpf_ function and optionally similar functions for mpc_ and mpi_ defines the function as a context method .
def _wrap_libmp_function(ctx, mpf_f, mpc_f=None, mpi_f=None, doc="<no doc>"):
        """
        Given a low-level mpf_ function, and optionally similar functions
        for mpc_ and mpi_, defines the function as a context method.

        It is assumed that the return type is the same as that of
        the input; the exception is that propagation from mpf to mpc is possible
        by raising ComplexResult.

        """
        def f(x, **kwargs):
            if type(x) not in ctx.types:
                x = ctx.convert(x)
            prec, rounding = ctx._prec_rounding
            if kwargs:
                prec = kwargs.get('prec', prec)
                if 'dps' in kwargs:
                    prec = dps_to_prec(kwargs['dps'])
                rounding = kwargs.get('rounding', rounding)
            if hasattr(x, '_mpf_'):
                try:
                    return ctx.make_mpf(mpf_f(x._mpf_, prec, rounding))
                except ComplexResult:
                    # Handle propagation to complex
                    if ctx.trap_complex:
                        raise
                    return ctx.make_mpc(mpc_f((x._mpf_, fzero), prec, rounding))
            elif hasattr(x, '_mpc_'):
                return ctx.make_mpc(mpc_f(x._mpc_, prec, rounding))
            raise NotImplementedError("%s of a %s" % (name, type(x)))
        name = mpf_f.__name__[4:]
        f.__doc__ = function_docs.__dict__.get(name, "Computes the %s of x" % doc)
        return f
def _wrap_libmp_function ( ctx , mpf_f , mpc_f = None , mpi_f = None , doc = "<no doc>" ) : def f ( x , * * kwargs ) : if type ( x ) not in ctx . types : x = ctx . convert ( x ) prec , rounding = ctx . _prec_rounding if kwargs : prec = kwargs . get ( 'prec' , prec ) if 'dps' in kwargs : prec = dps_to_prec ( kwargs [ 'dps' ] ) rounding = kwargs . get ( 'rounding' , rounding ) if hasattr ( x , '_mpf_' ) : try : return ctx . make_mpf ( mpf_f ( x . _mpf_ , prec , rounding ) ) except ComplexResult : # Handle propagation to complex if ctx . trap_complex : raise return ctx . make_mpc ( mpc_f ( ( x . _mpf_ , fzero ) , prec , rounding ) ) elif hasattr ( x , '_mpc_' ) : return ctx . make_mpc ( mpc_f ( x . _mpc_ , prec , rounding ) ) raise NotImplementedError ( "%s of a %s" % ( name , type ( x ) ) ) name = mpf_f . __name__ [ 4 : ] f . __doc__ = function_docs . __dict__ . get ( name , "Computes the %s of x" % doc ) return f