コード例 #1
0
ファイル: test_utps.py プロジェクト: b45ch1/taylorpoly
 def test_mul_same(self):
     x = UTPS(numpy.array([1.,2.,3.]), P = 1)
     y = x.copy()
     z = mul(x,y)
     x = mul(x,x,x)
     
     assert_array_almost_equal(z.data, x.data)
コード例 #2
0
ファイル: test_utps.py プロジェクト: b45ch1/taylorpoly
 def test_pow(self):
     x = UTPS(numpy.array([2.,2.,3.,7., 1., 3., 2.]),P = 2)
     x1 = UTPS(numpy.array([2.,2.,3.,7.]),P = 1)
     x2 = UTPS(numpy.array([2.,1., 3., 2.]),P = 1)
     y = pow(x,2.)
     y1 = mul(x1,x1)
     y2 = mul(x2,x2);
     
     assert_array_almost_equal(y1.data, y.data[[0,1,2,3]])
     assert_array_almost_equal(y2.data, y.data[[0,4,5,6]])
コード例 #3
0
ファイル: test_utps.py プロジェクト: b45ch1/taylorpoly
 def test_mul_vectorized(self):
     x = UTPS(numpy.array([1.,2.,3, 4.,6.]),P = 2)
     y = UTPS(numpy.array([5.,7.,11, 1.,2.]),P = 2)
     
     z = mul(x,y)
     
     assert_array_almost_equal([5.,17.,40., 21., 36.], z.data)
コード例 #4
0
ファイル: test_utps.py プロジェクト: b45ch1/taylorpoly
 def test_mul(self):
     x = UTPS(numpy.array([1.,2.,3.]), P = 1)
     y = UTPS(numpy.array([5.,7.,11.]), P = 1)
     
     z = mul(x,y)
     
     assert_array_almost_equal([5.,17.,40.], z.data)
コード例 #5
0
ファイル: test_utps.py プロジェクト: b45ch1/taylorpoly
 def test_imul(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(mul(x2,y,x2).data,x.data)
コード例 #6
0
ファイル: test_utps_epb.py プロジェクト: b45ch1/taylorpoly
 def test_compare_pushforward_pullback_derivatives(self):
     x = UTPS(numpy.array([7.,1.,0.]), P = 1)
     y = UTPS(numpy.array([13.,0.,0.]), P = 1)
     v1 = mul(x,y)
     v2 = mul(x,v1)
     
     v2bar = UTPS([1.,0.,0.], P = 1)
     v1bar = UTPS(numpy.zeros(3), P = 1)
     xbar = UTPS(numpy.zeros(3), P = 1)
     ybar = UTPS(numpy.zeros(3), P = 1)
     
     epb_mul(x,v1,v2, v2bar, xbar, v1bar)
     epb_mul(x,y,v1, v1bar, xbar, ybar)
     
     assert_array_almost_equal(xbar.data[0], v2.data[1])
     assert_array_almost_equal(xbar.data[1], 2*v2.data[2])
コード例 #7
0
ファイル: test_utps.py プロジェクト: b45ch1/taylorpoly
    def test_amul(self):
        x = UTPS(numpy.array([1.,2.,3.]), P = 1)
        y = UTPS(numpy.array([5.,7.,11.]), P = 1)
        r = numpy.random.rand(3)
        
        z = UTPS(r, P = 1)
        z += mul(x, y, z)

        z2 = UTPS(r, P = 1)
        z2 = amul(x, y, z2)
        
        assert_array_almost_equal(z.data,z2.data)
コード例 #8
0
ファイル: test_utps_epb.py プロジェクト: b45ch1/taylorpoly
 def test_mul_epb(self):
     x = UTPS(numpy.array([1.,2.,3.]), P = 1)
     y = UTPS(numpy.array([5.,7.,11.]), P = 1)
     z = mul(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_mul(x,y,z, zbar, xbar, ybar)
     
     assert_array_almost_equal( (zbar*x).data, ybar.data)
     assert_array_almost_equal( (zbar*y).data, xbar.data)
コード例 #9
0
ファイル: test_utps.py プロジェクト: b45ch1/taylorpoly
 def test_pow(self):
     x = UTPS(numpy.array([2.,2.,3.,7.]),P = 1)
     y = pow(x,2.)
     
     y2 = mul(x,x);
     assert_array_almost_equal(y2.data, y.data)