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


C++ ArrayRCP::size方法代码示例

本文整理汇总了C++中ArrayRCP::size方法的典型用法代码示例。如果您正苦于以下问题:C++ ArrayRCP::size方法的具体用法?C++ ArrayRCP::size怎么用?C++ ArrayRCP::size使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在ArrayRCP的用法示例。


在下文中一共展示了ArrayRCP::size方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: getNodeNumRows

  void EpetraCrsMatrixT<EpetraGlobalOrdinal>::setAllValues(const ArrayRCP<size_t>& rowptr, const ArrayRCP<LocalOrdinal>& colind, const ArrayRCP<Scalar>& values) {
    XPETRA_MONITOR("EpetraCrsMatrixT::setAllValues");

    // Check sizes
    TEUCHOS_TEST_FOR_EXCEPTION(Teuchos::as<size_t>(rowptr.size()) != getNodeNumRows()+1, Xpetra::Exceptions::RuntimeError,
                               "An exception is thrown to let you know that the size of your rowptr array is incorrect.");
    TEUCHOS_TEST_FOR_EXCEPTION(values.size() != colind.size(), Xpetra::Exceptions::RuntimeError,
                               "An exception is thrown to let you know that you mismatched your pointers.");

    // Check pointers
    if (values.size() > 0) {
      TEUCHOS_TEST_FOR_EXCEPTION(colind.getRawPtr() != mtx_->ExpertExtractIndices().Values(), Xpetra::Exceptions::RuntimeError,
                                 "An exception is thrown to let you know that you mismatched your pointers.");
      TEUCHOS_TEST_FOR_EXCEPTION(values.getRawPtr() != mtx_->ExpertExtractValues(), Xpetra::Exceptions::RuntimeError,
                                 "An exception is thrown to let you know that you mismatched your pointers.");
    }

    // We have to make a copy here, it is unavoidable
    // See comments in allocateAllValues
    const size_t N = getNodeNumRows();

    Epetra_IntSerialDenseVector& myRowptr = mtx_->ExpertExtractIndexOffset();
    myRowptr.Resize(N+1);
    for (size_t i = 0; i < N+1; i++)
      myRowptr[i] = Teuchos::as<int>(rowptr[i]);
  }
开发者ID:abhishek4747,项目名称:trilinos,代码行数:26,代码来源:Xpetra_EpetraCrsMatrix.cpp

示例2: getMaxWeightedEdgeCut

 /*! \brief Return the max cut for the requested weight.
  *  \param cut on return is the requested value.
  *  \param idx is the weight index reqested, ranging from zero
  *     to one less than the number of weights provided in the input.
  *  If there were no weights, this is the cut count.
  */
 void getMaxWeightedEdgeCut(scalar_t &cut, int idx=0) const{
   if (idx >= graphMetrics_.size())  // idx too high
     cut = graphMetrics_[graphMetrics_.size() - 1].getGlobalMax();
   else if (idx < 0)   //  idx too low
     cut = graphMetrics_[0].getGlobalMax();
   else                       // 
     cut = graphMetrics_[idx].getGlobalMax();
 }
开发者ID:agrippa,项目名称:Trilinos,代码行数:14,代码来源:Zoltan2_EvaluatePartition.hpp

示例3: getWeightCut

 /*! \brief Return the max cut for the requested weight.
  *  \param cut on return is the requested value.
  *  \param idx is the weight index reqested, ranging from zero
  *     to one less than the number of weights provided in the input.
  *  If there were no weights, this is the cut count.
  */
 void getWeightCut(scalar_t &cut, int idx=0) const{
   if (graphMetrics_.size() < idx)  // idx too high
     cut = graphMetrics_[graphMetrics_.size()-1].getGlobalMax();
   else if (idx < 0)   //  idx too low
     cut = graphMetrics_[0].getGlobalMax();
   else                       // idx weight
     cut = graphMetrics_[idx].getGlobalMax();
 }
开发者ID:petsc,项目名称:Trilinos,代码行数:14,代码来源:Zoltan2_EvaluatePartition.hpp

