当前位置: 首页>>代码示例>>C++>>正文


C++ Matrix::GetFixedBlockSize方法代码示例

本文整理汇总了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()
开发者ID:jgoldfar,项目名称:trilinos,代码行数:13,代码来源:MueLu_ZoltanInterface_def.hpp

示例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()
开发者ID:,项目名称:,代码行数:44,代码来源:

示例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);
      }
    }

  }
开发者ID:jgoldfar,项目名称:trilinos,代码行数:39,代码来源:MueLu_ZoltanInterface_def.hpp


注:本文中的Matrix::GetFixedBlockSize方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。