8#ifndef OPENFPM_NUMERICS_SRC_VECTOR_VECTOR_EIGEN_HPP_
9#define OPENFPM_NUMERICS_SRC_VECTOR_VECTOR_EIGEN_HPP_
12#include "util/mul_array_extents.hpp"
14#include "Grid/staggered_dist_grid.hpp"
15#include "Space/Ghost.hpp"
16#include "FiniteDifference/util/common.hpp"
17#include <boost/mpl/vector_c.hpp>
18#include <unordered_map>
19#include "Vector_util.hpp"
94 mutable Eigen::Matrix<T, Eigen::Dynamic, 1>
v;
103 mutable std::unordered_map<size_t,size_t>
map;
122 row_val_recv.clear();
125 vcl.
SGather(row_val,row_val_recv,prc,sz,0);
130 row_val.swap(row_val_recv);
143 for (
size_t i = 0 ; i < row_val.
size() ; i++)
144 v[row_val.get(i).row()] = row_val.get(i).value();
155 for (
size_t i = 0 ; i < row_val.
size() ; i++)
156 map[row_val.get(i).row()] = i;
222 map[i] = row_val.
size()-1;
224 row_val.last().row() = i;
225 row_val.last().value() = val;
240 map[i] = row_val.
size()-1;
242 row_val.last().row() = i;
243 return row_val.last().value();
258 map[i] = row_val.
size()-1;
260 row_val.last().row() = i;
261 return row_val.last().value();
277 std::unordered_map<size_t,size_t>::iterator it = map.find(i);
279 if ( it != map.end() )
280 return row_val.get(it->second).value();
298 std::unordered_map<size_t,size_t>::iterator it = map.find(i);
300 if ( it != map.end() )
301 return row_val.get(it->second).value();
311 const Eigen::Matrix<T, Eigen::Dynamic, 1> &
getVec()
const
324 Eigen::Matrix<T, Eigen::Dynamic, 1> &
getVec()
341 row_val_recv.clear();
344 vcl.
SScatter(row_val,row_val_recv,prc,sz,0);
348 if (row_val_recv.
size() != 0)
351 row_val.add(row_val_recv);
363 std::ifstream inputf;
366 for (
size_t i = 0 ; i < v.size() ; i++)
412 for (
size_t i = 0 ; i < row_val.
size() ; i++)
413 row_val.get(i).value() = v(row_val.get(i).row());
size_t getProcessUnitID()
Get the process unit id.
Implementation of VCluster class.
bool SScatter(T &send, S &recv, openfpm::vector< size_t > &prc, openfpm::vector< size_t > &sz, size_t root)
Semantic Scatter, scatter the data from one processor to the other node.
bool SGather(T &send, S &recv, size_t root)
Semantic Gather, gather the data from all processors into one node.
Eigen::Matrix< T, Eigen::Dynamic, 1 > & getVec()
Get the Eigen Vector object.
void insert(size_t i, T val)
Return a reference to the vector element.
Vector< T > & operator=(Eigen::Matrix< T, Eigen::Dynamic, 1 > &v)
Copy the vector (it is used for special purpose)
std::unordered_map< size_t, size_t > map
global to local map
void scatter()
Scatter the vector information to the other processors.
const T & insert(size_t i) const
Return a reference to the vector element.
Vector(size_t n)
Create a vector with n elements.
openfpm::vector< rval< T, EIGEN_RVAL > > row_val
row val vector
void build_map() const
Build the map.
T & insert(size_t i)
Return a reference to the vector element.
openfpm::vector< size_t > prc
Processors from where we gather.
Vector< T > & operator=(const Vector< T > &v)
Copy the vector.
Vector< T > & operator=(const Vector< T > &&v)
Copy the vector.
void resize(size_t row, size_t l_row)
Resize the Vector.
Vector(const Vector< T > &v)
Copy the vector.
void collect() const
Here we collect the full vector on master.
Eigen::Matrix< T, Eigen::Dynamic, 1 > v
Eigen vector.
T & operator()(size_t i)
Return a reference to the vector element.
Vector()
Create a vector with 0 elements.
Vector(const Vector< T > &&v)
Copy the vector.
void setEigen() const
Set the Eigen internal vector.
void fromFile(std::string file)
Load from file.
openfpm::vector< rval< T, EIGEN_RVAL > > row_val_recv
row val vector received
const T & operator()(size_t i) const
Return a reference to the vector element.
const Eigen::Matrix< T, Eigen::Dynamic, 1 > & getVec() const
Get the Eigen Vector object.
Sparse Matrix implementation stub object when OpenFPM is compiled with no linear algebra support.
void resize(size_t row, size_t row_n)
stub resize
void insert(size_t i, T val)
stub insert
Vector< T > & operator=(const Vector< T > &v)
stub operator=
Implementation of 1-D std::vector like structure.
static bool noPointers()
Indicate that the structure has no pointer.
rval(long int i, T val)
Constructor from row, colum and value.
T & value()
Return the value.
rval()
Default constructor.
long int & row()
Return the row index.
It store one row value of a vector.