26 #ifndef TILEDARRAY_CONVERSIONS_MAKE_ARRAY_H__INCLUDED
27 #define TILEDARRAY_CONVERSIONS_MAKE_ARRAY_H__INCLUDED
36 class aligned_allocator;
71 template <
typename Array,
typename Op,
72 typename std::enable_if<is_dense<Array>::value>::type* =
nullptr>
77 typedef typename value_type::range_type range_type;
80 Array result(world, trange);
83 for (
const auto index : *result.
pmap()) {
85 auto tile = world.taskq.add(
86 [=](
const range_type& range) -> value_type {
91 trange.make_tile_range(index));
94 result.
set(index, tile);
135 template <
typename Array,
typename Op,
136 typename std::enable_if<!is_dense<Array>::value>::type* =
nullptr>
137 inline Array make_array(World& world,
const detail::trange_t<Array>& trange,
138 const std::shared_ptr<detail::pmap_t<Array> >& pmap,
142 typedef std::pair<ordinal_type, Future<value_type> > datum_type;
145 std::vector<datum_type> tiles;
146 tiles.reserve(pmap->size());
150 typename detail::shape_t<Array>::value_type,
152 tile_norms(trange.tiles_range(), 0);
155 madness::AtomicInt counter;
158 auto task = [&](
const ordinal_type index) -> value_type {
160 tile_norms[index] = op(tile, trange.make_tile_range(index));
165 for (
const auto index : *pmap) {
166 auto result_tile = world.taskq.add(task, index);
168 tiles.emplace_back(index, std::move(result_tile));
174 [&counter, task_count]() ->
bool {
return counter == task_count; });
177 Array result(world, trange,
179 for (
auto& it : tiles) {
180 const auto index = it.first;
181 if (!result.is_zero(index)) result.set(it.first, it.second);
221 template <
typename Array,
typename Op>
224 return make_array<Array>(world, trange,
226 world, trange.tiles_range().volume()),
232 #endif // TILEDARRAY_CONVERSIONS_MAKE_ARRAY_H__INCLUDED