C++ main module for emicrom Package  1.0
FFTW_ComplexArray.hpp
Go to the documentation of this file.
1 #ifndef FFTW_ComplexArray_HPP
2 #define FFTW_ComplexArray_HPP
3 
4 template<class T>
5 void FFTW_ComplexArray::copy(const complex<T>* f,const tUIndex& n) {
6  tUIndex i;
7 
8  if (n==0) {
9  desallocate();
10  return;
11  }
12 
13  //allocate the vector
14  if (n>mCapacity) {
15  mSize=n;
16  allocate(n);
17  }
18 
19  //copy the vector
20  if (n==0) return;
21 
22  const complex<T>* pf=&f[0];
23  tFFTWComplex * vs=mValues;
24  OMP_PARALLEL_PRIVATE_SHARED_DEFAULT(private(i),shared(n,pf,vs),default(none)) {
25  // id of the thread
26  tUInteger threadId=OMP_GET_THREAD_ID();
27  // number of threads
29 
30  // compute the loop index of each thread
31  tUIndex start=threadId*n/nThreads;
32  tUIndex end=(threadId+1)*n/nThreads;
33 
34  const complex<T> *fi=&pf[start];
35  tFFTWComplex* vi=&vs[start];
36 
37  for (i=start;i<end;i++) {
38  (*vi)[0]=fi->real();
39  (*vi)[1]=fi->imag();
40  vi++;
41  fi++;
42 
43  }
44  }//end parallel loop
45 }
46 
47 
48 #endif
void allocate(const tUIndex &cap)
allocate the memory if the array
Definition: FFTW_ComplexArray.cpp:38
void copy(const FFTW_ComplexArray &f)
copy the complex array
Definition: FFTW_ComplexArray.cpp:180
#define OMP_GET_THREAD_ID()
Definition: openMP.h:76
#define tUInteger
Definition: types.h:91
#define tFFTWComplex
Definition: fftw_types.h:65
#define tUIndex
Definition: types.h:126
#define OMP_PARALLEL_PRIVATE_SHARED_DEFAULT(P, S, D)
Definition: openMP.h:88
tFFTWComplex * mValues
Definition: FFTW_ComplexArray.h:25
#define OMP_GET_THREADS_NUMBER()
Definition: openMP.h:74
tUIndex mSize
Definition: FFTW_ComplexArray.h:28
tUIndex mCapacity
Definition: FFTW_ComplexArray.h:31
void desallocate()
desallocate the memory
Definition: FFTW_ComplexArray.cpp:27