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


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

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


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

示例1: rawMpiRequests

void MpiComm<Ordinal>::waitAll(
    const ArrayView<RCP<CommRequest> > &requests
) const
{
    TEUCHOS_COMM_TIME_MONITOR(
        "Teuchos::MpiComm<"<<OrdinalTraits<Ordinal>::name()<<">::waitAll(...)"
    );
    const int count = requests.size();
#ifdef TEUCHOS_DEBUG
    TEST_FOR_EXCEPT( requests.size() == 0 );
#endif

    Array<MPI_Request> rawMpiRequests(count, MPI_REQUEST_NULL);
    for (int i = 0; i < count; ++i) {
        RCP<CommRequest> &request = requests[i];
        if (!is_null(request)) {
            const RCP<MpiCommRequest> mpiCommRequest =
                rcp_dynamic_cast<MpiCommRequest>(request);
            rawMpiRequests[i] = mpiCommRequest->releaseRawMpiRequest();
        }
        // else already null
        request = null;
    }

    Array<MPI_Status> rawMpiStatuses(count);
    MPI_Waitall( count, rawMpiRequests.getRawPtr(), rawMpiStatuses.getRawPtr() );
    // ToDo: We really should check the status?

}
开发者ID:haripandey,项目名称:trilinos,代码行数:29,代码来源:Teuchos_DefaultMpiComm.hpp

示例2: make_pair

    std::pair<CudaEvent, view_type>
    copy(const ArrayView<
                value_type,
                HostCoordinator<
                    value_type,
                    PinnedAllocator<
                        value_type,
                        alignment>>> &from,
         view_type &to) {
        assert(from.size()==to.size());

        #ifdef VERBOSE
        using oType = ArrayView< value_type, HostCoordinator< value_type, PinnedAllocator< value_type, alignment>>>;
        std::cout << util::pretty_printer<DeviceCoordinator>::print(*this)
                  << "::" << util::blue("copy") << "(asynchronous, " << from.size() << ")"
                  << "\n  " << util::type_printer<oType>::print() << " @ " << from.data()
                  << util::yellow(" -> ")
                  << util::type_printer<view_type>::print() << " @ " << to.data() << std::endl;
        #endif

        auto status = cudaMemcpy(
                reinterpret_cast<void*>(to.begin()),
                reinterpret_cast<const void*>(from.begin()),
                from.size()*sizeof(value_type),
                cudaMemcpyHostToDevice
        );
        if(status != cudaSuccess) {
            std::cerr << util::red("error") << " bad CUDA memcopy, unable to copy " << sizeof(T)*from.size() << " bytes from host to device";
            exit(-1);
        }

        CudaEvent event;
        return std::make_pair(event, to);
    }
开发者ID:w-klijn,项目名称:vector,代码行数:34,代码来源:DeviceCoordinator.hpp

示例3:

  void
  AbstractConcreteMatrixAdapter<
    Epetra_RowMatrix,
    DerivedMat>::getGlobalRowCopy_impl(global_ordinal_t row,
                                       const ArrayView<global_ordinal_t>& indices,
                                       const ArrayView<scalar_t>& vals,
                                       size_t& nnz) const
  {
    using Teuchos::as;

    local_ordinal_t local_row = this->row_map_->getLocalElement(row);
    int nnz_ret = 0;
    int rowmatrix_return_val
      = this->mat_->ExtractMyRowCopy(as<int>(local_row),
                                     as<int>(std::min(indices.size(), vals.size())),
                                     nnz_ret,
                                     vals.getRawPtr(),
                                     indices.getRawPtr());
    TEUCHOS_TEST_FOR_EXCEPTION( rowmatrix_return_val != 0,
                        std::runtime_error,
                        "Epetra_RowMatrix object returned error code "
                        << rowmatrix_return_val << " from ExtractMyRowCopy." );
    nnz = as<size_t>(nnz_ret);

    // Epetra_CrsMatrix::ExtractMyRowCopy returns local column
    // indices, so transform these into global indices
    for( size_t i = 0; i < nnz; ++i ){
      indices[i] = this->col_map_->getGlobalElement(indices[i]);
    }
  }
开发者ID:KineticTheory,项目名称:Trilinos,代码行数:30,代码来源:Amesos2_EpetraRowMatrix_AbstractMatrixAdapter_def.hpp

示例4: apply_op_validate_input

