本文整理汇总了C++中ArrayRCP::resize方法的典型用法代码示例。如果您正苦于以下问题:C++ ArrayRCP::resize方法的具体用法?C++ ArrayRCP::resize怎么用?C++ ArrayRCP::resize使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ArrayRCP
的用法示例。
在下文中一共展示了ArrayRCP::resize方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: globalWeightedCutsMessagesByPart
void globalWeightedCutsMessagesByPart(
const RCP<const Environment> &env,
const RCP<const Comm<int> > &comm,
const RCP<const GraphModel<typename Adapter::base_adapter_t> > &graph,
const ArrayView<const typename Adapter::part_t> &parts,
typename Adapter::part_t &numParts,
ArrayRCP<RCP<BaseClassMetrics<typename Adapter::scalar_t> > > &metrics,
ArrayRCP<typename Adapter::scalar_t> &globalSums)
{
env->debug(DETAILED_STATUS, "Entering globalWeightedCutsMessagesByPart");
//////////////////////////////////////////////////////////
// Initialize return values
typedef typename Adapter::lno_t t_lno_t;
typedef typename Adapter::gno_t t_gno_t;
typedef typename Adapter::scalar_t t_scalar_t;
typedef typename Adapter::part_t part_t;
typedef typename Adapter::node_t t_node_t;
typedef typename Zoltan2::GraphModel<typename Adapter::base_adapter_t>::input_t t_input_t;
t_lno_t localNumVertices = graph->getLocalNumVertices();
t_gno_t globalNumVertices = graph->getGlobalNumVertices();
t_lno_t localNumEdges = graph->getLocalNumEdges();
ArrayView<const t_gno_t> Ids;
ArrayView<t_input_t> v_wghts;
graph->getVertexList(Ids, v_wghts);
typedef GraphMetrics<t_scalar_t> mv_t;
//get the edge ids, and weights
ArrayView<const t_gno_t> edgeIds;
ArrayView<const t_lno_t> offsets;
ArrayView<t_input_t> e_wgts;
graph->getEdgeList(edgeIds, offsets, e_wgts);
std::vector <t_scalar_t> edge_weights;
int numWeightPerEdge = graph->getNumWeightsPerEdge();
int numMetrics = 2; // "edge cuts", messages
if (numWeightPerEdge) numMetrics += numWeightPerEdge; // "weight n"
// add some more metrics to the array
typedef typename ArrayRCP<RCP<BaseClassMetrics<typename Adapter::scalar_t> > >::size_type array_size_type;
metrics.resize( metrics.size() + numMetrics );
for( array_size_type n = metrics.size() - numMetrics; n < metrics.size(); ++n ){
mv_t * newMetric = new mv_t; // allocate the new memory
env->localMemoryAssertion(__FILE__,__LINE__,1,newMetric); // check errors
metrics[n] = rcp( newMetric); // create the new members
}
array_size_type next = metrics.size() - numMetrics; // MDM - this is most likely temporary to preserve the format here - we are now filling a larger array so we may not have started at 0
std::vector <part_t> e_parts (localNumEdges);
#ifdef HAVE_ZOLTAN2_MPI
if (comm->getSize() > 1)
{
Zoltan_DD_Struct *dd = NULL;
MPI_Comm mpicomm = Teuchos::getRawMpiComm(*comm);
int size_gnot = Zoltan2::TPL_Traits<ZOLTAN_ID_PTR, t_gno_t>::NUM_ID;
int debug_level = 0;
Zoltan_DD_Create(&dd, mpicomm,
size_gnot, 0,
sizeof(part_t), localNumVertices, debug_level);
ZOLTAN_ID_PTR ddnotneeded = NULL; // Local IDs not needed
Zoltan_DD_Update(
dd,
(ZOLTAN_ID_PTR) Ids.getRawPtr(),
ddnotneeded,
(char *) &(parts[0]),
NULL,
int(localNumVertices));
Zoltan_DD_Find(
dd,
(ZOLTAN_ID_PTR) edgeIds.getRawPtr(),
ddnotneeded,
(char *)&(e_parts[0]),
NULL,
localNumEdges,
NULL
);
Zoltan_DD_Destroy(&dd);
} else
#endif
{
std::map<t_gno_t,t_lno_t> global_id_to_local_index;
//else everything is local.
//we need a globalid to local index conversion.
//this does not exists till this point, so we need to create one.
for (t_lno_t i = 0; i < localNumVertices; ++i){
//at the local index i, we have the global index Ids[i].
//.........这里部分代码省略.........