8 #ifndef OPENFPM_NUMERICS_SRC_VECTOR_VECTOR_EIGEN_HPP_
9 #define OPENFPM_NUMERICS_SRC_VECTOR_VECTOR_EIGEN_HPP_
11 #include <type_traits>
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());
void insert(size_t i, T val)
stub insert
const T & insert(size_t i) const
Return a reference to the vector element.
rval(long int i, T val)
Constructor from row, colum and value.
Eigen::Matrix< T, Eigen::Dynamic, 1 > & getVec()
Get the Eigen Vector object.
openfpm::vector< size_t > prc
Processors from where we gather.
Vector< T > & operator=(const Vector< T > &v)
Copy the vector.
Vector(const Vector< T > &v)
Copy the vector.
size_t getProcessUnitID()
Get the process unit id.
Sparse Matrix implementation stub object when OpenFPM is compiled with no linear algebra support...
void collect() const
Here we collect the full vector on master.
const T & operator()(size_t i) const
Return a reference to the vector element.
Vector(const Vector< T > &&v)
Copy the vector.
openfpm::vector< rval< T, EIGEN_RVAL > > row_val_recv
row val vector received
void scatter()
Scatter the vector information to the other processors.
T & operator()(size_t i)
Return a reference to the vector element.
void fromFile(std::string file)
Load from file.
Implementation of VCluster class.
T & value()
Return the value.
Vector< T > & operator=(const Vector< T > &v)
stub operator=
Vector< T > & operator=(const Vector< T > &&v)
Copy the vector.
void resize(size_t row, size_t row_n)
stub resize
T & insert(size_t i)
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)
It store one row value of a vector.
void insert(size_t i, T val)
Return a reference to the vector element.
void resize(size_t row, size_t l_row)
Resize the Vector.
long int & row()
Return the row index.
static bool noPointers()
Indicate that the structure has no pointer.
bool SGather(T &send, S &recv, size_t root)
Semantic Gather, gather the data from all processors into one node.
rval()
Default constructor.
void build_map() const
Build the map.
void setEigen() const
Set the Eigen internal vector.
Eigen::Matrix< T, Eigen::Dynamic, 1 > v
Eigen vector.
openfpm::vector< rval< T, EIGEN_RVAL > > row_val
row val vector
std::unordered_map< size_t, size_t > map
global to local map
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.
Vector()
Create a vector with 0 elements.
Implementation of 1-D std::vector like structure.
Vector(size_t n)
Create a vector with n elements.
const Eigen::Matrix< T, Eigen::Dynamic, 1 > & getVec() const
Get the Eigen Vector object.