示例4: newSmootherList

  ArrayRCP<RCP<MueLu::SmootherPrototype<Scalar, LocalOrdinal, GlobalOrdinal, Node, LocalMatOps> > > MergedSmoother<Scalar, LocalOrdinal, GlobalOrdinal, Node, LocalMatOps>::SmootherListDeepCopy(const ArrayRCP<const RCP<SmootherPrototype> >& srcSmootherList) {
    ArrayRCP<RCP<SmootherPrototype> > newSmootherList(srcSmootherList.size());

    for (typename ArrayRCP<RCP<SmootherPrototype> >::size_type i = 0; i < srcSmootherList.size(); i++)
      newSmootherList[i] = srcSmootherList[i]->Copy();

    return newSmootherList;
  }
开发者ID:jgoldfar,项目名称:trilinos,代码行数:8,代码来源:MueLu_MergedSmoother_def.hpp

示例5: getWeightImbalance

 /*! \brief Return the imbalance for the requested weight.
  *  \param imbalance on return is the requested value.
  *  \param idx is the weight index requested, ranging from zero
  *     to one less than the number of weights provided in the input.
  *  If there were no weights, this is the object count imbalance.
  */
 void getWeightImbalance(scalar_t &imbalance, int idx=0) const{
   imbalance = 0;
   if (metrics_.size() > 2)  // idx of multiple weights
     imbalance = metrics_[idx+2].getMaxImbalance();
   else if (metrics_.size() == 2)   //  only one weight
     imbalance = metrics_[1].getMaxImbalance();
   else                       // no weights, return object count imbalance
     imbalance = metrics_[0].getMaxImbalance();
 }  
开发者ID:petsc,项目名称:Trilinos,代码行数:15,代码来源:Zoltan2_EvaluatePartition.hpp

示例6: setMap_RankForPart

  void setMap_RankForPart(ArrayRCP<part_t> &parts, ArrayRCP<int> &ranks) {
    nParts = parts.size();
    int maxRank = 0;

    // Need data stored in unordered_map; create it
    rankForPart = rcp(new rankmap_t(parts.size()));

    for (size_t i = 0; i < nParts; i++) {
      (*rankForPart)[parts[i]] = ranks[i];
      if (parts[i] > maxPart) maxPart = parts[i];
      if (ranks[i] > maxRank) maxRank = ranks[i];
    }
    nRanks = maxRank+1;
  }
开发者ID:trilinos,项目名称:Trilinos,代码行数:14,代码来源:Zoltan2_MappingSolution.hpp

示例7:

 void UncoupledAggregationAlgorithm<LocalOrdinal, GlobalOrdinal, Node, LocalMatOps>::RandomReorder(ArrayRCP<LO> list) const {
   //TODO: replace int
   int n = list.size();
   for(int i = 0; i < n-1; i++) {
     std::swap(list[i], list[RandomOrdinal(i,n-1)]);
   }
 }
开发者ID:jgoldfar,项目名称:trilinos,代码行数:7,代码来源:MueLu_UncoupledAggregationAlgorithm_def.hpp

示例8: analyzePartitionMetrics

  static bool analyzePartitionMetrics(  const ParameterList &metricsPlist,
                                        const RCP<const Zoltan2::EvaluatePartition <basic_id_t> > &metricObject,
                                        const RCP<const Comm<int>> &comm,
                                        std::ostringstream &msg_stream) {

      ArrayRCP<const metric_t> metrics = metricObject->getMetrics();
      bool all_tests_pass = true;
      zscalar_t metric_value = 0.0;
      for (int i = 0; i < metrics.size(); i++) {
        // print their names...
        if (metricsPlist.isSublist(metrics[i].getName())) {
          auto metric_plist = metricsPlist.sublist(metrics[i].getName());
          // loop on tests
          auto p= metric_plist.begin(); // iterator
          while (p != metric_plist.end()) {
            auto test_name = metric_plist.name(p);
            if( metrics[i].hasMetricValue(test_name)) {
              if(!MetricAnalyzer::MetricBoundsTest( metrics[i].getMetricValue(test_name),
                                                    test_name,
                                                    metric_plist.sublist(test_name),
                                                    comm,
                                                    msg_stream)) {
                all_tests_pass = false;
              }
            } else msg_stream << "UNKNOWN TEST: " + test_name << std::endl;
            ++p;
          }
        } else {
          msg_stream << "UNKNOWN METRIC: " + metrics[i].getName() << std::endl;
        }
      }
      return all_tests_pass;
  }
