cMHN 1.1
C++ library for learning MHNs with pRC
Loading...
Searching...
No Matches
identity.hpp
Go to the documentation of this file.
1// SPDX-License-Identifier: BSD-2-Clause
2
3#ifndef pRC_CORE_TENSOR_IDENTITY_H
4#define pRC_CORE_TENSOR_IDENTITY_H
5
9
10namespace pRC
11{
12 template<class T>
13 struct Identity<T, If<IsTensorView<T>>> : Identity<ResultOf<Eval, T>>
14 {
15 };
16
17 template<class T>
18 struct Identity<T, If<IsTensor<T>>>
19 {
20 static_assert(IsInvocable<Diagonal, T>(),
21 "Diagonal has to be invocable for T.");
22 constexpr auto operator()()
23 {
24 return diagonal(unit<T>());
25 }
26
27 template<class X, If<IsConstructible<typename T::Type, X>> = 0>
28 constexpr auto operator()(X &&value)
29 {
30 return diagonal(unit<T>(forward<X>(value)));
31 }
32 };
33}
34#endif // pRC_CORE_TENSOR_IDENTITY_H
Definition cholesky.hpp:18
static constexpr auto makeConstantSequence()
Definition sequence.hpp:402
static constexpr auto diagonal(X &&a)
Definition diagonal.hpp:16
std::enable_if_t< B{}, int > If
Definition type_traits.hpp:68
constexpr auto operator()()
Definition identity.hpp:22
constexpr auto operator()(X &&value)
Definition identity.hpp:28
Definition type_traits.hpp:262
Definition type_traits.hpp:60
Definition type_traits.hpp:16