Go to the documentation of this file.
26 #ifndef TILEDARRAY_ARRAY_IMPL_H__INCLUDED
27 #define TILEDARRAY_ARRAY_IMPL_H__INCLUDED
42 template <
typename,
typename>
48 template <
typename Impl>
51 template <
typename,
typename>
57 typedef typename Impl::range_type range_type;
58 typedef typename Impl::range_type::index index_type;
59 typedef typename Impl::ordinal_type ordinal_type;
69 : tensor_(tensor), index_(
index) {}
72 : tensor_(other.tensor_), index_(other.index_) {}
74 template <
typename Value>
76 tensor_->set(index_, value);
80 typename Impl::future
future()
const {
82 return tensor_->get(index_);
85 typename Impl::value_type
get()
const {
91 operator typename Impl::future()
const {
return this->
future(); }
93 operator typename Impl::value_type()
const {
return get(); }
100 return tensor_->tiles_range().idx(index_);
106 ordinal_type
ordinal()
const {
return index_; }
113 return tensor_->trange().make_tile_range(index_);
119 template <
typename Impl>
121 return a.
get() == b.
get();
125 template <
typename Impl>
131 template <
typename Impl>
140 template <
typename Impl>
143 template <
typename,
typename>
147 typename Impl::ordinal_type index_;
154 const typename Impl::ordinal_type index)
155 : tensor_(tensor), index_(index) {}
158 : tensor_(other.tensor_), index_(other.index_) {}
161 : tensor_(other.tensor_), index_(other.index_) {}
165 return tensor_->get(index_);
168 typename Impl::value_type
get()
const {
174 operator typename Impl::future()
const {
return tensor_->get(index_); }
176 operator typename Impl::value_type()
const {
return get(); }
180 template <
typename Impl>
183 return a.
get() == b.
get();
187 template <
typename Impl>
194 template <
typename Impl>
210 template <
typename Impl>
212 typedef typename Impl::value_type
type;
216 template <
typename Impl>
217 struct task_arg<
TiledArray::detail::TileConstReference<Impl>> {
218 typedef typename Impl::value_type
type;
235 template <
typename Impl,
typename Reference>
239 template <
typename,
typename>
243 typename Impl::pmap_interface::const_iterator it_;
251 typedef std::forward_iterator_tag
262 const typename Impl::pmap_interface::const_iterator end =
263 array_->pmap()->end();
266 }
while ((it_ != end) && array_->is_zero(*it_));
274 ArrayIterator(Impl* tensor,
typename Impl::pmap_interface::const_iterator it)
275 : array_(tensor), it_(it) {}
281 : array_(other.array_), it_(other.it_) {}
288 typename I,
typename R,
289 typename std::enable_if<!((!std::is_const<Impl>::value) &&
290 std::is_const<I>::value)>::type* =
nullptr>
292 : array_(other.array_), it_(other.it_) {}
299 array_ = other.array_;
310 template <
typename R>
312 array_ = other.array_;
341 template <
typename I,
typename R>
343 return (array_ == other.array_) && (it_ == other.it_);
352 template <
typename I,
typename R>
354 return (array_ != other.array_) || (it_ != other.it_);
370 return pointer(array_->get(*it_));
378 return array_->tiles_range().idx(*it_);
395 return array_->trange().make_tile_range(*it_);
409 template <
typename Tile,
typename Policy>
454 const std::shared_ptr<pmap_interface>&
pmap)
467 template <
typename Index,
468 typename = std::enable_if_t<std::is_integral_v<Index> ||
469 detail::is_integral_range_v<Index>>>
481 template <
typename Integer,
482 typename = std::enable_if_t<std::is_integral_v<Integer>>>
483 future get(
const std::initializer_list<Integer>& i)
const {
484 return get<std::initializer_list<Integer>>(i);
493 template <
typename Index,
494 typename = std::enable_if_t<std::is_integral_v<Index> ||
495 detail::is_integral_range_v<Index>>>
507 template <
typename Integer,
508 typename = std::enable_if_t<std::is_integral_v<Integer>>>
510 return get_local<std::initializer_list<Integer>>(i);
519 template <
typename Index,
520 typename = std::enable_if_t<std::is_integral_v<Index> ||
521 detail::is_integral_range_v<Index>>>
533 template <
typename Integer,
534 typename = std::enable_if_t<std::is_integral_v<Integer>>>
536 return get_local<std::initializer_list<Integer>>(i);
548 template <
typename Index,
typename Value,
549 typename = std::enable_if_t<std::is_integral_v<Index> ||
550 detail::is_integral_range_v<Index>>>
551 void set(
const Index& i, Value&& value) {
554 data_.
set(ord, std::forward<Value>(value));
569 template <
typename Index,
typename Value,
570 typename = std::enable_if_t<std::is_integral_v<Index>>>
571 void set(
const std::initializer_list<Index>& i, Value&& value) {
574 data_.
set(ord, std::forward<Value>(value));
588 const typename pmap_interface::const_iterator
end =
604 const typename pmap_interface::const_iterator
end =
627 const madness::uniqueidT&
id()
const {
return data_.id(); }
629 static std::function<void(
const ArrayImpl_&, int64_t)>&
631 static std::function<void(
const ArrayImpl_&, int64_t)> value;
637 #ifndef TILEDARRAY_HEADER_ONLY
639 extern template class ArrayImpl<
641 extern template class ArrayImpl<Tensor<float, Eigen::aligned_allocator<float>>,
643 extern template class ArrayImpl<Tensor<int, Eigen::aligned_allocator<int>>,
645 extern template class ArrayImpl<Tensor<long, Eigen::aligned_allocator<long>>,
653 extern template class ArrayImpl<
655 extern template class ArrayImpl<Tensor<float, Eigen::aligned_allocator<float>>,
657 extern template class ArrayImpl<Tensor<int, Eigen::aligned_allocator<int>>,
659 extern template class ArrayImpl<Tensor<long, Eigen::aligned_allocator<long>>,
667 #endif // TILEDARRAY_HEADER_ONLY
672 #endif // TILEDARRAY_ARRAY_IMPL_H__INCLUDED
ArrayIterator_ & operator++()
Prefix increment operator.
Policy policy_type
Policy type.
TileConstReference(const Impl *tensor, const typename Impl::ordinal_type index)
ordinal_type ordinal() const
Tile ordinal index accessor.
static std::function< void(const ArrayImpl_ &, int64_t)> & set_notifier_accessor()
const future & get_local(const size_type i) const
Get local element.
ArrayIterator_ operator++(int)
Post-fix increment operator.
Tensor implementation and base for other tensor implementation objects.
future get(const std::initializer_list< Integer > &i) const
Tile future accessor.
bool operator!=(const ArrayIterator< I, R > &other) const
Inequality operator.
TensorImpl_::ordinal_type ordinal_type
Ordinal type.
World & world() const
World accessor.
const_iterator cbegin() const
Array begin iterator.
Tile value_type
Tile or data type.
future & get_local(const Index &i)
Local tile future accessor.
TileReference(Impl *tensor, const typename Impl::ordinal_type index)
Impl::future future() const
pointer operator->() const
Arrow dereference operator.
void set(size_type i, const value_type &value)
Set element i with value.
TensorImpl_::index1_type index1_type
1-index type
TileConstReference< ArrayImpl_ > const_reference
Tile constant reference type.
TensorImpl_::range_type range_type
Elements/tiles range type.
TensorImpl< Policy > TensorImpl_
The base class of this object.
Impl::range_type range_type
Distributed tensor iterator.
bool is_zero(const Index &i) const
Query for a zero tile.
TensorImpl_::pmap_interface pmap_interface
process map interface type
index_type index() const
Tile coordinate index accessor.
ArrayIterator< Impl, Reference > ArrayIterator_
This object type.
range_type make_range() const
Tile range factory function.
index_type index() const
Tile coordinate index accessor.
TileReference< ArrayImpl_ > reference
Tile reference type.
std::ostream & operator<<(std::ostream &os, const TileReference< Impl > &a)
redirect operator to std::ostream for TileReference objects
virtual ~ArrayImpl()
Virtual destructor.
TensorImpl_::policy_type policy_type
Policy type for this object.
ArrayIterator(const ArrayIterator< I, R > &other)
Copy const iterator constructor.
const range_type & tiles_range() const
Tiles range accessor.
ArrayIterator< ArrayImpl_, reference > iterator
Iterator type.
ArrayIterator(const ArrayIterator_ &other)
Copy constructor.
Impl::value_type get() const
const std::shared_ptr< pmap_interface > & pmap() const
Tensor process map accessor.
Reference reference
Reference type to iterator value.
Impl::value_type get() const
iterator begin()
Array begin iterator.
ArrayIterator(Impl *tensor, typename Impl::pmap_interface::const_iterator it)
Constructor.
Tensor implementation and base for other tensor implementation objects.
operator typename Impl::future() const
bool operator==(const ArrayIterator< I, R > &other) const
Equality operator.
#define TA_ASSERT(EXPR,...)
iterator end()
Array end iterator.
Policy::ordinal_type ordinal_type
Ordinal type.
Impl::range_type::index index_type
ArrayIterator_ & operator=(const ArrayIterator_ &other)
Copy operator.
DistributedStorage< value_type > storage_type
The data container type.
ArrayImpl(World &world, const trange_type &trange, const shape_type &shape, const std::shared_ptr< pmap_interface > &pmap)
Constructor.
TileConstReference(const TileReference< Impl > &other)
ArrayImpl< Tile, Policy > ArrayImpl_
This object type.
range_type make_range() const
Tile range factory function.
future get(size_type i) const
Get local or remote element.
future & get_local(const std::initializer_list< Integer > &i)
Local tile future accessor.
Impl::future future() const
void set(const Index &i, Value &&value)
Set tile.
bool operator==(const TileReference< Impl > &a, const TileReference< Impl > &b)
comparison operator for TileReference objects
const_iterator cend() const
Array end iterator.
Policy::shape_type shape_type
Tensor shape type.
ArrayIterator_ & operator=(const ArrayIterator< Impl, R > &other)
Copy operator.
const future & get_local(const std::initializer_list< Integer > &i) const
Local tile future accessor.
reference operator*() const
Dereference operator.
std::forward_iterator_tag iterator_category
Iterator category type.
TileConstReference(const TileConstReference< Impl > &other)
ordinal_type ordinal() const
Tile ordinal index accessor.
const future & get_local(const Index &i) const
Local tile future accessor.
numeric_type< value_type >::type numeric_type
the numeric type that supports Tile
Impl::value_type tile_type
const madness::uniqueidT & id() const
Unique object id accessor.
Policy::range_type range_type
Element/tile range type.
storage_type::future future
Future tile type.
Policy::trange_type trange_type
Tiled range type.
size_t volume(const DistArray< Tile, Policy > &a)
Policy::pmap_interface pmap_interface
Process map interface type.
void set(const std::initializer_list< Index > &i, Value &&value)
Set tile.
Policy::index1_type index1_type
1-index type
eval_trait< Tile >::type eval_type
The tile evaluation type.
Impl::ordinal_type ordinal_type
future get(const Index &i) const
Tile future accessor.
TileReference< Impl > & operator=(const Value &value)
Determine the object type used in the evaluation of tensor expressions.
const trange_type & trange() const
Tiled range accessor.
const shape_type & shape() const
Tensor shape accessor.
PointerProxy< value_type > pointer
Pointer type to iterator value.
TensorImpl_::trange_type trange_type
Tiled range type for this object.
ptrdiff_t difference_type
Difference type.
An N-dimensional tensor object.
ArrayIterator< const ArrayImpl_, const_reference > const_iterator
Constant iterator type.
Impl::future value_type
Iterator dereference value type.
bool operator!=(const TileReference< Impl > &a, const TileReference< Impl > &b)
inequality operator for TileReference objects
TileReference(const TileReference< Impl > &other)
TensorImpl_::shape_type shape_type
Shape type.
An N-dimensional shallow copy wrapper for tile objects.
bool is_local(const Index &i) const
Query for a locally owned tile.
ArrayIterator()
Default constructor.