45 #ifndef _ZOLTAN2_STRIDEDDATA_HPP_
46 #define _ZOLTAN2_STRIDEDDATA_HPP_
75 template<
typename lno_t,
typename scalar_t>
78 ArrayRCP<const scalar_t> vec_;
90 vec_(x), stride_(stride)
103 lno_t
size()
const {
return vec_.size(); }
111 scalar_t
operator[](lno_t idx)
const {
return vec_[idx*stride_]; }
122 template <
typename T>
void getInputArray(ArrayRCP<const T> &array)
const;
145 if (len != 0) vec = vec_.getRawPtr();
167 template<
typename scalar_t,
typename T>
169 ArrayRCP<const T> &target,
170 const ArrayRCP<const scalar_t> &src)
174 size_t n = src.size();
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; i < n; i++){
184 tmp[i] =
static_cast<T
>(src[i]);
186 target = arcp(tmp, 0, n);
190 template<
typename scalar_t>
192 ArrayRCP<const scalar_t> &target,
193 const ArrayRCP<const scalar_t> &src)
199 template<
typename lno_t,
typename scalar_t>
202 ArrayRCP<const T> &array)
const
204 if (vec_.size() < 1){
205 array = ArrayRCP<const T>();
207 else if (stride_ > 1) {
209 size_t n = vec_.size() / stride_;
213 std::cerr <<
"Error: " << __FILE__ <<
", " << __LINE__<< std::endl;
214 std::cerr << n <<
" objects" << std::endl;
215 throw std::bad_alloc();
218 for (
size_t i=0,j=0; i < n; i++,j+=stride_){
219 tmp[i] =
static_cast<T
>(vec_[j]);
221 array = arcp(tmp, 0, n);
224 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.
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.