pRC
multi-purpose Tensor Train library for C++
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{
22 template<class X, class R = RemoveReference<X>, If<IsTensorish<R>> = 0>
23 static inline constexpr auto squeeze(X &&a)
24 {
25 return expand(makeSeries<Index, typename R::Dimension{}>(),
26 [&a](auto const... seq)
27 {
28 return expand(
29 filter<NotFn<IsUnit>>(Sequence<Size, R::size(seq)...>()),
30 [&a](auto const... sizes)
31 {
32 return reshape<sizes...>(forward<X>(a));
33 });
34 });
35 }
36}
37#endif // pRC_CORE_TENSOR_FUNCTIONS_SQUEEZE_H
Definition sequence.hpp:34
Definition cholesky.hpp:18
static constexpr auto filter(Sequence< T, Is... > const)
Definition sequence.hpp:517
std::size_t Size
Definition type_traits.hpp:20
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 reshape(X &&a)
Reshapes a Tensor.
Definition reshape.hpp:29
static constexpr auto squeeze(X &&a)
Remove axes with mode size 1 from a Tensor.
Definition squeeze.hpp:23
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 not_fn.hpp:13