예제 #1
0
 def test_add_1(self):
     A = VectorMatrix(Shape(100,100,10))
     B = VectorMatrix(Shape(100,100,10))
     for idx in range(A.size()):
         A.set(idx, (1*idx, 2*idx, 3*idx))
         B.set(idx, (4*idx, 5*idx, 6*idx))
     A.add(B, 2.0)
     for idx in range(A.size()):
         self.assertEqual(A.get(idx), (9*idx, 12*idx, 15*idx))
예제 #2
0
 def test_add_1(self):
   A = VectorMatrix(Shape(100,100,10))
   B = VectorMatrix(Shape(100,100,10))
   for idx in range(A.size()):
     A.set(idx, (1*idx, 2*idx, 3*idx))
     B.set(idx, (4*idx, 5*idx, 6*idx))
   A.add(B, 2.0)
   for idx in range(A.size()):
     self.assertEqual(A.get(idx), (9*idx, 12*idx, 15*idx))
예제 #3
0
  def test_dotSum(self):
    A = VectorMatrix(Shape(10,10,10))
    B = VectorMatrix(Shape(10,10,10))

    for idx in range(A.size()):
      A.set(idx, (0.1*idx, 0.2*idx, -0.3*idx))
      B.set(idx, (-0.4*idx, 0.5*idx, -0.6*idx))
    self.assertTrue(abs(A.dotSum(B) - 79880040.0) < 0.1)
예제 #4
0
    def test_dotSum(self):
        A = VectorMatrix(Shape(10,10,10))
        B = VectorMatrix(Shape(10,10,10))

        for idx in range(A.size()):
            A.set(idx, (0.1*idx, 0.2*idx, -0.3*idx))
            B.set(idx, (-0.4*idx, 0.5*idx, -0.6*idx))
        self.assertTrue(abs(A.dotSum(B) - 79880040.0) < 0.1)
예제 #5
0
 def test_average(self):
   A = VectorMatrix(Shape(10,10,10))
   for idx in range(A.size()):
     A.set(idx, (idx, 2*idx, 3*idx))
   self.assertTrue(A.average() == (999.0/2,2*999.0/2,3*999.0/2))
예제 #6
0
 def test_absMax(self):
   A = VectorMatrix(Shape(10,10,10))
   for idx in range(A.size()):
     A.set(idx, (10,10,10))
   A.set(500, (10,20,30))
   self.assertTrue(A.absMax() - 37.41657387 < 0.0001)
예제 #7
0
 def test_fill(self):
   A = VectorMatrix(Shape(100,100,10))
   A.fill((1.0, 2.0, 3.0))
   for idx in range(A.size()):
     self.assertTrue(A.get(idx) == (1.0, 2.0, 3.0))
예제 #8
0
 def test_average(self):
     A = VectorMatrix(Shape(10,10,10))
     for idx in range(A.size()):
         A.set(idx, (idx, 2*idx, 3*idx))
     self.assertTrue(A.average() == (999.0/2,2*999.0/2,3*999.0/2))
예제 #9
0
 def test_absMax(self):
     A = VectorMatrix(Shape(10,10,10))
     for idx in range(A.size()):
         A.set(idx, (10,10,10))
     A.set(500, (10,20,30))
     self.assertTrue(A.absMax() - 37.41657387 < 0.0001)
예제 #10
0
 def test_fill(self):
     A = VectorMatrix(Shape(100,100,10))
     A.fill((1.0, 2.0, 3.0))
     for idx in range(A.size()):
         self.assertTrue(A.get(idx) == (1.0, 2.0, 3.0))