10 #ifndef _ZOLTAN2_STRIDEDDATA_HPP_
11 #define _ZOLTAN2_STRIDEDDATA_HPP_
40 template<
typename lno_t,
typename scalar_t>
43 ArrayRCP<const scalar_t> vec_;
55 vec_(x), stride_(stride)
87 template <
typename T>
void getInputArray(ArrayRCP<const T> &array)
const;
110 if (len != 0) vec = vec_.getRawPtr();
132 template<
typename scalar_t,
typename T>
134 ArrayRCP<const T> &target,
135 const ArrayRCP<const scalar_t> &src)
139 size_t n = src.size();
143 std::cerr <<
"Error: " << __FILE__ <<
", " << __LINE__<< std::endl;
144 std::cerr << n <<
" objects" << std::endl;
145 throw std::bad_alloc();
148 for (
size_t i=0; i < n; i++){
149 tmp[i] =
static_cast<T
>(src[i]);
151 target = arcp(tmp, 0, n);
155 template<
typename scalar_t>
157 ArrayRCP<const scalar_t> &target,
158 const ArrayRCP<const scalar_t> &src)
164 template<
typename lno_t,
typename scalar_t>
167 ArrayRCP<const T> &array)
const
169 if (vec_.size() < 1){
170 array = ArrayRCP<const T>();
172 else if (stride_ > 1) {
174 size_t n = vec_.size() / stride_;
178 std::cerr <<
"Error: " << __FILE__ <<
", " << __LINE__<< std::endl;
179 std::cerr << n <<
" objects" << std::endl;
180 throw std::bad_alloc();
183 for (
size_t i=0,j=0; i < n; i++,j+=stride_){
184 tmp[i] =
static_cast<T
>(vec_[j]);
186 array = arcp(tmp, 0, n);
189 Zoltan2::getInputArrayHelper<scalar_t, T>(array, vec_);
scalar_t operator[](lno_t idx) const
Access an element of the input array.
lno_t size() const
Return the length of the strided array.
StridedData()
Default constructor. A zero-length strided array.
void getInputArray(ArrayRCP< const T > &array) const
Create a contiguous array of the required type, perhaps for a TPL.
The StridedData class manages lists of weights or coordinates.
map_t::local_ordinal_type lno_t
void getStridedList(ArrayRCP< const scalar_t > &vec, int &stride) const
Get a reference counted pointer to the input.
static void getInputArrayHelper(ArrayRCP< const T > &target, const ArrayRCP< const scalar_t > &src)
Gathering definitions used in software development.
Defines the Environment class.
StridedData & operator=(const StridedData &sInput)
Assignment operator.
void getStridedList(size_t &len, const scalar_t *&vec, int &stride) const
Get the raw input information.
StridedData(ArrayRCP< const scalar_t > x, int stride)
Constructor.