借助於scipy.fft.dctn()方法,我們可以通過選擇不同類型的序列來計算多維離散餘弦變換,並使用此方法返回變換後的數組。
用法:
scipy.fft.dctn(x, type=2)
返回值:它將返回轉換後的數組。
範例1:在此示例中,我們可以看到,通過使用scipy.fft.dctn()方法,我們可以通過默認選擇2種不同類型的序列來獲得多維離散餘弦變換。
Python3
# import scipy and numpy
from scipy import fft
import numpy as np
array_gfg = np.random.randn(3, 3)
# Using scipy.fft.dctn() method
gfg = fft.dctn(array_gfg)
print(gfg)
輸出:
[[ -4.16635907 -4.02741393 -3.60128725] [ -4.53247906 -3.48696887 0.9338914 ] [-10.02597376 -5.30097223 6.56879818]]
範例2:
Python3
# import scipy and numpy
from scipy import fft
import numpy as np
array_gfg = np.random.randn(5, 5)
# Using scipy.fft.dctn() method
gfg = fft.dctn(array_gfg, 1)
print(gfg)
輸出:
[[-22.58866562 4.34759109 6.27133607 -10.09673997 1.42277882] [-10.38551445 -1.73284723 4.77719083 -8.1483736 2.31129559] [ 5.09865556 7.7860346 -1.99346709 -8.19680308 5.54398566] [ 11.03512166 -13.2738255 -6.30390925 5.55873569 -3.67046116] [ 11.70752959 -13.28207081 6.20179649 11.0564309 5.17738824]]
相關用法
- Python os._exit()用法及代碼示例
- Python os.WEXITSTATUS()用法及代碼示例
- Python os.abort()用法及代碼示例
- Python os.renames()用法及代碼示例
- Python os.lseek()用法及代碼示例
- Python calendar formatmonth()用法及代碼示例
- Python PyTorch sin()用法及代碼示例
- Python Sympy Line.is_parallel()用法及代碼示例
- Python PIL GaussianBlur()用法及代碼示例
- Python range()用法及代碼示例
- Python Numpy np.hermefit()用法及代碼示例
- Python Numpy np.hermevander()用法及代碼示例
注:本文由純淨天空篩選整理自Jitender_1998大神的英文原創作品 Python – scipy.fft.dctn() method。非經特殊聲明,原始代碼版權歸原作者所有,本譯文未經允許或授權,請勿轉載或複製。