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


C++ NodeSet::clear方法代码示例

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


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

示例1: test_clear

void NodeSetTest::test_clear()
{
  NodeSet set;
  set.set_corner_node(1);
  set.clear();
  CPPUNIT_ASSERT( !set.get_bits() );
  set.set_mid_edge_node(2);
  set.clear();
  CPPUNIT_ASSERT( !set.get_bits() );
  set.set_mid_region_node();
  set.clear();
  CPPUNIT_ASSERT( !set.get_bits() );
}
开发者ID:haripandey,项目名称:trilinos,代码行数:13,代码来源:NodeSetTest.cpp

示例2: test_have_any

void NodeSetTest::test_have_any()
{
  NodeSet set;
  set.clear();
  
  CPPUNIT_ASSERT( !set.have_any_corner_node() );
  set.set_corner_node(0);
  CPPUNIT_ASSERT( set.have_any_corner_node() );
  set.clear_corner_node(0);
  CPPUNIT_ASSERT( !set.have_any_corner_node() );
  set.set_corner_node( NodeSet::NUM_CORNER_BITS-1 );
  CPPUNIT_ASSERT( set.have_any_corner_node() );
  CPPUNIT_ASSERT( !set.have_any_mid_node() );

  CPPUNIT_ASSERT( !set.have_any_mid_edge_node() );
  set.set_mid_edge_node(0);
  CPPUNIT_ASSERT( set.have_any_mid_edge_node() );
  CPPUNIT_ASSERT( set.have_any_mid_node() );
  set.clear_mid_edge_node(0);
  CPPUNIT_ASSERT( !set.have_any_mid_edge_node() );
  CPPUNIT_ASSERT( !set.have_any_mid_node() );
  set.set_mid_edge_node( NodeSet::NUM_EDGE_BITS-1 );
  CPPUNIT_ASSERT( set.have_any_mid_edge_node() );
  CPPUNIT_ASSERT( set.have_any_mid_node() );
  set.clear();

  CPPUNIT_ASSERT( !set.have_any_mid_face_node() );
  set.set_mid_face_node(0);
  CPPUNIT_ASSERT( set.have_any_mid_face_node() );
  CPPUNIT_ASSERT( set.have_any_mid_node() );
  set.clear_mid_face_node(0);
  CPPUNIT_ASSERT( !set.have_any_mid_face_node() );
  CPPUNIT_ASSERT( !set.have_any_mid_node() );
  set.set_mid_face_node( NodeSet::NUM_FACE_BITS-1 );
  CPPUNIT_ASSERT( set.have_any_mid_face_node() );
  CPPUNIT_ASSERT( set.have_any_mid_node() );
  set.clear();

  CPPUNIT_ASSERT( !set.have_any_mid_region_node() );
  set.set_mid_region_node(0);
  CPPUNIT_ASSERT( set.have_any_mid_region_node() );
  CPPUNIT_ASSERT( set.have_any_mid_node() );
  set.clear_mid_region_node(0);
  CPPUNIT_ASSERT( !set.have_any_mid_region_node() );
  CPPUNIT_ASSERT( !set.have_any_mid_node() );
  set.set_mid_region_node( NodeSet::NUM_REGION_BITS-1 );
  CPPUNIT_ASSERT( set.have_any_mid_region_node() );
  CPPUNIT_ASSERT( set.have_any_mid_node() );
  set.clear();
}
开发者ID:haripandey,项目名称:trilinos,代码行数:50,代码来源:NodeSetTest.cpp

示例3: test_num_before

