Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix ifdef guards for Eigen #21

Merged
merged 1 commit into from
Nov 10, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Move ifdef guards for eigen
pierrepebay committed Nov 8, 2024
commit 330c93a0ba81d53ae67e76aadae51408c9c40a8d
4 changes: 0 additions & 4 deletions include/pressio/type_traits.hpp
Original file line number Diff line number Diff line change
@@ -59,9 +59,7 @@ template<class T, class Enable = void> struct Traits;
#include "type_traits/nested_typedef_detection.hpp"

//*** vector ****
#ifdef PRESSIO_ENABLE_TPL_EIGEN
#include "type_traits/native_eigen_vector.hpp"
#endif
#ifdef PRESSIO_ENABLE_TPL_KOKKOS
#include "type_traits/native_kokkos_vector.hpp"
#endif
@@ -81,10 +79,8 @@ template<class T, class Enable = void> struct Traits;
#ifdef PRESSIO_ENABLE_TPL_TRILINOS
#include "type_traits/native_teuchos_dense_matrix.hpp"
#endif
#ifdef PRESSIO_ENABLE_TPL_EIGEN
#include "type_traits/native_eigen_dense_matrix.hpp"
#include "type_traits/native_eigen_sparse_matrix.hpp"
#endif

//*** multi vector ****
#ifdef PRESSIO_ENABLE_TPL_TRILINOS
12 changes: 12 additions & 0 deletions include/pressio/type_traits/native_eigen_dense_matrix.hpp
Original file line number Diff line number Diff line change
@@ -49,13 +49,16 @@
#ifndef PRESSIOOPS_TYPE_TRAITS_NATIVE_EIGEN_DENSE_MATRIX_HPP_
#define PRESSIOOPS_TYPE_TRAITS_NATIVE_EIGEN_DENSE_MATRIX_HPP_

#ifdef PRESSIO_ENABLE_TPL_EIGEN
#include "Eigen/Dense"
#endif

