21 MPI_Comm_rank(MPI_COMM_WORLD, &rank);
22 MPI_Comm_size(MPI_COMM_WORLD, &num_pes);
26 printf(
"m = %d, n = %d, p = %d\n",
39 for (i=0; i<
np; i++ ) pairs[i] = drand48()-.5;
40 A.
write(np, indices, pairs);
44 C_NS[
"ij"] = A[
"ik"]*A[
"jk"];
45 C_SY[
"ij"] = A[
"ik"]*A[
"jk"];
47 diff[
"ij"] = C_SY[
"ij"] - C_NS[
"ij"];
49 double err = diff.
norm2();
52 printf(
"{ A[\"ik\"]*A[\"jk\"] = C_NS[\"ij\"] = C_AS[\"ij\"] } passed.\n");
54 printf(
"{ A[\"ik\"]*A[\"jk\"] = C_NS[\"ij\"] = C_AS[\"ij\"] } failed!\n");
65 char ** itr = std::find(begin, end, option);
66 if (itr != end && ++itr != end){
72 int main(
int argc,
char ** argv){
75 char ** input_str = argv;
77 MPI_Init(&argc, &argv);
78 MPI_Comm_rank(MPI_COMM_WORLD, &rank);
79 MPI_Comm_size(MPI_COMM_WORLD, &np);
82 n = atoi(
getCmdOption(input_str, input_str+in_num,
"-n"));
86 m = atoi(
getCmdOption(input_str, input_str+in_num,
"-m"));
91 World dw(MPI_COMM_WORLD, argc, argv);
Matrix class which encapsulates a 2D tensor.
an instance of the CTF library (world) on a MPI communicator
dtype norm2()
computes the frobenius norm of the tensor (needs sqrt()!)
char * getCmdOption(char **begin, char **end, const std::string &option)
int main(int argc, char **argv)
int multi_tsr_sym(int m, int n, World &dw)
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.
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...