2 # Created January 2008 by Pearu Peterson
4 """ Provides Constant class.
6 __docformat__
= "restructuredtext"
7 __all__
= ['Constant', 'const_pi', 'const_E', 'const_gamma']
9 from ..core
import classes
10 from ..utils
import SYMBOL
, NUMBER
11 from ..arithmetic
.evalf
import evalf
12 from ..arithmetic
import mpmath
, setdps
17 return '%s(%r)' % (self
.__class
__.__name
__, str(self
))
19 def evalf(self
, n
=None):
28 raise NotImplementedError('%s(%r).evalf'
29 % (self
.__class
__.__name
__, self
))
31 def as_algebra(self
, cls
):
32 if cls
is classes
.Calculus
:
33 return cls
.Symbol(self
)
34 return cls
.convert(self
)
36 def get_direction(self
):
37 if self
in ['pi', 'E']:
43 if self
in ['pi', 'E']:
47 const_pi
= Constant('pi')
48 const_E
= Constant('E')
49 const_gamma
= Constant('gamma')