11 MPI_Comm_rank(MPI_COMM_WORLD, &rank);
12 MPI_Comm_size(MPI_COMM_WORLD, &num_pes);
30 for (i=0; i<size; i++){
31 values[i] = drand48();
33 T.
write(size, indices, values);
37 for (i=0; i<size; i++){
38 values[i] = drand48();
40 V.
write(size, indices, values);
43 Z_NS[
"af"] = T[
"ae"]*V[
"ef"];
44 W_ans[
"ab"] = Z_NS[
"af"]*T[
"fb"];
45 Z_AS[
"af"] = T[
"ae"]*V[
"ef"];
46 Z_SY[
"af"] = T[
"ae"]*V[
"ef"];
48 W[
"ab"] = .5*Z_SY[
"af"]*T[
"fb"];
49 W[
"ab"] += .5*Z_SY[
"aa"]*T[
"ab"];
50 W[
"ab"] += .5*Z_AS[
"af"]*T[
"fb"];
51 W[
"ab"] -= W_ans[
"ab"];
53 int pass = (W.
norm2() <=1.E-10);
56 MPI_Reduce(MPI_IN_PLACE, &pass, 1, MPI_INT, MPI_MIN, 0, MPI_COMM_WORLD);
57 if (pass) printf(
"{ C[\"(ij)\"] = A[\"(ik)\"]*B[\"(kj)\"] } passed\n");
58 else printf(
"{ C[\"(ij)\"] = A[\"(ik)\"]*B[\"(kj)\"] } failed\n");
60 MPI_Reduce(&pass, MPI_IN_PLACE, 1, MPI_INT, MPI_MIN, 0, MPI_COMM_WORLD);
68 char ** itr = std::find(begin, end, option);
69 if (itr != end && ++itr != end){
76 int main(
int argc,
char ** argv){
78 int const in_num = argc;
79 char ** input_str = argv;
81 MPI_Init(&argc, &argv);
82 MPI_Comm_rank(MPI_COMM_WORLD, &rank);
83 MPI_Comm_size(MPI_COMM_WORLD, &np);
86 n = atoi(
getCmdOption(input_str, input_str+in_num,
"-n"));
91 World dw(MPI_COMM_WORLD, argc, argv);
93 printf(
"Computing W^(ab)=sum_(ef)T^(ae)*V^(ef)*T^(fb)\n");
Matrix class which encapsulates a 2D tensor.
Vector class which encapsulates a 1D tensor.
an instance of the CTF library (world) on a MPI communicator
void read_local(int64_t *npair, int64_t **global_idx, dtype **data, bool unpack_sym=false) const
Using get_local_data(), which returns an array that must be freed with delete [], is more efficient...
dtype norm2()
computes the frobenius norm of the tensor (needs sqrt()!)
int main(int argc, char **argv)
char * getCmdOption(char **begin, char **end, const std::string &option)
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...
int fast_diagram(int const n, World &ctf)