pRC
multi-purpose Tensor Train library for C++
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{
25 template<class X, class R = RemoveReference<X>, If<IsTensorish<R>> = 0,
26 If<IsInvocable<View, X>> = 0,
27 If<IsSatisfied<(isEven(typename R::Dimension()))>> = 0>
28 static inline constexpr auto extractDiagonal(X &&a)
29 {
31 return TensorViews::ExtractDiagonal<typename R::Type,
32 decltype(pick<Min>(cut<2, 0>(typename R::Sizes()),
33 cut<2, 1>(typename R::Sizes()))),
34 V>(view(forward<X>(a)));
35 }
36
51 template<class X, class R = RemoveReference<X>, If<IsTensorish<R>> = 0,
52 If<Not<IsInvocable<View, X>>> = 0,
53 If<IsInvocable<ExtractDiagonal, X &>> = 0>
54 static inline constexpr auto extractDiagonal(X &&a)
55 {
56 return eval(extractDiagonal(a));
57 }
58}
59#endif // pRC_CORE_TENSOR_OPERATOR_FUNCTIONS_EXTRACT_DIAGONAL_H
Definition extract_diagonal.hpp:16
Definition cholesky.hpp:18
static constexpr auto extractDiagonal(X &&a)
Extracts the diagonal of a Tensor.
Definition extract_diagonal.hpp:28
static constexpr X eval(X &&a)
Definition eval.hpp:11
static constexpr X view(X &&a)
Returns a TensorView obtained from a TensorView.
Definition view.hpp:22
static constexpr Conditional< IsSatisfied< C >, RemoveConstReference< X >, X > copy(X &&a)
Definition copy.hpp:13