Rheolef  7.2
an efficient C++ finite element environment
compiler_eigen.h
Go to the documentation of this file.
1 #ifndef _RHEOLEF_COMPILER_EIGEN_H
2 #define _RHEOLEF_COMPILER_EIGEN_H
23 // just include eigen Dense & Tensor without any warning
24 // author: Pierre.Saramito@imag.fr
25 // date: 22 january 2019
26 
27 #include "rheolef/compiler.h"
28 
29 #pragma GCC diagnostic push
30 #pragma GCC diagnostic ignored "-Weffc++"
31 #pragma GCC diagnostic ignored "-Wignored-attributes"
32 #pragma GCC diagnostic ignored "-Wuninitialized"
33 #pragma GCC diagnostic ignored "-Wmaybe-uninitialized"
34 #include <Eigen/Dense>
35 #include <Eigen/Sparse>
36 #include <unsupported/Eigen/CXX11/Tensor>
37 #pragma GCC diagnostic pop
38 
39 namespace rheolef { namespace details {
40 
41 // c(j,k) = a(i,j,k)*b(i)
42 template<class T1, class T2, class T3>
43 void
45  const Eigen::Tensor<T1,3>& a,
46  const Eigen::Matrix<T2,Eigen::Dynamic,1>& b,
47  Eigen::Matrix<T3,Eigen::Dynamic,Eigen::Dynamic>& c)
48 {
49  // TODO: c = b.transpose()*a; ==> need compat between Eigen::Matrix and Tensor
50  size_t ni = a.dimension(0);
51  size_t nj = a.dimension(1);
52  size_t nk = a.dimension(2);
53  c.resize (nj, nk);
54  for (size_t j = 0; j < nj; ++j) {
55  for (size_t k = 0; k < nk; ++k) {
56  T3 sum = 0;
57  for (size_t i = 0; i < ni; ++i) {
58  sum += b[i]*a(i,j,k);
59  }
60  c(j,k) = sum;
61  }}
62 }
63 
64 }} // namespace rheolef::details
65 #endif // _RHEOLEF_COMPILER_EIGEN_H
void contract0_tensor3_vector(const Eigen::Tensor< T1, 3 > &a, const Eigen::Matrix< T2, Eigen::Dynamic, 1 > &b, Eigen::Matrix< T3, Eigen::Dynamic, Eigen::Dynamic > &c)
This file is part of Rheolef.