/* * (C) Copyright 2013 ECMWF. * * This software is licensed under the terms of the Apache Licence Version 2.0 * which can be obtained at http://www.apache.org/licenses/LICENSE-2.0. * In applying this licence, ECMWF does not waive the privileges and immunities * granted to it by virtue of its status as an intergovernmental organisation * nor does it submit to any jurisdiction. */ #include #include "atlas/array/native/NativeIndexView.h" #include "atlas/array/helpers/ArrayAssigner.h" //------------------------------------------------------------------------------------------------------ namespace atlas { namespace array { #undef ENABLE_IF_NON_CONST #define ENABLE_IF_NON_CONST \ template ::value && EnableBool), int>::type*> //------------------------------------------------------------------------------------------------------ template IndexView::IndexView(Value* data, const idx_t shape[Rank]): data_(data) { static_assert(Rank == 1); strides_[0] = 1; shape_[0] = shape[0]; } template IndexView::IndexView(Value* data, const idx_t shape[Rank], const idx_t strides[Rank]): data_(const_cast(data)) { static_assert(Rank == 1); strides_[0] = strides[0]; shape_[0] = shape[0]; } template void IndexView::dump(std::ostream& os) const { os << "size: " << size() << " , values: "; os << "[ "; for (idx_t j = 0; j < size(); ++j) { os << (*this)(j) << " "; } os << "]" << std::endl; } template ENABLE_IF_NON_CONST void IndexView::assign(const std::initializer_list& list) { helpers::array_assigner::apply(*this, list); } //------------------------------------------------------------------------------------------------------ // Explicit template instatiation #define EXPLICIT_TEMPLATE_INSTANTIATION_TYPE_RANK(TYPE, RANK) \ template class IndexView; \ template class IndexView; \ template void IndexView::assign(std::initializer_list const&); #define EXPLICIT_TEMPLATE_INSTANTIATION(RANK) \ EXPLICIT_TEMPLATE_INSTANTIATION_TYPE_RANK(int, RANK) \ EXPLICIT_TEMPLATE_INSTANTIATION_TYPE_RANK(long, RANK) EXPLICIT_TEMPLATE_INSTANTIATION(1) // EXPLICIT_TEMPLATE_INSTANTIATION(2) #undef EXPLICIT_TEMPLATE_INSTANTIATION_TYPE_RANK #undef EXPLICIT_TEMPLATE_INSTANTIATION //------------------------------------------------------------------------------------------------------ } // namespace array } // namespace atlas