开发者ID:agrippa,项目名称:Trilinos,代码行数:33,代码来源:Zoltan2_MetricAnalyzer.hpp

示例9: mueluFactory

TEUCHOS_UNIT_TEST_TEMPLATE_4_DECL(ParameterListInterpreter, SetParameterList, Scalar, LocalOrdinal, GlobalOrdinal, Node)
{
#   include <MueLu_UseShortNames.hpp>
    MUELU_TESTING_SET_OSTREAM;
    MUELU_TESTING_LIMIT_SCOPE(Scalar,GlobalOrdinal,Node);
#if defined(HAVE_MUELU_TPETRA) && defined(HAVE_MUELU_EPETRA) && defined(HAVE_MUELU_IFPACK) && defined(HAVE_MUELU_IFPACK2) && defined(HAVE_MUELU_AMESOS) && defined(HAVE_MUELU_AMESOS2)

    RCP<Matrix> A = TestHelpers::TestFactory<SC, LO, GO, NO>::Build1DPoisson(99);
    RCP<const Teuchos::Comm<int> > comm = TestHelpers::Parameters::getDefaultComm();

    ArrayRCP<std::string> fileList = TestHelpers::GetFileList(std::string("ParameterList/ParameterListInterpreter/"), std::string(".xml"));

    for(int i=0; i< fileList.size(); i++) {
        out << "Processing file: " << fileList[i] << std::endl;
        ParameterListInterpreter mueluFactory("ParameterList/ParameterListInterpreter/" + fileList[i],*comm);

        RCP<Hierarchy> H = mueluFactory.CreateHierarchy();
        H->GetLevel(0)->Set("A", A);

        mueluFactory.SetupHierarchy(*H);

        //TODO: check no unused parameters
        //TODO: check results of Iterate()
    }

#   else
    out << "Skipping test because some required packages are not enabled (Tpetra, Epetra, EpetraExt, Ifpack, Ifpack2, Amesos, Amesos2)." << std::endl;
#   endif
}
开发者ID:uppatispr,项目名称:trilinos-official,代码行数:29,代码来源:ParameterListInterpreter.cpp

示例10: m

  void BraessSarazinSmoother<Scalar, LocalOrdinal, GlobalOrdinal, Node>::Setup(Level& currentLevel) {
    FactoryMonitor m(*this, "Setup Smoother", currentLevel);

    if (SmootherPrototype::IsSetup() == true)
      this->GetOStream(Warnings0) << "MueLu::BreaessSarazinSmoother::Setup(): Setup() has already been called";

    // Extract blocked operator A from current level
    A_ = Factory::Get<RCP<Matrix> > (currentLevel, "A");
    RCP<BlockedCrsMatrix> bA = rcp_dynamic_cast<BlockedCrsMatrix>(A_);
    TEUCHOS_TEST_FOR_EXCEPTION(bA.is_null(), Exceptions::BadCast,
                               "MueLu::BraessSarazinSmoother::Setup: input matrix A is not of type BlockedCrsMatrix! error.");

    // Store map extractors
    rangeMapExtractor_  = bA->getRangeMapExtractor();
    domainMapExtractor_ = bA->getDomainMapExtractor();

    // Store the blocks in local member variables
    A00_ = MueLu::Utilities<Scalar,LocalOrdinal,GlobalOrdinal,Node>::Crs2Op(bA->getMatrix(0,0));
    A01_ = MueLu::Utilities<Scalar,LocalOrdinal,GlobalOrdinal,Node>::Crs2Op(bA->getMatrix(0,1));
    A10_ = MueLu::Utilities<Scalar,LocalOrdinal,GlobalOrdinal,Node>::Crs2Op(bA->getMatrix(1,0));
    A11_ = MueLu::Utilities<Scalar,LocalOrdinal,GlobalOrdinal,Node>::Crs2Op(bA->getMatrix(1,1));

    // TODO move this to BlockedCrsMatrix->getMatrix routine...
    A00_->CreateView("stridedMaps", bA->getRangeMap(0), bA->getDomainMap(0));
    A01_->CreateView("stridedMaps", bA->getRangeMap(0), bA->getDomainMap(1));
    A10_->CreateView("stridedMaps", bA->getRangeMap(1), bA->getDomainMap(0));
    if (!A11_.is_null())
      A11_->CreateView("stridedMaps", bA->getRangeMap(1), bA->getDomainMap(1));

    const ParameterList& pL = Factory::GetParameterList();
    SC omega = pL.get<SC>("Damping factor");

    // Create the inverse of the diagonal of F
    D_ = VectorFactory::Build(A00_->getRowMap());

    ArrayRCP<SC> diag;
    if (pL.get<bool>("lumping") == false)
      diag = Utilities::GetMatrixDiagonal      (*A00_);
    else
      diag = Utilities::GetLumpedMatrixDiagonal(*A00_);

    SC one = Teuchos::ScalarTraits<SC>::one();

    ArrayRCP<SC> Ddata = D_->getDataNonConst(0);
    for (GO row = 0; row < Ddata.size(); row++)
      Ddata[row] = one / (diag[row]*omega);

    // Set the Smoother
    // carefully switch to the SubFactoryManagers (defined by the users)
    {
      SetFactoryManager currentSFM(rcpFromRef(currentLevel), FactManager_);
      smoo_ = currentLevel.Get<RCP<SmootherBase> >("PreSmoother", FactManager_->GetFactory("Smoother").get());
      S_    = currentLevel.Get<RCP<Matrix> >      ("A",           FactManager_->GetFactory("A").get());
    }

    SmootherPrototype::IsSetup(true);
  }
