ndarray: /home/runner/work/ndarray/ndarray/include/ndarray/ExpressionBase.h Source File

1

2

3

4

5

6

7

8

9

10

11#ifndef NDARRAY_ExpressionBase_h_INCLUDED

12#define NDARRAY_ExpressionBase_h_INCLUDED

13

22

23namespace ndarray {

24

39template <typename Derived>

41public:

56

59

62

64 Reference back() const { return this->operator[](this->template getSize<0>()-1); }

65

68

71

73 template <int P> Size getSize() const { return getSelf().template getSize<P>(); }

74

77

79 Size getNumElements() const { return getSelf().getNumElements(); }

80

81

82

83 typedef Value value_type;

85 typedef Iterator const_iterator;

87 typedef Reference const_reference;

89 typedef Offset difference_type;

90 typedef Size size_type;

91

93 size_type size() const { return this->template getSize<0>(); }

94

96 bool empty() const { return this->template getSize<0>() == 0; }

97

98

99

100protected:

101 Self & getSelf() { return *static_cast<Self *>(this); }

102 Self const & getSelf() const { return *static_cast<Self const *>(this); }

103};

104

105}

106

107#endif

CRTP base class for all multidimensional expressions.

Definition ExpressionBase.h:40

ExpressionTraits< Derived >::Value Value

Nested expression or element value type.

Definition ExpressionBase.h:51

size_type size() const

Return the size of the first dimension.

Definition ExpressionBase.h:93

Reference front() const

Return the first nested expression or element.

Definition ExpressionBase.h:61

Reference back() const

Return the last nested expression or element.

Definition ExpressionBase.h:64

Vector< Size, ND::value > Index

Vector type for N-dimensional indices.

Definition ExpressionBase.h:53

Reference operator[](Size n) const

Return a single nested expression or element.

Definition ExpressionBase.h:58

ExpressionTraits< Derived >::ND ND

Number of dimensions (boost::mpl::int_).

Definition ExpressionBase.h:45

ExpressionTraits< Derived >::Reference Reference

Nested expression or element reference.

Definition ExpressionBase.h:49

Index getShape() const

Return a Vector of the sizes of all dimensions.

Definition ExpressionBase.h:76

Size getNumElements() const

Return the total number of elements in the expression.

Definition ExpressionBase.h:79

ExpressionTraits< Derived >::Element Element

Data type of expression elements.

Definition ExpressionBase.h:43

Iterator end() const

Return an Iterator to one past the end of the expression.

Definition ExpressionBase.h:70

Iterator begin() const

Return an Iterator to the beginning of the expression.

Definition ExpressionBase.h:67

Derived Self

CRTP derived type.

Definition ExpressionBase.h:55

bool empty() const

Return true if the first dimension has no elements.

Definition ExpressionBase.h:96

ExpressionTraits< Derived >::Iterator Iterator

Nested expression or element iterator.

Definition ExpressionBase.h:47

Size getSize() const

Return the size of a specific dimension.

Definition ExpressionBase.h:73

Traits for expressions.

Definition ExpressionTraits.h:30

A fixed-size 1D array class.

Definition Vector.h:82