本文整理汇总了C++中Matrix::GetFixedBlockSize方法的典型用法代码示例。如果您正苦于以下问题:C++ Matrix::GetFixedBlockSize方法的具体用法?C++ Matrix::GetFixedBlockSize怎么用?C++ Matrix::GetFixedBlockSize使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Matrix
的用法示例。
在下文中一共展示了Matrix::GetFixedBlockSize方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1:
int ZoltanInterface<LocalOrdinal, GlobalOrdinal, Node, LocalMatOps>::GetLocalNumberOfRows(void *data, int *ierr) {
if (data == NULL) {
*ierr = ZOLTAN_FATAL;
return -1;
}
Matrix *A = (Matrix*) data;
*ierr = ZOLTAN_OK;
LO blockSize = A->GetFixedBlockSize();
TEUCHOS_TEST_FOR_EXCEPTION(blockSize == 0, Exceptions::RuntimeError, "MueLu::Zoltan : Matrix has block size 0.");
return A->getRowMap()->getNodeNumElements() / blockSize;
} //GetLocalNumberOfRows()
示例2: RuntimeError
void ZoltanInterface<LocalOrdinal, GlobalOrdinal, Node, LocalMatOps>::
GetLocalNumberOfNonzeros(void *data, int NumGidEntries, int NumLidEntries, ZOLTAN_ID_PTR gids,
ZOLTAN_ID_PTR lids, int wgtDim, float *weights, int *ierr)
{
if (data == NULL || NumGidEntries < 1) {
*ierr = ZOLTAN_FATAL;
return;
} else {
*ierr = ZOLTAN_OK;
}
Matrix *A = (Matrix*) data;
RCP<const Map> map = A->getRowMap();
LO blockSize = A->GetFixedBlockSize();
if (blockSize == 0)
throw Exceptions::RuntimeError("MueLu::Zoltan : Matrix has block size 0.");
Teuchos::ArrayView<const LO> cols;
Teuchos::ArrayView<const SC> vals;
if (blockSize == 1) {
for (size_t i = 0; i < map->getNodeNumElements(); ++i) {
gids[i] = (ZOLTAN_ID_TYPE) map->getGlobalElement(i);
A->getLocalRowView(i, cols, vals);
weights[i] = cols.size();
}
} else {
LO numBlocks = A->getRowMap()->getNodeNumElements() / blockSize;
for (LO i = 0; i < numBlocks; ++i) {
// Assign zoltan GID to the first row GID in the block
// NOTE: Zoltan GIDs are different from GIDs in the Coordinates vector
gids[i] = (ZOLTAN_ID_TYPE) map->getGlobalElement(i*blockSize);
LO nnz = 0;
for (LO j = i*blockSize; j < (i+1)*blockSize; ++j) {
A->getLocalRowView(j, cols, vals);
nnz += vals.size();
}
weights[i] = nnz;
} //for (LocalOrdinal i=0; i<numBlocks; ++i)
}
} //GetLocalNumberOfNonzeros()
示例3: GetLocalNumberOfNonzeros
void ZoltanInterface<LocalOrdinal, GlobalOrdinal, Node, LocalMatOps>::
GetLocalNumberOfNonzeros(void *data, int NumGidEntries, int NumLidEntries, ZOLTAN_ID_PTR gids,
ZOLTAN_ID_PTR lids, int wgtDim, float *weights, int *ierr) {
if (data == NULL || NumGidEntries < 1) {
*ierr = ZOLTAN_FATAL;
return;
} else {
*ierr = ZOLTAN_OK;
}
Matrix *A = (Matrix*) data;
RCP<const Map> map = A->getRowMap();
LO blockSize = A->GetFixedBlockSize();
TEUCHOS_TEST_FOR_EXCEPTION(blockSize == 0, Exceptions::RuntimeError, "MueLu::Zoltan : Matrix has block size 0.");
size_t numElements = map->getNodeNumElements();
ArrayView<const GO> mapGIDs = map->getNodeElementList();
if (blockSize == 1) {
for (size_t i = 0; i < numElements; i++) {
gids[i] = as<ZOLTAN_ID_TYPE>(mapGIDs[i]);
weights[i] = A->getNumEntriesInLocalRow(i);
}
} else {
LO numBlockElements = numElements / blockSize;
for (LO i = 0; i < numBlockElements; i++) {
// Assign zoltan GID to the first row GID in the block
// NOTE: Zoltan GIDs are different from GIDs in the Coordinates vector
gids[i] = as<ZOLTAN_ID_TYPE>(mapGIDs[i*blockSize]);
weights[i] = 0.0;
for (LO j = 0; j < blockSize; j++)
weights[i] += A->getNumEntriesInLocalRow(i*blockSize+j);
}
}
}