14 #include "logs/logs.hpp" 28 #if !defined(SDIM_BYTES) || SDIM_BYTES <= 1 33 using DimT = uint32_t;
35 using DimT = uint64_t;
50 using ShapeT = std::array<DimT,rank_cap>;
56 using CoordT = std::array<CDimT,rank_cap>;
112 logs::fatalf(
"cannot access out of bounds index %d", idx);
114 return dims_.at(idx);
120 auto it =
dims_.begin();
122 std::multiplies<NElemT>());
129 auto it =
dims_.begin();
138 bool compatible =
false;
141 compatible = std::equal(
dims_.begin() + idx,
158 return dims_.begin();
170 return dims_.begin();
182 auto src = dims.begin();
183 if (std::any_of(src, dims.end(),
189 logs::fatalf(
"cannot create shape with vector containing zero: %s",
192 auto dest =
dims_.begin();
194 std::copy(src, src + rank, dest);
195 std::fill(dest + rank, dest +
rank_cap, 1);
200 dims_ = std::move(other.dims_);
201 std::fill(other.dims_.begin(), other.dims_.end(), 1);
223 #endif // TEQ_SHAPE_HPP std::array< CDimT, rank_cap > CoordT
Definition: shape.hpp:56
std::string to_string(void) const
Return string representation of shape.
Definition: shape.hpp:148
const RankT rank_cap
Number of dimsensions in a shape/coordinate.
Definition: shape.hpp:47
uint64_t NElemT
Definition: shape.hpp:44
ShapeT::const_iterator const_iterator
Type of constant iterator used to iterate through internal array.
Definition: shape.hpp:68
uint8_t RankT
Type used for shape rank.
Definition: shape.hpp:23
bool compatible_after(const Shape &other, RankT idx) const
Definition: shape.hpp:136
void move_helper(Shape &&other)
Definition: shape.hpp:198
const_iterator begin(void) const
Return begin constant iterator of internal array.
Definition: shape.hpp:168
Shape(Shape &&other)
Definition: shape.hpp:90
double CDimT
Type used for coordinate dimensions.
Definition: shape.hpp:39
Shape(std::vector< DimT > dims)
Definition: shape.hpp:75
std::string to_string(teq::CoordptrT c)
Return brief hashable string representation of coordinate mapper.
Shape & operator=(const Shape &other)=default
uint16_t DimT
Type used for shape dimension.
Definition: shape.hpp:31
ShapeT dims_
Array of dimension values.
Definition: shape.hpp:205
void vector_assign(const std::vector< DimT > &dims)
Definition: shape.hpp:180
bool compatible_before(const Shape &other, RankT idx) const
Definition: shape.hpp:127
Shape(void)
Definition: shape.hpp:70
std::array< DimT, rank_cap > ShapeT
Array type used to hold dimension info in Shape.
Definition: shape.hpp:50
ShapeT::iterator iterator
Type of iterator used to iterate through internal array.
Definition: shape.hpp:65
EigenptrT< T > min(teq::Shape &outshape, const OpArg< T > &a, const OpArg< T > &b)
Definition: operator.hpp:939
NElemT index(Shape shape, CoordT coord)
iterator end(void)
Return end iterator of internal array.
Definition: shape.hpp:162
iterator begin(void)
Return begin iterator of internal array.
Definition: shape.hpp:156
const_iterator end(void) const
Return end constant iterator of internal array.
Definition: shape.hpp:174
DimT at(RankT idx) const
Return DimT element at idx for any index in range [0:rank_cap)
Definition: shape.hpp:108
NElemT n_elems(void) const
Return the total number of elements represented by the shape.
Definition: shape.hpp:118
CoordT coordinate(Shape shape, NElemT idx)