51 #include <Teuchos_GlobalMPISession.hpp> 52 #include <Teuchos_DefaultComm.hpp> 53 #include <Teuchos_RCP.hpp> 54 #include <Teuchos_CommHelpers.hpp> 58 using Teuchos::DefaultComm;
68 bool strideOne =
false;
70 if (valueStrides == NULL) strideOne =
true;
83 for (
int i=0; !
fail && i < len; i++)
87 for (
int v=0; !
fail && v < mvdim; v++){
89 int correctStride = (strideOne ? 1 : valueStrides[v]);
94 if (!
fail && stride != correctStride)
97 for (
int i=0; !
fail && i < len; i++){
104 for (
int w=0; !
fail && w < wdim; w++){
110 if (!
fail && stride != weightStrides[w])
113 for (
int i=0; !
fail && i < len; i++){
114 if (wgts[stride*i] !=
weights[w][weightStrides[w]*i])
123 int main(
int argc,
char *argv[])
125 Teuchos::GlobalMPISession session(&argc, &argv);
126 RCP<const Comm<int> > comm = DefaultComm<int>::getComm();
127 int rank = comm->getRank();
128 int nprocs = comm->getSize();
136 zgno_t base = rank * numLocalIds;
140 int *weightStrides =
new int [wdim];
146 int *valueStrides =
new int [mvdim];
149 for (
zlno_t i=0; i < numLocalIds; i++){
152 for (
int w=0; w < wdim; w++)
153 weights[w*numLocalIds + i] = w + 1 + nprocs - rank;
155 v_values[i] = numLocalIds-i;
157 for (
int v=0; v < mvdim; v++)
158 mv_values[i*mvdim + v] = (v+1) * (nprocs-rank) / (i+1);
161 for (
int w=0; w < wdim; w++){
162 weightStrides[w] = 1;
163 weightPtrs[w] =
weights + numLocalIds*w;
166 for (
int v=0; v < mvdim; v++){
167 valueStrides[v] = mvdim;
168 valuePtrs[v] = mv_values + v;
176 std::vector<const zscalar_t *> weightValues;
177 std::vector<int> strides;
183 catch (std::exception &e){
190 myIds, 1, valuePtrs, NULL, 0, NULL, NULL);
200 std::vector<const zscalar_t *> weightValues;
201 std::vector<int> strides;
203 weightValues.push_back(weightPtrs[0]);
204 weightValues.push_back(weightPtrs[1]);
205 strides.push_back(1);
206 strides.push_back(1);
210 v_values, 1,
true, weightPtrs[0], 1);
212 catch (std::exception &e){
219 myIds, 1, valuePtrs, NULL, 1, weightPtrs, weightStrides);
229 std::vector<const zscalar_t *> weightValues, values;
230 std::vector<int> wstrides, vstrides;
232 for (
int dim=0; dim < mvdim; dim++){
233 values.push_back(valuePtrs[dim]);
234 vstrides.push_back(mvdim);
240 numLocalIds, myIds, values, vstrides, weightValues, wstrides);
242 catch (std::exception &e){
249 myIds, mvdim, valuePtrs, valueStrides, 0, NULL, NULL);
259 std::vector<const zscalar_t *> weightValues, values;
260 std::vector<int> wstrides, vstrides;
262 for (
int dim=0; dim < wdim; dim++){
263 weightValues.push_back(weightPtrs[dim]);
264 wstrides.push_back(1);
267 for (
int dim=0; dim < mvdim; dim++){
268 values.push_back(valuePtrs[dim]);
269 vstrides.push_back(mvdim);
274 numLocalIds, myIds, values, vstrides, weightValues, wstrides);
277 catch (std::exception &e){
284 myIds, mvdim, valuePtrs, valueStrides,
285 wdim, weightPtrs, weightStrides);
293 std::cout <<
"PASS" << std::endl;
297 delete [] weightStrides;
298 delete [] weightPtrs;
301 delete [] valueStrides;
void getIDsView(const gno_t *&ids) const
Provide a pointer to this process' identifiers.
A simple class that can be the User template argument for an InputAdapter.
common code used by tests
list idList
Match up parameters to validators.
void getEntriesView(const scalar_t *&entries, int &stride, int idx=0) const
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
int getNumEntriesPerID() const
Return the number of vectors (typically one).
static const std::string fail
#define TEST_FAIL_AND_RETURN_VALUE(comm, ok, s, rc)
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.
Defines the BasicVectorAdapter class.