VisionCpp  0.0.1
eval_assign.hpp
Go to the documentation of this file.
1 // This file is part of VisionCpp, a lightweight C++ template library
2 // for computer vision and image processing.
3 //
4 // Copyright (C) 2016 Codeplay Software Limited. All Rights Reserved.
5 //
6 // Contact: visioncpp@codeplay.com
7 //
8 // Licensed under the Apache License, Version 2.0 (the "License");
9 // you may not use this file except in compliance with the License.
10 // You may obtain a copy of the License at
11 //
12 // http://www.apache.org/licenses/LICENSE-2.0
13 //
14 // Unless required by applicable law or agreed to in writing, software
15 // distributed under the License is distributed on an "AS IS" BASIS,
16 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17 // See the License for the specific language governing permissions and
18 // limitations under the License.
19 
20 /// \file eval_assign.hpp
21 /// \brief This file contains the specialisation of the Evaluator struct for
22 /// assign when it is a root struct
23 
24 #ifndef VISIONCPP_INCLUDE_FRAMEWORK_EVALUATOR_EVAL_ASSIGN_EVAL_ASSIGN_HPP_
25 #define VISIONCPP_INCLUDE_FRAMEWORK_EVALUATOR_EVAL_ASSIGN_EVAL_ASSIGN_HPP_
26 
27 namespace visioncpp {
28 namespace internal {
29 /// \brief Partial specialisation of the Evaluator when the expression is an
30 /// internal::Assign expression and the internal::ops_category is
31 /// GlobalNeighbourOP.
32 template <size_t OutputIndex, size_t Offset, size_t LC, size_t LR, typename LHS,
33  typename RHS, size_t Cols, size_t Rows, size_t LfType, size_t LVL,
34  typename Loc, typename... Params>
35 struct Evaluator<internal::ops_category::GlobalNeighbourOP, OutputIndex, Offset,
36  LC, LR, internal::Assign<LHS, RHS, Cols, Rows, LfType, LVL>,
37  Loc, Params...> {
38  static inline void eval(Loc &cOffset,
40  EvalExpr<RHS, Loc, Params...>::template eval_global_neighbour<
41  true, Offset, OutputIndex, LC, LR>(cOffset, t);
42  }
43 };
44 
45 /// \brief Partial specialisation of the Evaluator when the expression is an
46 /// internal::Assign expression and the internal::ops_category is NeighbourOP.
47 template <size_t OutputIndex, size_t Offset, size_t LC, size_t LR, typename LHS,
48  typename RHS, size_t Cols, size_t Rows, size_t LfType, size_t LVL,
49  typename Loc, typename... Params>
50 struct Evaluator<internal::ops_category::NeighbourOP, OutputIndex, Offset, LC,
51  LR, internal::Assign<LHS, RHS, Cols, Rows, LfType, LVL>, Loc,
52  Params...> {
53  static inline void eval(Loc &cOffset,
55  EvalExpr<RHS, Loc, Params...>::template eval_neighbour<
56  true, 0, 0, 0, 0, Offset, OutputIndex, LC, LR>(cOffset, t);
57  }
58 };
59 
60 /// \brief Partial specialisation of the Evaluator when the expression is an
61 /// internal::Assign expression and the internal::ops_category is PointOP.
62 template <size_t Output_Index, size_t Offset, size_t LC, size_t LR,
63  typename LHS, typename RHS, size_t Cols, size_t Rows, size_t LfType,
64  size_t LVL, typename Loc, typename... Params>
65 struct Evaluator<internal::ops_category::PointOP, Output_Index, Offset, LC, LR,
66  internal::Assign<LHS, RHS, Cols, Rows, LfType, LVL>, Loc,
67  Params...> {
69  static inline void eval(Loc &cOffset,
71  using RHS_Eval_Expr = EvalExpr<RHS, Loc, Params...>;
72  using LHS_Eval_Expr = EvalExpr<LHS, Loc, Params...>;
73 
74  using ElementType =
75  typename MemoryTrait<Expr::LeafType,
76  decltype(tools::tuple::get<0>(t))>::Type;
77  for (int i = 0; i < LC; i += cOffset.cLRng)
78  if (cOffset.g_c + i < Expr::Type::Cols)
79  for (int j = 0; j < LR; j += cOffset.rLRng)
80  if (cOffset.g_r + j < Expr::Type::Rows) {
81  cOffset.pointOp_gc = cOffset.g_c + i;
82  cOffset.pointOp_gr = cOffset.g_r + j;
83  *(LHS_Eval_Expr::get_accessor(t).get_pointer() +
84  calculate_index(cOffset.g_c + i, cOffset.g_r + j,
85  Expr::Type::Cols, Expr::Type::Rows)) =
86  tools::convert<ElementType>(
87  RHS_Eval_Expr::eval_point(cOffset, t));
88  }
89  }
90 };
91 } // namespace internal
92 } // namespace visioncpp
93 #endif // VISIONCPP_INCLUDE_FRAMEWORK_EVALUATOR_EVAL_ASSIGN_EVAL_ASSIGN_HPP_
static size_t calculate_index(size_t c, size_t r, size_t cols, size_t rows)
function calculate_index
VisionCpp namespace.
Definition: sycl/device.hpp:24
The definition is in Assign file.
Definition: assign.hpp:44
eval_global_neighbour function:
Definition: evaluator.hpp:195
the root of the expression tree.
Definition: evaluator.hpp:195
This class is used to determine the ElementType of accessor template parameters.
The tuple is a fixed-size collection of heterogeneous values.
Definition: tuple.hpp:48