Skip to content

Commit

Permalink
Fix docs and bugs.
Browse files Browse the repository at this point in the history
  • Loading branch information
pearu.peterson committed Feb 28, 2008
1 parent 5f7d524 commit e4c3e9c
Show file tree
Hide file tree
Showing 37 changed files with 491 additions and 343 deletions.
2 changes: 1 addition & 1 deletion epydoc.conf
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ introspect: yes

# Don't examine in any way the modules whose dotted name match this
# regular expression pattern.
exclude: sympycore.arithmetic.mpmath
#exclude:

# Don't perform introspection on the modules whose dotted name match this
# regular expression pattern.
Expand Down
2 changes: 2 additions & 0 deletions src/mk_numbers_methods.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@

template = '''\
"""
Generated arithmetic methods for numbers.
This file is generated by the src/mk_numbers_methods.py script.
See http://sympycore.googlecode.com/ for more information.
Expand Down
2 changes: 2 additions & 0 deletions src/mk_pairs_iops.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@

template = '''\
"""
Generated low-level arithmetic inplace functions for CommutativeRingWithPairs.
This file is generated by the src/mk_pairs_iops.py script.
See http://sympycore.googlecode.com/ for more information.
Expand Down
3 changes: 2 additions & 1 deletion src/mk_pairs_ops.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@
targetfile_py = os.path.join(cwd,'..','sympycore','basealgebra','pairs_ops.py')

template = '''\
"""
"""Generated low-level arithmetic methods for CommutativeRingWithPairs.
This file is generated by the src/mk_pairs_ops.py script.
See http://sympycore.googlecode.com/ for more information.
Expand Down
3 changes: 1 addition & 2 deletions sympycore/__init__.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
"""SympyCore - An efficient pure Python CAS.
"""SympyCore - An efficient pure Python Computer Algebra System.
See http://sympycore.googlecode.com/ for more information.
"""
__docformat__ = "restructuredtext"

Expand Down
10 changes: 5 additions & 5 deletions sympycore/arithmetic/__init__.py
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
"""Low-level arithmetics support.
Arithmetic package provides
Arithmetic package provides:
* low-level number types ``FractionTuple``, ``Float``, ``Complex``
* base class ``Infinity`` for extended numbers
* various low-level number theory functions: ``gcd``, ``multinomial_coefficients``, etc.
* low-level number types ``FractionTuple``, ``Float``, ``Complex``
* base class ``Infinity`` for extended numbers
* various low-level number theory functions: ``gcd``, ``multinomial_coefficients``, etc.
"""
__docformat__ = "restructuredtext en"
__docformat__ = "restructuredtext"

__all__ = ['FractionTuple', 'Float', 'Complex', 'Infinity',
'gcd', 'multinomial_coefficients']
Expand Down
101 changes: 65 additions & 36 deletions sympycore/arithmetic/infinity.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
"""Provides base class for extended numbers: Infinity.
"""

__docformat__ = "restructuredtext"
__all__ = ['Infinity']

from .numbers import realtypes, complextypes, Complex, numbertypes, div
Expand All @@ -20,26 +20,29 @@ class Infinity(object):
The formal definition of directional infinity is
::
Infinity(direction) == oo * direction
where oo represents a symbol of formal limiting process limit(r, r->oo).
where ``oo`` represents a symbol of a formal limiting process
``limit(r, r->oo)``.
Direction can be
* 0 - defines undefined
* 0 - defines ``undefined``
* complex number - defines direction in complex plain
* undefined - defines infinity with undefined direction (zoo)
* undefined - defines infinity with undefined direction (``zoo``)
Derived classes may redefine classmethods
Derived classes may redefine classmethods::
IsUnbounded(x) - returns 1 if x is unbounded expression
IsZero(x) - returns 1 if x is zero
EqualArg(x,y) - return 1 if Arg(x)==Arg(y).
EqualArg(x,y) - returns 1 if Arg(x)==Arg(y).
to add algebra support (including symbolic functions) to direction
expression.
The following notation is used:
The following notation is used::
+oo = Infinity(1)
-oo = Infinity(-1)
Expand Down Expand Up @@ -134,27 +137,32 @@ def __eq__(self, other):
return False

