9 #ifndef BC_INTERNAL_BASE_H_ 10 #define BC_INTERNAL_BASE_H_ 18 template<
class Derived>
23 return static_cast<const Derived&
>(*this);
28 return static_cast<Derived&
>(*this);
34 using bc::traits::true_call;
38 static_assert(std::is_trivially_copy_constructible<Derived>::value,
39 "ExpressionTemplates must be trivially constructible");
41 static_assert(std::is_trivially_copyable<Derived>::value,
42 "ExpressionTemplates must be tricially copyable");
44 static_assert(true_call<typename Derived::value_type>(),
45 "ExpressionTemplates must define: 'using value_type = <T>;'");
47 static_assert(true_call<decltype(std::declval<Derived>().inner_shape())>(),
48 "ExpressionTemplates must define: inner_shape()");
50 static_assert(true_call<decltype(std::declval<Derived>().rows())>(),
51 "ExpressionTemplates must define: rows()");
53 static_assert(true_call<decltype(std::declval<Derived>().cols())>(),
54 "ExpressionTemplates must define: cols()");
56 static_assert(true_call<decltype(std::declval<Derived>().
dim(0))>(),
57 "ExpressionTemplates must define: dim(int)");
59 static_assert(true_call<Integer<Derived::tensor_dim>>(),
60 "ExpressionTemplates must define: " 61 "static constexpr int tensor_dim");
63 static_assert(true_call<Integer<Derived::tensor_iterator_dim>>(),
64 "ExpressionTemplates must define: " 65 "static constexpr int tensor_iterator_dim");
67 static_assert(Derived::tensor_iterator_dim >= Derived::tensor_dim
68 || Derived::tensor_iterator_dim <= 1,
69 "Iterator Dimension must be greater than or equal to the tensor_dim");
76 template<
class Derived>
88 for (
bc::size_t i = 0; i < Derived::tensor_dim; ++i) {
89 dim[i] =
static_cast<const Derived&
>(*this).
dim(i);
96 static_cast<const Derived&
>(*this).inner_shape());
100 auto& derived =
static_cast<const Derived&
>(*this);
101 return derived.dim(derived.tensor_dim-1);
106 template<
class Derived>
113 using value_type = std::remove_const_t<typename Derived::value_type>;
114 using data_type = decltype(std::declval<Derived>().data());
115 using data_value_type = std::remove_const_t<std::remove_pointer_t<data_type>>;
117 static_assert(std::is_same<value_type, data_value_type>::value,
118 "Array_Types must define: data() which returns a pointer of the ExpressionTemplate's value_type");
#define BCINLINE
Definition: common.h:96
BCINLINE const auto get_shape() const
Definition: expression_template_base.h:94
std::true_type expression_template_expression_type
Definition: expression_template_base.h:84
BCINLINE value_type dim(size_t i, size_t default_value=1) const
Definition: dim.h:61
std::false_type copy_constructible
Definition: expression_template_base.h:80
Definition: expression_template_base.h:19
Definition: constexpr_int.h:14
std::false_type move_assignable
Definition: expression_template_base.h:83
BCINLINE Expression_Template_Base()
Definition: expression_template_base.h:32
std::true_type expression_template_array_type
Definition: expression_template_base.h:109
BCINLINE Kernel_Array_Base()
Definition: expression_template_base.h:112
BCINLINE auto dim(const Integers &... ints)
Definition: dim.h:336
std::false_type copy_assignable
Definition: expression_template_base.h:82
void deallocate() const
Definition: expression_template_base.h:72
BCINLINE Derived & expression_template()
Definition: expression_template_base.h:27
int size_t
Definition: common.h:283
std::false_type move_constructible
Definition: expression_template_base.h:81
BCINLINE const Derived & expression_template() const
Definition: expression_template_base.h:22
Definition: expression_template_base.h:77
BCINLINE const auto inner_shape() const
Definition: expression_template_base.h:86
BCINLINE bc::size_t outer_dim() const
Definition: expression_template_base.h:99
Definition: expression_template_base.h:107
The Evaluator determines if an expression needs to be greedily optimized.
Definition: algorithms.h:22