Python – scipy.fft.dctn() method
With the help of scipy.fft.dctn() method, we can compute the multidimensional discrete cosine transform by selecting different types of sequences and return the transformed array by using this method.
Syntax :
scipy.fft.dctn(x, type=2)
Return value: It will return the transformed array.
Example #1: In this example, we can see that by using scipy.fft.dctn() method, we are able to get the multidimensional discrete cosine transform by selecting different types of sequences by default it’s 2.
Python3
from scipy import fft
import numpy as np
array_gfg = np.random.randn( 3 , 3 )
gfg = fft.dctn(array_gfg)
print (gfg)
|
Output :
[[ -4.16635907 -4.02741393 -3.60128725]
[ -4.53247906 -3.48696887 0.9338914 ]
[-10.02597376 -5.30097223 6.56879818]]
Example #2:
Python3
from scipy import fft
import numpy as np
array_gfg = np.random.randn( 5 , 5 )
gfg = fft.dctn(array_gfg, 1 )
print (gfg)
|
Output :
[[-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]]
Last Updated :
01 Oct, 2020
Like Article
Save Article
Share your thoughts in the comments
Please Login to comment...