#include #include #include #include #include #include #include #include namespace ublas = boost::numeric::ublas; using namespace std; //const int numNodes = 196; //const int numTetrahedrons = 617; // const int numNodes = 920; // const int numTetrahedrons = 4196; const unsigned int numNodes = 32000ul; const unsigned int numTetrahedrons = numNodes*4; struct use_append { template < class MATRIX, class I, class T > static void apply (MATRIX & M, I i, I j, T value) { M.append_element(i,j,value); } }; struct use_plus_assign { template < class MATRIX, class I, class T > static void apply (MATRIX & M, I i, I j, T value) { M(i,j) += value; } }; template < class MATRIX, class OPERATION > MATRIX assemble() { MATRIX K(numNodes*3, numNodes*3); ublas::matrix ke[numTetrahedrons];//array of element stiffness matrices (12x12) ublas::vector index(numTetrahedrons*12);//mapping from local element index to global index, 12 for each element boost::mt19937 mtrand; mtrand.seed(12345ul); //fill index vector with random unsigned integers in [0, numNodes-1] and fill element stiffness matrix with random stuff for(unsigned int i=0; i > > GVOV; typedef ublas::coordinate_matrix COO; typedef ublas::compressed_matrix CRS; cout << "GVOV with COO-vector\n"; GVOV gvov = GVOV( assemble< GVOV , use_append >() ); cout << "COO-matrix\n"; COO coo = COO ( assemble< COO , use_append >() ); cout << "CRS-matrix\n"; CRS crs; if (numNodes <= 500ul) { crs = CRS( assemble< CRS , use_plus_assign >() ); } else { cout << "skipped due to size\n"; } cout << "dense-matrix\n"; if (numNodes <= 8000ul) { assemble< ublas::matrix , use_plus_assign >(); } else { cout << "skipped due to size\n"; } cout << "gvov - coo: " << norm_inf(gvov - coo) << endl; if (numNodes <= 500ul) { cout << "gvov - crs: " << norm_inf(gvov - crs) << endl; cout << "crs - coo: " << norm_inf(crs - coo) << endl; } return 0; }