50 #ifndef _ZOLTAN2_IDENTIFIERMODEL_HPP_
51 #define _ZOLTAN2_IDENTIFIERMODEL_HPP_
69 template <
typename Adapter>
74 #ifndef DOXYGEN_SHOULD_SKIP_THIS
75 typedef typename Adapter::scalar_t scalar_t;
76 typedef typename Adapter::gno_t gno_t;
77 typedef typename Adapter::lno_t lno_t;
89 const RCP<const Environment> &env,
90 const RCP<
const Comm<int> > &comm,
modelFlag_t &modelFlags);
99 return numGlobalIdentifiers_;
111 ArrayView<input_t> &wgts)
const
113 Ids = ArrayView<const gno_t>();
114 wgts = weights_.view(0, nUserWeights_);
117 Ids = ArrayView<const gno_t>(
118 reinterpret_cast<const gno_t*>(gids_.getRawPtr()), n);
132 gno_t numGlobalIdentifiers_;
133 const RCP<const Environment> env_;
134 const RCP<const Comm<int> > comm_;
135 ArrayRCP<const gno_t> gids_;
137 ArrayRCP<input_t> weights_;
141 template <
typename Adapter>
143 const RCP<const Adapter> &ia,
144 const RCP<const Environment> &env,
145 const RCP<
const Comm<int> > &comm,
147 numGlobalIdentifiers_(), env_(env), comm_(comm),
148 gids_(), nUserWeights_(0), weights_()
151 size_t nLocalIds = ia->getLocalNumIDs();
152 gno_t lsum = nLocalIds;
153 reduceAll<int, gno_t>(*comm_, Teuchos::REDUCE_SUM, 1, &lsum,
154 &numGlobalIdentifiers_);
157 int tmp = ia->getNumWeightsPerID();
159 Teuchos::reduceAll<int, int>(*comm, Teuchos::REDUCE_MAX, 1,
160 &tmp, &nUserWeights_);
165 Array<const scalar_t *> wgts(nUserWeights_, (
const scalar_t *)NULL);
166 Array<int> wgtStrides(nUserWeights_, 0);
168 if (nUserWeights_ > 0){
169 input_t *w =
new input_t [nUserWeights_];
170 weights_ = arcp<input_t>(w, 0, nUserWeights_);
173 const gno_t *gids=NULL;
177 ia->getIDsView(gids);
178 for (
int idx=0; idx < nUserWeights_; idx++)
179 ia->getWeightsView(wgts[idx], wgtStrides[idx], idx);
184 gids_ = arcp(gids, 0, nLocalIds,
false);
186 if (nUserWeights_ > 0){
187 for (
int idx=0; idx < nUserWeights_; idx++){
188 ArrayRCP<const scalar_t> wgtArray(wgts[idx], 0,
189 nLocalIds*wgtStrides[idx],
false);
190 weights_[idx] = input_t(wgtArray, wgtStrides[idx]);
195 env_->memory(
"After construction of identifier model");