void NodeSetTest::test_num_before()
{
  const EntityTopology type = HEXAHEDRON;
  NodeSet set;
  set.clear();
  set.set_mid_face_node( 2 );
  CPPUNIT_ASSERT_EQUAL( 0u, set.num_before_mid_face( 2 ) );
  CPPUNIT_ASSERT_EQUAL( 1u, set.num_before_mid_face( 3 ) );
  set.set_corner_node( 0 );
  CPPUNIT_ASSERT_EQUAL( 1u, set.num_before_mid_face( 2 ) );
  CPPUNIT_ASSERT_EQUAL( 2u, set.num_before_mid_face( 3 ) );
  CPPUNIT_ASSERT_EQUAL( 0u, set.num_before_corner( 0 ) );
  CPPUNIT_ASSERT_EQUAL( 1u, set.num_before_corner( 1 ) );
  set.set_all_corner_nodes( type );
  CPPUNIT_ASSERT_EQUAL( TopologyInfo::corners(type), set.num_before_mid_edge(0) );
  CPPUNIT_ASSERT_EQUAL( TopologyInfo::corners(type)-1, set.num_before_corner(TopologyInfo::corners(type)-1) );
  CPPUNIT_ASSERT_EQUAL( 0u, set.num_before_corner(0) );
  CPPUNIT_ASSERT_EQUAL( 1u, set.num_before_corner(1) );
  CPPUNIT_ASSERT_EQUAL( 2u, set.num_before_corner(2) );
  CPPUNIT_ASSERT_EQUAL( 3u, set.num_before_corner(3) );
  CPPUNIT_ASSERT_EQUAL( 4u, set.num_before_corner(4) );
  
  const unsigned total_nodes = 27;
  set.set_all_nodes( type );
  CPPUNIT_ASSERT_EQUAL( total_nodes - 1, set.num_before_mid_region( 0 ) );
  set.clear_mid_edge_node( 0 );
  CPPUNIT_ASSERT_EQUAL( total_nodes - 2, set.num_before_mid_region( 0 ) );
  set.clear_mid_edge_node( 1 );
  CPPUNIT_ASSERT_EQUAL( total_nodes - 3, set.num_before_mid_region( 0 ) );
}
开发者ID:haripandey,项目名称:trilinos,代码行数:30,代码来源:NodeSetTest.cpp

示例4: test_deriv_edges

void TriLagrangeShapeTest::test_deriv_edges()
{
  NodeSet ns;
  
  ns.clear();
  test_edge_derivs( 0, ns );
  test_edge_derivs( 1, ns );
  test_edge_derivs( 2, ns );

  ns.set_mid_edge_node(0);
  test_edge_derivs( 0, ns );
  test_edge_derivs( 1, ns );
  test_edge_derivs( 2, ns );

  ns.clear();
  ns.set_mid_edge_node(1);
  test_edge_derivs( 0, ns );
  test_edge_derivs( 1, ns );
  test_edge_derivs( 2, ns );

  ns.set_mid_edge_node(0);
  test_edge_derivs( 0, ns );
  test_edge_derivs( 1, ns );
  test_edge_derivs( 2, ns );

  ns.clear();
  ns.set_mid_edge_node(2);
  test_edge_derivs( 0, ns );
  test_edge_derivs( 1, ns );
  test_edge_derivs( 2, ns );

  ns.set_mid_edge_node(0);
  test_edge_derivs( 0, ns );
  test_edge_derivs( 1, ns );
  test_edge_derivs( 2, ns );

  ns.set_mid_edge_node(1);
  test_edge_derivs( 0, ns );
  test_edge_derivs( 1, ns );
  test_edge_derivs( 2, ns );

  ns.clear_mid_edge_node(0);
  test_edge_derivs( 0, ns );
  test_edge_derivs( 1, ns );
  test_edge_derivs( 2, ns );
}
开发者ID:00liujj,项目名称:trilinos,代码行数:46,代码来源:TriLagrangeShapeTest.cpp

示例5: test_coeff_edges

void TriLagrangeShapeTest::test_coeff_edges()
{
  NodeSet ns;
  
  ns.clear();
  test_edge_coeff( 0, ns );
  test_edge_coeff( 1, ns );
  test_edge_coeff( 2, ns );

  ns.set_mid_edge_node(0);
  test_edge_coeff( 0, ns );
  test_edge_coeff( 1, ns );
  test_edge_coeff( 2, ns );

  ns.clear();
  ns.set_mid_edge_node(1);
  test_edge_coeff( 0, ns );
  test_edge_coeff( 1, ns );
  test_edge_coeff( 2, ns );

  ns.set_mid_edge_node(0);
  test_edge_coeff( 0, ns );
  test_edge_coeff( 1, ns );
  test_edge_coeff( 2, ns );

  ns.clear();
  ns.set_mid_edge_node(2);
  test_edge_coeff( 0, ns );
  test_edge_coeff( 1, ns );
  test_edge_coeff( 2, ns );

  ns.set_mid_edge_node(0);
  test_edge_coeff( 0, ns );
  test_edge_coeff( 1, ns );
  test_edge_coeff( 2, ns );

  ns.set_mid_edge_node(1);
  test_edge_coeff( 0, ns );
  test_edge_coeff( 1, ns );
  test_edge_coeff( 2, ns );

  ns.clear_mid_edge_node(0);
  test_edge_coeff( 0, ns );
  test_edge_coeff( 1, ns );
  test_edge_coeff( 2, ns );
}
开发者ID:00liujj,项目名称:trilinos,代码行数:46,代码来源:TriLagrangeShapeTest.cpp

