
"""
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()
