TiledArray  0.7.0
scal_tsr_engine.h
Go to the documentation of this file.
1 /*
2  * This file is a part of TiledArray.
3  * Copyright (C) 2014 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  * scal_tsr_engine.h
22  * Mar 31, 2014
23  *
24  */
25 
26 #ifndef TILEDARRAY_EXPRESSIONS_SCAL_TSR_ENGINE_H__INCLUDED
27 #define TILEDARRAY_EXPRESSIONS_SCAL_TSR_ENGINE_H__INCLUDED
28 
32 
33 namespace TiledArray {
34  namespace expressions {
35 
36  template <typename, typename> class ScalTsrExpr;
37  template <typename, typename, typename> class ScalTsrEngine;
38 
39 
40  template <typename Tile, typename Policy, typename Scalar, typename Result>
41  struct EngineTrait<ScalTsrEngine<DistArray<Tile, Policy>, Scalar, Result> >
42  {
43  // Argument typedefs
45 
46  // Operational typedefs
47  typedef Scalar scalar_type;
48  typedef TiledArray::detail::Scal<Result, typename TiledArray::eval_trait<
49  typename array_type::value_type>::type, scalar_type,
55  typedef typename eval_trait<value_type>::type
57  typedef Policy policy;
60 
61  // Meta data typedefs
62  typedef typename policy::size_type size_type;
63  typedef typename policy::trange_type trange_type;
64  typedef typename policy::shape_type shape_type;
65  typedef typename policy::pmap_interface pmap_interface;
66 
67  static constexpr bool consumable = true;
68  static constexpr unsigned int leaves = 1;
69 
70  };
71 
72 
74 
76  template <typename Array, typename Scalar, typename Result>
77  class ScalTsrEngine : public LeafEngine<ScalTsrEngine<Array, Scalar, Result> > {
78  public:
79  // Class hierarchy typedefs
83 
84  // Argument typedefs
86 
87  // Operational typedefs
94 
95  // Meta data typedefs
100 
101  private:
102 
103  scalar_type factor_;
104 
105  public:
106 
107  template <typename A, typename S>
109  LeafEngine_(expr), factor_(expr.factor())
110  { }
111 
113 
115  shape_type make_shape() { return LeafEngine_::array_.shape().scale(factor_); }
116 
118 
122  return LeafEngine_::array_.shape().scale(factor_, perm);
123  }
124 
126 
129  return op_type(op_base_type(factor_));
130  }
131 
133 
137  return op_type(op_base_type(factor_), perm);
138  }
139 
141 
143  std::string make_tag() const {
144  std::stringstream ss;
145  ss << "[" << factor_ << "] ";
146  return ss.str();
147  }
148 
149  }; // class ScalTsrEngine
150 
151  } // namespace expressions
152 } // namespace TiledArray
153 
154 #endif // TILEDARRAY_EXPRESSIONS_SCAL_TSR_ENGINE_H__INCLUDED
EngineTrait< ScalTsrEngine_ >::value_type value_type
Tensor value type.
shape_type make_shape()
Non-permuting shape factory function.
Determine the object type used in the evaluation of tensor expressions.
Definition: type_traits.h:296
Expression wrapper for scaled array objects.
EngineTrait< ScalTsrEngine_ >::policy policy
The result policy type.
array_type array_
The array object.
Definition: leaf_engine.h:74
Scaled tensor expression engine.
TiledArray::detail::Scal< Result, typename TiledArray::eval_trait< typename array_type::value_type >::type, scalar_type, TiledArray::eval_trait< typename array_type::value_type >::is_consumable > op_base_type
The tile operation.
Unary tile operation wrapper.
Definition: unary_wrapper.h:82
EngineTrait< ScalTsrEngine_ >::size_type size_type
Size type.
Tile scaling operation.
Definition: scal.h:46
Lazy tile for on-the-fly evaluation of array tiles.
Definition: array_eval.h:42
EngineTrait< ScalTsrEngine_ >::dist_eval_type dist_eval_type
This expression&#39;s distributed evaluator type.
Tensor expression object.
Definition: dist_eval.h:241
EngineTrait< ScalTsrEngine_ >::pmap_interface pmap_interface
Process map interface type.
ScalTsrEngine(const ScalTsrExpr< A, S > &expr)
EngineTrait< ScalTsrEngine_ >::scalar_type scalar_type
Tile scalar type.
std::string make_tag() const
Expression identification tag.
Forward declarations.
Definition: clone.h:32
EngineTrait< ScalTsrEngine_ >::trange_type trange_type
Tiled range type type.
EngineTrait< ScalTsrEngine_ >::op_base_type op_base_type
Tile base operation type.
LeafEngine_::ExprEngine_ ExprEngine_
Expression engine base class.
EngineTrait< ScalTsrEngine_ >::array_type array_type
The left-hand expression type.
EngineTrait< ScalTsrEngine_ >::op_type op_type
Tile operation type.
TiledArray::detail::LazyArrayTile< typename array_type::value_type, op_type > value_type
Tile type.
Permutation of a sequence of objects indexed by base-0 indices.
Definition: permutation.h:119
shape_type make_shape(const Permutation &perm)
Permuting shape factory function.
EngineTrait< ScalTsrEngine_ >::shape_type shape_type
Tensor shape type.
op_type make_tile_op() const
Non-permuting tile operation factory function.
op_type make_tile_op(const Permutation &perm) const
Permuting tile operation factory function.
LeafEngine< ScalTsrEngine_ > LeafEngine_
Leaf base class type.
An N-dimensional shallow copy wrapper for tile objects.
Definition: tile.h:80
TiledArray::detail::DistEval< value_type, policy > dist_eval_type
The distributed evaluator type.
Leaf expression engine.
Definition: leaf_engine.h:39
ScalTsrEngine< Array, Scalar, Result > ScalTsrEngine_
This class type.