cMHN 1.2
C++ library for learning MHNs with pRC
Loading...
Searching...
No Matches
orthogonalize.hpp
Go to the documentation of this file.
1// SPDX-License-Identifier: BSD-2-Clause
2
3#ifndef pRC_TENSOR_TRAIN_ALGORITHMS_ORTHOGONALIZE_H
4#define pRC_TENSOR_TRAIN_ALGORITHMS_ORTHOGONALIZE_H
5
8
9namespace pRC
10{
11 template<Position P, class X, IsTensorish R = RemoveReference<X>>
12 requires(P == Position::Left)
13 static inline constexpr auto orthogonalize(X &&a)
14 {
16 [&](auto const... seq)
17 {
18 auto const [q, r] = qr(folding<P>(forward<X>(a)));
19
20 return Tuple(eval(reshape<R::size(seq)...,
21 RemoveReference<decltype(q)>::size(1)>(q)),
22 r);
23 });
24 }
25
26 template<Position P, class X, IsTensorish R = RemoveReference<X>>
27 requires(P == Position::Right)
28 static inline constexpr auto orthogonalize(X &&a)
29 {
31 [&](auto const... seq)
32 {
33 auto const [l, q] = lq(folding<P>(forward<X>(a)));
34
35 return Tuple(l,
36 eval(reshape<RemoveReference<decltype(q)>::size(0),
37 R::size(seq)...>(q)));
38 });
39 }
40}
41#endif // pRC_TENSOR_TRAIN_ALGORITHMS_ORTHOGONALIZE_H
Definition cholesky.hpp:10
std::tuple< Ts... > Tuple
Definition basics.hpp:23
std::remove_reference_t< T > RemoveReference
Definition basics.hpp:41
static constexpr auto qr(X &&input)
Definition qr.hpp:13
static constexpr auto reshape(X &&a)
Definition reshape.hpp:14
static constexpr auto makeSeries()
Definition sequence.hpp:390
static constexpr auto lq(X &&input)
Definition lq.hpp:13
static constexpr auto makeRange()
Definition sequence.hpp:421
static constexpr auto orthogonalize(X &&a)
Definition orthogonalize.hpp:13
static constexpr auto folding(X &&a)
Definition folding.hpp:15
static constexpr decltype(auto) expand(Sequence< T, Seq... > const, F &&f, Xs &&...args)
Definition sequence.hpp:383
static constexpr decltype(auto) eval(X &&a)
Definition eval.hpp:12