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,
65 template <
class View,
class ... ViewPack>
69 return dim0 >= dim1 ? dim0 : dim1 ;
77 template <
class ... ViewPack>
82 template <
class ResultView,
class CtorProp,
class ... Dims>
86 const Dims ... dims) {
88 using value_type =
typename ResultView::non_const_value_type;
90 constexpr
bool is_dyn_rank = is_dyn_rank_view<ResultView>::value;
93 constexpr
unsigned rank =
sizeof...(Dims);
96 static_assert( rank <= 7,
"Invalid rank...too many dimension arguments" );
99 typename ResultView::array_layout layout(dims...);
107 if (!is_scalar && layout.dimension[rank] == 0)
108 layout.dimension[rank] = 1;
112 constexpr
unsigned r = is_scalar ? rank : rank + 1;
113 layout = Experimental::Impl::reconstructLayout(layout, r);
116 return ResultView(prop, layout);
122 template <
typename ResultViewType,
typename InputViewType,
typename CtorProp,
124 typename std::enable_if<
125 is_view<InputViewType>::value || is_dyn_rank_view<InputViewType>::value,
126 ResultViewType>::type
128 const CtorProp& prop,
132 return view_factory::template create_view<ResultViewType>(
a,prop,dims...);
138 template <
typename InputView>
148 typename std::conditional<
149 std::is_same< input_layout, Kokkos::LayoutStride >::value,
153 Kokkos::DynRankView<input_value, result_layout, input_device>;
159 template <
typename InputViewType,
typename CtorProp,
typename ... Dims >
160 typename std::enable_if<
161 is_view<InputViewType>::value || is_dyn_rank_view<InputViewType>::value,
165 const CtorProp& prop,
169 return createDynRankViewWithType<ResultViewType>(
a, prop, dims...);
173 template <
typename ResultViewType,
typename InputViewType,
typename CtorProp,
175 typename std::enable_if<
176 is_view<InputViewType>::value || is_dyn_rank_view<InputViewType>::value,
177 ResultViewType>::type
179 const CtorProp& prop,
183 return view_factory::template create_view<ResultViewType>(
a,prop,dims...);
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.
typename InputView::device_type input_device
typename std::conditional< std::is_same< input_layout, Kokkos::LayoutStride >::value, default_layout, input_layout >::type result_layout
Impl::ViewFactoryType< ViewPack... >::type value_type
static ResultView create_view(const ViewPack &... views, const CtorProp &prop, const Dims ... dims)
typename input_device::execution_space::array_layout default_layout
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.
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.
Kokkos::DynRankView< input_value, result_layout, input_device > type
typename InputView::array_layout input_layout
typename InputView::non_const_value_type input_value
Base template specification for IsScalarType.
unsigned dimension_scalar(const View &v, const ViewPack &... views)