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[] = {
SY,
NS,
SY,NS};
26 int sizeN4[] = {n,n,n,n};
38 for (i=0; i<
np; i++ ) pairs[i] = drand48()-.5;
39 mA.
write(np, indices, pairs);
43 for (i=0; i<
np; i++ ) pairs[i] = drand48()-.5;
44 mB.
write(np, indices, pairs);
50 A[
"abij"] -= mB[
"aa"];
51 B[
"abij"] -= mB[
"bb"];
52 C[
"abij"] = A[
"abij"]-B[
"abij"];
54 double norm = C.
norm2();
59 printf(
"{ (A[\"(ab)(ij)\"]=mA[\"ii\"]-mB[\"aa\"]=mA[\"jj\"]-mB[\"bb\"] } passed \n");
63 printf(
"{ (A[\"(ab)(ij)\"]=mA[\"ii\"]-mB[\"aa\"]=mA[\"jj\"]-mB[\"bb\"] } failed \n");
73 char ** itr = std::find(begin, end, option);
74 if (itr != end && ++itr != end){
81 int main(
int argc,
char ** argv){
84 char ** input_str = argv;
86 MPI_Init(&argc, &argv);
87 MPI_Comm_rank(MPI_COMM_WORLD, &rank);
88 MPI_Comm_size(MPI_COMM_WORLD, &np);
91 n = atoi(
getCmdOption(input_str, input_str+in_num,
"-n"));
char * getCmdOption(char **begin, char **end, const std::string &option)
int main(int argc, char **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 diag_sym(int n, World &dw)
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...