TensorSyclLeafCount.h
00001 // This file is part of Eigen, a lightweight C++ template library
00002 // for linear algebra.
00003 //
00004 // Mehdi Goli    Codeplay Software Ltd.
00005 // Ralph Potter  Codeplay Software Ltd.
00006 // Luke Iwanski  Codeplay Software Ltd.
00007 // Contact: <eigen@codeplay.com>
00008 //
00009 // This Source Code Form is subject to the terms of the Mozilla
00010 // Public License v. 2.0. If a copy of the MPL was not distributed
00011 // with this file, You can obtain one at http://mozilla.org/MPL/2.0/.
00012 
00013 /*****************************************************************
00014  * TensorSyclLeafCount.h
00015  *
00016  * \brief:
00017  *  The leaf count used the pre-order expression tree traverse in order to name
00018  *  count the number of leaf nodes in the expression
00019  *
00020 *****************************************************************/
00021 
00022 #ifndef UNSUPPORTED_EIGEN_CXX11_SRC_TENSOR_TENSORSYCL_LEAF_COUNT_HPP
00023 #define UNSUPPORTED_EIGEN_CXX11_SRC_TENSOR_TENSORSYCL_LEAF_COUNT_HPP
00024 
00025 namespace Eigen {
00026 namespace TensorSycl {
00027 namespace internal {
00031 template <typename Expr>
00032 struct LeafCount;
00033 
00034 template<typename... Args> struct CategoryCount;
00035 
00036 template<> struct CategoryCount<>
00037 {
00038   static const size_t Count =0;
00039 };
00040 
00041 template<typename Arg, typename... Args>
00042 struct CategoryCount<Arg,Args...>{
00043   static const size_t Count = LeafCount<Arg>::Count + CategoryCount<Args...>::Count;
00044 };
00045 
00047 template <typename PlainObjectType, int Options_, template <class> class MakePointer_>
00048 struct LeafCount<const TensorMap<PlainObjectType, Options_, MakePointer_> > {
00049   static const size_t Count =1;
00050 };
00051 
00053 template <typename PlainObjectType, int Options_, template <class> class MakePointer_>
00054 struct LeafCount<TensorMap<PlainObjectType, Options_, MakePointer_> > :LeafCount<const TensorMap<PlainObjectType, Options_, MakePointer_> >{};
00055 
00056 // const TensorCwiseUnaryOp, const TensorCwiseNullaryOp, const TensorCwiseBinaryOp, const TensorCwiseTernaryOp, and Const TensorBroadcastingOp
00057 template <template <class, class...> class CategoryExpr, typename OP, typename... RHSExpr>
00058 struct LeafCount<const CategoryExpr<OP, RHSExpr...> >: CategoryCount<RHSExpr...> {};
00059 // TensorCwiseUnaryOp,  TensorCwiseNullaryOp,  TensorCwiseBinaryOp,  TensorCwiseTernaryOp, and  TensorBroadcastingOp
00060 template <template <class, class...> class CategoryExpr, typename OP, typename... RHSExpr>
00061 struct LeafCount<CategoryExpr<OP, RHSExpr...> > :LeafCount<const CategoryExpr<OP, RHSExpr...> >{};
00062 
00064 template <typename IfExpr, typename ThenExpr, typename ElseExpr>
00065 struct LeafCount<const TensorSelectOp<IfExpr, ThenExpr, ElseExpr> > : CategoryCount<IfExpr, ThenExpr, ElseExpr> {};
00067 template <typename IfExpr, typename ThenExpr, typename ElseExpr>
00068 struct LeafCount<TensorSelectOp<IfExpr, ThenExpr, ElseExpr> >: LeafCount<const TensorSelectOp<IfExpr, ThenExpr, ElseExpr> > {};
00069 
00070 
00072 template <typename LHSExpr, typename RHSExpr>
00073 struct LeafCount<const TensorAssignOp<LHSExpr, RHSExpr> >: CategoryCount<LHSExpr,RHSExpr> {};
00074 
00077 template <typename LHSExpr, typename RHSExpr>
00078 struct LeafCount<TensorAssignOp<LHSExpr, RHSExpr> > :LeafCount<const TensorAssignOp<LHSExpr, RHSExpr> >{};
00079 
00081 template <typename Expr>
00082 struct LeafCount<const TensorForcedEvalOp<Expr> > {
00083     static const size_t Count =1;
00084 };
00085 
00087 template <typename Expr>
00088 struct LeafCount<TensorForcedEvalOp<Expr> >: LeafCount<const TensorForcedEvalOp<Expr> > {};
00089 
00091 template <typename Expr>
00092 struct LeafCount<const TensorEvalToOp<Expr> > {
00093   static const size_t Count = 1 + CategoryCount<Expr>::Count;
00094 };
00095 
00097 template <typename OP, typename Dim, typename Expr>
00098 struct LeafCount<const TensorReductionOp<OP, Dim, Expr> > {
00099     static const size_t Count =1;
00100 };
00101 
00103 template <typename OP, typename Dim, typename Expr>
00104 struct LeafCount<TensorReductionOp<OP, Dim, Expr> >: LeafCount<const TensorReductionOp<OP, Dim, Expr> >{};
00105 
00107 template <typename Expr>
00108 struct LeafCount<TensorEvalToOp<Expr> >: LeafCount<const TensorEvalToOp<Expr> >{};
00109 
00110 } 
00111 } 
00112 } 
00113 
00114 #endif  // UNSUPPORTED_EIGEN_CXX11_SRC_TENSOR_TENSORSYCL_LEAF_COUNT_HPP
 All Classes Functions Variables Typedefs Enumerator