26 #ifndef TILEDARRAY_ARRAY_IMPL_H__INCLUDED 27 #define TILEDARRAY_ARRAY_IMPL_H__INCLUDED 45 template <
typename Impl>
49 template <
typename,
typename>
55 typedef typename Impl::range_type range_type;
56 typedef typename Impl::range_type::index index_type;
57 typedef typename Impl::size_type ordinal_type;
67 tensor_(tensor), index_(
index)
71 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_);
115 return tensor_->trange().make_tile_range(index_);
121 template <
typename Impl>
124 return a.
get() == b.
get();
128 template <
typename Impl>
135 template <
typename Impl>
136 std::ostream& operator<<(std::ostream& os, const TileReference<Impl>& a) {
144 template <
typename Impl>
148 template <
typename,
typename>
152 typename Impl::size_type index_;
159 tensor_(tensor), index_(index)
163 tensor_(other.tensor_), index_(other.index_)
167 tensor_(other.tensor_), index_(other.index_)
172 return tensor_->get(index_);
175 typename Impl::value_type
get()
const {
181 operator typename Impl::future()
const {
return tensor_->get(index_); }
183 operator typename Impl::value_type()
const {
return get(); }
187 template <
typename Impl>
190 return a.
get() == b.
get();
194 template <
typename Impl>
201 template <
typename Impl>
202 std::ostream& operator<<(std::ostream& os, const TileConstReference<Impl>& a) {
218 template <
typename Impl>
220 typedef typename Impl::value_type
type;
224 template <
typename Impl>
225 struct task_arg<
TiledArray::detail::TileConstReference<Impl> > {
226 typedef typename Impl::value_type
type;
244 template <
typename Impl,
typename Reference>
245 class ArrayIterator {
248 template <
typename,
typename>
252 typename Impl::pmap_interface::const_iterator it_;
270 const typename Impl::pmap_interface::const_iterator end =
271 array_->pmap()->end();
274 }
while((it_ != end) && array_->is_zero(*it_));
283 ArrayIterator(Impl* tensor,
typename Impl::pmap_interface::const_iterator it) :
284 array_(tensor), it_(it)
291 array_(other.array_), it_(other.it_)
298 template <
typename I,
typename R,
299 typename std::enable_if<
300 !((! std::is_const<Impl>::value) &&
301 std::is_const<I>::value)
304 array_(other.array_), it_(other.it_)
312 array_ = other.array_;
323 template <
typename R>
325 array_ = other.array_;
354 template <
typename I,
typename R>
356 return (array_ == other.array_) && (it_ == other.it_);
365 template <
typename I,
typename R>
367 return (array_ != other.array_) || (it_ != other.it_);
383 return pointer(array_->get(*it_));
391 return array_->tiles_range().idx(*it_);
408 return array_->trange().make_tile_range(*it_);
422 template <
typename Tile,
typename Policy>
460 const std::shared_ptr<pmap_interface>&
pmap) :
474 template <
typename Index>
486 template <
typename Integer>
487 future get(
const std::initializer_list<Integer>& i)
const {
488 return get<std::initializer_list<Integer>>(i);
500 template <
typename Index,
typename Value>
501 void set(
const Index& i,
const Value& value) {
553 const madness::uniqueidT&
id()
const {
return data_.id(); }
558 #ifndef TILEDARRAY_HEADER_ONLY 561 class ArrayImpl<Tensor<double, Eigen::aligned_allocator<double> >,
DensePolicy>;
563 class ArrayImpl<Tensor<float, Eigen::aligned_allocator<float> >,
DensePolicy>;
565 class ArrayImpl<Tensor<int, Eigen::aligned_allocator<int> >,
DensePolicy>;
567 class ArrayImpl<Tensor<long, Eigen::aligned_allocator<long> >,
DensePolicy>;
574 class ArrayImpl<Tensor<double, Eigen::aligned_allocator<double> >,
SparsePolicy>;
576 class ArrayImpl<Tensor<float, Eigen::aligned_allocator<float> >,
SparsePolicy>;
578 class ArrayImpl<Tensor<int, Eigen::aligned_allocator<int> >,
SparsePolicy>;
580 class ArrayImpl<Tensor<long, Eigen::aligned_allocator<long> >,
SparsePolicy>;
586 #endif // TILEDARRAY_HEADER_ONLY 591 #endif // TILEDARRAY_ARRAY_IMPL_H__INCLUDED TensorImpl_::range_type range_type
Elements/tiles range type.
TensorImpl_::shape_type shape_type
Shape type.
TensorImpl< Policy > TensorImpl_
The base class of this object.
Distributed tensor iterator.
ptrdiff_t difference_type
Difference type.
const_iterator cbegin() const
Array begin iterator.
ArrayIterator_ & operator=(const ArrayIterator_ &other)
Copy operator.
const shape_type & shape() const
Tensor shape accessor.
ArrayIterator(const ArrayIterator_ &other)
Copy constructor.
const trange_type & trange() const
Tiled range accessor.
Policy::range_type range_type
Element/tile range type.
TileReference< ArrayImpl_ > reference
Tile reference type.
ArrayIterator(Impl *tensor, typename Impl::pmap_interface::const_iterator it)
Constructor.
Policy::pmap_interface pmap_interface
Process map interface type.
bool operator==(const ArrayIterator< I, R > &other) const
Equality operator.
Reference reference
Reference type to iterator value.
bool operator!=(const TileReference< Impl > &a, const TileReference< Impl > &b)
inequality operator for TileReference objects
std::forward_iterator_tag iterator_category
Iterator category type.
future get(size_type i) const
Get local or remote element.
range_type make_range() const
Tile range factory function.
iterator begin()
Array begin iterator.
eval_trait< Tile >::type eval_type
The tile evaluation type.
Tensor implementation and base for other tensor implementation objects.
TileConstReference(const TileReference< Impl > &other)
reference operator*() const
Dereference operator.
ordinal_type ordinal() const
Tile ordinal index accessor.
TensorImpl_::size_type size_type
Size type.
Impl::range_type range_type
Policy policy_type
Policy type.
TileReference(const TileReference< Impl > &other)
Policy::trange_type trange_type
Tiled range type.
void set(size_type i, const value_type &value)
Set element i with value.
ArrayIterator< Impl, Reference > ArrayIterator_
This object type.
index_type index() const
Tile coordinate index accessor.
ArrayIterator< const ArrayImpl_, const_reference > const_iterator
Constant iterator type.
bool operator!=(const ArrayIterator< I, R > &other) const
Inequality operator.
DistributedStorage< value_type > storage_type
The data container type.
Impl::future future() const
Impl::size_type ordinal_type
Impl::value_type get() const
TensorImpl_::trange_type trange_type
Tiled range type for this object.
storage_type::future future
Future tile type.
TileReference< Impl > & operator=(const Value &value)
Tensor implementation and base for other tensor implementation objects.
ArrayIterator_ & operator++()
Prefix increment operator.
PointerProxy< value_type > pointer
Pointer type to iterator value.
bool is_zero(const Index &i) const
Query for a zero tile.
TensorImpl_::policy_type policy_type
Policy type for this object.
TensorImpl_::pmap_interface pmap_interface
process map interface type
const madness::uniqueidT & id() const
Unique object id accessor.
Policy::size_type size_type
Size type.
range_type make_range() const
Tile range factory function.
index_type index() const
Tile coordinate index accessor.
TileReference(Impl *tensor, const typename Impl::size_type index)
operator typename Impl::future() const
TileConstReference(const Impl *tensor, const typename Impl::size_type index)
Impl::future value_type
Iterator dereference value type.
ArrayImpl(World &world, const trange_type &trange, const shape_type &shape, const std::shared_ptr< pmap_interface > &pmap)
Constructor.
TileConstReference< ArrayImpl_ > const_reference
Tile constant reference type.
ArrayIterator()
Default constructor.
ArrayIterator< ArrayImpl_, reference > iterator
Iterator type.
ArrayIterator_ operator++(int)
Post-fix increment operator.
bool operator==(const TileReference< Impl > &a, const TileReference< Impl > &b)
comparison operator for TileReference objects
Impl::range_type::index index_type
World & world() const
World accessor.
ArrayIterator_ & operator=(const ArrayIterator< Impl, R > &other)
Copy operator.
pointer operator->() const
Arrow dereference operator.
ArrayIterator(const ArrayIterator< I, R > &other)
Copy const iterator constructor.
iterator end()
Array end iterator.
virtual ~ArrayImpl()
Virtual destructor.
ArrayImpl< Tile, Policy > ArrayImpl_
This object type.
Impl::future future() const
const range_type & tiles_range() const
Tiles range accessor.
const_iterator cend() const
Array end iterator.
ordinal_type ordinal() const
Tile ordinal index accessor.
Future< value_type > future
Element container type.
const std::shared_ptr< pmap_interface > & pmap() const
Tensor process map accessor.
Impl::value_type get() const
An N-dimensional shallow copy wrapper for tile objects.
TileConstReference(const TileConstReference< Impl > &other)
numeric_type< value_type >::type numeric_type
the numeric type that supports Tile
Policy::shape_type shape_type
Tensor shape type.
Tile value_type
Tile or data type.
Impl::value_type tile_type