本文整理汇总了C++中tpetra::MultiVector::getData方法的典型用法代码示例。如果您正苦于以下问题:C++ MultiVector::getData方法的具体用法?C++ MultiVector::getData怎么用?C++ MultiVector::getData使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类tpetra::MultiVector
的用法示例。
在下文中一共展示了MultiVector::getData方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: apply
void
apply(
const Tpetra::MultiVector<double,int,int> & X,
Tpetra::MultiVector<double,int,int> & Y,
Teuchos::ETransp mode = Teuchos::NO_TRANS,
double alpha = Teuchos::ScalarTraits<double>::one(),
double beta = Teuchos::ScalarTraits<double>::zero()
) const
{
for (size_t k = 0; k < Y.getNumVectors(); k++) {
const auto x_data = X.getData(k);
const auto x0_data = x0_.getData();
auto y_data = Y.getDataNonConst(k);
for (size_t i = 0; i < y_data.size(); i++) {
y_data[i] = 2 * x0_data[i] * x_data[i];
}
}
return;
}
示例2: findUniqueGids
size_t findUniqueGids(
Tpetra::MultiVector<gno_t, lno_t, gno_t> &keys,
Tpetra::Vector<gno_t, lno_t, gno_t> &gids
)
{
// Input: Tpetra MultiVector of keys; key length = numVectors()
// May contain duplicate keys within a processor.
// May contain duplicate keys across processors.
// Input: Empty Tpetra Vector with same map for holding the results
// Output: Filled gids vector, containing unique global numbers for
// each unique key. Global numbers are in range [0,#UniqueKeys).
size_t num_keys = keys.getLocalLength();
size_t num_entries = keys.getNumVectors();
#ifdef HAVE_ZOLTAN2_MPI
MPI_Comm mpicomm = Teuchos::getRawMpiComm(*(keys.getMap()->getComm()));
#else
// Zoltan's siMPI will be used here
{
int flag;
MPI_Initialized(&flag);
if (!flag) {
int narg = 0;
char **argv = NULL;
MPI_Init(&narg, &argv);
}
}
MPI_Comm mpicomm = MPI_COMM_WORLD; // Will get MPI_COMM_WORLD from siMPI
#endif
int num_gid = sizeof(gno_t)/sizeof(ZOLTAN_ID_TYPE) * num_entries;
int num_user = sizeof(gno_t);
// Buffer the keys for Zoltan_DD
Teuchos::ArrayRCP<const gno_t> *tmpKeyVecs =
new Teuchos::ArrayRCP<const gno_t>[num_entries];
for (size_t v = 0; v < num_entries; v++) tmpKeyVecs[v] = keys.getData(v);
ZOLTAN_ID_PTR ddkeys = new ZOLTAN_ID_TYPE[num_gid * num_keys];
size_t idx = 0;
for (size_t i = 0; i < num_keys; i++) {
for (size_t v = 0; v < num_entries; v++) {
ZOLTAN_ID_PTR ddkey = &(ddkeys[idx]);
TPL_Traits<ZOLTAN_ID_PTR,gno_t>::ASSIGN(ddkey, tmpKeyVecs[v][i]);
idx += TPL_Traits<ZOLTAN_ID_PTR,gno_t>::NUM_ID;
}
}
delete [] tmpKeyVecs;
// Allocate memory for the result
char *ddnewgids = new char[num_user * num_keys];
// Compute the new GIDs
size_t nUnique = findUniqueGidsCommon<gno_t>(num_keys, num_gid,
ddkeys, ddnewgids, mpicomm);
// Copy the result into the output vector
gno_t *result = (gno_t *)ddnewgids;
for (size_t i = 0; i < num_keys; i++)
gids.replaceLocalValue(i, result[i]);
// Clean up
delete [] ddkeys;
delete [] ddnewgids;
return nUnique;
}