Esempio n. 1
0
 def setUp(self):
     self.i = SimpleVector([R(1), R(0), R(0)])
     self.j = SimpleVector([R(0), R(1), R(0)])
     self.k = SimpleVector([R(0), R(0), R(1)])
     self.x = VectorSpace([self.i])
     self.y = VectorSpace([self.j])
     self.z = VectorSpace([self.k])
     self.xy = VectorSpace([self.i, self.j])
     self.yz = VectorSpace([self.j, self.k])
     self.zx = VectorSpace([self.k, self.i])
     self.xyz = VectorSpace([self.i, self.j, self.k])
Esempio n. 2
0
 def test_pow2(self):
     a = PolyHomBivar([R(0), R(1), R(2), R(1)])
     b = PolyHomBivar([R(1), R(1)])
     c = PolyHomBivar([R(0), R(1), R(3), R(3), R(1)])
     e = PolyHomBivar([R(1), R(3), R(3), R(1)])
     self.assertEqual(c, a**b)
     self.assertNotEqual(e, a**b)
Esempio n. 3
0
 def test_linearlyIndependent(self):
     a = PolyUnivar([R(1), R(2), R(3)])
     b = PolyUnivar([R(2), R(3), R(4)])
     c = PolyUnivar([R(3), R(4), R(5)])
     d = PolyUnivar([R(3), R(5), R(5)])
     self.assertTrue(a.linearlyIndependent([a, b, d]))
     self.assertFalse(a.linearlyIndependent([a, b, c]))
     self.assertFalse(a.linearlyIndependent([a, b, PolyUnivar([])]))
Esempio n. 4
0
 def test_eq(self):
     a = PolyUnivar([R(1), R(2), R(3)])
     b = PolyUnivar([R(1), R(2), R(3)])
     c = PolyUnivar([R(1), R(1), R(2), R(3)])
     self.assertEqual(a, b)
     self.assertNotEqual(a, c)
Esempio n. 5
0
 def test_add(self):
     a = PolyUnivar([R(1), R(2), R(3)])
     b = PolyUnivar([R(-1), R(2), R(3)])
     c = PolyUnivar([R(4), R(6)])
     d = PolyUnivar([R(4), R(6), R(6)])
     self.assertEqual(c, a + b)
     self.assertNotEqual(d, a + b)
Esempio n. 6
0
 def test_rmul(self):
     a = PolyUnivar([R(1), R(2), R(3)])
     b = PolyUnivar([R(2), R(4), R(6)])
     c = PolyUnivar([R(2), R(4), R(7)])
     self.assertEqual(b, R(2) * a)
     self.assertEqual(PolyUnivar([]), R(0) * a)
     self.assertNotEqual(c, R(2) * a)
     self.assertNotEqual(c, R(0) * a)
Esempio n. 7
0
 def test_add(self):
     self.assertEqual(R(42), R(29) + R(13))
Esempio n. 8
0
 def test_vector_add(self):
     self.assertEqual(SimpleVector([R(1), R(1), R(1)]), self.i + self.j + self.k)
Esempio n. 9
0
 def test_lt(self):
     self.assertTrue(R(20) < R(21))
     self.assertFalse(R(21) < R(21))
Esempio n. 10
0
 def test_le(self):
     self.assertTrue(R(20) <= R(20))
     self.assertFalse(R(22) <= R(21))
Esempio n. 11
0
 def test_ge(self):
     self.assertTrue(R(20) >= R(20))
     self.assertFalse(R(21) >= R(22))
Esempio n. 12
0
 def test_gt(self):
     self.assertTrue(R(21) > R(20))
     self.assertFalse(R(21) > R(21))
Esempio n. 13
0
 def test_eq(self):
     self.assertEqual(R(21), R(21))
     self.assertNotEqual(R(20), R(21))
Esempio n. 14
0
 def test_vector_rmul(self):
     self.assertEqual(SimpleVector([R(2), R(2), R(2)]), R(2) * SimpleVector([R(1), R(1), R(1)]))
Esempio n. 15
0
 def test_zero(self):
     self.assertEqual(R(10), R(10) + self.c.zero())
Esempio n. 16
0
 def test_vector_mul(self):
     self.assertEqual(R(10), SimpleVector([R(1), R(2), R(3)]) * SimpleVector([R(3), R(2), R(1)]))
Esempio n. 17
0
 def test_mul(self):
     self.assertEqual(R(10), R(5) * R(2))
Esempio n. 18
0
 def test_vector_linearlyIndependent(self):
     self.assertTrue(SimpleVector.linearlyIndependent([self.i, self.j, self.k]))
     self.assertFalse(SimpleVector.linearlyIndependent([SimpleVector([R(1), R(2), R(3)]), SimpleVector([R(1), R(4), R(9)]), SimpleVector([R(3), R(8), R(15)])]))
     self.assertFalse(SimpleVector.linearlyIndependent([SimpleVector([R(2), R(3), R(4)]), SimpleVector([R(5), R(6), R(3)]), SimpleVector([R(14), R(32), R(54)]), SimpleVector([R(9), R(8), R(7)])]))
Esempio n. 19
0
 def test_rmul(self):
     self.assertEqual(R(10), 2 * R(5))
Esempio n. 20
0
 def test_mul(self):
     a = PolyUnivar([R(1), R(2), R(3)])
     b = PolyUnivar([R(1), R(2), R(3), R(4)])
     self.assertEqual(R(20), a * b)
     self.assertNotEqual(R(21), a * b)
Esempio n. 21
0
 def test_sub(self):
     self.assertEqual(R(10), R(12) - R(2))
Esempio n. 22
0
 def test_zero(self):
     a = PolyUnivar([R(1), R(2), R(3)])
     self.assertEqual(a.zero() + a, a)
     self.assertEqual(a.zero(), R(0) * a)
Esempio n. 23
0
 def test_div(self):
     self.assertEqual(R(4), R(16) / R(4))
Esempio n. 24
0
 def test_pow(self):
     a = PolyUnivar([R(1), R(2), R(3)])
     b = PolyUnivar([R(2), R(3), R(4)])
     c = PolyUnivar([R(2), R(7), R(16), R(17), R(12)])
     d = PolyUnivar([R(2), R(7), R(16), R(17), R(13)])
     self.assertEqual(c, a ** b)
     self.assertEqual(c, b ** a)
     self.assertNotEqual(d, a ** b)
Esempio n. 25
0
 def setUp(self):
     # Set up unit vectors in R3
     self.i = SimpleVector([R(1), R(0), R(0)])
     self.j = SimpleVector([R(0), R(1), R(0)])
     self.k = SimpleVector([R(0), R(0), R(1)])
     self.c = R(0)
Esempio n. 26
0
 def test_pow(self):
     a = PolyHomBivar([R(1), R(2), R(1)])
     b = PolyHomBivar([R(1), R(1)])
     self.assertEqual(a, b**b)
Esempio n. 27
0
 def test_inv(self):
     self.assertEqual(R(10) + R.inv(R(10)), self.c.zero())
Esempio n. 28
0
 def test_add(self):
     a = PolyHomBivar([R(1), R(2), R(3)])
     b = PolyHomBivar([R(4), R(5), R(6)])
     c = PolyHomBivar([R(5), R(7), R(9)])
     self.assertEqual(c, a + b)
Esempio n. 29
0
 def test_contains(self):
     # Check that the i + 2j lies in the xy plane
     self.assertIn(self.i + R(2) * self.j, self.xy)
     # Check that i + 2k does not lie in the xy planes
     self.assertNotIn(self.i + R(2) * self.k, self.xy)