forked from xtensor-stack/xtensor
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathxtensor_forward.hpp
More file actions
210 lines (183 loc) · 7.95 KB
/
Copy pathxtensor_forward.hpp
File metadata and controls
210 lines (183 loc) · 7.95 KB
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
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
/***************************************************************************
* Copyright (c) Johan Mabille, Sylvain Corlay and Wolf Vollprecht *
* Copyright (c) QuantStack *
* *
* Distributed under the terms of the BSD 3-Clause License. *
* *
* The full license is in the file LICENSE, distributed with this software. *
****************************************************************************/
#ifndef XTENSOR_FORWARD_HPP
#define XTENSOR_FORWARD_HPP
// This file contains forward declarations and
// alias types to solve the problem of circular
// includes. It should not contain anything else
// and should not bring additional dependencies to
// the files that include it. So:
// - do NOT define classes of metafunctions here
// - do NOT include other headers
//
// If you need to do so, something is probably
// going wrong (either your change, or xtensor
// needs to be refactored).
#include <memory>
#include <vector>
#include <xtl/xoptional_sequence.hpp>
#include "xlayout.hpp"
#include "xtensor_config.hpp"
namespace xt
{
struct xtensor_expression_tag;
struct xoptional_expression_tag;
template <class C>
struct xcontainer_inner_types;
template <class D>
class xcontainer;
template <class T, class A>
class uvector;
template <class T, std::size_t N, class A, bool Init>
class svector;
template <class EC,
layout_type L = XTENSOR_DEFAULT_LAYOUT,
class SC = XTENSOR_DEFAULT_SHAPE_CONTAINER(typename EC::value_type,
typename EC::allocator_type,
std::allocator<typename EC::size_type>),
class Tag = xtensor_expression_tag>
class xarray_container;
/**
* @typedef xarray
* Alias template on xarray_container with default parameters for data container
* type and shape / strides container type. This allows to write
*
* \code{.cpp}
* xt::xarray<double> a = {{1., 2.}, {3., 4.}};
* \endcode
*
* instead of the heavier syntax
*
* \code{.cpp}
* xt::xarray_container<std::vector<double>, std::vector<std::size_t>> a = ...
* \endcode
*
* @tparam T The value type of the elements.
* @tparam L The layout_type of the xarray_container (default: XTENSOR_DEFAULT_LAYOUT).
* @tparam A The allocator of the container holding the elements.
* @tparam SA The allocator of the containers holding the shape and the strides.
*/
template <class T,
layout_type L = XTENSOR_DEFAULT_LAYOUT,
class A = XTENSOR_DEFAULT_ALLOCATOR(T),
class SA = std::allocator<typename std::vector<T, A>::size_type>>
using xarray = xarray_container<XTENSOR_DEFAULT_DATA_CONTAINER(T, A), L, XTENSOR_DEFAULT_SHAPE_CONTAINER(T, A, SA)>;
template <class EC,
layout_type L = XTENSOR_DEFAULT_LAYOUT,
class SC = XTENSOR_DEFAULT_SHAPE_CONTAINER(typename EC::value_type,
std::allocator<typename EC::size_type>,
std::allocator<typename EC::size_type>),
class Tag = xtensor_expression_tag>
class xarray_adaptor;
/**
* @typedef xarray_optional
* Alias template on xarray_container for handling missing values
*
* @tparam T The value type of the elements.
* @tparam L The layout_type of the container (default: XTENSOR_DEFAULT_LAYOUT).
* @tparam A The allocator of the container holding the elements.
* @tparam BA The allocator of the container holding the missing flags.
* @tparam SA The allocator of the containers holding the shape and the strides.
*/
template <class T,
layout_type L = XTENSOR_DEFAULT_LAYOUT,
class A = XTENSOR_DEFAULT_ALLOCATOR(T),
class BC = xtl::xdynamic_bitset<std::size_t>,
class SA = std::allocator<typename std::vector<T, A>::size_type>>
using xarray_optional = xarray_container<xtl::xoptional_vector<T, A, BC>, L, XTENSOR_DEFAULT_SHAPE_CONTAINER(T, A, SA), xoptional_expression_tag>;
template <class EC, std::size_t N, layout_type L = XTENSOR_DEFAULT_LAYOUT, class Tag = xtensor_expression_tag>
class xtensor_container;
/**
* @typedef xtensor
* Alias template on xtensor_container with default parameters for data container
* type. This allows to write
*
* \code{.cpp}
* xt::xtensor<double, 2> a = {{1., 2.}, {3., 4.}};
* \endcode
*
* instead of the heavier syntax
*
* \code{.cpp}
* xt::xtensor_container<std::vector<double>, 2> a = ...
* \endcode
*
* @tparam T The value type of the elements.
* @tparam N The dimension of the tensor.
* @tparam L The layout_type of the tensor (default: XTENSOR_DEFAULT_LAYOUT).
* @tparam A The allocator of the containers holding the elements.
*/
template <class T,
std::size_t N,
layout_type L = XTENSOR_DEFAULT_LAYOUT,
class A = XTENSOR_DEFAULT_ALLOCATOR(T)>
using xtensor = xtensor_container<XTENSOR_DEFAULT_DATA_CONTAINER(T, A), N, L>;
template <class EC, std::size_t N, layout_type L = XTENSOR_DEFAULT_LAYOUT, class Tag = xtensor_expression_tag>
class xtensor_adaptor;
template <class EC, std::size_t N, layout_type L = XTENSOR_DEFAULT_LAYOUT, class Tag = xtensor_expression_tag>
class xtensor_view;
template <std::size_t... N>
class fixed_shape;
/**
* @typedef xshape
* Alias template for ``fixed_shape`` allows for a shorter template shape definition in ``xtensor_fixed``.
*/
template <std::size_t... N>
using xshape = fixed_shape<N...>;
template <class ET, class S, layout_type L = XTENSOR_DEFAULT_LAYOUT, bool Sharable = true, class Tag = xtensor_expression_tag>
class xfixed_container;
template <class ET, class S, layout_type L = XTENSOR_DEFAULT_LAYOUT, bool Sharable = true, class Tag = xtensor_expression_tag>
class xfixed_adaptor;
/**
* @typedef xtensor_fixed
* Alias template on xfixed_container with default parameters for layout
* type. This allows to write
*
* \code{.cpp}
* xt::xtensor_fixed<double, xt::xshape<2, 2>> a = {{1., 2.}, {3., 4.}};
* \endcode
*
* instead of the syntax
*
* \code{.cpp}
* xt::xfixed_container<double, xt::xshape<2, 2>, xt::layout_type::row_major> a = ...
* \endcode
*
* @tparam T The value type of the elements.
* @tparam FSH A xshape template shape.
* @tparam L The layout_type of the tensor (default: XTENSOR_DEFAULT_LAYOUT).
* @tparam Sharable Whether the tensor can be used in a shared expression.
*/
template <class T,
class FSH,
layout_type L = XTENSOR_DEFAULT_LAYOUT,
bool Sharable = true>
using xtensor_fixed = xfixed_container<T, FSH, L, Sharable>;
/**
* @typedef xtensor_optional
* Alias template on xtensor_container for handling missing values
*
* @tparam T The value type of the elements.
* @tparam N The dimension of the tensor.
* @tparam L The layout_type of the container (default: XTENSOR_DEFAULT_LAYOUT).
* @tparam A The allocator of the containers holding the elements.
* @tparam BA The allocator of the container holding the missing flags.
*/
template <class T,
std::size_t N,
layout_type L = XTENSOR_DEFAULT_LAYOUT,
class A = XTENSOR_DEFAULT_ALLOCATOR(T),
class BC = xtl::xdynamic_bitset<std::size_t>>
using xtensor_optional = xtensor_container<xtl::xoptional_vector<T, A, BC>, N, L, xoptional_expression_tag>;
template <class CT, class... S>
class xview;
template <class F, class... CT>
class xfunction;
}
#endif