#ifndef ALIASING_H_ #define ALIASING_H_ #include "Fastor/tensor/ForwardDeclare.h" #include "Fastor/tensor/Tensor.h" namespace Fastor { // template // FASTOR_INLINE bool does_alias(const Tensor &dst, const Tensor &src) { // return dst.data() == src.data() ? true : false; // } template FASTOR_INLINE bool does_alias(const AbstractTensor &dst, const Tensor &src) { return dst.self().data() == src.data() ? true : false; } // template // FASTOR_INLINE bool does_alias(const AbstractTensor &dst, const AbstractTensor &src) { // return does_alias(dst.self(),src.self()); // } #define FASTOR_MAKE_ALIAS_FUNC_UNARY_OPS(NAME)\ template\ FASTOR_INLINE bool does_alias(const AbstractTensor &dst, const Unary ##NAME ## Op &src) {\ return does_alias(dst.self(),src.expr().self());\ }\ FASTOR_MAKE_ALIAS_FUNC_UNARY_OPS(Add ) FASTOR_MAKE_ALIAS_FUNC_UNARY_OPS(Sub ) FASTOR_MAKE_ALIAS_FUNC_UNARY_OPS(Abs ) FASTOR_MAKE_ALIAS_FUNC_UNARY_OPS(Sqrt) FASTOR_MAKE_ALIAS_FUNC_UNARY_OPS(Exp ) FASTOR_MAKE_ALIAS_FUNC_UNARY_OPS(Log ) FASTOR_MAKE_ALIAS_FUNC_UNARY_OPS(Sin ) FASTOR_MAKE_ALIAS_FUNC_UNARY_OPS(Cos ) FASTOR_MAKE_ALIAS_FUNC_UNARY_OPS(Tan ) FASTOR_MAKE_ALIAS_FUNC_UNARY_OPS(Asin) FASTOR_MAKE_ALIAS_FUNC_UNARY_OPS(Acos) FASTOR_MAKE_ALIAS_FUNC_UNARY_OPS(Atan) FASTOR_MAKE_ALIAS_FUNC_UNARY_OPS(Sinh) FASTOR_MAKE_ALIAS_FUNC_UNARY_OPS(Cosh) FASTOR_MAKE_ALIAS_FUNC_UNARY_OPS(Tanh) // FASTOR_MAKE_ALIAS_FUNC_UNARY_OPS(Det ) // FASTOR_MAKE_ALIAS_FUNC_UNARY_OPS(Norm) // FASTOR_MAKE_ALIAS_FUNC_UNARY_OPS(Trace) FASTOR_MAKE_ALIAS_FUNC_UNARY_OPS(Trans) #define FASTOR_MAKE_ALIAS_FUNC_BINARY_OPS(NAME)\ template\ FASTOR_INLINE bool does_alias(const AbstractTensor &dst, const Binary ##NAME ## Op &src) {\ return does_alias(dst.self(),src.lhs().self()) || does_alias(dst.self(),src.rhs().self());\ }\ FASTOR_MAKE_ALIAS_FUNC_BINARY_OPS(Add) FASTOR_MAKE_ALIAS_FUNC_BINARY_OPS(Sub) FASTOR_MAKE_ALIAS_FUNC_BINARY_OPS(Mul) FASTOR_MAKE_ALIAS_FUNC_BINARY_OPS(Div) FASTOR_MAKE_ALIAS_FUNC_BINARY_OPS(MatMul) } #endif // ALIASING_H_