void Thyra::apply_op_validate_input(
  const std::string &func_name,
  const VectorSpaceBase<Scalar> &domain,
  const VectorSpaceBase<Scalar> &range,
  const RTOpPack::RTOpT<Scalar> &primary_op,
  const ArrayView<const Ptr<const MultiVectorBase<Scalar> > > &multi_vecs,
  const ArrayView<const Ptr<MultiVectorBase<Scalar> > > &targ_multi_vecs,
  const ArrayView<const Ptr<RTOpPack::ReductTarget> > &reduct_objs,
  const Ordinal primary_global_offset_in
  )
{
  using Teuchos::as;
  // Validate primary range arguments
  TEST_FOR_EXCEPTION(
    primary_global_offset_in < 0, std::logic_error
    ,func_name << " : Error! primary_global_offset_in = "
    <<primary_global_offset_in<<" is not valid" );
  // Validate secondary domain arguments
  // Validate spaces
  for (int k = 0; k < multi_vecs.size(); ++k) {
    THYRA_ASSERT_VEC_SPACES(func_name,domain,*multi_vecs[k]->domain());
    THYRA_ASSERT_VEC_SPACES(func_name,range,*multi_vecs[k]->range());
  }
  for (int k = 0; k < targ_multi_vecs.size(); ++k) {
    THYRA_ASSERT_VEC_SPACES(func_name,domain,*targ_multi_vecs[k]->domain());
    THYRA_ASSERT_VEC_SPACES(func_name,range,*targ_multi_vecs[k]->range());
  }
}
开发者ID:haripandey,项目名称:trilinos,代码行数:28,代码来源:Thyra_apply_op_helper_def.hpp

示例5:

TestLagrPolyMeritFunc1D<Scalar>::TestLagrPolyMeritFunc1D(
  const ArrayView<const Scalar> &alpha,
  const ArrayView<const Scalar> &phi
  )
  : alpha_(alpha), phi_(phi)
{
  TEUCHOS_ASSERT_EQUALITY(alpha.size(), phi.size());
}
开发者ID:00liujj,项目名称:trilinos,代码行数:8,代码来源:GlobiPack_TestLagrPolyMeritFunc1D_def.hpp

示例6: vecs

void MultiVectorDefaultBase<Scalar>::mvMultiReductApplyOpImpl(
  const RTOpPack::RTOpT<Scalar> &prim_op,
  const ArrayView<const Ptr<const MultiVectorBase<Scalar> > > &multi_vecs,
  const ArrayView<const Ptr<MultiVectorBase<Scalar> > > &targ_multi_vecs,
  const ArrayView<const Ptr<RTOpPack::ReductTarget> > &reduct_objs,
  const Ordinal prim_global_offset_in
  ) const
{

  using Teuchos::Workspace;
  using Teuchos::as;
  Teuchos::WorkspaceStore* wss = Teuchos::get_default_workspace_store().get();

  const int num_multi_vecs = multi_vecs.size();
  const int num_targ_multi_vecs = targ_multi_vecs.size();

  // ToDo: Validate the input!

  const VectorSpaceBase<Scalar> &l_domain = *this->domain();

  // Get the primary and secondary dimensions.

  const Ordinal sec_dim = l_domain.dim();

  //
  // Apply the reduction/transformation operator and transform the
  // target vectors and reduce each of the reduction objects.
  //

  Workspace<RCP<const VectorBase<Scalar> > > vecs_s(wss, num_multi_vecs);
  Workspace<Ptr<const VectorBase<Scalar> > > vecs(wss, num_multi_vecs);
  Workspace<RCP<VectorBase<Scalar> > > targ_vecs_s(wss, num_targ_multi_vecs);
  Workspace<Ptr<VectorBase<Scalar> > > targ_vecs(wss, num_targ_multi_vecs);

  for(Ordinal j = 0; j < sec_dim; ++j) {
    // Fill the arrays of vector arguments
    {for(Ordinal k = 0; k < as<Ordinal>(num_multi_vecs); ++k) {
        vecs_s[k] = multi_vecs[k]->col(j);
        vecs[k] = vecs_s[k].ptr();
      }}
    {for(Ordinal k = 0; k < as<Ordinal>(num_targ_multi_vecs); ++k) {
        targ_vecs_s[k] = targ_multi_vecs[k]->col(j);
        targ_vecs[k] = targ_vecs_s[k].ptr();
      }}
    // Apply the reduction/transformation operator
    Thyra::applyOp(
      prim_op,
      vecs().getConst(),
      targ_vecs().getConst(),
      reduct_objs.size() ? reduct_objs[j] : Ptr<RTOpPack::ReductTarget>(),
      prim_global_offset_in);
  }
  // At this point all of the designated targ vectors in the target multi-vectors have
  // been transformed and all the reduction objects in reduct_obj[] have accumulated
  // the reductions.
}
开发者ID:00liujj,项目名称:trilinos,代码行数:56,代码来源:Thyra_MultiVectorDefaultBase_def.hpp

示例7:

