Matrix operation using multiple cores with multithreading
Code: "multi_dft.py". Programming language: Python
DMelt Version 1. Last modified: 09/20/2015. License: Pro
https://datamelt.org/code/cache/multi_dft_1282.py
To run this script using the DMelt IDE,
copy the above URL link to the menu [File]→[Read script from URL] of the DMelt IDE.
"""
In Parallel Colt threads are used automatically when computations are done on a
machine with multiple CPUs. Literally zero configuration is needed.
for testing performance, increase 100 to 1000
"""
from cern.colt.matrix.tdcomplex import *
from cern.colt.matrix.tdouble import *
# compute 2D Discrete Fourier Transform (DFT) of a random complex matrix:
# See: http://en.wikipedia.org/wiki/Discrete_Fourier_Transform
M = DComplexFactory2D.dense.random(1000, 1000) # random matrix
M.fft2() # compute 2D DFT in-place
# print M.toString()
# compute 1D DFT of each column of a random complex matrix
M=DComplexFactory2D.dense.random(1000, 1000) # random matrix
M.fftColumns() # compute 1D DFT of each column of M
# print M.toString()
# compute 2D Discrete Cosine Transform (DCT) of a random real matrix:
# See http://en.wikipedia.org/wiki/Discrete_cosine_transform
M=DoubleFactory2D.dense.random(100, 100) # random matrix
M.dct2(1) # compute 2D DCT in-place
print M.toString()
You see the box below because you did not login.