本文整理汇总了C++中map_type::getIndexBase方法的典型用法代码示例。如果您正苦于以下问题:C++ map_type::getIndexBase方法的具体用法?C++ map_type::getIndexBase怎么用?C++ map_type::getIndexBase使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类map_type
的用法示例。
在下文中一共展示了map_type::getIndexBase方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: newColMap
//.........这里部分代码省略.........
// orignal count, fill in any remaining GID spots with an
// obviously invalid value. We don't want to stop yet, because
// other processes might not have noticed this error; Map
// construction is a collective, so we can't stop now.
if (ownedPos != numOwnedGids) {
lclErr = true;
err << prefix << "On Process " << comm->getRank () << ", ownedPos = "
<< ownedPos << " != numOwnedGids = " << numOwnedGids << endl;
for (LO colMapLid = ownedPos; colMapLid < numOwnedGids; ++colMapLid) {
ownedGids[colMapLid] = Teuchos::OrdinalTraits<GO>::invalid ();
}
}
if (remotePos != numRemoteGids) {
lclErr = true;
err << prefix << "On Process " << comm->getRank () << ", remotePos = "
<< remotePos << " != numRemoteGids = " << numRemoteGids << endl;
for (LO colMapLid = remotePos; colMapLid < numRemoteGids; ++colMapLid) {
remoteGids[colMapLid] = Teuchos::OrdinalTraits<GO>::invalid ();
}
}
// Figure out what processes own what GIDs in the domain Map.
// Initialize the output array of remote PIDs with the "invalid
// process rank" -1, to help us test whether getRemoteIndexList
// did its job.
Array<int> remotePids (numRemoteGids, -1);
Array<LO> remoteLids;
if (makeImport) {
remoteLids.resize (numRemoteGids);
std::fill (remoteLids.begin (), remoteLids.end (),
Teuchos::OrdinalTraits<LO>::invalid ());
}
LookupStatus lookupStatus;
if (makeImport) {
lookupStatus = domMap.getRemoteIndexList (remoteGids, remotePids (),
remoteLids ());
} else {
lookupStatus = domMap.getRemoteIndexList (remoteGids, remotePids ());
}
// If any process returns IDNotPresent, then at least one of the
// remote indices was not present in the domain Map. This means
// that the Import object cannot be constructed, because of
// incongruity between the column Map and domain Map. This means
// that either the column Map or domain Map, or both, is
// incorrect.
const bool getRemoteIndexListFailed = (lookupStatus == IDNotPresent);
if (getRemoteIndexListFailed) {
lclErr = true;
err << prefix << "On Process " << comm->getRank () << ", some indices "
"in the input colMap (the original column Map) are not in domMap (the "
"domain Map). Either these indices or the domain Map is invalid. "
"Likely cause: For a nonsquare matrix, you must give the domain and "
"range Maps as input to fillComplete." << endl;
}
// Check that getRemoteIndexList actually worked, by making sure
// that none of the remote PIDs are -1.
for (LO k = 0; k < numRemoteGids; ++k) {
bool foundInvalidPid = false;
if (remotePids[k] == -1) {
foundInvalidPid = true;
break;
}
if (foundInvalidPid) {
lclErr = true;
err << prefix << "On Process " << comm->getRank () << ", "
"getRemoteIndexList returned -1 for the process ranks of "
"one or more GIDs on this process." << endl;
}
}
// Sort incoming remote column Map indices so that all columns
// coming from a given remote process are contiguous. This means
// the Import's Distributor doesn't need to reorder data.
if (makeImport) {
sort2 (remotePids.begin (), remotePids.end (), remoteGids.begin ());
}
else {
sort3 (remotePids.begin (), remotePids.end (),
remoteGids.begin (),
remoteLids.begin ());
}
// Make the new column Map.
MapType newColMap (colMap.getGlobalNumElements (), allGids (),
colMap.getIndexBase (), comm, colMap.getNode ());
// Optionally, make the new Import object.
RCP<import_type> imp;
if (makeImport) {
imp = rcp (new import_type (rcp (new map_type (domMap)),
rcp (new map_type (newColMap))));
// FIXME (mfh 06 Jul 2014) This constructor throws a runtime
// error, so I'm not using it for now.
//
// imp = rcp (new import_type (domMap, newColMap, remoteGids,
// remotePids (), remoteLids (),
// Teuchos::null, Teuchos::null));
}
return std::make_pair (newColMap, imp);
}