26 #ifndef TILEDARRAY_BLOCK_RANGE_H__INCLUDED 27 #define TILEDARRAY_BLOCK_RANGE_H__INCLUDED 44 template <
typename Index>
45 void init(
const Range& range,
const Index& lower_bound,
const Index& upper_bound) {
50 TA_ASSERT(std::equal(upper_bound.begin(), upper_bound.end(), lower_bound.begin(),
63 const auto* MADNESS_RESTRICT
const range_stride = range.
stride_data();
64 const auto* MADNESS_RESTRICT
const lower_bound_ptr =
detail::data(lower_bound);
65 const auto* MADNESS_RESTRICT
const upper_bound_ptr =
detail::data(upper_bound);
66 auto* MADNESS_RESTRICT
const lower =
data_;
67 auto* MADNESS_RESTRICT
const upper = lower +
rank_;
68 auto* MADNESS_RESTRICT
const extent = upper +
rank_;
72 for(
int i =
int(
rank_) - 1; i >= 0; --i) {
74 const auto lower_bound_i = lower_bound_ptr[i];
75 const auto upper_bound_i = upper_bound_ptr[i];
76 const auto range_stride_i = range_stride[i];
77 const auto extent_i = upper_bound_i - lower_bound_i;
85 lower[i] = lower_bound_i;
86 upper[i] = upper_bound_i;
88 stride[i] = range_stride_i;
89 block_offset_ += lower_bound_i * range_stride_i;
104 template <
typename Index>
106 const Index& upper_bound) :
109 init(range, lower_bound, upper_bound);
114 const std::initializer_list<size_type>& upper_bound) :
117 init(range, lower_bound, upper_bound);
128 template <
typename Index,
129 typename std::enable_if<! std::is_integral<Index>::value>::type* =
nullptr>
134 template <
typename... Index,
135 typename std::enable_if<(
sizeof...(Index) > 1ul)>::type* =
nullptr>
159 for(
int i =
int(
rank_) - 1; i >= 0; --i) {
160 const auto size_i =
size[i];
161 const auto stride_i =
stride[i];
164 result += (
index % size_i) * stride_i;
168 return result + block_offset_ -
offset_;
172 template <
typename Index>
184 template <
typename Index>
186 TA_EXCEPTION(
"BlockRange::inplace_shift() is not supported");
194 template <
typename Index>
202 std::swap(block_offset_, other.block_offset_);
206 template <
typename Archive>
216 #endif // TILEDARRAY_BLOCK_RANGE_H__INCLUDED std::vector< size_type > index
Coordinate index type.
size_type volume_
Total number of elements.
A (hyperrectangular) interval on , space of integer n-indices.
size_array lobound() const
Range lower bound accessor.
auto data(T &t)
Container data pointer accessor.
ordinal_type ordinal(const Index &index) const
calculate the ordinal index of i
Range_ shift(const Index &)
Shift the lower and upper bound of this range.
void swap(Bitset< B > &b0, Bitset< B > &b1)
std::size_t ordinal_type
Ordinal type, to conform Tensor Working Group spec.
BlockRange & resize(const Index &, const Index &)
Resize of block range is not supported.
BlockRange & operator=(const BlockRange &)=default
void swap(BlockRange &other)
unsigned int rank() const
Rank accessor.
const size_type * stride_data() const
Range stride data accessor.
size_t size(const DistArray< Tile, Policy > &a)
const size_type * upbound_data() const
Range upper bound data accessor.
ordinal_type ordinal(const Index &... index) const
size_type offset_
Ordinal index offset correction.
unsigned int rank_
The rank (or number of dimensions) in the range.
void serialize(const Archive &ar) const
Serialization Block range.
ordinal_type ordinal(ordinal_type index) const
calculate the coordinate index of the ordinal index, index.
Range_ & inplace_shift(const Index &)
Shift the lower and upper bound of this range.
size_array upbound() const
Range upper bound accessor.
bool includes(const Index &index) const
Check the coordinate to make sure it is within the range.
std::size_t size_type
Size type.
const size_type * lobound_data() const
Range lower bound data accessor.
Range that references a subblock of another range.
BlockRange(const Range &range, const std::initializer_list< size_type > &lower_bound, const std::initializer_list< size_type > &upper_bound)
ordinal_type ordinal(const ordinal_type index) const
calculate the ordinal index of i
void serialize(const Archive &ar)
extent_type extent() const
Range extent accessor.
ordinal_type offset() const
Range offset.
BlockRange(const Range &range, const Index &lower_bound, const Index &upper_bound)
size_array stride() const
Range stride accessor.