10 #ifndef KOKKOS_VIEW_FACTORY_HPP
11 #define KOKKOS_VIEW_FACTORY_HPP
13 #include <type_traits>
25 template <
class ... ViewPack>
30 typedef typename View::value_type
type;
33 template <
class View,
class ... ViewPack>
36 typename View::value_type,
51 template <
class ... ViewPack>
56 template <
class ResultView,
class CtorProp,
class ... Dims>
60 const Dims ... dims) {
62 using nc_value_type =
typename ResultView::non_const_value_type;
67 constexpr
unsigned rank =
sizeof...(Dims);
70 static_assert( rank <= 7,
"Invalid rank...too many dimension arguments" );
73 typename ResultView::array_layout layout(dims...);
76 layout.dimension[rank] = dimension_scalar(views...);
81 if (!is_scalar && layout.dimension[rank] == 0)
82 layout.dimension[rank] = 1;
86 constexpr
unsigned r = is_scalar ? rank : rank + 1;
87 layout = Impl::reconstructLayout(layout, r);
90 return ResultView(prop, layout);
96 template <
typename ResultViewType,
typename InputViewType,
typename CtorProp,
98 typename std::enable_if<
100 ResultViewType>::type
102 const CtorProp& prop,
106 return view_factory::template create_view<ResultViewType>(
a,prop,dims...);
112 template <
typename InputView>
122 typename std::conditional<
127 Kokkos::DynRankView<input_value, result_layout, input_device>;
133 template <
typename InputViewType,
typename CtorProp,
typename ... Dims >
134 typename std::enable_if<
139 const CtorProp& prop,
143 return createDynRankViewWithType<ResultViewType>(
a, prop, dims...);
147 template <
typename ResultViewType,
typename InputViewType,
typename CtorProp,
149 typename std::enable_if<
151 ResultViewType>::type
153 const CtorProp& prop,
157 return view_factory::template create_view<ResultViewType>(
a,prop,dims...);
typename InputView::device_type input_device
std::enable_if< is_view< InputViewType >::value||is_dyn_rank_view< InputViewType >::value, typename Impl::ResultDynRankView< InputViewType >::type >::type createDynRankView(const InputViewType &a, const CtorProp &prop, const Dims...dims)
Wrapper to simplify use of Sacado ViewFactory.
typename std::conditional< std::is_same< input_layout, Kokkos::LayoutStride >::value, default_layout, input_layout >::type result_layout
Impl::ViewFactoryType< ViewPack...>::type value_type
typename input_device::execution_space::array_layout default_layout
Sacado::Promote< typename View::value_type, typename ViewFactoryType< ViewPack...>::type >::type type
std::enable_if< is_view< InputViewType >::value||is_dyn_rank_view< InputViewType >::value, ResultViewType >::type createDynRankViewWithType(const InputViewType &a, const CtorProp &prop, const Dims...dims)
Wrapper to simplify use of Sacado ViewFactory.
Kokkos::DynRankView< input_value, result_layout, input_device > type
typename InputView::array_layout input_layout
std::enable_if< is_view< InputViewType >::value||is_dyn_rank_view< InputViewType >::value, ResultViewType >::type createViewWithType(const InputViewType &a, const CtorProp &prop, const Dims...dims)
Wrapper to simplify use of Sacado ViewFactory.
static ResultView create_view(const ViewPack &...views, const CtorProp &prop, const Dims...dims)
typename InputView::non_const_value_type input_value
Base template specification for IsScalarType.