void SparsePoisonedClustering::loadNextEdges() {
  edgesLeft_ = false;
  std::cerr << "  Loading new edges." << std::endl;
  
  size_t numNewEdges = pvals_.size();
  for (int i = 0; i < numNewEdges; ++i) {
    ScanId s1 = (std::min)(pvals_[i].scannr1, pvals_[i].scannr2);
    ScanId s2 = (std::max)(pvals_[i].scannr1, pvals_[i].scannr2);
    
    if (isPoisoned_[s1] && isPoisoned_[s2]) {
      poisonedEdges_.push_back(pvals_[i]);
    } else {
#ifdef SINGLE_LINKAGE
      if (row != col) {
        size_t idx = 0;
        addNewEdge(SparseMissingEdge(pvec[i].pval, s1, s2, clusters_[s1].size()*clusters_[s2].size()), idx);
      }
#else
      insertEdge(s1, s2, pvals_[i].pval);
#endif
    }
  }
  matrix_.sortRows();
  pvals_.clear();
}
コード例 #2
0
ファイル: tri.C プロジェクト: davidheryanto/sc14
void chunk::newMesh(int nEl, int nGhost, const int *conn_, const int *gid_, int idxOffset)
{
  int i, j;

  CkPrintf("[tmr] newMesh on chunk %d...\n", cid);
  numElements = nEl;
  numGhosts = nGhost;
  allocMesh(nEl);
  int *conn = new int[3*numGhosts];
  int *gid = new int[2*numGhosts];
  
  // add elements to chunk
  for (i=0; i<numElements; i++) {
    int nodes[3];
    edgeRef edges[3];
    for (j=0; j<3; j++) {
      int c=conn_[i*3+j]-idxOffset;
      conn[i*3 + j]=c;
      nodes[j] = c;
      edges[j].init();
    }
    theElements[i].init(nodes, edges, i, this);
    gid[i*2] = cid;
    gid[i*2 + 1] = i;
  }

  // add ghost elements to chunk
  for (i=nEl; i<nGhost; i++) {
    for (j=0; j<3; j++)
      conn[i*3+j] = conn_[i*3+j]-idxOffset;
    gid[i*2+0] = gid_[i*2]-idxOffset;
    gid[i*2+1] = gid_[i*2 + 1]-idxOffset;
  }

/***** derive edges from elements on this chunk ****/
  
  // need to add edges to the chunk, and update all edgeRefs on all elements
  // also need to add nodes to the chunk
  int n1localIdx, n2localIdx, newEdge;

  deriveNodes(); // now numNodes and theNodes have values
  
  for (i=0; i<numElements; i++) {
    elemRef myRef(cid,i);
    for (j=0; j<3; j++) {
      n1localIdx = j;
      n2localIdx = (j+1) % 3;

      // look for edge
      if (theElements[i].edges[j] == nullRef) { // the edge doesn't exist yet
	// get nbr ref
	elemRef nbrRef;
	int edgeIdx = getNbrRefOnEdge(theElements[i].nodes[n1localIdx], 
				      theElements[i].nodes[n2localIdx], 
				      conn, numGhosts, gid, i, &nbrRef); 
	if (edgeLocal(myRef, nbrRef)) { // make edge here
	  newEdge = addNewEdge();
	  // point edge to the two neighboring elements
	  theEdges[newEdge].updateElement(nullRef, myRef);
	  theEdges[newEdge].updateElement(nullRef, nbrRef);
	  // point elem i's edge j at the edge
	  theElements[i].updateEdge(j, theEdges[newEdge].getRef());
	  // point nbrRef at the edge
	  if (nbrRef.cid==cid) // Local neighbor
	    theElements[nbrRef.idx].updateEdge(edgeIdx,
					       theEdges[newEdge].getRef());
	  else if (nbrRef.cid != -1) // Remote neighbor
	    mesh[nbrRef.cid].addRemoteEdge(nbrRef.idx, edgeIdx, 
					   theEdges[newEdge].getRef());
	}
	// else edge will be made on a different chunk
      }
    }
  }
  delete[] conn;
  delete[] gid;
  CkPrintf("[tmr] Finished newMesh on chunk %d...\n", cid);
}