TEUCHOS_UNIT_TEST( Rythmos_StackedStepper, addgetStepper ) {
    RCP<StackedStepper<double> > sStepper = stackedStepper<double>();
    {
        ArrayView<const RCP<StepperBase<double> > > stepperArray;
        stepperArray = sStepper->getNonconstSteppers();
        TEST_ASSERT( stepperArray.size() == 0 );
    }
    {
        RCP<StepperBase<double> > stepper;
        const RCP<StepperBuilder<double> > builder = stepperBuilder<double>();
        RCP<ParameterList> pl = Teuchos::parameterList();
        pl->set("Stepper Type","Explicit RK");
        builder->setParameterList(pl);
        stepper = builder->create();
        sStepper->addStepper(stepper);
        pl->set("Stepper Type","Implicit RK");
        sStepper->addStepper(builder->create());
        pl->set("Stepper Type","Implicit BDF");
        sStepper->addStepper(builder->create());
    }
    ArrayView<const RCP<StepperBase<double> > > stepperArray;
    stepperArray = sStepper->getNonconstSteppers();
    TEST_ASSERT(stepperArray.size() == 3);

    RCP<const StepperBase<double> > stepper;
    stepper = stepperArray[0];
    TEST_ASSERT( !is_null(stepper) );
    {
        RCP<const ExplicitRKStepper<double> > erkStepper =
            Teuchos::rcp_dynamic_cast<const ExplicitRKStepper<double> >(
                stepper,
                false
            );
        TEST_ASSERT( !is_null(erkStepper) );
    }
    stepper = stepperArray[1];
    TEST_ASSERT( !is_null(stepper) );
    {
        RCP<const ImplicitRKStepper<double> > irkStepper =
            Teuchos::rcp_dynamic_cast<const ImplicitRKStepper<double> >(
                stepper,
                false
            );
        TEST_ASSERT( !is_null(irkStepper) );
    }
    stepper = stepperArray[2];
    TEST_ASSERT( !is_null(stepper) );
    {
        RCP<const ImplicitBDFStepper<double> > ibdfStepper =
            Teuchos::rcp_dynamic_cast<const ImplicitBDFStepper<double> >(
                stepper,
                false
            );
        TEST_ASSERT( !is_null(ibdfStepper) );
    }
}
开发者ID:haripandey,项目名称:trilinos,代码行数:56,代码来源:Rythmos_StackedStepper_UnitTest.cpp

示例8: set_regions

void TextureAtlas::set_regions(const ArrayView<int>& rects)
{
    R_ASSERT(rects.size() % 4 == 0,
             "Rectangle data size must be a multiple of 4");

    regions_.clear();
    regions_.reserve(rects.size() / 4);
    for (size_t i = 0; i < rects.size(); i += 4)
        add_region(rects[i], rects[i + 1], rects[i + 2], rects[i + 3]);
}
开发者ID:AntonioModer,项目名称:rainbow,代码行数:10,代码来源:TextureAtlas.cpp

示例9:

void ArrayView<T>::assign(const ArrayView<const T>& array) const
{
  debug_assert_valid_ptr();
  debug_assert_not_null();
  if (this->getRawPtr()==array.getRawPtr() && this->size()==array.size())
    return; // Assignment to self
  debug_assert_in_range(0,array.size());
  std::copy( array.begin(), array.end(), this->begin() );
  // Note: Above, in debug mode, the iterators are range checked!  In
  // optimized mode, these are raw pointers which should run very fast!
}
开发者ID:crtrott,项目名称:Trilinos,代码行数:11,代码来源:Teuchos_ArrayView.hpp

示例10: convertToIndepVarFadArray

Array<Sacado::Fad::DFad<ScalarT> > convertToIndepVarFadArray(
  const ArrayView<const ScalarT> &av, const int num_derivs,
  const Ptr<int> &deriv_idx)
{
  using Sacado::Fad::DFad;
  Array<DFad<ScalarT> > a_fad(av.size());
  for (int i = 0; i < av.size(); ++i) {
    a_fad[i] = DFad<double>(num_derivs, (*deriv_idx)++, av[i]);
  }
  return a_fad;
}
开发者ID:haripandey,项目名称:trilinos,代码行数:11,代码来源:VanderPolModel.cpp

示例11: convertToPassiveFadArray

Array<Sacado::Fad::DFad<ScalarT> > convertToPassiveFadArray(
  const ArrayView<const ScalarT> &av
  )
{
  using Sacado::Fad::DFad;
  Array<DFad<ScalarT> > a_fad(av.size());
  for (int i = 0; i < av.size(); ++i) {
    a_fad[i] = DFad<double>(av[i]);
  }
  return a_fad;
}
开发者ID:haripandey,项目名称:trilinos,代码行数:11,代码来源:VanderPolModel.cpp

