Morpheus 1.0.0
Dynamic matrix type and algorithms for sparse matrices
Loading...
Searching...
No Matches
Dynamic/Morpheus_Convert_Impl.hpp
1
24#ifndef MORPHEUS_DYNAMIC_CONVERT_IMPL_HPP
25#define MORPHEUS_DYNAMIC_CONVERT_IMPL_HPP
26
27#include <Morpheus_FormatTags.hpp>
28
29#include <impl/Morpheus_Variant.hpp>
30#include <impl/Morpheus_Convert_Impl.hpp>
31
32namespace Morpheus {
33namespace Impl {
34
35template <typename ExecSpace>
36struct convert_fn {
37 using result_type = void;
38
39 template <typename SourceType, typename DestinationType>
40 result_type operator()(const SourceType& src, DestinationType& dst) {
41 Impl::convert<ExecSpace>(src, dst);
42 }
43};
44
45template <typename ExecSpace, typename SourceType, typename DestinationType>
46void convert(
47 const SourceType& src, DestinationType& dst,
48 typename std::enable_if<
51 nullptr) {
52 auto f = std::bind(Impl::convert_fn<ExecSpace>(), std::placeholders::_1,
53 std::ref(dst));
54 Impl::Variant::visit(f, src.const_formats());
55}
56
57template <typename ExecSpace, typename SourceType, typename DestinationType>
58void convert(const SourceType& src, DestinationType& dst,
59 typename std::enable_if<
62 DestinationType>::value>::type* = nullptr) {
63 dst.set_nrows(src.nrows());
64 dst.set_ncols(src.ncols());
65 dst.set_nnnz(src.nnnz());
66 auto f = std::bind(Impl::convert_fn<ExecSpace>(), std::cref(src),
67 std::placeholders::_1);
68 Impl::Variant::visit(f, dst.formats());
69}
70
71template <typename ExecSpace, typename SourceType, typename DestinationType>
72void convert(
73 const SourceType& src, DestinationType& dst,
74 typename std::enable_if<
77 type* = nullptr) {
78 dst.set_nrows(src.nrows());
79 dst.set_ncols(src.ncols());
80 dst.set_nnnz(src.nnnz());
81 Impl::Variant::visit(Impl::convert_fn<ExecSpace>(), src.const_formats(),
82 dst.formats());
83}
84
85} // namespace Impl
86} // namespace Morpheus
87
88#endif // MORPHEUS_DYNAMIC_CONVERT_IMPL_HPP
Checks if the given type T is a valid Dynamic Matrix Format Container i.e is valid matrix container a...
Definition: Morpheus_FormatTags.hpp:201
A valid Sparse Matrix container is the one that has a valid Sparse Matrix tag i.e satisfies the has_s...
Definition: Morpheus_FormatTraits.hpp:85
Generic Morpheus interfaces.
Definition: dummy.cpp:24
Definition: Dynamic/Morpheus_Convert_Impl.hpp:36