Morpheus 1.0.0
Dynamic matrix type and algorithms for sparse matrices
Loading...
Searching...
No Matches
Morpheus_Functors.hpp
1
23#ifndef MORPHEUS_FUNCTORS_HPP
24#define MORPHEUS_FUNCTORS_HPP
25
26#include <Kokkos_Core.hpp>
27
28namespace Morpheus {
29namespace Impl {
30// primary template
31template <typename View, typename... Types>
32struct set_functor {};
33
34template <typename View, typename ValueType, typename IndexType>
36 View _data;
37 ValueType _val;
38 IndexType _ncols;
39
40 set_functor(View data, ValueType val, IndexType ncols)
41 : _data(data), _val(val), _ncols(ncols) {}
42
43 KOKKOS_INLINE_FUNCTION
44 void operator()(const IndexType& i) const {
45 for (IndexType j = 0; j < _ncols; j++) {
46 _data(i, j) = _val;
47 }
48 }
49};
50
51template <typename View, typename ValueType>
52struct set_functor<View, ValueType> {
53 View _data;
54 ValueType _val;
55
56 set_functor(View data, ValueType val) : _data(data), _val(val) {}
57
58 KOKKOS_INLINE_FUNCTION
59 void operator()(const size_t& i) const { _data(i) = _val; }
60};
61
62} // namespace Impl
63} // namespace Morpheus
64
65#endif // MORPHEUS_FUNCTORS_HPP
Generic Morpheus interfaces.
Definition: dummy.cpp:24
Definition: Morpheus_Functors.hpp:32
A wrapper that checks if the provided type is an integral type.
Definition: Morpheus_TypeTraits.hpp:73
A wrapper that checks if the provided type is a scalar type.
Definition: Morpheus_TypeTraits.hpp:85