GMatTensor 0.10.6
Loading...
Searching...
No Matches
config.h
Go to the documentation of this file.
1
9#ifndef GMATTENSOR_CONFIG_H
10#define GMATTENSOR_CONFIG_H
11
12#include <algorithm>
13#include <string>
14
15#ifdef GMATTENSOR_USE_XTENSOR_PYTHON
16#include <xtensor-python/pytensor.hpp>
17#else
18#include <xtensor/xtensor.hpp>
19#endif
20
24#define Q(x) #x
25#define QUOTE(x) Q(x)
26
27#define UNUSED(p) ((void)(p))
28
29#define GMATTENSOR_ASSERT_IMPL(expr, file, line) \
30 if (!(expr)) { \
31 throw std::runtime_error( \
32 std::string(file) + ':' + std::to_string(line) + \
33 ": assertion failed (" #expr ") \n\t"); \
34 }
56#ifdef GMATTENSOR_ENABLE_ASSERT
57#define GMATTENSOR_ASSERT(expr) GMATTENSOR_ASSERT_IMPL(expr, __FILE__, __LINE__)
58#else
59#define GMATTENSOR_ASSERT(expr)
60#endif
61
65namespace GMatTensor {
66
70namespace array_type {
71
72#ifdef GMATTENSOR_USE_XTENSOR_PYTHON
73
77template <typename T, size_t N>
78using tensor = xt::pytensor<T, N>;
79
80#else
81
85template <typename T, size_t N>
86using tensor = xt::xtensor<T, N>;
87
88#endif
89
90} // namespace array_type
91
106template <size_t RANK, class T>
107struct allocate {
108};
109
113template <size_t RANK, class EC, size_t N, xt::layout_type L, class Tag>
114struct allocate<RANK, xt::xtensor<EC, N, L, Tag>> {
115 using type = typename xt::xtensor<EC, RANK, L, Tag>;
116};
117
118#ifdef XTENSOR_FIXED_HPP
119template <size_t RANK, class EC, class S, xt::layout_type L>
120struct allocate<RANK, xt::xtensor_fixed<EC, S, L>> {
121 using type = typename xt::xtensor<EC, RANK, L>;
122};
123#endif
124
125#ifdef XTENSOR_FIXED_HPP
126template <size_t RANK, class EC, class S, xt::layout_type L, bool SH, class Tag>
127struct allocate<RANK, xt::xfixed_container<EC, S, L, SH, Tag>> {
128 using type = typename xt::xtensor<EC, RANK, L, Tag>;
129};
130#endif
131
132#ifdef PY_TENSOR_HPP
133template <size_t RANK, class EC, size_t N, xt::layout_type L>
134struct allocate<RANK, xt::pytensor<EC, N, L>> {
135 using type = typename xt::pytensor<EC, RANK, L>;
136};
137#endif
142} // namespace GMatTensor
143
144#endif
xt::xtensor< T, N > tensor
Fixed (static) rank array.
Definition: config.h:86
Tensor products / operations.
Definition: Cartesian2d.h:20
Helper to allocate 'output' which is of the same type of some 'input', but of a different rank.
Definition: config.h:107