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>
37 class ScalTsrExpr;
38 template <typename, typename, typename>
39 class ScalTsrEngine;
40 
41 template <typename Tile, typename Policy, typename Scalar, typename Result>
42 struct EngineTrait<ScalTsrEngine<DistArray<Tile, Policy>, Scalar, Result>> {
43  // Argument typedefs
45 
46  // Operational typedefs
47  typedef Scalar scalar_type;
49  Result,
56  op_type>
58  typedef typename eval_trait<value_type>::type
60  typedef Policy policy;
63 
64  // Meta data typedefs
65  typedef typename policy::ordinal_type size_type;
66  typedef typename policy::trange_type trange_type;
67  typedef typename policy::shape_type shape_type;
68  typedef typename policy::pmap_interface
70 
71  static constexpr bool consumable = true;
72  static constexpr unsigned int leaves = 1;
73 };
74 
76 
78 template <typename Array, typename Scalar, typename Result>
79 class ScalTsrEngine : public LeafEngine<ScalTsrEngine<Array, Scalar, Result>> {
80  public:
81  // Class hierarchy typedefs
85  typedef typename LeafEngine_::ExprEngine_
87 
88  // Argument typedefs
91 
92  // Operational typedefs
101  typedef typename EngineTrait<ScalTsrEngine_>::policy
105 
106  // Meta data typedefs
107  typedef
115 
116  private:
117  scalar_type factor_;
118 
119  public:
120  template <typename A, typename S>
122  : LeafEngine_(expr), factor_(expr.factor()) {}
123 
125 
127  shape_type make_shape() { return LeafEngine_::array_.shape().scale(factor_); }
128 
130 
134  return LeafEngine_::array_.shape().scale(factor_, perm);
135  }
136 
138 
140  op_type make_tile_op() const { return op_type(op_base_type(factor_)); }
141 
143 
146  template <typename Perm, typename = std::enable_if_t<
147  TiledArray::detail::is_permutation_v<Perm>>>
148  op_type make_tile_op(const Perm& perm) const {
149  return op_type(op_base_type(factor_), perm);
150  }
151 
153 
155  std::string make_tag() const {
156  std::stringstream ss;
157  ss << "[" << factor_ << "] ";
158  return ss.str();
159  }
160 
161 }; // class ScalTsrEngine
162 
163 } // namespace expressions
164 } // namespace TiledArray
165 
166 #endif // TILEDARRAY_EXPRESSIONS_SCAL_TSR_ENGINE_H__INCLUDED
EngineTrait< ScalTsrEngine_ >::scalar_type scalar_type
Tile scalar type.
shape_type make_shape(const Permutation &perm)
Permuting shape factory function.
Permutation of a sequence of objects indexed by base-0 indices.
Definition: permutation.h:130
EngineTrait< ScalTsrEngine_ >::array_type array_type
The left-hand expression type.
op_type make_tile_op() const
Non-permuting tile operation factory function.
EngineTrait< ScalTsrEngine_ >::op_type op_type
Tile operation type.
TiledArray::detail::DistEval< value_type, policy > dist_eval_type
The distributed evaluator type.
EngineTrait< ScalTsrEngine_ >::dist_eval_type dist_eval_type
This expression's distributed evaluator type.
LeafEngine_::ExprEngine_ ExprEngine_
Expression engine base class.
Lazy tile for on-the-fly evaluation of array tiles.
Definition: array_eval.h:42
ScalTsrEngine< Array, Scalar, Result > ScalTsrEngine_
This class type.
Leaf expression engine.
Definition: leaf_engine.h:39
EngineTrait< ScalTsrEngine_ >::trange_type trange_type
Tiled range type type.
TiledArray::detail::LazyArrayTile< typename array_type::value_type, op_type > value_type
Tile type.
Scaled tensor expression engine.
shape_type make_shape()
Non-permuting shape factory function.
Forward declarations.
Definition: dist_array.h:57
array_type array_
The array object.
Definition: leaf_engine.h:81
EngineTrait< ScalTsrEngine_ >::size_type size_type
Size type.
op_type make_tile_op(const Perm &perm) const
Permuting tile operation factory function.
EngineTrait< ScalTsrEngine_ >::shape_type shape_type
Tensor shape type.
LeafEngine< ScalTsrEngine_ > LeafEngine_
Leaf base class type.
Expression wrapper for scaled array objects.
Definition: scal_tsr_expr.h:67
Unary tile operation wrapper.
Definition: unary_wrapper.h:83
std::string make_tag() const
Expression identification tag.
ScalTsrEngine(const ScalTsrExpr< A, S > &expr)
EngineTrait< ScalTsrEngine_ >::value_type value_type
Tensor value type.
EngineTrait< ScalTsrEngine_ >::pmap_interface pmap_interface
Process map interface type.
Determine the object type used in the evaluation of tensor expressions.
Definition: type_traits.h:580
Tile scaling operation.
Definition: scal.h:46
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.
Tensor expression object.
Definition: dist_eval.h:247
An N-dimensional shallow copy wrapper for tile objects.
Definition: tile.h:82
EngineTrait< ScalTsrEngine_ >::policy policy
The result policy type.
EngineTrait< ScalTsrEngine_ >::op_base_type op_base_type
Tile base operation type.