25 spA[
"ij"] += dnA[
"ij"];
28 dnA[
"ij"] += spA[
"ij"];
32 c1[
"i"] += dnA[
"ij"]*b[
"j"];
34 c2[
"i"] += .5*spA[
"ij"]*b[
"j"];
35 c2[
"i"] += .5*b[
"j"]*spA[
"ij"];
38 bool pass = c2.
norm2() >= 1E-6;
42 if (pass) pass = c2.
norm2() <= 1.E-6;
46 printf(
"{ c[\"i\"] += A[\"ij\"]*b[\"j\"] with sparse, A } passed \n");
48 printf(
"{ c[\"i\"] += A[\"ij\"]*b[\"j\"] with sparse, A } failed \n");
58 char ** itr = std::find(begin, end, option);
59 if (itr != end && ++itr != end){
66 int main(
int argc,
char ** argv){
68 int const in_num = argc;
69 char ** input_str = argv;
71 MPI_Init(&argc, &argv);
72 MPI_Comm_rank(MPI_COMM_WORLD, &rank);
73 MPI_Comm_size(MPI_COMM_WORLD, &np);
76 n = atoi(
getCmdOption(input_str, input_str+in_num,
"-n"));
85 printf(
"Multiplying %d-by-%d sparse matrix by vector\n",n,n);
Matrix class which encapsulates a 2D tensor.
int spmv(int n, World &dw)
Vector class which encapsulates a 1D tensor.
an instance of the CTF library (world) on a MPI communicator
dtype norm2()
computes the frobenius norm of the tensor (needs sqrt()!)
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 main(int argc, char **argv)
int rank
rank of local processor
char * getCmdOption(char **begin, char **end, const std::string &option)
void sparsify()
reduce tensor to sparse format, storing only nonzero data, or data above a specified threshold...