Example #1
0
 def test_isub(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(sub(x2,y,x2).data,x.data)
Example #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 = sub(y,x,y)
     
     assert_array_almost_equal([4.,5.,8., -3., -4.], y.data)
Example #3
0
 def test_isub(self):
     """ test y -= x"""
     x = UTPS(numpy.array([1.,2.,3.]), P = 1)
     y = UTPS(numpy.array([5.,7.,11.]), P = 1)
     
     y = sub(y,x,y)
     
     assert_array_almost_equal([4.,5.,8.], y.data)
Example #4
0
 def test_sub(self):
     """ test z = x - y"""
     x = UTPS(numpy.array([1.,2.,3.]), P = 1)
     y = UTPS(numpy.array([5.,7.,11.]), P = 1)
     
     z = sub(x,y)
     
     assert_array_almost_equal([-4.,-5.,-8.], z.data)
Example #5
0
 def test_sub_epb(self):
     x = UTPS(numpy.array([1.,2.,3.]), P = 1)
     y = UTPS(numpy.array([5.,7.,11.]), P = 1)
     z = sub(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_sub(x,y,z, zbar, xbar, ybar)
     assert_array_almost_equal(zbar.data, xbar.data)
     assert_array_almost_equal(zbar.data, -ybar.data)
Example #6
0
 def test_sub_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 = sub(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_sub(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)
Example #7
0
 def test_sub(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(sub(x,y).data,z.data)