Rheolef  7.1
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 #include <Eigen/Dense>
33 #include <Eigen/Sparse>
34 #include <unsupported/Eigen/CXX11/Tensor>
35 #pragma GCC diagnostic pop
36 
37 namespace rheolef { namespace details {
38 
39 // c(j,k) = a(i,j,k)*b(i)
40 template<class T1, class T2, class T3>
41 void
43  const Eigen::Tensor<T1,3>& a,
44  const Eigen::Matrix<T2,Eigen::Dynamic,1>& b,
45  Eigen::Matrix<T3,Eigen::Dynamic,Eigen::Dynamic>& c)
46 {
47  // TODO: c = b.transpose()*a; ==> need compat between Eigen::Matrix and Tensor
48  size_t ni = a.dimension(0);
49  size_t nj = a.dimension(1);
50  size_t nk = a.dimension(2);
51  c.resize (nj, nk);
52  for (size_t j = 0; j < nj; ++j) {
53  for (size_t k = 0; k < nk; ++k) {
54  T3 sum = 0;
55  for (size_t i = 0; i < ni; ++i) {
56  sum += b[i]*a(i,j,k);
57  }
58  c(j,k) = sum;
59  }}
60 }
61 
62 }} // namespace rheolef::details
63 #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.