26 #ifndef TILEDARRAY_CONVERSIONS_MAKE_ARRAY_H__INCLUDED 27 #define TILEDARRAY_CONVERSIONS_MAKE_ARRAY_H__INCLUDED 34 template <
typename>
class aligned_allocator;
68 template <
typename Array,
typename Op,
69 typename std::enable_if<is_dense<Array>::value>::type* =
nullptr>
75 typedef typename value_type::range_type range_type;
78 Array result(world, trange);
81 for(
const auto index : * result.
pmap()) {
85 world.taskq.add([=] (
const range_type& range) -> value_type {
89 }, trange.make_tile_range(index));
92 result.
set(index, tile);
132 template <
typename Array,
typename Op,
133 typename std::enable_if<! is_dense<Array>::value>::type* =
nullptr>
135 make_array(World& world,
const detail::trange_t<Array>& trange,
136 const std::shared_ptr<detail::pmap_t<Array> >& pmap, Op&& op)
140 typedef std::pair<size_type, Future<value_type> > datum_type;
143 std::vector<datum_type> tiles;
144 tiles.reserve(pmap->size());
149 tile_norms(trange.tiles_range(), 0);
152 madness::AtomicInt counter; counter = 0;
154 auto task = [&](
const size_type index) -> value_type {
156 tile_norms[index] = op(tile, trange.make_tile_range(index));
161 for(
const auto index : *pmap) {
162 auto result_tile = world.taskq.
add(task, index);
164 tiles.emplace_back(index, std::move(result_tile));
169 world.await([&counter,task_count] () ->
bool {
return counter == task_count; });
172 Array result(world, trange,
174 for(
auto& it : tiles) {
175 const size_type index = it.first;
176 if(! result.is_zero(index))
177 result.set(it.first, it.second);
217 template <
typename Array,
typename Op>
220 return make_array<Array>(world, trange,
222 trange.tiles_range().volume()), op);
227 #endif // TILEDARRAY_CONVERSIONS_MAKE_ARRAY_H__INCLUDED std::enable_if< detail::is_input_iterator< InIter >::value >::type set(const Index &i, InIter first)
Set a tile and fill it using a sequence.
impl_type::shape_type shape_type
Shape type for array tiling.
An N-dimensional tensor object.
typename T::pmap_interface pmap_t
impl_type::value_type value_type
Tile type.
typename T::trange_type trange_t
Tensor_ add(const Right &right) const
Add this and other to construct a new tensors.
typename T::policy_type policy_t
impl_type::size_type size_type
Size type.
Array make_array(World &world, const detail::trange_t< Array > &trange, const std::shared_ptr< detail::pmap_t< Array > > &pmap, Op &&op)
Construct dense Array.
An N-dimensional shallow copy wrapper for tile objects.
DistArray< Tile, Policy > Array
const std::shared_ptr< pmap_interface > & pmap() const
Process map accessor.