def __abs__(self):
"""
abs(oo*x) -> oo*abs(x)
""" ``abs(oo*x) -> oo*abs(x)``
"""
if is_undefined(self):
return self
return type(self)(1) # +oo

def __neg__(self):
"""
-(oo*U1(x)) -> oo*(-U1(x))
-zoo -> zoo
""" negation of extended number
::
-(oo*U1(x)) -> oo*(-U1(x))
-zoo -> zoo
"""
if is_zoo(self) or is_undefined(self):
return self
return type(self)(-self.data)

def __add__(self, other):
"""
oo*x + oo*y -> oo*(EqualArg(x, y) * x)
oo*x + y -> oo*((1+IsUnbounded(y)*(EqualArg(x,y)-1))*x)
y + oo*x -> oo*x + y
""" addition of extended numbers
::
oo*x + oo*y -> oo*(EqualArg(x, y) * x)
oo*x + y -> oo*((1+IsUnbounded(y)*(EqualArg(x,y)-1))*x)
y + oo*x -> oo*x + y
"""
cls = type(self)
if is_undefined(self) or is_undefined(other) or is_zoo(other):
Expand All @@ -175,21 +183,30 @@ def __add__(self, other):
__radd__ = __add__

def __sub__(self, other):
"""
oo*x - y -> oo*x + (-y)
""" substraction of extended numbers
::
oo*x - y -> oo*x + (-y)
"""
return self + (-other)

def __rsub__(self, other):
"""
y - oo*x -> oo*(-x) + y
""" substraction of extended numbers
::
y - oo*x -> oo*(-x) + y
"""
return (-self) + other

def __mul__(self, other):
"""
(oo*x) * (oo*y) -> oo*(x*y)
(oo*x) * y -> oo*(x*y)
""" multiplication of extended numbers
::
(oo*x) * (oo*y) -> oo*(x*y)
(oo*x) * y -> oo*(x*y)
"""
cls = type(self)
if is_undefined(self) or is_undefined(other) or not other:
Expand All @@ -201,10 +218,13 @@ def __mul__(self, other):
__rmul__ = __mul__

def __div__(self, other):
"""
(oo*x) / (oo*y) -> undefined
(oo*x) / 0 -> zoo
(oo*x) / y -> oo*(x/y)
""" division of extended numbers
::
(oo*x) / (oo*y) -> undefined
(oo*x) / 0 -> zoo
(oo*x) / y -> oo*(x/y)
"""
cls = type(self)
if is_undefined(self) or is_undefined(other) or isinstance(other, cls):
Expand All @@ -218,18 +238,24 @@ def __div__(self, other):
return cls(self.data / other)

def __rdiv__(self, other):
"""
y / oo*x -> 0*(1/x)
""" division of extended numbers
::
y / oo*x -> 0*(1/x)
"""
if is_undefined(self):
return self
return 0

def __pow__(self, other):
"""
(oo*x)**0 -> 1
(oo*x)**(oo*y) -> 0 if y<0; oo*(IsPositive(x)) if y > 0
(oo*x)**y -> 0 if y<0; oo*(x**y) if y > 0
""" exponentiation of extended numbers
::
(oo*x)**0 -> 1
(oo*x)**(oo*y) -> 0 if y<0; oo*(IsPositive(x)) if y > 0
(oo*x)**y -> 0 if y<0; oo*(x**y) if y > 0
"""
if not other:
return 1
Expand Down Expand Up @@ -261,9 +287,12 @@ def __pow__(self, other):
return NotImplemented

def __rpow__(self, other):
"""
1 ** (oo*x) -> 1
y ** (oo*x) -> (y**x)**(oo)
""" exponentiation of extended numbers
::
1 ** (oo*x) -> 1
y ** (oo*x) -> (y**x)**(oo)
"""
cls = type(self)
x = self.data
Expand Down
2 changes: 2 additions & 0 deletions sympycore/arithmetic/methods.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
"""
Generated arithmetic methods for numbers.
This file is generated by the src/mk_numbers_methods.py script.
See http://sympycore.googlecode.com/ for more information.
Expand Down
Loading

0 comments on commit e4c3e9c

Please sign in to comment.