pRC
multi-purpose Tensor Train library for C++
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_VALUE_IDENTITY_H
4#define pRC_CORE_VALUE_IDENTITY_H
5
8
9namespace pRC
10{
16 template<class T>
17 struct Identity<T, If<IsValue<T>>>
18 {
22 constexpr T operator()()
23 {
24 return 1;
25 }
26
35 template<class X, If<IsConstructible<T, X>> = 0>
36 constexpr T operator()(X &&value)
37 {
38 return forward<X>(value);
39 }
40 };
41
48 template<>
49 struct Identity<Float<16>>
50 {
55 {
56 return BFloat16::FromRepresentation(0x3F80);
57 }
58
67 template<class X, If<IsConstructible<Float<16>, X>> = 0>
68 constexpr Float<16> operator()(X &&value)
69 {
70 return forward<X>(value);
71 }
72 };
73}
74#endif // pRC_CORE_VALUE_IDENTITY_H
static constexpr auto FromRepresentation(Representation const rep)
Definition bfloat16.hpp:34
Top-level class storing a floating point number.
Definition float.hpp:35
Definition cholesky.hpp:18
std::enable_if_t< B{}, int > If
Definition type_traits.hpp:68
static constexpr Conditional< IsSatisfied< C >, RemoveConstReference< X >, X > copy(X &&a)
Definition copy.hpp:13
Any< IsFloat< T >, IsInteger< T > > IsValue
Definition type_traits.hpp:72
constexpr Float< 16 > operator()()
Returns the identity, i.e. 1.
Definition identity.hpp:54
constexpr Float< 16 > operator()(X &&value)
Returns a scaled identity, for value types the scaling factor is returned directly.
Definition identity.hpp:68
constexpr T operator()(X &&value)
Returns a scaled identity, for value types the scaling factor is returned directly.
Definition identity.hpp:36
constexpr T operator()()
Returns the identity, i.e. 1.
Definition identity.hpp:22
Definition type_traits.hpp:262