30 #ifndef KOKKOS_VIEW_FACTORY_HPP
31 #define KOKKOS_VIEW_FACTORY_HPP
33 #include <type_traits>
45 template <
class ... ViewPack>
50 typedef typename View::value_type
type;
53 template <
class View,
class ... ViewPack>
56 typename View::value_type,
71 template <
class ... ViewPack>
76 template <
class ResultView,
class CtorProp,
class ... Dims>
80 const Dims ... dims) {
82 using nc_value_type =
typename ResultView::non_const_value_type;
84 constexpr
bool is_dyn_rank = is_dyn_rank_view<ResultView>::value;
87 constexpr
unsigned rank =
sizeof...(Dims);
90 static_assert( rank <= 7,
"Invalid rank...too many dimension arguments" );
93 typename ResultView::array_layout layout(dims...);
96 layout.dimension[rank] = dimension_scalar(views...);
101 if (!is_scalar && layout.dimension[rank] == 0)
102 layout.dimension[rank] = 1;
106 constexpr
unsigned r = is_scalar ? rank : rank + 1;
107 layout = Impl::reconstructLayout(layout, r);
110 return ResultView(prop, layout);
116 template <
typename ResultViewType,
typename InputViewType,
typename CtorProp,
118 typename std::enable_if<
119 is_view<InputViewType>::value || is_dyn_rank_view<InputViewType>::value,
120 ResultViewType>::type
122 const CtorProp& prop,
126 return view_factory::template create_view<ResultViewType>(
a,prop,dims...);
132 template <
typename InputView>
142 typename std::conditional<
143 std::is_same< input_layout, Kokkos::LayoutStride >::value,
147 Kokkos::DynRankView<input_value, result_layout, input_device>;
153 template <
typename InputViewType,
typename CtorProp,
typename ... Dims >
154 typename std::enable_if<
155 is_view<InputViewType>::value || is_dyn_rank_view<InputViewType>::value,
159 const CtorProp& prop,
163 return createDynRankViewWithType<ResultViewType>(
a, prop, dims...);
167 template <
typename ResultViewType,
typename InputViewType,
typename CtorProp,
169 typename std::enable_if<
170 is_view<InputViewType>::value || is_dyn_rank_view<InputViewType>::value,
171 ResultViewType>::type
173 const CtorProp& prop,
177 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.