Пример #1
0
 def test_csr_apply_0(self):
     vec = np.arange(30, dtype=float)
     B = BO.for_vector(vec)
     ref = B.apply(vec)
     B.is_mixed_derivative = True
     B = BOG.BandedOperator(B)
     tst = B.apply(vec)
     npt.assert_array_equal(ref, tst)
Пример #2
0
 def test_derivative_solve_0(self):
     x = np.linspace(0,1,500)
     B = BO.for_vector(x)
     B.D.data[1,:] += 1
     B.D.data[1,0] = B.D.data[1,-1] = 2
     BG = BOG.BandedOperator(B)
     ref = np.e**x
     tst = BG.apply(ref) / 2
     fp(ref - tst, 'e')
     npt.assert_allclose(tst, ref, rtol=1e-4, atol=1e-6,
                         err_msg="d/dx (apply) not accurate")
     # fp(B.D.data)
     tst = BG.solve(ref) * 2
     npt.assert_allclose(ref, tst, rtol=1e-4, atol=1e-6,
                         err_msg="integral (solve) not accurate")