16 int rank, i, num_pes, pass;
21 MPI_Comm_rank(MPI_COMM_WORLD, &rank);
22 MPI_Comm_size(MPI_COMM_WORLD, &num_pes);
25 int shapeN4[] = {
NS,
NS,
NS,NS};
26 int shapeS4[] = {
NS,
NS,
SY,NS};
27 int sizeN4[] = {n,n,n,n};
34 for (i=0; i<
np; i++ ) pairs[i] = drand48()-.5;
35 As.
write(np, indices, pairs);
36 An.
write(np, indices, pairs);
40 Anr[
"ijkl"] -= As[
"ijkl"];
42 double norm = Anr.
norm2();
50 printf(
"{ NS -> SY repack } failed \n");
55 Asur.
write(np, indices, pairs);
56 Anur[
"ijkl"] -= Asur[
"ijkl"];
63 printf(
"{ NS -> SY -> NS repack } passed \n");
67 printf(
"{ SY -> NS repack } failed \n");
81 char ** itr = std::find(begin, end, option);
82 if (itr != end && ++itr != end){
89 int main(
int argc,
char ** argv){
92 char ** input_str = argv;
94 MPI_Init(&argc, &argv);
95 MPI_Comm_rank(MPI_COMM_WORLD, &rank);
96 MPI_Comm_size(MPI_COMM_WORLD, &np);
99 n = atoi(
getCmdOption(input_str, input_str+in_num,
"-n"));
105 World dw(argc, argv);
int main(int argc, char **argv)
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)
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 repack(int n, World &dw)
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...