static char help[] = "Test duplication/destruction of FFTW vecs \n\n"; /* Compiling the code: This code uses the FFTW interface. Use one of the options below to configure: --with-fftw-dir=/.... or --download-fftw Usage: mpiexec -np ./ex228 */ #include int main(int argc,char **args) { Mat A; /* FFT Matrix */ Vec x,y,z; /* Work vectors */ Vec x1,y1,z1; /* Duplicate vectors */ PetscInt i,k; /* for iterating over dimensions */ PetscRandom rdm; /* for creating random input */ PetscScalar a; /* used to scale output */ PetscReal enorm; /* norm for sanity check */ PetscInt n=10,N=1; /* FFT dimension params */ PetscInt DIM,dim[5];/* FFT params */ PetscCall(PetscInitialize(&argc,&args,(char*)0,help)); PetscCall(PetscOptionsGetInt(NULL,NULL,"-n",&n,NULL)); /* To create random input vector */ PetscCall(PetscRandomCreate(PETSC_COMM_SELF, &rdm)); PetscCall(PetscRandomSetFromOptions(rdm)); /* Iterate over dimensions, use PETSc-FFTW interface */ for (i=1; i<5; i++) { DIM = i; N = 1; for (k=0; k 1.e-9) PetscCall(PetscPrintf(PETSC_COMM_WORLD," Error norm of |x - z1| %g\n",enorm)); /* free spaces */ PetscCall(VecDestroy(&x1)); PetscCall(VecDestroy(&y1)); PetscCall(VecDestroy(&z1)); PetscCall(VecDestroy(&x)); PetscCall(VecDestroy(&y)); PetscCall(VecDestroy(&z)); PetscCall(MatDestroy(&A)); } PetscCall(PetscRandomDestroy(&rdm)); PetscCall(PetscFinalize()); return 0; } /*TEST build: requires: fftw complex test: suffix: 2 nsize : 4 args: -mat_fftw_plannerflags FFTW_ESTIMATE -n 16 test: suffix: 3 nsize : 2 args: -mat_fftw_plannerflags FFTW_MEASURE -n 12 test: suffix: 4 nsize : 2 args: -mat_fftw_plannerflags FFTW_PATIENT -n 10 test: suffix: 5 nsize : 1 args: -mat_fftw_plannerflags FFTW_EXHAUSTIVE -n 5 TEST*/