50 #ifndef _ZOLTAN2_BASICVECTORADAPTER_HPP_ 51 #define _ZOLTAN2_BASICVECTORADAPTER_HPP_ 80 template <
typename User>
85 #ifndef DOXYGEN_SHOULD_SKIP_THIS 113 const scalar_t *entries,
int entryStride=1,
115 const scalar_t *wgts=NULL,
int wgtStride=1):
116 numIds_(numIds), idList_(ids),
117 numEntriesPerID_(1), entries_(),
118 numWeights_(usewgts==true), weights_()
120 std::vector<const scalar_t *> values;
121 std::vector<int> strides;
122 std::vector<const scalar_t *> weightValues;
123 std::vector<int> weightStrides;
125 values.push_back(entries);
126 strides.push_back(entryStride);
128 weightValues.push_back(wgts);
129 weightStrides.push_back(wgtStride);
132 createBasicVector(values, strides, weightValues, weightStrides);
161 std::vector<const scalar_t *> &entries, std::vector<int> &entryStride,
162 std::vector<const scalar_t *> &
weights, std::vector<int> &weightStrides):
163 numIds_(numIds), idList_(ids),
164 numEntriesPerID_(entries.size()), entries_(),
165 numWeights_(weights.size()), weights_()
167 createBasicVector(entries, entryStride, weights, weightStrides);
197 const scalar_t *x,
const scalar_t *y,
199 int xStride=1,
int yStride=1,
int zStride=1,
200 bool usewgts=
false,
const scalar_t *wgts=NULL,
202 numIds_(numIds), idList_(ids), numEntriesPerID_(0), entries_(),
203 numWeights_(usewgts==true), weights_()
205 std::vector<const scalar_t *> values, weightValues;
206 std::vector<int> strides, weightStrides;
210 strides.push_back(xStride);
214 strides.push_back(yStride);
218 strides.push_back(zStride);
224 weightValues.push_back(wgts);
225 weightStrides.push_back(wgtStride);
227 createBasicVector(values, strides, weightValues, weightStrides);
245 if (idx < 0 || idx >= numWeights_) {
246 std::ostringstream emsg;
247 emsg << __FILE__ <<
":" << __LINE__
248 <<
" Invalid vector index " << idx << std::endl;
249 throw std::runtime_error(emsg.str());
252 weights_[idx].getStridedList(length, weights, stride);
263 if (idx < 0 || idx >= numEntriesPerID_) {
264 std::ostringstream emsg;
265 emsg << __FILE__ <<
":" << __LINE__
266 <<
" Invalid vector index " << idx << std::endl;
267 throw std::runtime_error(emsg.str());
270 entries_[idx].getStridedList(length, entries, stride);
276 const gno_t *idList_;
278 int numEntriesPerID_;
279 ArrayRCP<StridedData<lno_t, scalar_t> > entries_ ;
282 ArrayRCP<StridedData<lno_t, scalar_t> > weights_;
284 void createBasicVector(
285 std::vector<const scalar_t *> &entries, std::vector<int> &entryStride,
286 std::vector<const scalar_t *> &
weights, std::vector<int> &weightStrides)
292 entries_ = arcp(
new input_t[numEntriesPerID_], 0, numEntriesPerID_,
true);
293 for (
int v=0; v < numEntriesPerID_; v++) {
294 if (entryStride.size()) stride = entryStride[v];
295 ArrayRCP<const scalar_t> eltV(entries[v], 0, stride*numIds_,
false);
296 entries_[v] = input_t(eltV, stride);
302 weights_ = arcp(
new input_t [numWeights_], 0, numWeights_,
true);
303 for (
int w=0; w < numWeights_; w++){
304 if (weightStrides.size()) stride = weightStrides[w];
305 ArrayRCP<const scalar_t> wgtV(weights[w], 0, stride*numIds_,
false);
306 weights_[w] = input_t(wgtV, stride);
void getIDsView(const gno_t *&ids) const
Provide a pointer to this process' identifiers.
InputTraits< User >::scalar_t scalar_t
BasicVectorAdapter(lno_t numIds, const gno_t *ids, const scalar_t *entries, int entryStride=1, bool usewgts=false, const scalar_t *wgts=NULL, int wgtStride=1)
Constructor for one vector with (optionally) one weight.
InputTraits< User >::gno_t gno_t
InputTraits< User >::lno_t lno_t
Defines the VectorAdapter interface.
void getEntriesView(const scalar_t *&entries, int &stride, int idx=0) const
BasicVectorAdapter(lno_t numIds, const gno_t *ids, std::vector< const scalar_t *> &entries, std::vector< int > &entryStride, std::vector< const scalar_t *> &weights, std::vector< int > &weightStrides)
Constructor for multivector (a set of vectors sharing the same global numbering and data distribution...
VectorAdapter defines the interface for vector input.
The StridedData class manages lists of weights or coordinates.
BasicVectorAdapter represents a vector (plus optional weights) supplied by the user as pointers to st...
void getWeightsView(const scalar_t *&weights, int &stride, int idx) const
InputTraits< User >::part_t part_t
int getNumEntriesPerID() const
Return the number of vectors (typically one).
int getNumWeightsPerID() const
Returns the number of weights per object. Number of weights per object should be zero or greater...
size_t getLocalNumIDs() const
Returns the number of objects on this process.
InputTraits< User >::offset_t offset_t
BasicVectorAdapter(lno_t numIds, const gno_t *ids, const scalar_t *x, const scalar_t *y, const scalar_t *z, int xStride=1, int yStride=1, int zStride=1, bool usewgts=false, const scalar_t *wgts=NULL, int wgtStride=1)
A simple constructor for coordinate-based problems with dimension 1, 2 or 3 and (optionally) one weig...
This file defines the StridedData class.