namespace pressio{

template <typename T, typename enable = void>
struct is_static_dense_matrix_eigen : std::false_type {};

#ifdef PRESSIO_ENABLE_TPL_EIGEN
/* T is a dense STATIC eigen matrix if
* T is not an eigen vector
* rows and cols are not = Eigen:Dynamic
@@ -73,11 +76,13 @@ struct is_static_dense_matrix_eigen<
T::ColsAtCompileTime != Eigen::Dynamic
>
> : std::true_type{};
#endif
//----------------------------------------------------------------------

template <typename T, typename enable = void>
struct is_dynamic_dense_matrix_eigen : std::false_type {};

#ifdef PRESSIO_ENABLE_TPL_EIGEN
/* T is a dense DYNAMIC eigen matrix if
* is not an eigen vector
* is not a static dense matrix
@@ -148,11 +153,13 @@ struct is_dynamic_dense_matrix_eigen<
T::ColsAtCompileTime != Eigen::Dynamic
>
> : std::true_type{};
#endif
//----------------------------------------------------------------------

template <typename T, typename enable = void>
struct is_dense_row_major_matrix_eigen : std::false_type {};

#ifdef PRESSIO_ENABLE_TPL_EIGEN
template<typename T>
struct is_dense_row_major_matrix_eigen<
T,
@@ -162,11 +169,13 @@ struct is_dense_row_major_matrix_eigen<
int(T::IsRowMajor)==1
>
> : std::true_type{};
#endif
//----------------------------------------------------------------------

template <typename T, typename enable = void>
struct is_dense_col_major_matrix_eigen : std::false_type {};

#ifdef PRESSIO_ENABLE_TPL_EIGEN
template<typename T>
struct is_dense_col_major_matrix_eigen<
T,
@@ -176,11 +185,13 @@ struct is_dense_col_major_matrix_eigen<
int(T::IsRowMajor)==0
>
> : std::true_type{};
#endif
//----------------------------------------------------------------------

template <typename T, typename enable = void>
struct is_dense_matrix_eigen : std::false_type {};

#ifdef PRESSIO_ENABLE_TPL_EIGEN
template<typename T>
struct is_dense_matrix_eigen<
T,
@@ -189,6 +200,7 @@ struct is_dense_matrix_eigen<
is_dynamic_dense_matrix_eigen<T>::value
>
> : std::true_type{};
#endif

}//end namespace
#endif // PRESSIOOPS_TYPE_TRAITS_NATIVE_EIGEN_DENSE_MATRIX_HPP_
5 changes: 4 additions & 1 deletion include/pressio/type_traits/native_eigen_sparse_matrix.hpp
Original file line number Diff line number Diff line change
@@ -49,13 +49,16 @@
#ifndef PRESSIOOPS_TYPE_TRAITS_NATIVE_EIGEN_SPARSE_MATRIX_HPP_
#define PRESSIOOPS_TYPE_TRAITS_NATIVE_EIGEN_SPARSE_MATRIX_HPP_

#ifdef PRESSIO_ENABLE_TPL_EIGEN
#include "Eigen/Sparse"
#endif

namespace pressio{

template <typename T, typename enable = void>
struct is_sparse_matrix_eigen : std::false_type {};

#ifdef PRESSIO_ENABLE_TPL_EIGEN
/*
* T is an eigen sparse matrix if is
* not an eigen vector
@@ -72,7 +75,7 @@ struct is_sparse_matrix_eigen<
>::value
>
> : std::true_type{};

#endif

//----------------------------------------------------------------------

20 changes: 20 additions & 0 deletions include/pressio/type_traits/native_eigen_vector.hpp
Original file line number Diff line number Diff line change
@@ -49,13 +49,16 @@
#ifndef PRESSIOOPS_TYPE_TRAITS_NATIVE_EIGEN_VECTOR_HPP_
#define PRESSIOOPS_TYPE_TRAITS_NATIVE_EIGEN_VECTOR_HPP_

#ifdef PRESSIO_ENABLE_TPL_EIGEN
#include <Eigen/Dense>
#endif

namespace pressio{

template <typename T, typename enable = void>
struct is_dynamic_row_vector_eigen : std::false_type {};

#ifdef PRESSIO_ENABLE_TPL_EIGEN
template <typename T>
struct is_dynamic_row_vector_eigen<
T,
@@ -66,11 +69,13 @@ struct is_dynamic_row_vector_eigen<
>::value
>
> : std::true_type{};
#endif
//----------------------------------------------

template <typename T, typename enable = void>
struct is_static_row_vector_eigen : std::false_type {};

#ifdef PRESSIO_ENABLE_TPL_EIGEN
template <typename T>
struct is_static_row_vector_eigen<
T,
@@ -82,11 +87,14 @@ struct is_static_row_vector_eigen<
!is_dynamic_row_vector_eigen<T>::value
>
> : std::true_type{};
#endif
//----------------------------------------------

template <typename T, typename enable = void>
struct is_dynamic_column_vector_eigen : std::false_type {};


#ifdef PRESSIO_ENABLE_TPL_EIGEN
template <typename T>
struct is_dynamic_column_vector_eigen<
T,
@@ -97,11 +105,14 @@ struct is_dynamic_column_vector_eigen<
>::value
>
> : std::true_type{};
#endif
//----------------------------------------------

template <typename T, typename enable = void>
struct is_static_column_vector_eigen : std::false_type {};


#ifdef PRESSIO_ENABLE_TPL_EIGEN
template <typename T>
struct is_static_column_vector_eigen<
T,
@@ -113,11 +124,14 @@ struct is_static_column_vector_eigen<
!is_dynamic_column_vector_eigen<T>::value
>
> : std::true_type{};
#endif
//----------------------------------------------

template <typename T, typename enable = void>
struct is_static_vector_eigen : std::false_type {};


#ifdef PRESSIO_ENABLE_TPL_EIGEN
template <typename T>
struct is_static_vector_eigen<
T,
@@ -126,11 +140,14 @@ struct is_static_vector_eigen<
is_static_column_vector_eigen<T>::value
>
> : std::true_type{};
#endif
//----------------------------------------------

template <typename T, typename enable = void>
struct is_dynamic_vector_eigen : std::false_type {};


#ifdef PRESSIO_ENABLE_TPL_EIGEN
template <typename T>
struct is_dynamic_vector_eigen<
T,
@@ -139,11 +156,13 @@ struct is_dynamic_vector_eigen<
is_dynamic_column_vector_eigen<T>::value
>
> : std::true_type{};
#endif
//----------------------------------------------

template <typename T, typename enable = void>
struct is_vector_eigen : std::false_type {};

#ifdef PRESSIO_ENABLE_TPL_EIGEN
template <typename T>
struct is_vector_eigen<
T,
@@ -152,6 +171,7 @@ struct is_vector_eigen<
is_static_vector_eigen<T>::value
>
> : std::true_type{};
#endif

}//end namespace
#endif // PRESSIOOPS_TYPE_TRAITS_NATIVE_EIGEN_VECTOR_HPP_