TiledArray  0.7.0
expr.h
Go to the documentation of this file.
1 /*
2  * This file is a part of TiledArray.
3  * Copyright (C) 2013 Virginia Tech
4  *
5  * This program is free software: you can redistribute it and/or modify
6  * it under the terms of the GNU General Public License as published by
7  * the Free Software Foundation, either version 3 of the License, or
8  * (at your option) any later version.
9  *
10  * This program is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13  * GNU General Public License for more details.
14  *
15  * You should have received a copy of the GNU General Public License
16  * along with this program. If not, see <http://www.gnu.org/licenses/>.
17  *
18  * Justus Calvin
19  * Department of Chemistry, Virginia Tech
20  *
21  * expr.h
22  * Apr 1, 2014
23  *
24  */
25 
26 #ifndef TILEDARRAY_EXPRESSIONS_EXPR_H__INCLUDED
27 #define TILEDARRAY_EXPRESSIONS_EXPR_H__INCLUDED
28 
29 #include "expr_engine.h"
30 #include "../reduce_task.h"
31 #include "../tile_interface/cast.h"
32 #include "../tile_interface/scale.h"
33 #include "../tile_op/shift.h"
34 #include "../tile_op/unary_wrapper.h"
35 #include "../tile_op/unary_reduction.h"
36 #include "../tile_op/binary_reduction.h"
37 #include "../tile_op/reduce_wrapper.h"
38 
39 namespace TiledArray {
40  namespace expressions {
41 
42  // Forward declaration
43  template <typename> struct ExprTrait;
44  template <typename, bool> class TsrExpr;
45  template <typename, bool> class BlkTsrExpr;
46  template <typename> struct is_aliased;
47 
48  template <typename Engine>
50 
51  EngineParamOverride() : world(nullptr), pmap(), shape(nullptr) {}
52 
56 
57  World* world;
58  std::shared_ptr<pmap_interface> pmap;
59  const shape_type* shape;
60  };
61 
64  template<class E>
65  class has_array {
67  template<class U>
68  static auto __test(U* p) -> decltype(p->array(), std::true_type());
70  template<class>
71  static std::false_type __test(...);
72  public:
73  static constexpr const bool value = std::is_same<std::true_type, decltype(__test<E>(0))>::value;
74  };
75 
76 
78 
80  template <typename Derived>
81  class Expr {
82  public:
83 
84  template <typename Derived_ = Derived>
86  template <typename Derived_ = Derived>
88 
89  typedef Expr<Derived> Expr_;
90  typedef Derived derived_type;
92 
93  private:
94 
95  template <typename D>
96  friend class ExprEngine;
97 
100  std::shared_ptr<override_type> override_ptr_;
101 
102  public:
108  if (override_ptr_ != nullptr) {
109  override_ptr_->shape = &shape;
110  } else {
111  override_ptr_ = std::make_shared<override_type>();
112  override_ptr_->shape = &shape;
113  }
114  return derived();
115  }
117  Expr<Derived> &set_world(World& world) {
118  if(override_ptr_ != nullptr){
119  override_ptr_->world = &world;
120  } else {
121  override_ptr_ = std::make_shared<override_type>();
122  override_ptr_->world = &world;
123  }
124  return derived();
125  }
128  const std::shared_ptr<typename override_type::pmap_interface>
129  pmap) {
130  if (override_ptr_) {
131  override_ptr_->pmap = pmap;
132  } else {
133  override_ptr_ = std::make_shared<override_type>();
134  override_ptr_->pmap = pmap;
135  }
136  return derived();
137  }
138 
139  private:
140 
142 
150  template <typename R, typename T, typename C, typename Op>
151  static auto eval_tile(T&& tile, const C& cast, const std::shared_ptr<Op>& op) {
152  auto&& cast_tile = cast(std::forward<T>(tile));
153  return (*op)(cast_tile);
154  }
155 
157 
164  template <typename T, typename Op>
165  static auto eval_tile(T&& tile, const std::shared_ptr<Op>& op) {
166  return (*op)(std::forward<T>(tile));
167  }
168 
169 
171 
180  template <typename A, typename I, typename T,
181  typename std::enable_if<
182  ! std::is_same<typename A::value_type, T>::value &&
183  is_lazy_tile<T>::value
184  >::type* = nullptr>
185  void set_tile(A& array, const I& index, const Future<T>& tile) const {
186  array.set(index, array.world().taskq.add(
188  }
189 
190 
192 
199  template <typename A, typename I, typename T,
200  typename std::enable_if<
201  std::is_same<typename A::value_type, T>::value
202  >::type* = nullptr>
203  void set_tile(A& array, const I& index, const Future<T>& tile) const {
204  array.set(index, tile);
205  }
206 
207 
209 
218  template <typename A, typename I, typename T, typename Op,
219  typename std::enable_if<
220  ! std::is_same<typename A::value_type, T>::value
221  >::type* = nullptr>
222  void set_tile(A& array, const I index, const Future<T>& tile,
223  const std::shared_ptr<Op>& op) const
224  {
225  auto eval_tile_fn = &Expr_::template eval_tile<
226  typename A::value_type, const T&,
228  array.set(index,
229  array.world().taskq.add(
230  eval_tile_fn, tile,
232  }
233 
234 
236 
247  template <typename A, typename I, typename T, typename Op,
248  typename std::enable_if<
249  std::is_same<typename A::value_type, T>::value
250  >::type* = nullptr>
251  void set_tile(A& array, const I index, const Future<T>& tile,
252  const std::shared_ptr<Op>& op) const
253  {
254  auto eval_tile_fn_ptr = &Expr_::template eval_tile<const T&, Op>;
255  using fn_ptr_type = decltype(eval_tile_fn_ptr);
256  static_assert(
257  madness::detail::function_traits<fn_ptr_type(const T&,const std::shared_ptr<Op>&)>::value,
258  "ouch");
259  array.set(index, array.world().taskq.add(eval_tile_fn_ptr, tile, op));
260  }
261 
262  public:
263 
264  // Compiler generated functions
265  Expr() = default;
266  Expr(const Expr_&) = default;
267  Expr(Expr_&&) = default;
268  ~Expr() = default;
269  Expr_& operator=(const Expr_&) = delete;
270  Expr_& operator=(Expr_&&) = delete;
271 
273  derived_type& derived() { return *static_cast<derived_type*>(this); }
274 
276  const derived_type& derived() const { return *static_cast<const derived_type*>(this); }
277 
279 
286  template <typename A, bool Alias>
287  void eval_to(TsrExpr<A, Alias>& tsr) const {
289  "Assignment to an array of lazy tiles is not supported.");
290 
291  // Get the target world
292  // 1. result's world is assigned, use it
293  // 2. if this expression's world was assigned by set_world(), use it
294  // 3. otherwise revert to the TA default for the MADNESS world
295  const auto has_set_world = override_ptr_ && override_ptr_->world;
296  World& world = (tsr.array().is_initialized() ?
297  tsr.array().world() :
298  (has_set_world ? *override_ptr_->world : TiledArray::get_default_world()));
299 
300  // Get the output process map.
301  // If result's pmap is assigned use it as the initial guess
302  // it will be assigned in engine.init
303  std::shared_ptr<typename TsrExpr<A, Alias>::array_type::pmap_interface> pmap;
304  if(tsr.array().is_initialized())
305  pmap = tsr.array().pmap();
306 
307  // Get result variable list.
308  VariableList target_vars(tsr.vars());
309 
310  // Construct the expression engine
311  engine_type engine(derived());
312  engine.init(world, pmap, target_vars);
313 
314  // Create the distributed evaluator from this expression
315  typename engine_type::dist_eval_type dist_eval = engine.make_dist_eval();
316  dist_eval.eval();
317 
318  // Create the result array
319  A result(dist_eval.world(), dist_eval.trange(),
320  dist_eval.shape(), dist_eval.pmap());
321 
322  // Move the data from dist_eval into the result array. There is no
323  // communication in this step.
324  for(const auto index : *dist_eval.pmap()) {
325  if(! dist_eval.is_zero(index))
326  set_tile(result, index, dist_eval.get(index));
327  }
328 
329  // Wait for child expressions of dist_eval
330  dist_eval.wait();
331 
332  // Swap the new array with the result array object.
333  result.swap(tsr.array());
334  }
335 
336 
338 
345  template <typename A, bool Alias>
346  void eval_to(BlkTsrExpr<A, Alias>& tsr) const {
352  "Assignment to an array of lazy tiles is not supported.");
353 
354 #ifndef NDEBUG
355  // Check that the array has been initialized.
356  if(! tsr.array().is_initialized()) {
357  if(TiledArray::get_default_world().rank() == 0) {
359  "Assignment to an uninitialized array sub-block is not supported.");
360  }
361 
362  TA_EXCEPTION("Assignment to an uninitialized array sub-block is not supported.");
363  }
364 
365  // Note: Unfortunately we cannot check that the array tiles have been
366  // set even though this is a requirement.
367 #endif // NDEBUG
368 
369  // Get the target world.
370  World& world = tsr.array().world();
371 
372  // Get the output process map.
373  std::shared_ptr<typename BlkTsrExpr<A, Alias>::array_type::pmap_interface> pmap;
374 
375  // Get result variable list.
376  VariableList target_vars(tsr.vars());
377 
378  // Construct the expression engine
379  engine_type engine(derived());
380  engine.init(world, pmap, target_vars);
381 
382  // Create the distributed evaluator from this expression
383  typename engine_type::dist_eval_type dist_eval = engine.make_dist_eval();
384  dist_eval.eval();
385 
386  // Create the result array
387  A result(world, tsr.array().trange(),
388  tsr.array().shape().update_block(tsr.lower_bound(), tsr.upper_bound(),
389  dist_eval.shape()), tsr.array().pmap());
390 
391  // NOTE: The tiles from the original array and the sub-block are copied
392  // in two separate steps because the two tensors have different data
393  // distribution.
394 
395  // Copy tiles from the original array to the result array that are not
396  // included in the sub-block assignment. There is no communication in
397  // this step.
398  const BlockRange blk_range(tsr.array().trange().tiles_range(),
399  tsr.lower_bound(), tsr.upper_bound());
400  for(const auto index : *tsr.array().pmap()) {
401  if(! tsr.array().is_zero(index)) {
402  if(! blk_range.includes(tsr.array().trange().tiles_range().idx(index)))
403  result.set(index, tsr.array().find(index));
404  }
405  }
406 
407  // Move the data from dist_eval into the sub-block of result array.
408  // This step may involve communication when the tiles are moved from the
409  // sub-block distribution to the array distribution.
410  {
411  const std::vector<long> shift =
412  tsr.array().trange().make_tile_range(tsr.lower_bound()).lobound();
413 
414  std::shared_ptr<op_type> shift_op =
415  std::make_shared<op_type>(shift_op_type(shift));
416 
417  for(const auto index : *dist_eval.pmap()) {
418  if(! dist_eval.is_zero(index))
419  set_tile(result, blk_range.ordinal(index), dist_eval.get(index),
420  shift_op);
421  }
422  }
423 
424  // Wait for child expressions of dist_eval
425  dist_eval.wait();
426 
427  // Swap the new array with the result array object.
428  result.swap(tsr.array());
429  }
430 
432 
435  void print(ExprOStream& os, const VariableList& target_vars) const {
436  // Construct the expression engine
437  engine_type engine(derived());
438  engine.init_vars(target_vars);
439  engine.init_struct(target_vars);
440  engine.print(os, target_vars);
441  }
442 
443  private:
444 
445  struct ExpressionReduceTag { };
446 
447  template <typename D, typename Enabler = void>
448  struct default_world_helper {
449  default_world_helper(const D&) {}
450  World& get() const { return TiledArray::get_default_world(); }
451  };
452  template <typename D>
453  struct default_world_helper<
454  D, typename std::enable_if<has_array<D>::value>::type> {
455  default_world_helper(const D& d) : derived_(d) {}
456  World& get() const { return derived_.array().world(); }
457  const D& derived_;
458  };
459  World& default_world() const {
460  return default_world_helper<Derived>(this->derived()).get();
461  }
462 
463  public:
464 
465  template <typename Op>
466  Future<typename Op::result_type>
467  reduce(const Op& op, World& world) const {
468  // Typedefs
469  typedef madness::TaggedKey<madness::uniqueidT, ExpressionReduceTag> key_type;
470  typedef TiledArray::math::UnaryReduceWrapper<typename engine_type::value_type,
471  Op> reduction_op_type;
472 
473  // Construct the expression engine
474  engine_type engine(derived());
475  engine.init(world, std::shared_ptr<typename engine_type::pmap_interface>(),
476  VariableList());
477 
478  // Create the distributed evaluator from this expression
479  typename engine_type::dist_eval_type dist_eval = engine.make_dist_eval();
480  dist_eval.eval();
481 
482  // Create a local reduction task
483  reduction_op_type wrapped_op(op);
484  TiledArray::detail::ReduceTask<reduction_op_type> reduce_task(world, wrapped_op);
485 
486  // Move the data from dist_eval into the local reduction task
487  typename engine_type::dist_eval_type::pmap_interface::const_iterator it =
488  dist_eval.pmap()->begin();
489  const typename engine_type::dist_eval_type::pmap_interface::const_iterator end =
490  dist_eval.pmap()->end();
491  for(; it != end; ++it)
492  if(! dist_eval.is_zero(*it))
493  reduce_task.add(dist_eval.get(*it));
494 
495  // All reduce the result of the expression
496  auto result = world.gop.all_reduce(key_type(dist_eval.id()), reduce_task.submit(), op);
497  dist_eval.wait();
498  return result;
499  }
500 
501  template <typename Op>
502  Future<typename Op::result_type>
503  reduce(const Op& op) const {
504  return reduce(op, default_world());
505  }
506 
507  template <typename D, typename Op>
508  Future<typename Op::result_type>
509  reduce(const Expr<D>& right_expr, const Op& op,
510  World& world) const
511  {
512  static_assert(is_aliased<D>::value,
513  "no_alias() expressions are not allowed on the right-hand side of "
514  "the assignment operator.");
515 
516  // Typedefs
517  typedef madness::TaggedKey<madness::uniqueidT, ExpressionReduceTag> key_type;
518  typedef TiledArray::math::BinaryReduceWrapper<typename engine_type::value_type,
519  typename D::engine_type::value_type, Op> reduction_op_type;
520 
521  // Evaluate this expression
522  engine_type left_engine(derived());
523  left_engine.init(world, std::shared_ptr<typename engine_type::pmap_interface>(),
524  VariableList());
525 
526  // Create the distributed evaluator for this expression
527  typename engine_type::dist_eval_type left_dist_eval =
528  left_engine.make_dist_eval();
529  left_dist_eval.eval();
530 
531  // Evaluate the right-hand expression
532  typename D::engine_type right_engine(right_expr.derived());
533  right_engine.init(world, left_engine.pmap(), left_engine.vars());
534 
535  // Create the distributed evaluator for the right-hand expression
536  typename D::engine_type::dist_eval_type right_dist_eval =
537  right_engine.make_dist_eval();
538  right_dist_eval.eval();
539 
540 #ifndef NDEBUG
541  if(left_dist_eval.trange() != right_dist_eval.trange()) {
542  if(TiledArray::get_default_world().rank() == 0) {
544  "The TiledRanges of the left- and right-hand arguments the binary reduction are not equal:" \
545  << "\n left = " << left_dist_eval.trange() \
546  << "\n right = " << right_dist_eval.trange() );
547  }
548 
549  TA_EXCEPTION("The TiledRange objects of a binary expression are not equal.");
550  }
551 #endif // NDEBUG
552 
553  // Create a local reduction task
554  reduction_op_type wrapped_op(op);
556  local_reduce_task(world, wrapped_op);
557 
558  // Move the data from dist_eval into the local reduction task
559  typename engine_type::dist_eval_type::pmap_interface::const_iterator it =
560  left_dist_eval.pmap()->begin();
561  const typename engine_type::dist_eval_type::pmap_interface::const_iterator end =
562  left_dist_eval.pmap()->end();
563  for(; it != end; ++it) {
564  const typename engine_type::size_type index = *it;
565  const bool left_not_zero = !left_dist_eval.is_zero(index);
566  const bool right_not_zero = !right_dist_eval.is_zero(index);
567 
568  if(left_not_zero && right_not_zero) {
569  local_reduce_task.add(left_dist_eval.get(index), right_dist_eval.get(index));
570  } else {
571  if(left_not_zero) left_dist_eval.get(index);
572  if(right_not_zero) right_dist_eval.get(index);
573  }
574  }
575 
576  auto result = world.gop.all_reduce(key_type(left_dist_eval.id()),
577  local_reduce_task.submit(), op);
578  left_dist_eval.wait();
579  right_dist_eval.wait();
580  return result;
581  }
582 
583  template <typename D, typename Op>
584  Future<typename Op::result_type>
585  reduce(const Expr<D>& right_expr, const Op& op) const {
586  return reduce(right_expr, op, default_world());
587  }
588 
589  Future<typename TiledArray::TraceReduction<
590  typename EngineTrait<engine_type>::eval_type>::result_type>
591  trace(World& world) const {
592  typedef typename EngineTrait<engine_type>::eval_type value_type;
594  }
595 
596  Future<typename TiledArray::TraceReduction<
597  typename EngineTrait<engine_type>::eval_type>::result_type>
598  trace() const {
599  return trace(default_world());
600  }
601 
602  Future<typename TiledArray::SumReduction<
603  typename EngineTrait<engine_type>::eval_type>::result_type>
604  sum(World& world) const {
605  typedef typename EngineTrait<engine_type>::eval_type value_type;
607  }
608 
609  Future<typename TiledArray::SumReduction<
610  typename EngineTrait<engine_type>::eval_type>::result_type>
611  sum() const {
612  return sum(default_world());
613  }
614 
615  Future<typename TiledArray::ProductReduction<
616  typename EngineTrait<engine_type>::eval_type>::result_type>
617  product(World& world) const {
618  typedef typename EngineTrait<engine_type>::eval_type value_type;
620  }
621 
622  Future<typename TiledArray::ProductReduction<
623  typename EngineTrait<engine_type>::eval_type>::result_type>
624  product() const {
625  return product(default_world());
626  }
627 
628  Future<typename TiledArray::SquaredNormReduction<
629  typename EngineTrait<engine_type>::eval_type>::result_type>
630  squared_norm(World& world) const {
631  typedef typename EngineTrait<engine_type>::eval_type value_type;
633  world);
634  }
635 
636  Future<typename TiledArray::SquaredNormReduction<
637  typename EngineTrait<engine_type>::eval_type>::result_type>
638  squared_norm() const {
639  return squared_norm(default_world());
640  }
641 
642  private:
643 
644  template <typename T>
645  static T sqrt(const T t) { return std::sqrt(t); }
646 
647  public:
648 
649  Future<typename TiledArray::SquaredNormReduction<
650  typename EngineTrait<engine_type>::eval_type>::result_type>
651  norm(World& world) const {
652  return world.taskq.add(Expr_::template sqrt<
654  typename EngineTrait<engine_type>::eval_type>::result_type>,
655  squared_norm(world));
656  }
657  Future<typename TiledArray::SquaredNormReduction<
658  typename EngineTrait<engine_type>::eval_type>::result_type>
659  norm() const {
660  return norm(default_world());
661  }
662 
663  template <typename Derived_ = Derived>
664  std::enable_if<
667  eval_type>>::value,
668  Future<typename TiledArray::MinReduction<
670  eval_type>::result_type>>
671  min(World& world) const {
672  typedef typename EngineTrait<engine_type>::eval_type value_type;
674  }
675 
676  template <typename Derived_ = Derived>
677  std::enable_if<
680  eval_type>>::value,
681  Future<typename TiledArray::MinReduction<
683  eval_type>::result_type>>
684  min() const {
685  return min(default_world());
686  }
687 
688  template <typename Derived_ = Derived>
689  std::enable_if<
692  eval_type>>::value,
693  Future<typename TiledArray::MaxReduction<
695  eval_type>::result_type>>
696  max(World& world) const {
697  typedef typename EngineTrait<engine_type>::eval_type value_type;
699  }
700 
701  template <typename Derived_ = Derived>
702  std::enable_if<
705  eval_type>>::value,
706  Future<typename TiledArray::MaxReduction<
708  eval_type>::result_type>>
709  max() const {
710  return max(default_world());
711  }
712 
713  Future<typename TiledArray::AbsMinReduction<
714  typename EngineTrait<engine_type>::eval_type>::result_type>
715  abs_min(World& world) const {
716  typedef typename EngineTrait<engine_type>::eval_type value_type;
718  }
719 
720  Future<typename TiledArray::AbsMinReduction<
721  typename EngineTrait<engine_type>::eval_type>::result_type>
722  abs_min() const {
723  return abs_min(default_world());
724  }
725 
726  Future<typename TiledArray::AbsMaxReduction<
727  typename EngineTrait<engine_type>::eval_type>::result_type>
728  abs_max(World& world) const {
729  typedef typename EngineTrait<engine_type>::eval_type value_type;
731  }
732 
733  Future<typename TiledArray::AbsMaxReduction<
734  typename EngineTrait<engine_type>::eval_type>::result_type>
735  abs_max() const {
736  return abs_max(default_world());
737  }
738 
739  template <typename D>
740  Future<typename TiledArray::DotReduction<
743  dot(const Expr<D>& right_expr, World& world) const {
744  typedef typename EngineTrait<engine_type>::eval_type left_value_type;
745  typedef typename EngineTrait<typename D::engine_type>::eval_type right_value_type;
746  return reduce(right_expr, TiledArray::DotReduction<left_value_type,
747  right_value_type>(), world);
748  }
749 
750  template <typename D>
751  Future<typename TiledArray::DotReduction<
754  dot(const Expr<D>& right_expr) const {
755  return dot(right_expr, default_world());
756  }
757 
758  template <typename D>
759  Future<typename TiledArray::InnerProductReduction<
762  inner_product(const Expr<D>& right_expr, World& world) const {
763  typedef typename EngineTrait<engine_type>::eval_type left_value_type;
764  typedef typename EngineTrait<typename D::engine_type>::eval_type right_value_type;
765  return reduce(right_expr, TiledArray::InnerProductReduction<left_value_type,
766  right_value_type>(), world);
767  }
768 
769  template <typename D>
770  Future<typename TiledArray::InnerProductReduction<
773  inner_product(const Expr<D>& right_expr) const {
774  return inner_product(right_expr, default_world());
775  }
776 
777  }; // class Expr
778 
779  } // namespace expressions
780 } // namespace TiledArray
781 
782 #endif // TILEDARRAY_EXPRESSIONS_EXPR_H__INCLUDED
Future< typename TiledArray::ProductReduction< typename EngineTrait< engine_type >::eval_type >::result_type > product(World &world) const
Definition: expr.h:617
detail::ShiftWrapper< T > shift(T &tensor)
Shift a tensor from one range to another.
Tile cast operation.
Definition: cast.h:34
void eval_to(BlkTsrExpr< A, Alias > &tsr) const
Evaluate this object and assign it to tsr.
Definition: expr.h:346
void print(ExprOStream &os, const VariableList &target_vars) const
Expression print.
Definition: expr.h:435
Expr< Derived > & set_pmap(const std::shared_ptr< typename override_type::pmap_interface > pmap)
Definition: expr.h:127
Future< typename TiledArray::SumReduction< typename EngineTrait< engine_type >::eval_type >::result_type > sum(World &world) const
Definition: expr.h:604
Future< typename TiledArray::InnerProductReduction< typename EngineTrait< engine_type >::eval_type, typename EngineTrait< typename D::engine_type >::eval_type >::result_type > inner_product(const Expr< D > &right_expr, World &world) const
Definition: expr.h:762
std::enable_if< TiledArray::detail::is_strictly_ordered< TiledArray::detail::numeric_t< typename EngineTrait< typename ExprTrait< Derived_ >::engine_type >::eval_type > >::value, Future< typename TiledArray::MaxReduction< typename EngineTrait< typename ExprTrait< Derived_ >::engine_type >::eval_type >::result_type > > max(World &world) const
Definition: expr.h:696
Vector inner product tile reduction.
const std::vector< std::size_t > & upper_bound() const
Upper bound accessor.
Definition: blk_tsr_expr.h:229
Future< typename TiledArray::AbsMinReduction< typename EngineTrait< engine_type >::eval_type >::result_type > abs_min(World &world) const
Definition: expr.h:715
Future< typename TiledArray::ProductReduction< typename EngineTrait< engine_type >::eval_type >::result_type > product() const
Definition: expr.h:624
STL namespace.
Tile sum reduction.
const std::string & vars() const
Tensor variable string accessor.
Definition: tsr_expr.h:239
Future< typename TiledArray::TraceReduction< typename EngineTrait< engine_type >::eval_type >::result_type > trace(World &world) const
Definition: expr.h:591
Minabs tile reduction.
Expr< Derived > Expr_
This class type.
Definition: expr.h:89
Unary tile operation wrapper.
Definition: unary_wrapper.h:82
static constexpr const bool value
Definition: expr.h:73
Future< typename TiledArray::AbsMaxReduction< typename EngineTrait< engine_type >::eval_type >::result_type > abs_max() const
Definition: expr.h:735
void add(const L &left, const R &right, madness::CallbackInterface *callback=nullptr)
Add a pair of arguments to the reduction task.
Definition: reduce_task.h:705
const derived_type & derived() const
Cast this object to it&#39;s derived type.
Definition: expr.h:276
Future< typename TiledArray::SumReduction< typename EngineTrait< engine_type >::eval_type >::result_type > sum() const
Definition: expr.h:611
typename TiledArray::detail::numeric_type< T >::type numeric_t
Definition: type_traits.h:525
Future< typename Op::result_type > reduce(const Op &op) const
Definition: expr.h:503
Vector dot product tile reduction.
Tile shift operation.
Definition: shift.h:46
Expression wrapper for array objects.
Definition: dist_array.h:39
std::enable_if< TiledArray::detail::is_strictly_ordered< TiledArray::detail::numeric_t< typename EngineTrait< typename ExprTrait< Derived_ >::engine_type >::eval_type > >::value, Future< typename TiledArray::MinReduction< typename EngineTrait< typename ExprTrait< Derived_ >::engine_type >::eval_type >::result_type > > min() const
Definition: expr.h:684
Future< typename TiledArray::SquaredNormReduction< typename EngineTrait< engine_type >::eval_type >::result_type > norm(World &world) const
Definition: expr.h:651
engine_t< derived_type > engine_type
Expression engine type.
Definition: expr.h:91
Future< typename Op::result_type > reduce(const Expr< D > &right_expr, const Op &op) const
Definition: expr.h:585
std::shared_ptr< pmap_interface > pmap
Definition: expr.h:58
EngineTrait< Engine >::shape_type shape_type
Tensor shape type.
Definition: expr.h:54
Tile product reduction.
const std::vector< std::size_t > & lower_bound() const
Lower bound accessor.
Definition: blk_tsr_expr.h:224
EngineTrait< Engine >::pmap_interface pmap_interface
Process map interface type.
Definition: expr.h:55
Binary reduction wrapper class that handles lazy tile evaluation.
Variable list manages a list variable strings.
Future< typename TiledArray::TraceReduction< typename EngineTrait< engine_type >::eval_type >::result_type > trace() const
Definition: expr.h:598
std::enable_if< TiledArray::detail::is_strictly_ordered< TiledArray::detail::numeric_t< typename EngineTrait< typename ExprTrait< Derived_ >::engine_type >::eval_type > >::value, Future< typename TiledArray::MinReduction< typename EngineTrait< typename ExprTrait< Derived_ >::engine_type >::eval_type >::result_type > > min(World &world) const
Definition: expr.h:671
std::enable_if< TiledArray::detail::is_strictly_ordered< TiledArray::detail::numeric_t< typename EngineTrait< typename ExprTrait< Derived_ >::engine_type >::eval_type > >::value, Future< typename TiledArray::MaxReduction< typename EngineTrait< typename ExprTrait< Derived_ >::engine_type >::eval_type >::result_type > > max() const
Definition: expr.h:709
Expr_ & operator=(const Expr_ &)=delete
Base class for expression evaluation.
Definition: expr.h:81
derived_type & derived()
Cast this object to it&#39;s derived type.
Definition: expr.h:273
void eval_to(TsrExpr< A, Alias > &tsr) const
Evaluate this object and assign it to tsr.
Definition: expr.h:287
Future< typename TiledArray::SquaredNormReduction< typename EngineTrait< engine_type >::eval_type >::result_type > squared_norm(World &world) const
Definition: expr.h:630
Expr< Derived > & set_shape(typename override_type::shape_type const &shape)
Definition: expr.h:107
Maxabs tile reduction.
Future< typename Op::result_type > reduce(const Expr< D > &right_expr, const Op &op, World &world) const
Definition: expr.h:509
typename engine_t< Derived_ >::eval_type eval_type_t
Definition: expr.h:87
Maximum tile reduction.
type trait checks if T has array() member Useful to determine if an Expr is a TsrExpr or a related ty...
Definition: expr.h:65
Unary reduction wrapper class that handles lazy tile evaluation.
Range that references a subblock of another range.
Definition: block_range.h:34
int add(const Arg &arg, madness::CallbackInterface *callback=nullptr)
Add an argument to the reduction task.
Definition: reduce_task.h:524
Future< typename TiledArray::DotReduction< typename EngineTrait< engine_type >::eval_type, typename EngineTrait< typename D::engine_type >::eval_type >::result_type > dot(const Expr< D > &right_expr, World &world) const
Definition: expr.h:743
const std::string & vars() const
Tensor variable string accessor.
Definition: blk_tsr_expr.h:219
#define TA_EXCEPTION(m)
Definition: error.h:72
typename ExprTrait< Derived_ >::engine_type engine_t
Definition: expr.h:85
Future< typename TiledArray::InnerProductReduction< typename EngineTrait< engine_type >::eval_type, typename EngineTrait< typename D::engine_type >::eval_type >::result_type > inner_product(const Expr< D > &right_expr) const
Definition: expr.h:773
Expr< Derived > & set_world(World &world)
Definition: expr.h:117
Minimum tile reduction.
Future< typename TiledArray::SquaredNormReduction< typename EngineTrait< engine_type >::eval_type >::result_type > norm() const
Definition: expr.h:659
Squared norm tile reduction.
Expression output stream.
Definition: expr_trace.h:39
Future< typename TiledArray::DotReduction< typename EngineTrait< engine_type >::eval_type, typename EngineTrait< typename D::engine_type >::eval_type >::result_type > dot(const Expr< D > &right_expr) const
Definition: expr.h:754
Tile trace reduction.
array_type & array() const
Array accessor.
Definition: tsr_expr.h:173
Future< typename TiledArray::AbsMinReduction< typename EngineTrait< engine_type >::eval_type >::result_type > abs_min() const
Definition: expr.h:722
Derived derived_type
The derived object type.
Definition: expr.h:90
Detect lazy evaluation tiles.
Definition: type_traits.h:388
Future< typename TiledArray::AbsMaxReduction< typename EngineTrait< engine_type >::eval_type >::result_type > abs_max(World &world) const
Definition: expr.h:728
#define TA_USER_ERROR_MESSAGE(m)
Definition: error.h:118
Future< result_type > submit()
Submit the reduction task to the task queue.
Definition: reduce_task.h:541
Future< typename TiledArray::SquaredNormReduction< typename EngineTrait< engine_type >::eval_type >::result_type > squared_norm() const
Definition: expr.h:638
EngineTrait< Engine >::policy policy
The result policy type.
Definition: expr.h:53
Future< typename Op::result_type > reduce(const Op &op, World &world) const
Definition: expr.h:467