13 int rank, num_pes, pass;
14 int64_t
np, * indices;
17 MPI_Comm_rank(MPI_COMM_WORLD, &rank);
18 MPI_Comm_size(MPI_COMM_WORLD, &num_pes);
28 pass -=!(indices[0] == 0);
30 pass -=!(
std::abs(pairs[0]) < 1.E-9);
34 A.
write(np,indices,pairs);
43 pass -=(indices[0] != 0);
45 pass -=!(pairs[0]-4.2 < 1.E-9);
51 pass -=!(val-4.2 < 1.E-9);
55 pass -=!((double)B-4.3 < 1.E-9);
59 pass -=!((double)B-4.2 < 1.E-9);
63 #if 0 //does not make sense to set AS matrix to scalar 95 int sizeN4[4] = {n,0,n,n};
96 int shapeN4[4] = {
NS,
NS,
SY,NS};
102 int sizeN2[2] = {n,n};
107 assert(E.
norm2() <1.E-6);
110 E[
"ii"]=D[
"klij"]*E[
"ki"];
115 E[
"ij"]=D[
"klij"]*E[
"ki"];
122 MPI_Reduce(MPI_IN_PLACE, &pass, 1, MPI_INT, MPI_MIN, 0, MPI_COMM_WORLD);
124 printf(
"{ scalar tests } failed\n");
126 printf(
"{ scalar tests } passed\n");
129 MPI_Reduce(&pass, MPI_IN_PLACE, 1, MPI_INT, MPI_MIN, 0, MPI_COMM_WORLD);
130 if (pass < 0) pass = 0;
140 char ** itr = std::find(begin, end, option);
141 if (itr != end && ++itr != end){
148 int main(
int argc,
char ** argv){
150 MPI_Init(&argc, &argv);
151 MPI_Comm_rank(MPI_COMM_WORLD, &rank);
152 MPI_Comm_size(MPI_COMM_WORLD, &np);
Matrix class which encapsulates a 2D tensor.
char * getCmdOption(char **begin, char **end, const std::string &option)
dtype reduce(OP op)
performs a reduction on the tensor
an instance of the CTF library (world) on a MPI communicator
dtype norm2()
computes the frobenius norm of the tensor (needs sqrt()!)
int scalar(CTF::World &dw)
Scalar class which encapsulates a 0D tensor.
int main(int argc, char **argv)
void print(FILE *fp, dtype cutoff) const
prints tensor data to file using process 0 (modify print(...) overload in set.h if you would like a d...
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...