cMHN 1.1
C++ library for learning MHNs with pRC
Loading...
Searching...
No Matches
squeeze.hpp
Go to the documentation of this file.
1// SPDX-License-Identifier: BSD-2-Clause
2
3#ifndef pRC_CORE_TENSOR_FUNCTIONS_SQUEEZE_H
4#define pRC_CORE_TENSOR_FUNCTIONS_SQUEEZE_H
5
10
11namespace pRC
12{
13 template<class X, class R = RemoveReference<X>, If<IsTensorish<R>> = 0>
14 static inline constexpr auto squeeze(X &&a)
15 {
16 return expand(makeSeries<Index, typename R::Dimension{}>(),
17 [&a](auto const... seq)
18 {
19 return expand(
20 filter<NotFn<IsUnit>>(Sequence<Size, R::size(seq)...>()),
21 [&a](auto const... sizes)
22 {
23 return reshape<sizes...>(forward<X>(a));
24 });
25 });
26 }
27}
28#endif // pRC_CORE_TENSOR_FUNCTIONS_SQUEEZE_H
Definition sequence.hpp:34
Definition cholesky.hpp:18
static constexpr auto makeConstantSequence()
Definition sequence.hpp:402
Size Index
Definition type_traits.hpp:21
std::size_t Size
Definition type_traits.hpp:20
static constexpr auto filter(Sequence< T, Is... > const)
Definition sequence.hpp:507
static constexpr auto makeSeries()
Definition sequence.hpp:351
static constexpr auto reshape(X &&a)
Definition reshape.hpp:17
static constexpr auto squeeze(X &&a)
Definition squeeze.hpp:14
static constexpr decltype(auto) expand(Sequence< T, Seq... > const, F &&f, Xs &&...args)
Definition sequence.hpp:344
Definition not_fn.hpp:13