Morpheus 1.0.0
Dynamic matrix type and algorithms for sparse matrices
Loading...
Searching...
No Matches
Morpheus_MirrorContainers.hpp
1
24#ifndef MORPHEUS_MIRRORCONTAINERS_HPP
25#define MORPHEUS_MIRRORCONTAINERS_HPP
26
27#include <Morpheus_FormatTraits.hpp>
28
29#include <impl/Morpheus_MirrorContainers_Impl.hpp>
30
31namespace Morpheus {
32
62template <template <class, class...> class Container, class T, class... P>
63typename Container<T, P...>::HostMirror create_mirror(
64 const Container<T, P...>& src,
65 typename std::enable_if_t<is_container_v<Container<T, P...>>>* = nullptr) {
66 using src_type = Container<T, P...>;
67 using dst_type = typename src_type::HostMirror;
68
69 return dst_type().allocate(src);
70}
71
85template <class Space, template <class, class...> class Container, class T,
86 class... P>
87typename Impl::MirrorType<Space, Container, T, P...>::container_type
89 const Container<T, P...>& src,
90 typename std::enable_if_t<is_container_v<Container<T, P...>>>* = nullptr) {
91 using container_type =
92 typename Impl::MirrorType<Space, Container, T, P...>::container_type;
93 return container_type().allocate(src);
94}
95
110template <template <class, class...> class Container, class T, class... P>
111typename Container<T, P...>::HostMirror create_mirror_container(
112 const Container<T, P...>& src,
113 typename std::enable_if_t<is_compatible_v<
114 Container<T, P...>, typename Container<T, P...>::HostMirror>>* =
115 nullptr) {
116 return src;
117}
118
130template <template <class, class...> class Container, class T, class... P>
131typename Container<T, P...>::HostMirror create_mirror_container(
132 const Container<T, P...>& src,
133 typename std::enable_if_t<!is_compatible_v<
134 Container<T, P...>, typename Container<T, P...>::HostMirror>>* =
135 nullptr) {
136 return Morpheus::create_mirror(src);
137}
138
155template <class Space, template <class, class...> class Container, class T,
156 class... P>
157typename Impl::MirrorContainerType<Space, Container, T, P...>::container_type
159 const Container<T, P...>& src,
160 typename std::enable_if<Impl::MirrorContainerType<Space, Container, T,
161 P...>::is_same_memspace &&
162 is_container<Container<T, P...>>::value>::type* =
163 nullptr) {
164 return src;
165}
166
179template <class Space, template <class, class...> class Container, class T,
180 class... P>
181typename Impl::MirrorContainerType<Space, Container, T, P...>::container_type
183 const Container<T, P...>& src,
184 typename std::enable_if<!Impl::MirrorContainerType<
185 Space, Container, T, P...>::is_same_memspace &&
186 is_container<Container<T, P...>>::value>::type* =
187 nullptr) {
188 using container_type =
189 typename Impl::MirrorContainerType<Space, Container, T,
190 P...>::container_type;
191 return container_type().allocate(src);
192}
195} // namespace Morpheus
196
197#endif // MORPHEUS_MIRRORCONTAINERS_HPP
Checks if the given type T is a valid Morpheus Container i.e is either a valid matrix or a vector con...
Definition: Morpheus_FormatTraits.hpp:182
Container< T, P... >::HostMirror create_mirror_container(const Container< T, P... > &src, typename std::enable_if_t< is_compatible_v< Container< T, P... >, typename Container< T, P... >::HostMirror > > *=nullptr)
Creates a mirror container on Host (specialization for same space)
Definition: Morpheus_MirrorContainers.hpp:111
Container< T, P... >::HostMirror create_mirror(const Container< T, P... > &src, typename std::enable_if_t< is_container_v< Container< T, P... > > > *=nullptr)
Allocates a mirror with the same characteristics as source on Host (specialization for different spac...
Definition: Morpheus_MirrorContainers.hpp:63
Generic Morpheus interfaces.
Definition: dummy.cpp:24
constexpr bool is_container_v
Short-hand to is_container.
Definition: Morpheus_FormatTraits.hpp:204
constexpr bool is_compatible_v
Short-hand to is_compatible.
Definition: Morpheus_FormatTraits.hpp:313
Definition: Morpheus_MirrorContainers_Impl.hpp:34
Definition: Morpheus_MirrorContainers_Impl.hpp:63