def test_add_epb(self): x = UTPS(numpy.array([1.,2.,3.]), P = 1) y = UTPS(numpy.array([5.,7.,11.]), P = 1) z = add(x,y) zbar = UTPS(numpy.random.rand(3), P = 1) xbar = UTPS(numpy.zeros(3), P = 1) ybar = UTPS(numpy.zeros(3), P = 1) epb_add(x,y,z, zbar, xbar, ybar) assert_array_almost_equal(zbar.data, xbar.data) assert_array_almost_equal(zbar.data, ybar.data)
def test_add_epb(self): Q,P,D = 3,1,3 x = UTPS(numpy.random.rand(1+P*(D-1)), P = P) y = UTPS(numpy.random.rand(1+P*(D-1)), P = P) z = add(x,y) zbar = UTPS(numpy.random.rand( Q*(1+P*(D-1))), Q = Q, P = P) xbar = UTPS(numpy.random.rand( Q*(1+P*(D-1))), Q = Q, P = P) ybar = UTPS(numpy.random.rand( Q*(1+P*(D-1))), Q = Q, P = P) xbar2 = xbar.copy() ybar2 = ybar.copy() zbar2 = ybar.copy() epb_add(x,y,z, zbar, xbar, ybar) assert_array_almost_equal(xbar2.data + zbar.data, xbar.data) assert_array_almost_equal(ybar2.data + zbar.data, ybar.data)