16   char ** itr = std::find(begin, end, option);
    17   if (itr != end && ++itr != end){
    24 int main(
int argc, 
char ** argv){
    26   int const in_num = argc;
    27   char ** input_str = argv;
    28   double *pairs, *opairs;
    29   int64_t *indices, *oindices, npair, onpair;
    31   MPI_Init(&argc, &argv);
    32   MPI_Comm_rank(MPI_COMM_WORLD, &rank);
    33   MPI_Comm_size(MPI_COMM_WORLD, &np);
    38     d = atoi(
getCmdOption(input_str, input_str+in_num, 
"-d"));
    48     for (
int i=0; i<npair; i++) {
    49       srand48(indices[i]*23);
    52     h.
write(npair, indices, pairs);
    60       for (
int i=0; i<L/2; i++) size[i] = d*d;
    62       for (
int i=0; i<L/2+1; i++) shape[i] = 
NS;
    63       Tensor<> v_in(L/2+1, size, shape, dw);
    65       double t_io_start = MPI_Wtime();
    68       for (
int i=0; i<npair; i++) {
    72       v_in.
write(npair, indices, pairs);
    75       Tensor<> v_out(L/2+1, size, shape, dw);
    77       double t_io_end = MPI_Wtime();
    79       double t_start = MPI_Wtime();
    84       v_out[
"acegikmo"] =  h[
"ax"]*v_in[
"xcegikmo"];
    85       v_out[
"acegikmo"] += h[
"cx"]*v_in[
"axegikmo"];
    86       v_out[
"acegikmo"] += h[
"ex"]*v_in[
"acxgikmo"];
    88       v_out[
"acegikmo"] += h[
"gx"]*v_in[
"acexikmo"];
    89       v_out[
"acegikmo"] += h[
"ix"]*v_in[
"acegxkmo"];
    91       v_out[
"acegikmo"] += h[
"kx"]*v_in[
"acegixmo"];
    92       v_out[
"acegikmo"] += h[
"mx"]*v_in[
"acegikxo"];
    96       double t_end = MPI_Wtime();
    98         printf(
"First set of folded contractions took %lf sec\n", t_end-t_start);
   100       double t_io_start2 = MPI_Wtime();
   102       v_in.get_local_data(&npair, &indices, &pairs);
   105       double t_io_end2 = MPI_Wtime();
   107         printf(
"IO for first set of folded contractions took %lf sec\n", t_io_end-t_io_start + (t_io_end2-t_io_start2));
   115       for (
int i=0; i<L/2; i++) size[i+1] = d*d;
   116       for (
int i=0; i<L/2+1; i++) shape[i] = 
NS;
   117       Tensor<> v_in(L/2+1, size, shape, dw);
   119       double t_io_start = MPI_Wtime();
   120       v_in.
write(npair, indices, pairs);
   123       Tensor<> v_out(L/2+1, size, shape, dw);
   124       v_out.
write(onpair, oindices, opairs);
   125       double t_io_end = MPI_Wtime();
   127       double t_start = MPI_Wtime();
   132       v_out[
"abdfhjln"] += h[
"bx"]*v_in[
"axdfhjln"];
   133       v_out[
"abdfhjln"] += h[
"dx"]*v_in[
"abxfhjln"];
   135       v_out[
"abdfhjln"] += h[
"fx"]*v_in[
"abdxhjln"];
   136       v_out[
"abdfhjln"] += h[
"hx"]*v_in[
"abdfxjln"];
   137       v_out[
"abdfhjln"] += h[
"jx"]*v_in[
"abdfhxln"];
   139       v_out[
"abdfhjln"] += h[
"lx"]*v_in[
"abdfhjxn"];
   140       v_out[
"abdfhjln"] += h[
"nx"]*v_in[
"abdfhjlx"];
   144       double t_end = MPI_Wtime();
   146       double t_norm_start = MPI_Wtime();
   147       double norm = v_out.
norm2();
   148       double t_norm_end = MPI_Wtime();
   150         printf(
"second set of folded contractions took %lf seconds\n",t_end-t_start);
   151         printf(
"IO for second set of folded contractions took %lf sec\n", t_io_end-t_io_start);
   152         printf(
"norm of v_out is %lf\n",norm);
   153         printf(
"calculating norm of v_out took %lf sec\n", t_norm_end-t_norm_start);
   162     for (
int i=0; i<L; i++) size[i] = d;
   163     for (
int i=0; i<L; i++) shape[i] = 
NS;
   166     double t_io_start = MPI_Wtime();
   168     for (
int i=0; i<npair; i++) {
   170       pairs[i] = drand48();
   172     v_in.
write(npair, indices, pairs);
   176     for (
int i=0; i<npair; i++) {
   177       srand48(indices[i]*23);
   178       pairs[i] = drand48();
   180     h.
write(npair, indices, pairs);
   185     double t_io_end = MPI_Wtime();
   187     double t_start = MPI_Wtime();
   192     v_out[
"abcdefghijklmno"] = h[
"abxy"]*v_in[
"xycdefghijklmno"];
   193     v_out[
"abcdefghijklmno"] += h[
"bcxy"]*v_in[
"axydefghijklmno"];
   194     v_out[
"abcdefghijklmno"] += h[
"cdxy"]*v_in[
"abxyefghijklmno"];
   195     v_out[
"abcdefghijklmno"] += h[
"dexy"]*v_in[
"abcxyfghijklmno"];
   196     v_out[
"abcdefghijklmno"] += h[
"efxy"]*v_in[
"abcdxyghijklmno"];
   198     v_out[
"abcdefghijklmno"] += h[
"fgxy"]*v_in[
"abcdexyhijklmno"];
   199     v_out[
"abcdefghijklmno"] += h[
"ghxy"]*v_in[
"abcdefxyijklmno"];
   200     v_out[
"abcdefghijklmno"] += h[
"hixy"]*v_in[
"abcdefgxyjklmno"];
   201     v_out[
"abcdefghijklmno"] += h[
"ijxy"]*v_in[
"abcdefghxyklmno"];
   202     v_out[
"abcdefghijklmno"] += h[
"jkxy"]*v_in[
"abcdefghixylmno"];
   204     v_out[
"abcdefghijklmno"] += h[
"klxy"]*v_in[
"abcdefghijxymno"];
   205     v_out[
"abcdefghijklmno"] += h[
"lmxy"]*v_in[
"abcdefghijkxyno"];
   206     v_out[
"abcdefghijklmno"] += h[
"mnxy"]*v_in[
"abcdefghijklxyo"];
   207     v_out[
"abcdefghijklmno"] += h[
"noxy"]*v_in[
"abcdefghijklmxy"];
   210     double t_end = MPI_Wtime();
   212     double t_norm_start = MPI_Wtime();
   213     double norm = v_out.
norm2();
   214     double t_norm_end = MPI_Wtime();
   216       printf(
"unfolded contractions took %lf seconds\n", t_end-t_start);
   217       printf(
"unfolded IO took %lf seconds\n", t_io_end-t_io_start);
   218       printf(
"unfolded norm of v_out is %lf\n", norm);
   219       printf(
"calculating norm of v_out took %lf sec\n", t_norm_end-t_norm_start);
 
char * getCmdOption(char **begin, char **end, const std::string &option)
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()!) 
epoch during which to measure timers 
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 
int main(int argc, char **argv)
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...