12 template <
typename dtype>
    18     W[
"ij"], [=](
dtype & 
a){ 
a=mulid; };
    19     int ssym[] = {
SH, 
NS};
    20     int nsym[] = {
NS, NS};
    23     V[
"i"] = W2[
"ji"]*V[
"j"];
    27     for (
int i=0; i<V.
order; i++){ str[i] = 
'a'+i; }
    33     W[
"ij"], [=](
dtype & 
a){ 
a=mulid; };
    34     int hsym[] = {
SH, 
NS};
    35     int nsym[] = {
NS, NS};
    39     memcpy(str2+1, str+1, V.
order-1);
    40     str2[0] = 
'a'+V.
order;
    41     char strW[2] = {str2[0],
'a'};
    42     V[str]  = W2[strW]*V[str2];
    47 template<
typename dtype>
    54   std::fill(lens, lens+logn, 2);
    60   V.
write(np, inds, data);
    69   v.
write(np, inds, data);
    83   double start_data[1<<logn];
    94   for (
int i=1; i<1<<logn; i++){
    95     if (
std::abs(data[i] - start_data[i-1] - data[i-1]) >= 1.E-9*(1<<logn)) pass = 0;
    99       printf(
"{ scan via tensor contractions } passed \n");
   101       printf(
"{ scan via tensor contractions } failed \n");
   111   char ** itr = std::find(begin, end, option);
   112   if (itr != end && ++itr != end){
   119 int main(
int argc, 
char ** argv){
   121   int const in_num = argc;
   122   char ** input_str = argv;
   124   MPI_Init(&argc, &argv);
   125   MPI_Comm_rank(MPI_COMM_WORLD, &rank);
   126   MPI_Comm_size(MPI_COMM_WORLD, &np);
   128   if (
getCmdOption(input_str, input_str+in_num, 
"-logn")){
   129     logn = atoi(
getCmdOption(input_str, input_str+in_num, 
"-logn"));
   130     if (logn < 0) logn = 4;
   135     World dw(argc, argv);
   138       printf(
"Running scan on dimension %d vector\n",1<<logn);
 
Matrix class which encapsulates a 2D tensor. 
Vector class which encapsulates a 1D tensor. 
void read_all(int64_t *npair, dtype **data, bool unpack=false)
collects the entire tensor data on each process (not memory scalable) 
char * getCmdOption(char **begin, char **end, const std::string &option)
an instance of the CTF library (world) on a MPI communicator 
int order
number of tensor dimensions 
CTF::World * wrld
distributed processor context on which tensor is defined 
void fill_random(dtype rmin, dtype rmax)
fills local unique tensor elements to random values in the range [min,max] works only for dtype in {f...
int rank
rank of local processor 
int * lens
unpadded tensor edge lengths 
void rec_scan(Tensor< dtype > &V)
algstrct * sr
algstrct on which tensor elements and operations are defined 
void scan(Vector< dtype > &v, int logn)
int scan_test(int logn, World &dw)
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...