Ejemplo n.º 1
0
 def test_dot_scalar_multiplitcation(self):
     for v1, v2 in itertools.product(utils.ALL_VECTORS, utils.ALL_VECTORS):
         for k1, k2 in itertools.product(utils.ALL_SCALARS,
                                         utils.ALL_SCALARS):
             f1 = vector_ops.dot(k1 * v1, k2 * v2)
             f2 = k1 * k2 * vector_ops.dot(v1, v2)
             self.assertAlmostEqual(f1, f2, PRECISION)
Ejemplo n.º 2
0
 def test_dot_bilinear(self):
     for v1, v2 in itertools.product(utils.ALL_VECTORS, utils.ALL_VECTORS):
         for v3 in utils.ALL_VECTORS:
             for k in utils.ALL_SCALARS:
                 f1 = vector_ops.dot(v1, (k * v2) + v3)
                 f2 = k * (vector_ops.dot(v1, v2)) + vector_ops.dot(v1, v3)
                 self.assertAlmostEqual(f1, f2, PRECISION)
Ejemplo n.º 3
0
 def test_dot_angle_equality(self):
     for v1, v2 in itertools.product(utils.ALL_VECTORS, utils.ALL_VECTORS):
         if v1.norm > 0 and v2.norm > 0:
             f1 = vector_ops.dot(v1, v2)
             f2 = v1.norm * v2.norm * math.cos(
                 vector_ops.angle_between(v1, v2))
             self.assertAlmostEqual(f1, f2, PRECISION)
Ejemplo n.º 4
0
 def test_dot(self):
     for v1, v2 in itertools.product(utils.ALL_VECTORS, utils.ALL_VECTORS):
         self.assertAlmostEqual(v1 @ v2, vector_ops.dot(v1, v2), PRECISION)
Ejemplo n.º 5
0
 def test_dot_orthogonal(self):
     v1 = Vector([0, 1, 0])
     v2 = Vector([1, 0, 0])
     self.assertAlmostEqual(vector_ops.dot(v1, v2), 0, PRECISION)
Ejemplo n.º 6
0
 def test_dot_not_associative(self):
     for v1, v2 in itertools.product(utils.ALL_VECTORS, utils.ALL_VECTORS):
         for v3 in utils.ALL_VECTORS:
             with self.assertRaises(AttributeError):
                 vector_ops.dot(vector_ops.dot(v1, v2), v3)
Ejemplo n.º 7
0
 def test_dot_distributive(self):
     for v1, v2 in itertools.product(utils.ALL_VECTORS, utils.ALL_VECTORS):
         for v3 in utils.ALL_VECTORS:
             f1 = vector_ops.dot(v1, v2 + v3)
             f2 = vector_ops.dot(v1, v2) + vector_ops.dot(v1, v3)
             self.assertAlmostEqual(f1, f2, PRECISION)
Ejemplo n.º 8
0
 def test_dot_commutative(self):
     for v1, v2 in itertools.product(utils.ALL_VECTORS, utils.ALL_VECTORS):
         self.assertAlmostEqual(vector_ops.dot(v1, v2),
                                vector_ops.dot(v2, v1))