def test_axpby2(self): # test axpby with BlockDataContainer and DataContainer ig0 = ImageGeometry(2, 3, 4) # ig1 = ImageGeometry(2,3,5) data0 = ig0.allocate(-1) data2 = ig0.allocate(1) data1 = ig0.allocate(2) # data3 = ig1.allocate(3) cp0 = BlockDataContainer(data0, data2) # cp1 = BlockDataContainer(data1,data3) out = cp0 * 0. - 10 cp0.axpby(3, -2, data1, out) # operation should be [ 3 * -1 + (-2) * 2 , 3 * 1 + (-2) * 2 ] # output should be [ -7 , -1 ] res0 = ig0.allocate(-7) res2 = ig0.allocate(-1) res = BlockDataContainer(res0, res2) self.assertBlockDataContainerEqual(out, res)
def test_axpby_ab_blockdc(self): # test axpby between BlockDataContainers, with a and b as a blockdatacontainer ig0 = ImageGeometry(2, 3, 4) ig1 = ImageGeometry(2, 3, 5) data0 = ig0.allocate(-1) data2 = ig0.allocate(1) data1 = ig0.allocate(2) data3 = ig0.allocate(3) a1 = ig0.allocate(3) a2 = ig0.allocate(2) b1 = ig0.allocate(-2) b2 = ig0.allocate(-3) cp0 = BlockDataContainer(data0, data2) cp1 = BlockDataContainer(data1, data3) a = BlockDataContainer(a1, a2) b = BlockDataContainer(b1, b2) out = cp0 * 0. - 10 cp0.axpby(a, b, cp1, out, num_threads=4) # operation should be [ 3 * -1 + (-2) * 2 , 2 * 1 + (-3) * 3 ] # output should be [ -7 , -7 ] res0 = ig0.allocate(-7) res2 = ig0.allocate(-7) res = BlockDataContainer(res0, res2) self.assertBlockDataContainerEqual(out, res)
def test_axpby(self): # test axpby between BlockDataContainers ig0 = ImageGeometry(2, 3, 4) ig1 = ImageGeometry(2, 3, 5) data0 = ig0.allocate(-1) data2 = ig0.allocate(1) data1 = ig0.allocate(2) data3 = ig0.allocate(3) cp0 = BlockDataContainer(data0, data2) cp1 = BlockDataContainer(data1, data3) out = cp0 * 0. - 10 cp0.axpby(3, -2, cp1, out, num_threads=4) # operation should be [ 3 * -1 + (-2) * 2 , 3 * 1 + (-2) * 3 ] # output should be [ -7 , -3 ] res0 = ig0.allocate(-7) res2 = ig0.allocate(-3) res = BlockDataContainer(res0, res2) self.assertBlockDataContainerEqual(out, res)