Beispiel #1
0
 def runBlockState(self):
     a = [1,2]
     b = [3,4]
     c = [5]
     d_numpy = array(a+b+c)
     d_bs = BlockState([2,2,1])
     for i, dataBlock in zip(range(3), [a,b,c]):
         d_bs.datablocks[i] = array(dataBlock)
     for i in range(5):
         self.assertTrue(d_numpy[i] == d_bs[i])
     d2_bs = BlockState([2,2,1])
     for i in range(5):
         d2_bs[i] = d_bs[i]
     for i in range(5):
         self.assertTrue(d_numpy[i] == d2_bs[i])
     xd_numpy = self.x_numpy.dot(d_numpy)
     xd_bms = bdot(self.x_bm, d_bs)
     for i in range(5):
         self.assertTrue(xd_numpy[i] == xd_bms[i])
     dd_numpy = d_numpy.dot(d_numpy)
     dd_bs = bdot(d_bs, d_bs)
     self.assertTrue(dd_numpy == dd_bs)
Beispiel #2
0
 def runBlockMatrixProduct(self):
     xx_numpy = self.x_numpy.dot(self.x_numpy)
     xx_bm = bdot(self.x_bm, self.x_bm)
     for i, j in product(range(5), range(5)):
         if xx_numpy[i, j] != 0:
             self.assertTrue(xx_numpy[i, j] == xx_bm[i, j])