cMHN 1.1
C++ library for learning MHNs with pRC
Loading...
Searching...
No Matches
extract_diagonal.hpp
Go to the documentation of this file.
1// SPDX-License-Identifier: BSD-2-Clause
2
3#ifndef pRC_CORE_TENSOR_OPERATOR_FUNCTIONS_EXTRACT_DIAGONAL_H
4#define pRC_CORE_TENSOR_OPERATOR_FUNCTIONS_EXTRACT_DIAGONAL_H
5
11
12namespace pRC
13{
14 template<class X, class R = RemoveReference<X>, If<IsTensorish<R>> = 0,
15 If<IsInvocable<View, X>> = 0,
16 If<IsSatisfied<(isEven(typename R::Dimension()))>> = 0>
17 static inline constexpr auto extractDiagonal(X &&a)
18 {
20 return TensorViews::ExtractDiagonal<typename R::Type,
21 decltype(pick<Min>(cut<2, 0>(typename R::Sizes()),
22 cut<2, 1>(typename R::Sizes()))),
23 V>(view(forward<X>(a)));
24 }
25
26 template<class X, class R = RemoveReference<X>, If<IsTensorish<R>> = 0,
27 If<Not<IsInvocable<View, X>>> = 0,
28 If<IsInvocable<ExtractDiagonal, X &>> = 0>
29 static inline constexpr auto extractDiagonal(X &&a)
30 {
31 return eval(extractDiagonal(a));
32 }
33}
34#endif // pRC_CORE_TENSOR_OPERATOR_FUNCTIONS_EXTRACT_DIAGONAL_H
Definition extract_diagonal.hpp:16
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 X view(X &&a)
Definition view.hpp:12