示例6: sample_points

NodeSet TriLagrangeShape::sample_points( NodeSet ns ) const
{
  if (ns.have_any_mid_node()) {
    ns.set_all_corner_nodes(TRIANGLE);
  }
  else {
    ns.clear();
    ns.set_mid_face_node(0);
  }
  return ns;
}
开发者ID:00liujj,项目名称:trilinos,代码行数:11,代码来源:TriLagrangeShape.cpp

示例7: divideTrees

void State::divideTrees(const State& a_other, NodePairSet& a_commonRoots, NodeSet& a_myUniqueRoots, NodeSet& a_otherUniqueRoots)
{
	NodeSet otherRootSet = a_other.getRootSet(); // Copy the entire set
	a_commonRoots.clear();
	a_myUniqueRoots.clear();
	a_otherUniqueRoots.clear();

	for (NodeSetIter iter = m_rootSet.begin(); iter != m_rootSet.end(); iter++)
	{
		bool isUnique = true;
		string rootName;
		if (!((*iter)->getUniqueName(rootName)))
		{
			error("State::divideTrees - Multiple roots (in this state) with the same name " + rootName + " exist! " + string(*this), true);
		}

		for (NodeSetIter otherIter = otherRootSet.begin(); otherIter != otherRootSet.end(); otherIter++)
		{
			string otherRootName;
			if (!((*otherIter)->getUniqueName(otherRootName)))
			{
				error("State::divideTrees - Multiple roots (in joined state) with the same name " + otherRootName + " exist! " + string(a_other), true);
			}

			if (rootName == otherRootName)
			{
				a_commonRoots.insert(make_pair((*iter), (*otherIter)));
				otherRootSet.erase(otherIter);
				isUnique = false;
				break;
			}
		}

		if (isUnique)
		{
			a_myUniqueRoots.insert(*iter);
		}
	}
	a_otherUniqueRoots = otherRootSet;
}
开发者ID:IdoBegun,项目名称:PAAV_Project,代码行数:40,代码来源:State.cpp

示例8: test_num_nodes

void NodeSetTest::test_num_nodes()
{
  NodeSet set;
  set.clear();
  set.set_corner_node(1);
  CPPUNIT_ASSERT_EQUAL( 1u, set.num_nodes() );
  set.set_corner_node(3);
  CPPUNIT_ASSERT_EQUAL( 2u, set.num_nodes() );
  set.set_mid_region_node(0);
  CPPUNIT_ASSERT_EQUAL( 3u, set.num_nodes() );
  set.set_mid_edge_node(1);
  set.set_mid_edge_node(2);
  CPPUNIT_ASSERT_EQUAL( 5u, set.num_nodes() );
  set.set_all_nodes(HEXAHEDRON);
  CPPUNIT_ASSERT_EQUAL( 27u, set.num_nodes() );
  set.clear();
  set.set_all_nodes(TETRAHEDRON);
  CPPUNIT_ASSERT_EQUAL( 15u, set.num_nodes() );
  set.clear();
  set.set_all_nodes(TRIANGLE);
  CPPUNIT_ASSERT_EQUAL( 7u, set.num_nodes() );
  set.clear();
  set.set_all_nodes(QUADRILATERAL);
  CPPUNIT_ASSERT_EQUAL( 9u, set.num_nodes() );
  set.clear();
  set.set_all_nodes(PYRAMID);
  CPPUNIT_ASSERT_EQUAL( 19u, set.num_nodes() );
  set.clear();
  set.set_all_nodes(PRISM);
  CPPUNIT_ASSERT_EQUAL( 21u, set.num_nodes() );
}
开发者ID:haripandey,项目名称:trilinos,代码行数:31,代码来源:NodeSetTest.cpp

示例9: test_set_all

void NodeSetTest::test_set_all()
{
  const EntityTopology types[] = { TRIANGLE, QUADRILATERAL,
                                   TETRAHEDRON, HEXAHEDRON,
                                   PRISM, PYRAMID };
  const int num_types = sizeof(types)/sizeof(types[0]);

  for (int i = 0; i < num_types; ++i) {
    NodeSet set;
    set.set_all_corner_nodes( types[i] );
    check_range_set( types[i], set, 0 );
    set.clear();
    set.set_all_mid_edge_nodes( types[i] );
    check_range_set( types[i], set, 1 );
    set.clear();
    set.set_all_mid_face_nodes( types[i] );
    check_range_set( types[i], set, 2 );
    set.clear();
    set.set_all_mid_region_nodes( types[i] );
    check_range_set( types[i], set, 3 );
  }
}
开发者ID:haripandey,项目名称:trilinos,代码行数:22,代码来源:NodeSetTest.cpp

示例10: test_deriv_center

void TriLagrangeShapeTest::test_deriv_center()
{
  NodeSet ns;
  
  ns.clear();
  test_mid_derivs( ns );
  ns.set_mid_edge_node(0);
  test_mid_derivs( ns );
  ns.clear();
  ns.set_mid_edge_node(1);
  test_mid_derivs( ns );
  ns.set_mid_edge_node(0);
  test_mid_derivs( ns );
  ns.clear();
  ns.set_mid_edge_node(2);
  test_mid_derivs( ns );
  ns.set_mid_edge_node(0);
  test_mid_derivs( ns );
  ns.set_mid_edge_node(1);
  test_mid_derivs( ns );
  ns.clear_mid_edge_node(0);
  test_mid_derivs( ns );
}
开发者ID:00liujj,项目名称:trilinos,代码行数:23,代码来源:TriLagrangeShapeTest.cpp

示例11: test_set_node

void NodeSetTest::test_set_node()
{
  NodeSet set;
  for (unsigned i = 0; i < NodeSet::NUM_CORNER_BITS; ++i) {
    set.set_corner_node( i );
    CPPUNIT_ASSERT_EQUAL( 1u << (NodeSet::CORNER_OFFSET + i), set.get_bits() );
    set.clear();
  }
  for (unsigned i = 0; i < NodeSet::NUM_EDGE_BITS; ++i) {
    set.set_mid_edge_node( i );
    CPPUNIT_ASSERT_EQUAL( 1u << (NodeSet::EDGE_OFFSET + i), set.get_bits() );
    set.clear();
  }
  for (unsigned i = 0; i < NodeSet::NUM_FACE_BITS; ++i) {
    set.set_mid_face_node( i );
    CPPUNIT_ASSERT_EQUAL( 1u << (NodeSet::FACE_OFFSET + i), set.get_bits() );
    set.clear();
  }
  for (unsigned i = 0; i < NodeSet::NUM_REGION_BITS; ++i) {
    set.set_mid_region_node( i );
    CPPUNIT_ASSERT_EQUAL( 1u << (NodeSet::REGION_OFFSET + i), set.get_bits() );
    set.clear();
  }
}
开发者ID:haripandey,项目名称:trilinos,代码行数:24,代码来源:NodeSetTest.cpp

示例12: main

int main(int argc, char* argv[])
{   	
	struct timeval startTime, endTime;
	
	gettimeofday(&startTime, NULL);
	
	string inFileName = "", cutoffFileName = "";
		
	printf("\n----------------------------------------------------------------------\n");
	printf("                  DENDROGRAM CUTTING GENETIC DISTANCES                  \n");

	int i, numReads;

	getOptions(argc, argv, inFileName, cutoffFileName, numReads);
	
	FILE * cutoffFile = NULL;
	vector<float> cutoffs;
	float cutoff;
	cutoffFile = fopen(cutoffFileName.c_str(),"r");
	while(!feof(cutoffFile)) {
		fscanf(cutoffFile, "%f\n", &cutoff);
		cutoffs.push_back(cutoff);
		cout << cutoff << endl;
	}
	fclose(cutoffFile);	

	leaves=(TreeNode**)malloc(sizeof(TreeNode*)*(2*numReads+1));

	if(leaves==0)
	{   
		cout<<"Error: Not enough memory" << endl;
		exit(-1);
	}
	
	for(i = 0; i < numReads; ++i) 
		leaves[i] = new TreeNode(i);	
	
	for(i = numReads+1; i < 2*numReads+1; ++i) 
		leaves[i] = 0;
	
	int idX, idY;
	float dist;		
	string mergeFileName=inFileName;
	mergeFileName.append("_Merge");	
	
	FILE * mergeFile;
	mergeFile = fopen(mergeFileName.c_str(), "r");
	
	newId = numReads;	
	while ( fscanf(mergeFile, "%d %d %f", &idX, &idY, &dist) == 3 ) 
		merge(leaves[idX-1], leaves[idY-1], dist);	
			
	fclose(mergeFile);
	cout << "DONE!" << endl;
	cout << "current node: " << newId << endl;	

	// get root nodes and orphan nodes
	NodeSet roots;
	IDList orphanNodes;	
	TreeNode *aLeaf = 0;
     	
	for(i=0; i< numReads; ++i)
	{   
		aLeaf = leaves[i];
		if(aLeaf->parent==0)  // find nodes with no parent
			orphanNodes.push_back(i); 				
		else
			roots.insert(aLeaf->topParent); 										
	}

 	// print output to files
 	
	string clusterListName, clusterName;

	clusterListName=inFileName;
	clusterListName.append(".Cluster_List");
	clusterName=inFileName;
	clusterName.append(".Cluster");

	printClusters(roots, orphanNodes, clusterListName, clusterName, cutoffs);		
	
	// clear memory
	emptyTree(roots);	
	roots.clear();	
	orphanNodes.clear();	
	free(leaves);
	
	gettimeofday(&endTime, NULL);	
	long elapsedTime = (endTime.tv_sec - startTime.tv_sec) * 1000u + (endTime.tv_usec - startTime.tv_usec) / 1.e3 + 0.5;

	printf("Time taken: %.3f s\n", elapsedTime/1.e3);
	printf("\n----------------------------------------------------------------------\n");
	return 0;
}
开发者ID:ngthuydiem,项目名称:crispy,代码行数:94,代码来源:sparsecut.cpp

示例13: main


//.........这里部分代码省略.........
			
	while(totalNumEdges < MAX_NUM_EDGES && !nodeMap.empty())
	{   
		// get the first item in the nodeMap
		iter = nodeMap.begin();
		fileId = iter->second.fileId;        

		// write to output
		idX = iter->second.idX;
		idY =  iter->second.idY;
		dist = iter->first;
		
		absorb(idX, idY, dist);	
		
		// remove the current item from the nodeMap
		nodeMap.erase(iter);
			
		suc = loadAPair(readSizes[fileId], indices[fileId], EOFTags[fileId], idX, idY, dist, pairFileList[fileId], distFileList[fileId], inPairArray[fileId], inDistArray[fileId]);				

		if (suc) 
			nodeMap.insert(pair<float, DistPair>(dist,DistPair(idX,idY,fileId)));	
	}
			
	while(!nodeMap.empty())
	{				
		// get the first item in the nodeMap
		iter = nodeMap.begin();
		fileId = iter->second.fileId;        

		// write to output
		idX = iter->second.idX;
		idY =  iter->second.idY;
		dist = iter->first;

		lookAhead(idX, idY, dist);	
		// remove the current item from the nodeMap
		nodeMap.erase(iter);
			
		suc = loadAPair(readSizes[fileId], indices[fileId], EOFTags[fileId], idX, idY, dist, pairFileList[fileId], distFileList[fileId], inPairArray[fileId], inDistArray[fileId]);				

		if (suc) 
			nodeMap.insert(pair<float, DistPair>(dist,DistPair(idX,idY,fileId)));	
	}
	
	cout << "DONE!" << endl;
	cout << "current node: " << newId << "\tnum unlinked: " << totalUnlinked << endl;	

	// get root nodes and orphan nodes
	NodeSet roots;
	IDList orphanNodes;	
	TreeNode *aLeaf = 0;
     	
	for(i=0; i< numReads; ++i)
	{   
		aLeaf = leaves[i];
		if(aLeaf->parent==0)  // find nodes with no parent
			orphanNodes.push_back(i); 				
		else
			roots.insert(aLeaf->topParent); 										
	}

 	// print output to files
 	
	string clusterListName, clusterName;

	clusterListName=inFileName;
	clusterListName.append(".Cluster_List");
	clusterName=inFileName;
	clusterName.append(".Cluster");

	printClusters(roots, orphanNodes, clusterListName, clusterName, stepSize, endLevel);			
	
	// clear memory
	emptyTree(roots);	
	roots.clear();	
	orphanNodes.clear();	
	free(leaves);
	vActiveNodes.clear();
	
	// clean up
	for(fileId=0; fileId<numFiles; ++fileId) {
		free(inDistArray[fileId]);
		free(inPairArray[fileId]);
	}
	free(inDistArray);
	free(inPairArray);
	free(indices);
	free(readSizes);
	free(EOFTags);
	free(pairFileList);
	free(distFileList);	
	
	gettimeofday(&endTime, NULL);	
	long elapsedTime = (endTime.tv_sec - startTime.tv_sec) * 1000u + (endTime.tv_usec - startTime.tv_usec) / 1.e3 + 0.5;
	
	printf("totalNumPairs: %llu\n", totalNumPairs);
	printf("Time taken: %.3f s\n", elapsedTime/1.e3);
	printf("\n----------------------------------------------------------------------\n");
	return 0;
}
开发者ID:ngthuydiem,项目名称:crispy-embed,代码行数:101,代码来源:singleclust.cpp

示例14: main


//.........这里部分代码省略.........
                endLevel = lambda;
                allLoaded = true;
                cout << "new endLevel: " << endLevel << endl;
            }
        }

        if (nodeMap.empty())
            allLoaded = true;

        updateAllMin(endLevel);

        minInexactDist = *min_element(vInexactDist.begin(), vInexactDist.end());
        minExactIter = min_element(vExactDist.begin(),vExactDist.end());
        minExactDist = *minExactIter;

        //cout << "lambda_" << iteration << " = " << lambda << "\t" << lambda/2 << "\t" << minInexactDist << endl;

        while ((minExactDist < 1.0f) && (minExactDist < minInexactDist || fabs(minExactDist-minInexactDist) < EPSILON))
        {
            minExactIndex = minExactIter-vExactDist.begin();

            nodeX = vActiveNodes[minExactIndex]->topParent;
            nodeY = vExactNodes[minExactIndex]->topParent;

            merge(nodeX, nodeY, minExactDist, endLevel);
            fprintf(mergeFile, "%d %d %.6f\n", nodeX->ID+1, nodeY->ID+1, minExactDist);

            minInexactDist = *min_element(vInexactDist.begin(), vInexactDist.end());
            minExactIter = min_element(vExactDist.begin(),vExactDist.end());
            minExactDist = *minExactIter;
        }

        //cout << "cannot progress: " << newId << "\t" << totalNumEdges << "\t" << minInexactDist << "\t" << minExactDist << "\t" << minExactDist - lambda/2 << "\n";
        ++iteration;
    }

    cout << "DONE!" << endl;
    cout << "current node: " << newId << "\tnum unlinked: " << totalUnlinked << endl;

    // get root nodes and orphan nodes
    NodeSet roots;
    IDList orphanNodes;
    TreeNode *aLeaf = 0;

    for(i=0; i< numReads; ++i)
    {
        aLeaf = leaves[i];
        if(aLeaf->parent==0)  // find nodes with no parent
            orphanNodes.push_back(i);
        else
            roots.insert(aLeaf->topParent);
    }

    // print output to files

    string clusterListName, clusterName;

    clusterListName=inFileName;
    clusterListName.append(".Cluster_List");
    clusterName=inFileName;
    clusterName.append(".Cluster");

    printClusters(roots, orphanNodes, clusterListName, clusterName, endLevel);

    // clear memory
    emptyTree(roots);
    roots.clear();
    orphanNodes.clear();
    free(leaves);
    vActiveNodes.clear();
    vExactNodes.clear();
    vExactDist.clear();

    // clean up
    for(fileId=0; fileId<numFiles; ++fileId) {
        free(inDistArray[fileId]);
        free(inPairArray[fileId]);
    }
    free(inDistArray);
    free(inPairArray);
    free(indices);
    free(readSizes);
    free(EOFTags);
    free(pairFileList);
    free(distFileList);

    gettimeofday(&endTime, NULL);
    long elapsedTime = (endTime.tv_sec - startTime.tv_sec) * 1000u + (endTime.tv_usec - startTime.tv_usec) / 1.e3 + 0.5;

    if (outFile != NULL) {
        fclose(outFile);
        fclose(outFile1);
    }
    fclose(mergeFile);

    printf("totalNumPairs: %llu\n", totalNumPairs);
    printf("Time taken: %.3f s\n", elapsedTime/1.e3);
    printf("\n----------------------------------------------------------------------\n");
    return 0;
}
开发者ID:ngthuydiem,项目名称:crispy-cuda,代码行数:101,代码来源:aveclust.cpp

