test.py 文件源码

python
阅读 26 收藏 0 点赞 0 评论 0

项目:signal_subspace 作者: scivision 项目源码 文件源码
def test_autocov():
    x = np.random.randn(4096).astype(np.complex128) # 2x extra speedup from casting correct type

    M=5
    tic = time()
    C= compute_autocovariance(x,M)
    tocpy = time()-tic
#%%
    tic = time()
    Cc = S['c'].covariance.autocov(x,M)
    tocfortcmpl = time()-tic

    tic = time()
    Cr = S['r'].covariance.autocov(x.real,M)
    tocfortreal = time() - tic


    #print(f'autocovariance: python {tocpy:.6f} sec  fortran {tocfortcmpl:.6f} sec')
    print('autocovariance: Fortran faster than Python by factor:',tocpy/tocfortcmpl)

    np.testing.assert_allclose(C,Cc,rtol=1)
    np.testing.assert_allclose(C.real,Cr,rtol=1)
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号