Xped
Loading...
Searching...
No Matches
VectorInterface_Eigen_impl.hpp
Go to the documentation of this file.
1#ifndef VECTOR_INTERFACE_EIGEN_IMPL_H_
2#define VECTOR_INTERFACE_EIGEN_IMPL_H_
3
4#include "Eigen/Dense"
5
6#include "Xped/Util/Mpi.hpp"
7
8namespace Xped {
9
10struct VectorInterface
11{
12 // typedefs
13 template <typename Scalar>
14 using VType = Eigen::Array<Scalar, Eigen::Dynamic, 1>;
15
16 typedef Eigen::Index VIndextype;
17
18 // constructors
19 template <typename Scalar>
20 static VType<Scalar> construct(const VIndextype& elems, const mpi::XpedWorld& = mpi::getUniverse());
21
22 template <typename Scalar>
24
25 template <typename Scalar>
26 static void resize(VType<Scalar>& V, const VIndextype& new_elems);
27
28 // initialization
29 template <typename Scalar>
30 static void setZero(VType<Scalar>& V);
31
32 template <typename Scalar>
33 static void setRandom(VType<Scalar>& V);
34
35 template <typename Scalar>
36 static void setConstant(VType<Scalar>& V, const Scalar& val);
37
38 // shape
39 template <typename Scalar>
41
42 template <typename Scalar>
43 static const Eigen::CwiseBinaryOp<Eigen::internal::scalar_sum_op<Scalar, Scalar>, const VType<Scalar>, const VType<Scalar>>
44 sum(const VType<Scalar>& V1, const VType<Scalar>& V2);
45
46 template <typename Scalar>
47 static const Eigen::CwiseBinaryOp<Eigen::internal::scalar_difference_op<Scalar, Scalar>, const VType<Scalar>, const VType<Scalar>>
48 substract(const VType<Scalar>& V1, const VType<Scalar>& V2);
49
50 template <typename Scalar>
51 static const Eigen::CwiseBinaryOp<Eigen::internal::scalar_product_op<Scalar, Scalar>, Scalar, const VType<Scalar>> scale(const VType<Scalar>& V,
52 const Scalar& val);
53
54 // block
55 template <typename Scalar>
56 static const Eigen::VectorBlock<const VType<Scalar>> sub(const VType<Scalar>& V, const VIndextype& off, const VIndextype& elems);
57
58 template <typename Scalar>
59 static std::string print(const VType<Scalar>& V);
60
61 template <typename Scalar>
62 static void vec_to_stdvec(const VType<Scalar>& V, std::vector<Scalar>& vec);
63};
64
65} // namespace Xped
66
67#ifndef XPED_COMPILED_LIB
69#endif
70
71#endif
XpedWorld & getUniverse()
Definition: Mpi.hpp:49
Definition: bench.cpp:62
static void setConstant(VType< Scalar > &V, const Scalar &val)
static void vec_to_stdvec(VT &&V, std::vector< Scalar > &vec)
Definition: VectorInterface_Cyclops_impl.cpp:98
static VType< Scalar > construct(const VIndextype &elems, CTF::World &world)
Definition: VectorInterface_Cyclops_impl.cpp:15
static VType< Scalar > construct_with_zero(const VIndextype &elems, CTF::World &world)
Definition: VectorInterface_Cyclops_impl.cpp:21
static VIndextype length(const VType< Scalar > &V)
static void setRandom(VType< Scalar > &V)
static void setZero(VType< Scalar > &V)
static const Eigen::CwiseBinaryOp< Eigen::internal::scalar_sum_op< Scalar, Scalar >, const VType< Scalar >, const VType< Scalar > > sum(const VType< Scalar > &V1, const VType< Scalar > &V2)
Definition: VectorInterface_Eigen_impl.cpp:60
static const Eigen::CwiseBinaryOp< Eigen::internal::scalar_difference_op< Scalar, Scalar >, const VType< Scalar >, const VType< Scalar > > substract(const VType< Scalar > &V1, const VType< Scalar > &V2)
Definition: VectorInterface_Eigen_impl.cpp:67
int VIndextype
Definition: VectorInterface_Cyclops_impl.hpp:14
static std::string print(const VType< Scalar > &V)
Eigen::Index VIndextype
Definition: VectorInterface_Eigen_impl.hpp:16
static VType< Scalar > scale(VT1 &&V, const Scalar &val)
Definition: VectorInterface_Cyclops_impl.cpp:75
CTF::Vector< Scalar > VType
Definition: VectorInterface_Cyclops_impl.hpp:12
static VType< Scalar > sub(const VType< Scalar > &V, const VIndextype &off, const VIndextype &elems)
Definition: VectorInterface_Cyclops_impl.cpp:84
static void resize(VType< Scalar > &V, const VIndextype &new_elems)
Definition: Mpi.hpp:34