示例12: replaceLocalValues

 //! Replace matrix entries, using local IDs.
 void
 replaceLocalValues (LocalOrdinal localRow,
                     const ArrayView<const LocalOrdinal> &cols,
                     const ArrayView<const Scalar> &vals)
 {
   XPETRA_MONITOR("TpetraCrsMatrix::replaceLocalValues");
   typedef typename ArrayView<const LocalOrdinal>::size_type size_type;
   const LocalOrdinal numValid =
     mtx_->replaceLocalValues (localRow, cols, vals);
   TEUCHOS_TEST_FOR_EXCEPTION(
     static_cast<size_type> (numValid) != cols.size (), std::runtime_error,
     "replaceLocalValues returned " << numValid << " != cols.size() = " <<
     cols.size () << ".");
 }
开发者ID:rainiscold,项目名称:trilinos,代码行数:15,代码来源:Xpetra_TpetraCrsMatrix.hpp

示例13: readyBuffers

      inline void readyBuffers(ArrayView<ArrayRCP<const char> > buffers, ArrayView<ArrayRCP<char> > ncBuffers) {
#ifdef HAVE_KOKKOSCLASSIC_DEBUG
        if (isHostNode == false) {
          for (size_t i=0; i < (size_t)buffers.size(); ++i) {
            CHECK_COMPUTE_BUFFER(buffers[i]);
          }
          for (size_t i=0; i < (size_t)ncBuffers.size(); ++i) {
            CHECK_COMPUTE_BUFFER(ncBuffers[i]);
          }
        }
#endif
        (void)buffers;
        (void)ncBuffers;
      }
开发者ID:rainiscold,项目名称:trilinos,代码行数:14,代码来源:Kokkos_StandardNodeMemoryModel.hpp

示例14: applyOp

inline
void applyOp(
  const RTOpPack::RTOpT<Scalar> &op,
  const ArrayView<const Ptr<const VectorBase<Scalar> > > &vecs,
  const ArrayView<const Ptr<VectorBase<Scalar> > > &targ_vecs,
  const Ptr<RTOpPack::ReductTarget> &reduct_obj,
  const Ordinal global_offset = 0
  )
{
  if (vecs.size())
    vecs[0]->applyOp(op, vecs, targ_vecs, reduct_obj, global_offset);
  else if (targ_vecs.size())
    targ_vecs[0]->applyOp(op, vecs, targ_vecs, reduct_obj, global_offset);
}
开发者ID:00liujj,项目名称:trilinos,代码行数:14,代码来源:Thyra_VectorBase.hpp

示例15: IndexMap

//-----------------------------------------------------------------------------
DofMap::DofMap(std::unordered_map<std::size_t, std::size_t>& collapsed_map,
               const DofMap& dofmap_view, const Mesh& mesh)
  : _cell_dimension(0), _ufc_dofmap(dofmap_view._ufc_dofmap), _is_view(false),
    _global_dimension(0), _ufc_offset(0), _multimesh_offset(0),
    _index_map(new IndexMap(mesh.mpi_comm()))
{
  dolfin_assert(_ufc_dofmap);

  // Check for dimensional consistency between the dofmap and mesh
  check_dimensional_consistency(*_ufc_dofmap, mesh);

  // Check that mesh has been ordered
  if (!mesh.ordered())
  {
     dolfin_error("DofMap.cpp",
                  "create mapping of degrees of freedom",
                  "Mesh is not ordered according to the UFC numbering convention. "
                  "Consider calling mesh.order()");
  }

  // Check dimensional consistency between UFC dofmap and the mesh
  check_provided_entities(*_ufc_dofmap, mesh);

  // Build new dof map
  DofMapBuilder::build(*this, mesh, constrained_domain);

  // Dimension sanity checks
  dolfin_assert(dofmap_view._dofmap.size()
                == mesh.num_cells()*dofmap_view._cell_dimension);
  dolfin_assert(global_dimension() == dofmap_view.global_dimension());
  dolfin_assert(_dofmap.size() == mesh.num_cells()*_cell_dimension);

  // FIXME: Could we use a std::vector instead of std::map if the
  //        collapsed dof map is contiguous (0, . . . , n)?

  // Build map from collapsed dof index to original dof index
  collapsed_map.clear();
  for (std::size_t i = 0; i < mesh.num_cells(); ++i)
  {
    const ArrayView<const dolfin::la_index> view_cell_dofs
      = dofmap_view.cell_dofs(i);
    const ArrayView<const dolfin::la_index> cell_dofs = this->cell_dofs(i);
    dolfin_assert(view_cell_dofs.size() == cell_dofs.size());

    for (std::size_t j = 0; j < view_cell_dofs.size(); ++j)
      collapsed_map[cell_dofs[j]] = view_cell_dofs[j];
  }
}
开发者ID:WeilinDeng,项目名称:dolfin,代码行数:49,代码来源:DofMap.cpp


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