def test_create_Toeplitz():
from stfinv.utils.inversion import _create_Toeplitz
# even length
d1 = np.array([1., 0., 0., 0., 1., 2., 1., 0., 0., 1])
d2 = np.array([0., 0., 1., 3., 2., 1., 0., 0., 0., 0])
G = _create_Toeplitz(d2)
npt.assert_allclose(np.matmul(G, d1),
np.convolve(d1, d2, 'same'),
atol=1e-7, rtol=1e-7)
# odd length
d1 = np.array([1., 0., 0., 0., 1., 2., 1., 0., 0.])
d2 = np.array([0., 0., 1., 3., 2., 1., 0., 0., 0.])
G = _create_Toeplitz(d2)
npt.assert_allclose(np.matmul(G, d1),
np.convolve(d1, d2, 'same'),
atol=1e-7, rtol=1e-7)
评论列表
文章目录