Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
sagemath
GitHub Repository: sagemath/sagelib
Path: blob/master/sage/libs/mpmath/all.py
4045 views
1
import mpmath
2
3
# Patch mpmath to use Cythonized functions
4
import utils as _utils
5
#mpmath.libmp.normalize = mpmath.libmp.normalize1 = normalize = _utils.normalize
6
#mpmath.libmp.from_man_exp = from_man_exp = _utils.from_man_exp
7
8
# Also import internal functions
9
from mpmath.libmp import *
10
11
# Main namespace
12
from mpmath import *
13
14
# Utilities
15
from utils import call, mpmath_to_sage, sage_to_mpmath
16
17
# Use mpmath internal functions for constants, to avoid unnecessary overhead
18
_constants_funcs = {
19
'glaisher' : glaisher_fixed,
20
'khinchin' : khinchin_fixed,
21
'twinprime' : twinprime_fixed,
22
'mertens' : mertens_fixed
23
}
24
25
def eval_constant(name, ring):
26
prec = ring.precision() + 20
27
return ring(_constants_funcs[name](prec)) >> prec
28
29
30