23 #ifndef FTL_TENSOR_STATIC_CPU_HPP
24 #define FTL_TENSOR_STATIC_CPU_HPP
32 #include <type_traits>
42 template <
typename Traits>
43 class TensorInterface;
46 template <
typename DT,
size_t SF,
size_t... SR>
50 template <
typename DT,
size_t SF,
size_t... SR>
52 StaticTensorCpu<DT, SF, SR...> ,
53 TensorTraits<DT, CPU, SF, SR...>> {
81 template <
typename... TR>
92 template <
typename Expression,
typename Traits>
127 void initialize(
const data_type min,
const data_type max);
152 template <
typename IF,
typename... IR>
153 DT& operator()(IF index_dim_one, IR... index_dim_other);
164 template <
typename IF,
typename... IR>
165 DT operator()(IF index_dim_one, IR... index_dim_other)
const;
167 data_container _data;
168 dim_container _dim_sizes;
175 template <
typename DT,
size_t SF,
size_t...SR>
179 _dim_sizes = nano::runtime_converter<typename container_type::dimension_sizes>::to_array();
182 template <
typename DT,
size_t SF,
size_t...SR>
187 _dim_sizes = nano::runtime_converter<typename container_type::dimension_sizes>::to_array();
190 template <
typename DT,
size_t SF,
size_t...SR>
template <
typename... TR>
192 : _data{{std::forward<DT>(first_value), std::forward<TR>(other_values)...}}
195 _dim_sizes = nano::runtime_converter<typename container_type::dimension_sizes>::to_array();
198 template <
typename DT,
size_t SF,
size_t...SR>
template <
typename E,
typename T>
202 _dim_sizes = nano::runtime_converter<typename container_type::dimension_sizes>::to_array();
203 for (
size_type i = 0; i != size(); ++i) _data[i] = expression[i];
206 template <
typename DT,
size_t SF,
size_t... SR>
209 std::random_device rand_device;
210 std::mt19937 gen(rand_device());
211 std::uniform_real_distribution<> dist(min, max);
212 for (
auto& element : _data) element =
static_cast<data_type>(dist(gen));
215 template <
typename DT,
size_t SF,
size_t...SR>
template <
typename IF,
typename... IR>
218 using dimension_sizes =
typename container_type::dimension_sizes;
219 return _data[StaticMapper::indices_to_index<dimension_sizes>(dim_one_index, other_dim_indices...)];
222 template <
typename DT,
size_t SF,
size_t...SR>
template <
typename IF,
typename... IR>
225 using dimension_sizes =
typename container_type::dimension_sizes;
226 return _data[StaticMapper::indices_to_index<dimension_sizes>(dim_one_index, other_dim_indices...)];
230 #endif // FTL_TENSOR_STATIC_CPU_HPP
typename traits::size_type size_type
Definition: tensor_static_cpu.hpp:57
typename container_type::data_container data_container
Definition: tensor_static_cpu.hpp:60
Definition: tensor_dynamic_cpu.hpp:44
constexpr size_type size() const
Gets the size (total number of elements) in the tensor.
Definition: tensor_static_cpu.hpp:105
constexpr const dim_container & dim_sizes() const
Gets a reference to the container holding the sizes of the dimensions for the tensor.
Definition: tensor_static_cpu.hpp:120
typename traits::container_type container_type
Definition: tensor_static_cpu.hpp:59
const data_type & operator[](size_type i) const
Gets an element from the tensor.
Definition: tensor_static_cpu.hpp:141
typename traits::data_type data_type
Definition: tensor_static_cpu.hpp:58
Definition: mapper.hpp:37
Defines a general tensor expression so that opertions on tensor expressions can be defined the syntax...
Definition: tensor_expression_interface.hpp:49
constexpr size_type rank() const
Gets the rank (number of dimensions) of the tensor.
Definition: tensor_static_cpu.hpp:99
typename container_type::dim_container dim_container
Definition: tensor_static_cpu.hpp:61
data_type & operator[](size_type i)
Gets an element from the tensor.
Definition: tensor_static_cpu.hpp:134
size_type size(const size_type dim) const
Gets the size (total number of elements) in a specific dimension of the tensor, if the dimension is v...
Definition: tensor_static_cpu.hpp:114
Traits class which specifies parameters for a tensor, such as what type of container it uses and what...
Definition: tensor_traits.hpp:48