#ifndef LINALG_TRAITS_H #define LINALG_TRAITS_H #include "Fastor/expressions/linalg_ops/binary_matmul_op.h" #include "Fastor/expressions/linalg_ops/unary_trans_op.h" #include "Fastor/expressions/linalg_ops/unary_ctrans_op.h" #include "Fastor/expressions/linalg_ops/unary_adj_op.h" #include "Fastor/expressions/linalg_ops/unary_cof_op.h" #include "Fastor/expressions/linalg_ops/unary_inv_op.h" #include "Fastor/expressions/linalg_ops/binary_solve_op.h" #include namespace Fastor { // Is a binary matmul expression //----------------------------------------------------------------------------------------------------------// template struct is_binary_matmul_op { static constexpr bool value = false; }; template struct is_binary_matmul_op,Tensor,DIM>> { static constexpr bool value = true; }; template struct is_binary_matmul_op> { static constexpr bool value = true; }; template struct has_binary_matmul_op { static constexpr bool value = is_binary_matmul_op::value ? true : false; }; template struct has_binary_matmul_op,Tensor,DIM>> { static constexpr bool value = true; }; template struct has_binary_matmul_op> { static constexpr bool value = true; }; template class UnaryExpr, typename Expr, size_t DIM> struct has_binary_matmul_op> { static constexpr bool value = has_binary_matmul_op::value; }; template class BinaryExpr, typename TLhs, typename TRhs, size_t DIMS> struct has_binary_matmul_op> { static constexpr bool value = has_binary_matmul_op::value || has_binary_matmul_op::value; }; // helper template static constexpr bool is_binary_matmul_op_v = is_binary_matmul_op::value; template static constexpr bool has_binary_matmul_op_v = has_binary_matmul_op::value; //----------------------------------------------------------------------------------------------------------// // Is unary trans expression //----------------------------------------------------------------------------------------------------------// template struct is_unary_trans_op { static constexpr bool value = false; }; template struct is_unary_trans_op> { static constexpr bool value = true; }; template struct has_unary_trans_op { static constexpr bool value = is_unary_trans_op::value ? true : false; }; template struct has_unary_trans_op> { static constexpr bool value = true; }; template class UnaryExpr, typename Expr, size_t DIM> struct has_unary_trans_op> { static constexpr bool value = has_unary_trans_op::value; }; template class BinaryExpr, typename TLhs, typename TRhs, size_t DIMS> struct has_unary_trans_op> { static constexpr bool value = has_unary_trans_op::value || has_unary_trans_op::value; }; // helper template static constexpr bool is_unary_trans_op_v = is_unary_trans_op::value; template static constexpr bool has_unary_trans_op_v = has_unary_trans_op::value; //----------------------------------------------------------------------------------------------------------// // Is unary ctrans expression //----------------------------------------------------------------------------------------------------------// template struct is_unary_ctrans_op { static constexpr bool value = false; }; template struct is_unary_ctrans_op> { static constexpr bool value = true; }; template struct has_unary_ctrans_op { static constexpr bool value = is_unary_ctrans_op::value ? true : false; }; template struct has_unary_ctrans_op> { static constexpr bool value = true; }; template class UnaryExpr, typename Expr, size_t DIM> struct has_unary_ctrans_op> { static constexpr bool value = has_unary_ctrans_op::value; }; template class BinaryExpr, typename TLhs, typename TRhs, size_t DIMS> struct has_unary_ctrans_op> { static constexpr bool value = has_unary_ctrans_op::value || has_unary_ctrans_op::value; }; // helper template static constexpr bool is_unary_ctrans_op_v = is_unary_ctrans_op::value; template static constexpr bool has_unary_ctrans_op_v = has_unary_ctrans_op::value; //----------------------------------------------------------------------------------------------------------// // Is unary adj expression //----------------------------------------------------------------------------------------------------------// template struct is_unary_adj_op { static constexpr bool value = false; }; template struct is_unary_adj_op> { static constexpr bool value = true; }; template struct has_unary_adj_op { static constexpr bool value = is_unary_adj_op::value ? true : false; }; template struct has_unary_adj_op> { static constexpr bool value = true; }; template class UnaryExpr, typename Expr, size_t DIM> struct has_unary_adj_op> { static constexpr bool value = has_unary_adj_op::value; }; template class BinaryExpr, typename TLhs, typename TRhs, size_t DIMS> struct has_unary_adj_op> { static constexpr bool value = has_unary_adj_op::value || has_unary_adj_op::value; }; // helper template static constexpr bool is_unary_adj_op_v = is_unary_adj_op::value; template static constexpr bool has_unary_adj_op_v = has_unary_adj_op::value; //----------------------------------------------------------------------------------------------------------// // Is unary adj expression //----------------------------------------------------------------------------------------------------------// template struct is_unary_cof_op { static constexpr bool value = false; }; template struct is_unary_cof_op> { static constexpr bool value = true; }; template struct has_unary_cof_op { static constexpr bool value = is_unary_cof_op::value ? true : false; }; template struct has_unary_cof_op> { static constexpr bool value = true; }; template class UnaryExpr, typename Expr, size_t DIM> struct has_unary_cof_op> { static constexpr bool value = has_unary_cof_op::value; }; template class BinaryExpr, typename TLhs, typename TRhs, size_t DIMS> struct has_unary_cof_op> { static constexpr bool value = has_unary_cof_op::value || has_unary_cof_op::value; }; // helper template static constexpr bool is_unary_cof_op_v = is_unary_cof_op::value; template static constexpr bool has_unary_cof_op_v = has_unary_cof_op::value; //----------------------------------------------------------------------------------------------------------// // Is unary inv expression //----------------------------------------------------------------------------------------------------------// template struct is_unary_inv_op { static constexpr bool value = false; }; template struct is_unary_inv_op> { static constexpr bool value = true; }; template struct has_unary_inv_op { static constexpr bool value = is_unary_inv_op::value ? true : false; }; template struct has_unary_inv_op> { static constexpr bool value = true; }; template class UnaryExpr, typename Expr, size_t DIM> struct has_unary_inv_op> { static constexpr bool value = has_unary_inv_op::value; }; template class BinaryExpr, typename TLhs, typename TRhs, size_t DIMS> struct has_unary_inv_op> { static constexpr bool value = has_unary_inv_op::value || has_unary_inv_op::value; }; // helper template static constexpr bool is_unary_inv_op_v = is_unary_inv_op::value; template static constexpr bool has_unary_inv_op_v = has_unary_inv_op::value; //----------------------------------------------------------------------------------------------------------// // Is a linear algebra expression //----------------------------------------------------------------------------------------------------------// template struct has_linalg_op { static constexpr bool value = has_binary_matmul_op::value || has_unary_trans_op::value || has_unary_ctrans_op::value || has_unary_adj_op::value || has_unary_cof_op::value || has_unary_inv_op::value; }; // helper template static constexpr bool has_linalg_op_v = has_linalg_op::value; //----------------------------------------------------------------------------------------------------------// // Requires immediate evaluation //----------------------------------------------------------------------------------------------------------// template struct requires_evaluation { static constexpr bool value = has_linalg_op::value; }; // helper template static constexpr bool requires_evaluation_v = requires_evaluation::value; //----------------------------------------------------------------------------------------------------------// } // end of namespace Fastor #endif // LINALG_TRAITS_H