17 char idx_rep[order+1];
19 char idx_chg[order+1];
21 for (
int i=0; i<order; i++){
32 Tensor<> A(order,
true, size, shape, dw);
50 double sum1 = A[idx_chg];
51 double sum2 = A[idx_rep];
53 int pass = (fabs(sum1-n)<1.E-9) & (fabs(sum2-n)<1.E-9);
54 MPI_Allreduce(MPI_IN_PLACE, &pass, 1, MPI_INT, MPI_MIN, MPI_COMM_WORLD);
57 printf(
"{ A is sparse; A[\"iii...\"]=1; sum(A) = range of i } passed \n");
59 printf(
"{ A is sparse; A[\"iii...\"]=1; sum(A) = range of i } failed \n");
69 char ** itr = std::find(begin, end, option);
70 if (itr != end && ++itr != end){
77 int main(
int argc,
char ** argv){
78 int rank,
np, n, pass, order;
79 int const in_num = argc;
80 char ** input_str = argv;
82 MPI_Init(&argc, &argv);
83 MPI_Comm_rank(MPI_COMM_WORLD, &rank);
84 MPI_Comm_size(MPI_COMM_WORLD, &np);
87 n = atoi(
getCmdOption(input_str, input_str+in_num,
"-n"));
91 if (
getCmdOption(input_str, input_str+in_num,
"-order")){
92 order = atoi(
getCmdOption(input_str, input_str+in_num,
"-order"));
93 if (order < 0) order = 3;
100 printf(
"Computing sum of I where I is an identity tensor of order %d and dimension %d stored sparse\n", order, n);
102 pass =
speye(n, order, dw);
char * getCmdOption(char **begin, char **end, const std::string &option)
an instance of the CTF library (world) on a MPI communicator
int rank
rank of local processor
int main(int argc, char **argv)
int speye(int n, int order, World &dw)
an instance of a tensor within a CTF world