Hide keyboard shortcuts

Hot-keys on this page

r m x p   toggle line displays

j k   next/prev highlighted chunk

0   (zero) top of page

1   (one) first highlighted chunk

1

2

3

4

5

6

7

8

9

10

11

12

13

14

15

16

17

18

19

20

21

22

23

24

25

26

27

28

29

30

31

32

33

34

35

36

37

38

39

40

41

42

43

44

45

46

47

48

49

50

51

52

53

54

55

56

57

58

59

60

61

62

63

64

65

66

67

68

69

70

71

72

73

74

75

76

77

78

79

80

"""Ground types for various mathematical domains in SymPy. """ 

 

from __future__ import print_function, division 

 

__all__ = [] 

 

from sympy.core.compatibility import builtins, HAS_GMPY 

 

PythonInteger = builtins.int 

PythonReal = builtins.float 

PythonComplex = builtins.complex 

 

from .pythonrational import PythonRational 

 

from sympy.core.numbers import ( 

igcdex as python_gcdex, 

igcd as python_gcd, 

ilcm as python_lcm, 

) 

 

from sympy import ( 

Float as SymPyReal, 

Integer as SymPyInteger, 

Rational as SymPyRational, 

) 

 

if HAS_GMPY == 1: 

from gmpy import ( 

mpz as GMPYInteger, 

mpq as GMPYRational, 

fac as gmpy_factorial, 

numer as gmpy_numer, 

denom as gmpy_denom, 

gcdext as gmpy_gcdex, 

gcd as gmpy_gcd, 

lcm as gmpy_lcm, 

sqrt as gmpy_sqrt, 

qdiv as gmpy_qdiv, 

) 

elif HAS_GMPY == 2: 

from gmpy2 import ( 

mpz as GMPYInteger, 

mpq as GMPYRational, 

fac as gmpy_factorial, 

numer as gmpy_numer, 

denom as gmpy_denom, 

gcdext as gmpy_gcdex, 

gcd as gmpy_gcd, 

lcm as gmpy_lcm, 

isqrt as gmpy_sqrt, 

qdiv as gmpy_qdiv, 

) 

else: 

class GMPYInteger(object): 

def __init__(self, obj): 

pass 

 

class GMPYRational(object): 

def __init__(self, obj): 

pass 

 

gmpy_factorial = None 

gmpy_numer = None 

gmpy_denom = None 

gmpy_gcdex = None 

gmpy_gcd = None 

gmpy_lcm = None 

gmpy_sqrt = None 

gmpy_qdiv = None 

 

 

import mpmath.libmp as mlib 

 

 

def python_sqrt(n): 

return int(mlib.isqrt(n)) 

 

 

def python_factorial(n): 

return int(mlib.ifac(n))