开发者ID:Russell-Jones-OxPhys,项目名称:Trilinos,代码行数:57,代码来源:MueLu_BraessSarazinSmoother_def.hpp

示例11: setMap_PartsForRank

  void setMap_PartsForRank(ArrayRCP<int> &idx, ArrayRCP<part_t> &parts) {
    nRanks = idx.size() - 1;
    nParts = parts.size();

    // Need data stored in unordered_map; create it
    rankForPart = rcp(new rankmap_t(idx[nRanks]));

    maxPart = 0;
    for (int i = 0; i < nRanks; i++) {
      for (part_t j = idx[i]; j < idx[i+1]; j++) {
        (*rankForPart)[parts[j]] = i;
        if (parts[j] > maxPart) maxPart = parts[j];
      }
    }

    // Parts for this rank are already contiguous in parts arcp.  
    // Keep a view of them.
    partsForRank = parts.persistingView(idx[myRank],idx[myRank+1]-idx[myRank]);
  }
开发者ID:trilinos,项目名称:Trilinos,代码行数:19,代码来源:Zoltan2_MappingSolution.hpp

示例12: dft_linprobmgr_getrhs

  int dft_linprobmgr_getrhs(void * linprobmgr, double** x) {
    BLPM * linprobmgr_ = (BLPM *) linprobmgr;
    ArrayRCP<ArrayRCP<SCALAR> > data = linprobmgr_->getRhs();
    for(int j = 0; j < data.size(); j++){
      for(int k = 0; k < data[j].size(); k++){
	x[j][k] = Teuchos::as<double>(data[j][k]);
      }
    }
    return( 0 );
  }
开发者ID:symashayak,项目名称:tramonto,代码行数:10,代码来源:dft_tpetra_basic_lin_prob_mgr_wrapper.cpp

