50 #ifndef _ZOLTAN2_BASICVECTORADAPTER_HPP_ 51 #define _ZOLTAN2_BASICVECTORADAPTER_HPP_ 80 template <
typename User>
85 #ifndef DOXYGEN_SHOULD_SKIP_THIS 112 const scalar_t *entries,
int entryStride=1,
114 const scalar_t *wgts=NULL,
int wgtStride=1):
115 numIds_(numIds), idList_(ids),
116 numEntriesPerID_(1), entries_(),
117 numWeights_(usewgts==true), weights_()
119 std::vector<const scalar_t *> values;
120 std::vector<int> strides;
121 std::vector<const scalar_t *> weightValues;
122 std::vector<int> weightStrides;
124 values.push_back(entries);
125 strides.push_back(entryStride);
127 weightValues.push_back(wgts);
128 weightStrides.push_back(wgtStride);
131 createBasicVector(values, strides, weightValues, weightStrides);
160 std::vector<const scalar_t *> &entries, std::vector<int> &entryStride,
161 std::vector<const scalar_t *> &
weights, std::vector<int> &weightStrides):
162 numIds_(numIds), idList_(ids),
163 numEntriesPerID_(entries.size()), entries_(),
164 numWeights_(weights.size()), weights_()
166 createBasicVector(entries, entryStride, weights, weightStrides);
196 const scalar_t *x,
const scalar_t *y,
198 int xStride=1,
int yStride=1,
int zStride=1,
199 bool usewgts=
false,
const scalar_t *wgts=NULL,
201 numIds_(numIds), idList_(ids), numEntriesPerID_(0), entries_(),
202 numWeights_(usewgts==true), weights_()
204 std::vector<const scalar_t *> values, weightValues;
205 std::vector<int> strides, weightStrides;
209 strides.push_back(xStride);
213 strides.push_back(yStride);
217 strides.push_back(zStride);
223 weightValues.push_back(wgts);
224 weightStrides.push_back(wgtStride);
226 createBasicVector(values, strides, weightValues, weightStrides);
244 if (idx < 0 || idx >= numWeights_) {
245 std::ostringstream emsg;
246 emsg << __FILE__ <<
":" << __LINE__
247 <<
" Invalid vector index " << idx << std::endl;
248 throw std::runtime_error(emsg.str());
251 weights_[idx].getStridedList(length, weights, stride);
262 if (idx < 0 || idx >= numEntriesPerID_) {
263 std::ostringstream emsg;
264 emsg << __FILE__ <<
":" << __LINE__
265 <<
" Invalid vector index " << idx << std::endl;
266 throw std::runtime_error(emsg.str());
269 entries_[idx].getStridedList(length, entries, stride);
275 const gno_t *idList_;
277 int numEntriesPerID_;
278 ArrayRCP<StridedData<lno_t, scalar_t> > entries_ ;
281 ArrayRCP<StridedData<lno_t, scalar_t> > weights_;
283 void createBasicVector(
284 std::vector<const scalar_t *> &entries, std::vector<int> &entryStride,
285 std::vector<const scalar_t *> &
weights, std::vector<int> &weightStrides)
291 entries_ = arcp(
new input_t[numEntriesPerID_], 0, numEntriesPerID_,
true);
292 for (
int v=0; v < numEntriesPerID_; v++) {
293 if (entryStride.size()) stride = entryStride[v];
294 ArrayRCP<const scalar_t> eltV(entries[v], 0, stride*numIds_,
false);
295 entries_[v] = input_t(eltV, stride);
301 weights_ = arcp(
new input_t [numWeights_], 0, numWeights_,
true);
302 for (
int w=0; w < numWeights_; w++){
303 if (weightStrides.size()) stride = weightStrides[w];
304 ArrayRCP<const scalar_t> wgtV(weights[w], 0, stride*numIds_,
false);
305 weights_[w] = input_t(wgtV, stride);
InputTraits< User >::scalar_t scalar_t
size_t getLocalNumIDs() const
Returns the number of objects on this process.
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.
int getNumEntriesPerID() const
Return the number of vectors (typically one).
void getWeightsView(const scalar_t *&weights, int &stride, int idx) const
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...
InputTraits< User >::part_t part_t
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...
void getIDsView(const gno_t *&ids) const
Provide a pointer to this process' identifiers.
int getNumWeightsPerID() const
Returns the number of weights per object. Number of weights per object should be zero or greater...
void getEntriesView(const scalar_t *&entries, int &stride, int idx=0) const
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.