8 #ifndef OPENFPM_NUMERICS_SRC_MATRIX_SPARSEMATRIX_EIGEN_HPP_ 
    9 #define OPENFPM_NUMERICS_SRC_MATRIX_SPARSEMATRIX_EIGEN_HPP_ 
   11 #include "Vector/map_vector.hpp" 
   12 #include <boost/mpl/int.hpp> 
   13 #include "VCluster/VCluster.hpp" 
   15 #define EIGEN_TRIPLET 1 
   26     Eigen::Triplet<T,long int> triplet_ei;
 
   32         size_t ptr = (size_t)&triplet_ei.row();
 
   34         return (
long int &)*(
long int *)ptr;
 
   39         size_t ptr = (size_t)&triplet_ei.col();
 
   41         return (
long int &)*(
long int *)ptr;
 
   46         size_t ptr = (size_t)&triplet_ei.value();
 
   48         return (T &)*(T *)ptr;
 
   76 template<
typename T, 
typename id_t>
 
   89     Eigen::SparseMatrix<T,0,id_t> mat;
 
  108                 mat.setFromTriplets(trpl_recv.begin(),trpl_recv.end());
 
  111             mat.setFromTriplets(trpl.begin(),trpl.end());
 
  165     const Eigen::SparseMatrix<T,0,id_t> & 
getMat()
 const 
  191     void resize(
size_t row, 
size_t col,
size_t l_row, 
size_t l_col)
 
  203         return mat.coeffRef(i,j);
 
  213     bool save(
const std::string & file)
 const 
  221         pmem.allocate(pap_prp);
 
  230         std::ofstream dump (file, std::ios::out | std::ios::binary);
 
  231         if (dump.is_open() == 
false)
 
  233         dump.write ((
const char *)pmem.getPointer(), pmem.size());
 
  245     bool load(
const std::string & file)
 
  247         std::ifstream fs (file, std::ios::in | std::ios::binary | std::ios::ate );
 
  248         if (fs.is_open() == 
false)
 
  252         size_t sz = fs.tellg();
 
  257         std::ifstream input (file, std::ios::in | std::ios::binary );
 
  258         if (input.is_open() == 
false)
 
  289         for (
size_t i = 0 ; i < trpl.size() ; i++)
 
  291             if (r == (
size_t)trpl.get(i).row() && c == (size_t)trpl.get(i).col())
 
  292                 return trpl.get(i).value();
 
void assemble()
Assemble the matrix. 
 
void collect()
Here we collect the full matrix on master. 
 
boost::mpl::int_< EIGEN_BASE > triplet_impl
Triplet implementation id. 
 
size_t getProcessUnitID()
Get the process unit id. 
 
It store the non zero elements of the matrix. 
 
Eigen::SparseMatrix< T, 0, id_t > & getMat()
Get the Eigen Matrix object. 
 
triplet< T, EIGEN_BASE > triplet_type
Triplet type. 
 
SparseMatrix(size_t N1, size_t N2)
Create an empty Matrix. 
 
This class allocate, and destroy CPU memory. 
 
void resize(size_t row, size_t col, size_t l_row, size_t l_col)
Resize the Sparse Matrix. 
 
Implementation of VCluster class. 
 
virtual void * getPointer()
get a readable pointer with the data 
 
SparseMatrix()
Create an empty Matrix. 
 
const Eigen::SparseMatrix< T, 0, id_t > & getMat() const 
Get the Eigen Matrix object. 
 
Sparse Matrix implementation. 
 
triplet(long int i, long int j, T val)
Constructor from row, colum and value. 
 
bool SGather(T &send, S &recv, size_t root)
Semantic Gather, gather the data from all processors into one node. 
 
bool load(const std::string &file)
Load this object from file. 
 
T getValue(size_t r, size_t c)
Get the value from triplet. 
 
bool save(const std::string &file) const 
Save this object into file. 
 
openfpm::vector< triplet_type > & getMatrixTriplets()
Get the Matrix triplets bugger. 
 
Implementation of 1-D std::vector like structure. 
 
size_t getProcessingUnits()
Get the total number of processors. 
 
T operator()(id_t i, id_t j)
Get the row i and the colum j of the Matrix.