示例13: initialize

  /** \brief . */
  void initialize(
    Teuchos_Ordinal globalOffset_in, Teuchos_Ordinal subDim_in, Teuchos_Ordinal subNz_in,
    const ArrayRCP<const Scalar> &values_in, ptrdiff_t valuesStride_in,
    const ArrayRCP<const Teuchos_Ordinal> &indices_in, ptrdiff_t indicesStride_in,
    ptrdiff_t localOffset_in, bool isSorted_in
    )
    {
      using Teuchos::as;
#ifdef TEUCHOS_DEBUG
      TEUCHOS_ASSERT(globalOffset_in >= 0);
      TEUCHOS_ASSERT(subDim_in > 0);
      TEUCHOS_ASSERT_IN_RANGE_UPPER_EXCLUSIVE(subNz_in, 0, subDim_in+1);
      TEUCHOS_ASSERT_EQUALITY(values_in.lowerOffset(), 0);
      TEUCHOS_ASSERT(valuesStride_in != 0);
      TEUCHOS_ASSERT_EQUALITY(values_in.size(),
        subNz_in*as<Teuchos_Ordinal>(std::abs(as<int>(valuesStride_in))));
      if (!is_null(indices_in)) {
        TEUCHOS_ASSERT(indicesStride_in != 0);
        TEUCHOS_ASSERT_EQUALITY(indices_in.size(),
          subNz_in*as<Teuchos_Ordinal>(std::abs(as<int>(indicesStride_in))));
        // Note: localOffset can be +, -, or 0 so there is nothing to assert!
        if (isSorted_in) {
          for (int k = 0; k < subNz_in-1; ++k) {
            const Teuchos_Ordinal idx_k = indices_in[k*indicesStride_in];
            const Teuchos_Ordinal idx_kp1 = indices_in[(k+1)*indicesStride_in];
            TEUCHOS_TEST_FOR_EXCEPTION( !(idx_k < idx_kp1), std::out_of_range,
              "Error indices["<<k<<"]="<<idx_k<<" >= indices["<<k+1<<"]="<<idx_kp1
              <<"!" );
          }
        }
      }
#endif
      globalOffset_ = globalOffset_in;
      subDim_ = subDim_in;
      subNz_ = subNz_in;
      values_ = values_in;
      valuesStride_ = valuesStride_in;
      indices_ = indices_in;
      indicesStride_ = indicesStride_in;
      localOffset_ = localOffset_in;
      isSorted_ = isSorted_in;
    }
开发者ID:00liujj,项目名称:trilinos,代码行数:43,代码来源:RTOpPack_SparseSubVectorT.hpp

示例14: getImportList

size_t getImportList(
   const PartitioningSolution<SolutionAdapter> &solution,
   const DataAdapter * const data,
   ArrayRCP<typename DataAdapter::zgid_t> &imports // output
)
{
  typedef typename PartitioningSolution<SolutionAdapter>::part_t part_t;
  typedef typename PartitioningSolution<SolutionAdapter>::gno_t gno_t;
  typedef typename DataAdapter::zgid_t zgid_t;

  size_t numParts = solution.getActualGlobalNumberOfParts();
  int numProcs = solution.getCommunicator()->getSize();

  if (numParts > size_t(numProcs)) {
    char msg[256];
    sprintf(msg, "Number of parts %lu exceeds number of ranks %d; "
                 "%s requires a MappingSolution for this case\n",
                  numParts, numProcs, __func__);
    throw std::logic_error(msg);
  }

  size_t localNumIds = data->getLocalNumIDs();
  const zgid_t *gids = NULL;
  data->getIDsView(gids);

  const part_t *parts = solution.getPartListView();

  // How many ids to each process?
  Array<int> counts(numProcs, 0);
  for (size_t i=0; i < localNumIds; i++)
    counts[parts[i]]++;

  Array<gno_t> offsets(numProcs+1, 0);
  for (int i=1; i <= numProcs; i++){
    offsets[i] = offsets[i-1] + counts[i-1];
  }

  Array<typename DataAdapter::zgid_t> gidList(localNumIds);
  for (size_t i=0; i < localNumIds; i++) {
    gno_t idx = offsets[parts[i]];
    gidList[idx] = gids[i];
    offsets[parts[i]] = idx + 1;
  }

  Array<int> recvCounts(numProcs, 0);
  try {
    AlltoAllv<zgid_t>(*(solution.getCommunicator()),
                      *(solution.getEnvironment()),
                      gidList(), counts(), imports, recvCounts());
  }
  Z2_FORWARD_EXCEPTIONS;

  return imports.size();
}
开发者ID:rainiscold,项目名称:trilinos,代码行数:54,代码来源:Zoltan2_PartitioningHelpers.hpp

示例15: jacobianPostRegistration

static void jacobianPostRegistration(
    RCP<Application>& app,
    ArrayRCP<RCP<FieldManager<AlbanyTraits> > >& fm)
{
  for (int ps=0; ps < fm.size(); ++ps)
  {
    std::vector<PHX::index_size_type> dd;
    dd.push_back(PHAL::getDerivativeDimensions<J>(app.get(), ps));
    fm[ps]->setKokkosExtendedDataTypeDimensions<J>(dd);
    fm[ps]->postRegistrationSetupForType<J>("Jacobian");
  }
}
开发者ID:arashafshar,项目名称:Albany,代码行数:12,代码来源:GOAL_AdjointResponse.cpp


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