pRC
multi-purpose Tensor Train library for C++
Loading...
Searching...
No Matches
norm.hpp
Go to the documentation of this file.
1// SPDX-License-Identifier: BSD-2-Clause
2
3#ifndef pRC_TENSOR_TRAIN_COMMON_FUNCTIONS_NORM_H
4#define pRC_TENSOR_TRAIN_COMMON_FUNCTIONS_NORM_H
5
12
13namespace pRC
14{
15 template<Index P = 2, Index Q = P, class X, class R = RemoveReference<X>,
16 If<Any<TensorTrain::IsTensorish<R>, TensorTrain::IsOperatorish<R>>> = 0,
17 If<IsSatisfied<(P == 2 && Q == 2)>> = 0>
18 static inline constexpr auto norm(X &&a)
19 {
21
22 return exp(expand(
24 [&a](auto const... seq)
25 {
26 return RecursiveLambda(
27 []<class XA, class XB>(auto const &self, XA &&a, XB &&b,
28 auto &&...cores) -> T
29 {
30 auto const [nrm, q, r] =
32
33 if(nrm <= identity<T>(
35 {
36 return zero();
37 }
38
40
41 if constexpr(sizeof...(cores) == 0)
42 {
43 return log(nrm) + log(norm(next));
44 }
45 else
46 {
47 return log(nrm) +
48 self(next, forward<decltype(cores)>(cores)...);
49 }
50 })(forward<X>(a).template core<seq>()...);
51 }));
52 }
53}
54#endif // pRC_TENSOR_TRAIN_COMMON_FUNCTIONS_NORM_H
Definition recursive_lambda.hpp:12
Class storing tensors.
Definition tensor.hpp:44
Definition cholesky.hpp:18
std::remove_reference_t< T > RemoveReference
Definition type_traits.hpp:56
static constexpr auto exp(Complex< T > const &a)
Definition exp.hpp:12
static constexpr auto zero()
Definition zero.hpp:12
static constexpr auto makeSeries()
Definition sequence.hpp:361
static constexpr Conditional< IsSatisfied< C >, RemoveConstReference< X >, X > copy(X &&a)
Definition copy.hpp:13
static constexpr auto log(Complex< T > const &a)
Definition log.hpp:11
static constexpr auto norm(Complex< T > const &a)
Definition norm.hpp:11
static constexpr decltype(auto) expand(Sequence< T, Seq... > const, F &&f, Xs &&...args)
forwards the values in a pRC::Sequence to a function as parameters
Definition sequence.hpp:354
Size Index
Definition type_traits.hpp:21
Definition limits.hpp:13