21 std::complex<long double> * data;
22 std::complex<long double>
imag(0,1);
25 int sym[] = {
NS,
NS,NS};
27 MPI_Comm_size(MPI_COMM_WORLD, &numPes);
28 MPI_Comm_rank(MPI_COMM_WORLD, &myRank);
39 data[i] = ((
long double)1./n)*
exp(-2.*(idx[i]/n)*(idx[i]%n)*((
long double)M_PI/n)*imag);
41 DFT.
write(np, idx, data);
49 data[i] = ((
long double)1./n)*
exp(2.*(idx[i]/n)*(idx[i]%n)*((
long double)M_PI/n)*imag);
51 IDFT.
write(np, idx, data);
59 data[i] +=
exp(imag*(
long double)((-2.*M_PI*(j/(
double)(n)))
60 *((idx[i]%n) + ((idx[i]/n)%n) +(idx[i]/(n*n)))));
63 MESH.
write(np, idx, data);
68 MESH[
"ijk"] = 1.0*MESH[
"pqr"]*DFT[
"ip"]*DFT[
"jq"]*DFT[
"kr"];
74 if (idx[i]%n == (idx[i]/n)%n && idx[i]%n == idx[i]/(n*n)){
75 if (fabs((
double)data[i].
real() - 1.)>=1.E-9) pass = 0;
77 if (fabs((
double)data[i].
real())>=1.E-9) pass = 0;
80 MPI_Allreduce(MPI_IN_PLACE, &pass, 1, MPI_INT, MPI_MIN, MPI_COMM_WORLD);
83 MPI_Reduce(MPI_IN_PLACE, &pass, 1, MPI_INT, MPI_MIN, 0, MPI_COMM_WORLD);
85 printf(
"{ MESH[\"ijk\"] = MESH[\"pqr\"]*DFT[\"ip\"]*DFT[\"jq\"]*DFT[\"kr\"] } passed\n");
87 printf(
"{ MESH[\"ijk\"] = MESH[\"pqr\"]*DFT[\"ip\"]*DFT[\"jq\"]*DFT[\"kr\"] } failed\n");
89 MPI_Reduce(&pass, MPI_IN_PLACE, 1, MPI_INT, MPI_MIN, 0, MPI_COMM_WORLD);
91 MPI_Barrier(MPI_COMM_WORLD);
103 int main(
int argc,
char ** argv){
106 MPI_Init(&argc, &argv);
109 logn = atoi(argv[1]);
110 if (logn<0) logn = 3;
117 World dw(argc, argv);
int test_dft_3D(int n, World &wrld)
int main(int argc, char **argv)
Forms N-by-N DFT matrix A and inverse-dft iA and checks A*iA=I.
Ring class defined by a datatype and addition and multiplicaton functions addition must have an ident...
Matrix class which encapsulates a 2D tensor.
an instance of the CTF library (world) on a MPI communicator
def exp(init_x, out=None, where=True, casting='same_kind', order='F', dtype=None, subok=True)
void get_local_data(int64_t *npair, int64_t **global_idx, dtype **data, bool nonzeros_only=false, bool unpack_sym=false) const
Gives the global indices and values associated with the local data.
an instance of a tensor within a CTF world
void write(int64_t npair, int64_t const *global_idx, dtype const *data)
writes in values associated with any set of indices The sparse data is defined in coordinate format...