Exemplo n.º 1
0
 def test_iadd(self):
     x = UTPS(numpy.array([1.,2.,3.]), P = 1)
     x2 = x.copy()
     y = UTPS(numpy.array([5.,7.,11.]), P = 1)
     
     x += y
     assert_array_almost_equal(add(x2,y,x2).data,x.data)
Exemplo n.º 2
0
 def test_iadd_vectorized(self):
     x = UTPS(numpy.array([1.,2.,3, 4.,6.]),P = 2)
     y = UTPS(numpy.array([5.,7.,11, 1.,2.]),P = 2)
     
     y = add(y,x,y)
     
     assert_array_almost_equal([6.,9.,14., 5., 8.], y.data)
Exemplo n.º 3
0
 def test_add(self):
     """ test z = x + y"""
     x = UTPS(numpy.array([1.,2.,3.]), P = 1)
     y = UTPS(numpy.array([5.,7.,11.]), P = 1)
     
     z = add(x,y)
     
     assert_array_almost_equal([6.,9.,14.], z.data)
Exemplo n.º 4
0
 def test_iadd(self):
     """ test y += x"""
     x = UTPS(numpy.array([1.,2.,3.]), P = 1)
     y = UTPS(numpy.array([5.,7.,11.]), P = 1)
     
     y = add(y,x,y)
     
     assert_array_almost_equal([6.,9.,14.], y.data)
Exemplo n.º 5
0
 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)
Exemplo n.º 6
0
 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)
Exemplo n.º 7
0
 def test_add(self):
     x = UTPS(numpy.array([1.,2.,3.]), P = 1)
     y = UTPS(numpy.array([5.,7.,11.]), P = 1)
     
     z = x + y
     assert_array_almost_equal(add(x,y).data,z.data)