ValueCategory.hpp 1.6 KB
Newer Older
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
#pragma once

#include <dune/common/fmatrix.hh>
#include <dune/common/fvector.hh>

namespace AMDiS 
{
  namespace tag 
  {
    // some tags representing Traits classes or categories
    struct none {};
    struct scalar {};
    struct vector {};
    struct matrix {};

  } // end namespace tag

  template <class T>
  struct ValueCategory;

  template <class T>
  using ValueCategory_t = typename ValueCategory<T>::type;

  template <class K, int SIZE>
  struct ValueCategory< Dune::FieldVector<K, SIZE> >
  {
    using type = tag::vector;
  };

  template <class K>
  struct ValueCategory< Dune::FieldVector<K, 1> >
  {
    using type = tag::scalar;
  };

  template <class K, int ROWS, int COLS>
  struct ValueCategory< Dune::FieldMatrix<K, ROWS, COLS> >
  {
    using type = tag::matrix;
  };

  template <class K>
  struct ValueCategory< Dune::FieldMatrix<K, 1, 1> >
  {
    using type = tag::scalar;
  };

  template <> struct ValueCategory<float> 	{ using type = tag::scalar; };
  template <> struct ValueCategory<double> 	{ using type = tag::scalar; };
  template <> struct ValueCategory<long double> { using type = tag::scalar; };
  template <> struct ValueCategory<int> 	{ using type = tag::scalar; };
  template <> struct ValueCategory<long>	{ using type = tag::scalar; };
  template <> struct ValueCategory<long long> 	{ using type = tag::scalar; };
  template <> struct ValueCategory<unsigned int> { using type = tag::scalar; };
  template <> struct ValueCategory<unsigned long> { using type = tag::scalar; };
  template <> struct ValueCategory<unsigned long long> { using type = tag::scalar; };

} // end namespace AMDiS