Skip to content
Snippets Groups Projects
Commit 4f310776 authored by hdd29's avatar hdd29
Browse files

Last commit

parent 25e2b119
No related branches found
No related tags found
No related merge requests found
......@@ -43,13 +43,13 @@ class gInt :
def __mul__( self, rhs ) :
'''Return a new gInt, self * rhs'''
r = self.real*rhs.real - self.imag*rhs.imag
i = self.real*rhs.imag - self.imag*rhs.real
i = self.real*rhs.imag + self.imag*rhs.real
return gInt(r, i)
def norm( self ) :
'''Return real^2 + imag^2 as an int'''
norm = (self.imag*2 + self.real*2)
norm = (self.imag**2 + self.real**2)
return norm
def test() :
......
......@@ -66,14 +66,12 @@ class gIntTest(unittest.TestCase):
self.assertEqual(self.np1, self.np1_copy, 'Right operand changed after mul')
self.assertEqual(self.small, self.small, 'Left operand changed after mul if it is small')
self.assertEqual(self.np1, self.np1_copy, 'Right operand changed after mul if it is small')
self.assertEqual(Product, gInt(10, 20)), 'Mul is not correct to every significant figures'
self.assertEqual(Product, gInt(11, 61)), 'Mul is not correct to every significant figures'
def test_norm(self):
#norm1 = self.oi.norm()
#self.assertEqual(norm1, (3^2) + (4^2))
norm2 = self.pn1.norm()
self.assertEqual(norm2, (3^2 + (-5)^2))
self.assertEqual(norm2, (3**2 + (-5)**2))
if __name__ == '__main__' :
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment