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


C++ set::IsInSet方法代码示例

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


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

示例1: sfexcl_split

REALNUM_TYPE dataset::sfexcl_split(set &seed, UNSIGNED_2B_TYPE Mode, REALNUM_TYPE f, bool ifForceDistCalc, UNSIGNED_1B_TYPE toTest, UNSIGNED_1B_TYPE toTrain, UNSIGNED_1B_TYPE nSeed, REALNUM_TYPE Kmetric)
//sphere exclusion implementation with some extra features added to the basic published version
//ref: Golbraikhm A, Tropsha A et al, J Comp-Aid Mol Design 2003, 17: 241-253
//There are two ways of calculating sphere's radius R:
//1) R =  f*(V/N)^1/k, where f is interpreted as Dissimilarity [0.2 .. 5.2]; 
//2) R =  mind.dist + f(max.dist- min.dist), where f should be varied [0 .. 0.25]
//
//Parameters:
//Mode				see the header-file
//seed				is the set of user-supplied points for seeding, nSeed - number of points to be seeded randomly in addition to that
//toTest, toTrain	#points from the sphere that are placed, respectively, into test and training set, 
//					which is done alternatingly (toTrain #points to training set, then toTest #points to test set, and repeated)
{
	UNSIGNED_4B_TYPE C, N = patt.RowNO(), D = patt.ColNO();
	SIGNED_4B_TYPE Z, Z1, el, el1;
	REALNUM_TYPE R, mnD, rtD;

	if ((N < 2) || (D < 2)) return 0;
	if ( (N != dist.ColNO()) || (!dist.IsSquare()) || ifForceDistCalc )
	{//!may be affected by changed metric-function
		if (Mode & SFEXCL_METRIC_COSINE)
			calc_dist(0, Kmetric, 1); //cosine-metric
		else
			if (Mode & SFEXCL_METRIC_CORR)
				calc_dist(0, Kmetric, 2); //similar to cosine-metric, but mean-centered
			else
				if (Mode & SFEXCL_METRIC_TANIMOTO)
					calc_dist(0, Kmetric, 3); //Tanimoto, though strange to apply it to non-discrete data : )
				else
					calc_dist(0, Kmetric, 0); //Euclidean-like
	}

	//----------------------
	//prepare seeding set
	if (nSeed)
	{
		if ((Mode & SFEXCL_SEED_BYACTS) == SFEXCL_SEED_BYACTS)	
			rand_split((UNSIGNED_4B_TYPE)nSeed, nSeed); 
		else 
			rand_split((UNSIGNED_4B_TYPE)nSeed, 1);
		seed |= test;
	}

	if ((Mode & SFEXCL_SEED_MINACT) == SFEXCL_SEED_MINACT)
	{
		C = 0;
		while (++C < N) if (act[sact[C]] > act[sact[0]]) break;
		Z = GetRandomNumber(C);
		seed.PutInSet(sact[Z]);
	}

	if ((Mode & SFEXCL_SEED_MAXACT) == SFEXCL_SEED_MAXACT)
	{
		C = 1;
		while (++C < N) if (act[sact[N-C]] < act[sact[N-1]]) break;
		Z = GetRandomNumber(--C) + 1;
		seed.PutInSet(sact[N - Z]);
	}

	if ((Mode & SFEXCL_R_BYDIST) == SFEXCL_R_BYDIST)
		R = f * (distAv - distMin) + distMin; //distMax is too big to use effectively!
	else
	{
		if ((Mode & SFEXCL_R_BYUSER) == SFEXCL_R_BYUSER) 
			R = f;
		else
		{//default
			REALNUM_TYPE l, h, V = 1;
			for (C = 0; C < D; C++)
			{//calculate volume of the descriptors' space
				patt.GetColScale(C, C, l, h);
				V *= pow(h - l, 1.0/D);
			}
			V /= pow(N, 1.0/D);
			R = f * V;
		}
	}

	if (R < distMin) R = distMin;
	
	//----------------------
	//prepare R-neiborhood-subsets to speed up splitting
	lneib Rneibs(N);
	for (C = 0; C < N - 1; C++)
	for (Z = C + 1; Z < SIGNED_4B_TYPE(N); Z++)
		if (dist(C, Z) < R)
		{
			Rneibs[C].PutInSet(Z);
			Rneibs[Z].PutInSet(C);
		}
	//----------------------
	test.Dump();
	train = seed;
	C = train.Size();
	SIGNED_4B_TYPE nspnts = 0;
	apvector<SIGNED_4B_TYPE> pnts_i(N), pnts(N - C), spnts(N), vecRneibs;
	for (Z1 = Z = 0; Z < SIGNED_4B_TYPE(N); Z++)
	{
		if (seed.IsInSet(Z)) continue;
		pnts[Z1++] = Z;
//.........这里部分代码省略.........
开发者ID:sedykh,项目名称:datasplit,代码行数:101,代码来源:dataset.cpp


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