pRC
multi-purpose Tensor Train library for C++
Loading...
Searching...
No Matches
unit.hpp
Go to the documentation of this file.
1// SPDX-License-Identifier: BSD-2-Clause
2
3#ifndef pRC_CORE_TENSOR_UNIT_H
4#define pRC_CORE_TENSOR_UNIT_H
5
9
10namespace pRC
11{
21 template<class T>
22 struct Unit<T, If<IsTensorView<T>>> : Unit<ResultOf<Eval, T>>
23 {
24 };
25
31 template<class T>
32 struct Unit<T, If<IsTensor<T>>>
33 {
38 constexpr auto operator()()
39 {
40 auto const f = []()
41 {
43 };
44 using F = RemoveConstReference<decltype(f)>;
45 using Sizes = typename T::Sizes;
47 }
48
57 template<class X, If<IsConstructible<typename T::Type, X>> = 0>
58 constexpr auto operator()(X &&value)
59 {
60 auto const f = [value = typename T::Type(forward<X>(value))]()
61 {
62 return value;
63 };
64 using F = RemoveConstReference<decltype(f)>;
65 using Sizes = typename T::Sizes;
67 }
68 };
69}
70#endif // pRC_CORE_TENSOR_UNIT_H
Definition sequence.hpp:56
Definition loop.hpp:18
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
RemoveConst< RemoveReference< T > > RemoveConstReference
Definition type_traits.hpp:62
Definition type_traits.hpp:60
Definition type_traits.hpp:16
constexpr auto operator()(X &&value)
Returns the scaled unit of Tensor class T, i.e. a Tensor filled with the scaling factor.
Definition unit.hpp:58
constexpr auto operator()()
Returns the unit of Tensor class T, i.e. a Tensor filled with 1s.
Definition unit.hpp:38
Definition type_traits.hpp:265