-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathrelation.py
53 lines (42 loc) · 1.79 KB
/
relation.py
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
from collections import namedtuple
import polygnomeObject
import coefficient
relationClass = namedtuple('relation',['leadingMonomial','lowerOrderTerms'])
class relation(relationClass,
polygnomeObject.polygnomeObject): # type definition: relation is
#a tuple with the leading monomial
# and the lower terms in the
# reduction hierarchy
"""
File: relation.py
Author: Chris Campbell
Email: c (dot) j (dot) campbell (at) ed (dot) ac (dot) uk
Github: https://github.com/campbellC
Description:A relation is a tuple with the leadingMonomial and lowerOrderTerms.
"""
def __init__(self,*args,**kwargs):
relationClass.__init__(self,args,kwargs)
self.coefficient = coefficient.coefficient(1)
def __repr__( self):
return '(' + repr(self.asPolynomial()) + ')'
def toLatex(self):
return '(' + (self.asPolynomial()).toLatex() + ')'
def doesAct(self,poly):
return poly == self.leadingMonomial
def degree(self):
return self.leadingMonomial.degree()
def __eq__(self,other):
return self.leadingMonomial == other.leadingMonomial and self.lowerOrderTerms == other.lowerOrderTerms
def asPolynomial(self):
return self.leadingMonomial - self.lowerOrderTerms
##############################################################################
###### CODE TO MAKE THIS USEABLE IN TENSOR PRODUCTS
##############################################################################
def clean(self):
return self
def isZero(self):
return False
def __iter__(self):
yield self
def withCoefficientOf1(self):
return self