18 std::complex<double> * data;
19 std::complex<double>
imag(0,1);
20 MPI_Comm_size(MPI_COMM_WORLD, &numPes);
21 MPI_Comm_rank(MPI_COMM_WORLD, &myRank);
28 data[i] =
exp(-2.*(idx[i]/n)*(idx[i]%n)*(M_PI/n)*imag);
31 DFT.
write(np, idx, data);
39 data[i] = (1./n)*
exp(2.*(idx[i]/n)*(idx[i]%n)*(M_PI/n)*
imag);
41 IDFT.
write(np, idx, data);
48 DFT[
"ik"] = .5*DFT[
"ij"]*IDFT[
"jk"];
51 ss[
""] =
Function< std::complex<double>, std::complex<double>, std::complex<double> >([](std::complex<double>
a, std::complex<double>
b){
return a+
b; })(DFT[
"ij"],DFT[
"ij"]);
58 if (idx[i]/n == idx[i]%n){
59 if (fabs(data[i].
real() - 1.)>=1.E-9)
62 if (fabs(data[i].
real())>=1.E-9)
66 MPI_Allreduce(MPI_IN_PLACE, &pass, 1, MPI_INT, MPI_MIN, MPI_COMM_WORLD);
69 MPI_Reduce(MPI_IN_PLACE, &pass, 1, MPI_INT, MPI_MIN, 0, MPI_COMM_WORLD);
71 printf(
"{ DFT[\"ik\"] = DFT[\"ij\"]*IDFT[\"jk\"] } passed\n");
73 printf(
"{ DFT[\"ik\"] = DFT[\"ij\"]*IDFT[\"jk\"] } failed\n");
75 MPI_Reduce(&pass, MPI_IN_PLACE, 1, MPI_INT, MPI_MIN, 0, MPI_COMM_WORLD);
77 MPI_Barrier(MPI_COMM_WORLD);
88 int main(
int argc,
char ** argv){
92 MPI_Init(&argc, &argv);
104 World dw(argc, argv);
Matrix class which encapsulates a 2D tensor.
int main(int argc, char **argv)
Forms N-by-N DFT matrix A and inverse-dft iA and checks A*iA=I.
an instance of the CTF library (world) on a MPI communicator
Scalar class which encapsulates a 0D tensor.
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.
int test_dft(int64_t n, World &wrld)
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...