maxframe.tensor.sinc#
- maxframe.tensor.sinc(x, **kwargs)[源代码]#
返回 sinc 函数。
sinc 函数为 \(\\sin(\\pi x)/(\\pi x)\)。
- 参数:
x (Tensor) -- 用于计算
sinc(x)的(可能是多维的)张量值。- 返回:
out --
sinc(x),其形状与输入相同。- 返回类型:
Tensor
备注
sinc(0)的极限值为 1。sinc 是 "sine cardinal" 或 "sinus cardinalis" 的简称。
sinc 函数用于各种信号处理应用中,包括抗混叠、Lanczos 重采样滤波器的构建以及插值。
对于离散时间信号的带限插值,理想的插值核与 sinc 函数成比例。
引用
示例
>>> import maxframe.tensor as mt
>>> x = mt.linspace(-4, 4, 41) >>> mt.sinc(x).execute() array([ -3.89804309e-17, -4.92362781e-02, -8.40918587e-02, -8.90384387e-02, -5.84680802e-02, 3.89804309e-17, 6.68206631e-02, 1.16434881e-01, 1.26137788e-01, 8.50444803e-02, -3.89804309e-17, -1.03943254e-01, -1.89206682e-01, -2.16236208e-01, -1.55914881e-01, 3.89804309e-17, 2.33872321e-01, 5.04551152e-01, 7.56826729e-01, 9.35489284e-01, 1.00000000e+00, 9.35489284e-01, 7.56826729e-01, 5.04551152e-01, 2.33872321e-01, 3.89804309e-17, -1.55914881e-01, -2.16236208e-01, -1.89206682e-01, -1.03943254e-01, -3.89804309e-17, 8.50444803e-02, 1.26137788e-01, 1.16434881e-01, 6.68206631e-02, 3.89804309e-17, -5.84680802e-02, -8.90384387e-02, -8.40918587e-02, -4.92362781e-02, -3.89804309e-17])
>>> import matplotlib.pyplot as plt >>> plt.plot(x.execute(), np.sinc(x).execute()) [<matplotlib.lines.Line2D object at 0x...>] >>> plt.title("Sinc Function") <matplotlib.text.Text object at 0x...> >>> plt.ylabel("Amplitude") <matplotlib.text.Text object at 0x...> >>> plt.xlabel("X") <matplotlib.text.Text object at 0x...> >>> plt.show()