LehrFEM++ 1.0.0
A simple Finite Element Library for teaching
eigen_tools.h
1
9#ifndef __1cc1076600024d7ea537871be7fc1fc0
10#define __1cc1076600024d7ea537871be7fc1fc0
11
12// clang-format off
13#include "lf_assert.h" // must be included before eigen!
14// clang-format on
15
16#include <Eigen/Core>
17#include <utility>
18
19namespace lf::base {
20
21namespace internal {
22
23struct IsEigenMatrixTester {
24 template <class SCALAR, int ROWS, int COLS, int OPTIONS, int MAX_ROWS,
25 int MAX_COLS>
26 static bool Test(
27 const Eigen::Matrix<SCALAR, ROWS, COLS, OPTIONS, MAX_ROWS, MAX_COLS>&,
28 int);
29
30 template <class T>
31 static float Test(const T&, long);
32};
33
34struct IsEigenArrayTester {
35 template <class SCALAR, int ROWS, int COLS, int OPTIONS, int MAX_ROWS,
36 int MAX_COLS>
37 static bool Test(
38 const Eigen::Array<SCALAR, ROWS, COLS, OPTIONS, MAX_ROWS, MAX_COLS>&,
39 int);
40
41 template <class T>
42 static float Test(const T&, long);
43};
44
45} // namespace internal
46
50template <class T>
51inline constexpr bool is_eigen_matrix = std::is_same_v<
52 decltype(internal::IsEigenMatrixTester::Test(std::declval<T>(), 0)), bool>;
53
57template <class T>
58inline constexpr bool is_eigen_array = std::is_same_v<
59 decltype(internal::IsEigenArrayTester::Test(std::declval<T>(), 0)), bool>;
60
61} // namespace lf::base
62
63#endif // __1cc1076600024d7ea537871be7fc1fc0
Contains basic functionality that is used by other parts of LehrFEM++.
Definition: base.h:15
constexpr bool is_eigen_matrix
Check if a given type T is an Eigen::Matrix.
Definition: eigen_tools.h:51
constexpr bool is_eigen_array
Check if a given type T is an Eigen::Array.
Definition: eigen_tools.h:58