14   int shapeN4[] = {
NS,
NS,
NS,NS};
    15   int sizeN4[] = {n,n,n,n};
    18   Tensor<> A(4, 
true, sizeN4, shapeN4, dw);
    19   Tensor<> B(4, 
true, sizeN4, shapeN4, dw);
    22     int64_t keys_A[4] = {1,2,4,8};
    23     double vals_A[4] = {3.2,42.,1.4,-.8};
    25     A.
write(4, keys_A, vals_A);
    27     int64_t keys_B[4] = {2,3};
    28     double vals_B[4] = {24.,7.2};
    30     B.
write(2, keys_B, vals_B);
    32     A.
write(0, NULL, NULL);
    33     B.
write(0, NULL, NULL);
    39   B[
"abij"] += A[
"abij"];
    48   for (
int i=0; i<nloc; i++){
    49     switch (new_keys_B[i]){
    51         if (fabs(3.2-new_vals_B[i]) > 1.E-9) pass = 0;
    54         if (fabs(66.-new_vals_B[i]) > 1.E-9) pass = 0;
    57         if (fabs(7.2-new_vals_B[i]) > 1.E-9) pass = 0;
    60         if (fabs(1.4-new_vals_B[i]) > 1.E-9) pass = 0;
    63         if (fabs(-.8-new_vals_B[i]) > 1.E-9) pass = 0;
    73   MPI_Allreduce(MPI_IN_PLACE, &pass, 1, MPI_INT, MPI_MIN, MPI_COMM_WORLD);
    76       printf(
"{ B[\"abij\"] += A[\"abij\"] with sparse, A, B } passed \n");
    78       printf(
"{ B[\"abij\"] += A[\"abij\"] with sparse, A, B } failed\n");
    88   char ** itr = std::find(begin, end, option);
    89   if (itr != end && ++itr != end){
    96 int main(
int argc, 
char ** argv){
    98   int const in_num = argc;
    99   char ** input_str = argv;
   101   MPI_Init(&argc, &argv);
   102   MPI_Comm_rank(MPI_COMM_WORLD, &rank);
   103   MPI_Comm_size(MPI_COMM_WORLD, &np);
   106     n = atoi(
getCmdOption(input_str, input_str+in_num, 
"-n"));
   112     World dw(argc, argv);
   115       printf(
"Computing B+=A with B, A sparse\n");
 
char * getCmdOption(char **begin, char **end, const std::string &option)
an instance of the CTF library (world) on a MPI communicator 
int sptensor_sum(int n, World &dw)
int rank
rank of local processor 
int main(int argc, char **argv)
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...
int np
number of processors