cMHN 1.1
C++ library for learning MHNs with pRC
Loading...
Searching...
No Matches
trace.hpp
Go to the documentation of this file.
1// SPDX-License-Identifier: BSD-2-Clause
2
3#ifndef pRC_CORE_TENSOR_OPERATOR_FUNCTIONS_TRACE_H
4#define pRC_CORE_TENSOR_OPERATOR_FUNCTIONS_TRACE_H
5
12
13namespace pRC
14{
15 template<class X, If<IsTensorish<RemoveReference<X>>> = 0,
16 If<IsInvocable<View, X>> = 0, If<IsInvocable<ExtractDiagonal, X>> = 0,
17 If<IsInvocable<Reduce<Add>, ResultOf<ExtractDiagonal, X>>> = 0>
18 static inline constexpr auto trace(X &&a)
19 {
20 return reduce<Add>(extractDiagonal(forward<X>(a)));
21 }
22
23 template<class X, If<IsTensorish<RemoveReference<X>>> = 0,
24 If<Not<IsInvocable<View, X>>> = 0, If<IsInvocable<Trace, X &>> = 0>
25 static inline constexpr auto trace(X &&a)
26 {
27 return eval(trace(a));
28 }
29}
30#endif // pRC_CORE_TENSOR_OPERATOR_FUNCTIONS_TRACE_H
Definition cholesky.hpp:18
static constexpr auto extractDiagonal(X &&a)
Definition extract_diagonal.hpp:17
static constexpr X eval(X &&a)
Definition eval.hpp:11
static constexpr auto makeConstantSequence()
Definition sequence.hpp:402
static constexpr auto trace(X &&a)
Definition trace.hpp:18