Skip to content

Commit

Permalink
Allow hermitian to take any rank (#292)
Browse files Browse the repository at this point in the history
  • Loading branch information
cliffburdick authored Oct 14, 2022
1 parent 65dd8e8 commit ee70f76
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions include/matx/operators/hermitian.h
Original file line number Diff line number Diff line change
Expand Up @@ -56,13 +56,18 @@ namespace matx
using scalar_type = typename T1::scalar_type;

__MATX_INLINE__ std::string str() { return "hermitian(" + op_.str() + ")"; }
__MATX_INLINE__ HermitianTransOp(T1 op) : op_(op) {}
__MATX_INLINE__ HermitianTransOp(T1 op) : op_(op) {
static_assert(Rank() >= 2, "Hermitian operation needs input with rank >= 2");
}

template <typename... Is>
__MATX_INLINE__ __MATX_DEVICE__ __MATX_HOST__ auto operator()(Is... indices) const
{
auto tup = cuda::std::make_tuple(indices...);
return conj(mapply_reverse(op_, tup));
auto stl = cuda::std::get<Rank()-2>(tup);
cuda::std::get<Rank()-2>(tup) = cuda::std::get<Rank()-1>(tup);
cuda::std::get<Rank()-1>(tup) = stl;
return conj(mapply(op_, tup));
}

static __MATX_INLINE__ constexpr __MATX_HOST__ __MATX_DEVICE__ int32_t Rank()
Expand Down

0 comments on commit ee70f76

Please sign in to comment.