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 sizeN4[] = {n,n,n,n};
40 for (i=0; i<
np; i++ ) pairs[i] = drand48()-.5;
45 for (i=0; i<
np; i++ ) pairs[i] = drand48()-.5;
50 for (i=0; i<
np; i++ ) pairs[i] = drand48()-.5;
51 C.
write(np, indices, pairs);
58 C[
"ij"] += A[
"ij"]*B[
"ijkl"];
59 Cn[
"ij"] += An[
"ij"]*B[
"ijkl"];
60 Cn[
"ji"] += An[
"ij"]*B[
"ijkl"];
65 double norm = Cn.
norm2();
70 printf(
"{ C[\"(ij)\"]=A[\"(ij)\"]*B[\"ijkl\"] } passed \n");
74 printf(
"{ C[\"(ij)\"]=A[\"(ij)\"]*B[\"ijkl\"] } failed \n");
84 char ** itr = std::find(begin, end, option);
85 if (itr != end && ++itr != end){
92 int main(
int argc,
char ** argv){
95 char ** input_str = argv;
97 MPI_Init(&argc, &argv);
98 MPI_Comm_rank(MPI_COMM_WORLD, &rank);
99 MPI_Comm_size(MPI_COMM_WORLD, &np);
102 n = atoi(
getCmdOption(input_str, input_str+in_num,
"-n"));
108 World dw(argc, argv);
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()!)
int main(int argc, char **argv)
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 sy_times_ns(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...