示例15: requisiteNodes

  void BayesBall::requisiteNodes( const DAG& dag,
                                  const NodeSet& query,
                                  const NodeSet& hardEvidence,
                                  const NodeSet& softEvidence,
                                  NodeSet& requisite ) {
    // for the moment, no node is requisite
    requisite.clear ();
    
    // create the marks (top = first and bottom = second )
    NodeProperty<std::pair<bool, bool>> marks ( dag.size() );
    const std::pair<bool, bool> empty_mark( false, false );

    // indicate that we will send the ball to all the query nodes (as children):
    // in list nodes_to_visit, the first element is the next node to send the
    // ball to and the Boolean indicates whether we shall reach it from one of
    // its children (true) or from one parent (false)
    List<std::pair<NodeId, bool>> nodes_to_visit;
    for ( const auto node : query ) {
      nodes_to_visit.insert( std::pair<NodeId, bool>( node, true ) );
    }

    // perform the bouncing ball until there is no node in the graph to send
    // the ball to
    while ( ! nodes_to_visit.empty() ) {
      // get the next node to visit
      NodeId node = nodes_to_visit.front().first;

      // if the marks of the node do not exist, create them
      if ( ! marks.exists( node ) )
        marks.insert( node, empty_mark );

      // bounce the ball toward the neighbors
      if ( nodes_to_visit.front().second ) {  // visit from a child
        nodes_to_visit.popFront();
        requisite.insert ( node );

        if ( hardEvidence.exists( node ) ) {
          continue;
        }

        if ( not marks[node].first ) {
          marks[node].first = true;  // top marked
          for ( const auto par : dag.parents( node ) ) {
            nodes_to_visit.insert( std::pair<NodeId, bool>( par, true ) );
          }
        }

        if ( not marks[node].second ) {
          marks[node].second = true;  // bottom marked
          for ( const auto chi : dag.children( node ) ) {
            nodes_to_visit.insert( std::pair<NodeId, bool>( chi, false ) );
          }
        }
      }
      else {  // visit from a parent
        nodes_to_visit.popFront();

        const bool is_hard_evidence = hardEvidence.exists( node );
        const bool is_evidence = is_hard_evidence or softEvidence.exists( node );

        if ( is_evidence && ! marks[node].first ) {
          marks[node].first = true;
          requisite.insert ( node );

          for ( const auto par : dag.parents( node ) ) {
            nodes_to_visit.insert( std::pair<NodeId, bool>( par, true ) );
          }
        }

        if ( ! is_hard_evidence && ! marks[node].second ) {
          marks[node].second = true;

          for ( const auto chi : dag.children( node ) ) {
            nodes_to_visit.insert( std::pair<NodeId, bool>( chi, false ) );
          }
        }
      }
    }
  }
开发者ID:jhonatanoliveira,项目名称:aGrUM_iSep,代码行数:79,代码来源:BayesBall.cpp


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