Exemplo n.º 1
0
//第二条线在两个点的左边,共三条线
bool PathFind::Left(const Point& first,const Point& second)
{  
	for(int i=first.Y-1;i>=0;i--)//循环Y轴(横线)
	{
		if(A[first.X][i]!=ZERO)
		{
			return false;
		}
		Point first1(first.X,i);//第一个拐点
		Point second1(second.X,i);
		if(A[second1.X][second1.Y]!=ZERO)
		{
			return false;
		}
		bool isOK=SameY(first1,second1);//同竖线 
		if(!isOK)
		{
			continue;
		} 
		isOK=SameX(second1,second);//同横线 
		if(isOK)//寻路成功
		{ 
			centerPoint.Clear();
			centerPoint.AddPoint(first1);
			centerPoint.AddPoint(second1); 
			return true;
		} 
	}
	return false;
}
Exemplo n.º 2
0
		void testCase11(){
			int arr1[] = { 0, 1, 3, 5, 9 }, arr2[] = { 2, 4, 6, 7, 8 };
			stdL<double> first1(std::begin(arr1), std::end(arr1)), second1(std::begin(arr2), std::end(arr2));
			tsL<double> first2(std::begin(arr1), std::end(arr1)), second2(std::begin(arr2), std::end(arr2));

			first1.merge(second1);
			first2.merge(second2);
			assert(TinySTL::Test::container_equal(first1, first2));
		}
Exemplo n.º 3
0
bool MOGA::dominates( const individual & i1, const individual & i2 ) const
{
	std::vector<double>::const_iterator first1( i1.obj.begin() ),
	                                    first2( i2.obj.begin() ),
	                                    last1( i1.obj.end() );

	bool result = false;
	for ( ; first1 != last1; ++first1, ++first2 )
	{
		if ( *first2 < *first1 ) return false;
		result = result || ( *first1 < *first2 );
	}
	return result;
}
Exemplo n.º 4
0
bool PathFind::Right(const Point& first,const Point& second)
{
	for(int i=first.Y+1;i<second.Y;i++)
	{
		if(A[first.X][i]!=ZERO)
		{
			return false;
		}
	}
	for(int i=second.Y;i<column;i++)
	{
		if(A[first.X][i]!=ZERO)
		{
			return false;
		}
		Point first1(first.X,i);//第一个拐点
		Point second1(second.X,i);//第二个拐点
		if(A[second1.X][second1.Y]!=ZERO)
		{
			return false;
		}
		bool isOK=SameY(first1,second1);//同竖线 
		if(!isOK)
		{
			continue;
		} 
		isOK=SameX(second1,second);//同横线 
		if(isOK)//寻路成功
		{
			//do something
			centerPoint.Clear();
			centerPoint.AddPoint(first1);
			centerPoint.AddPoint(second1); 
			return true;
		}
	}
	return false;
}
Exemplo n.º 5
0
void FCIpspace_h0tril_uhf(double *h0, double *h1e_a, double *h1e_b,
                          double *g2e_aa, double *g2e_ab, double *g2e_bb,
                          uint64_t *stra, uint64_t *strb,
                          int norb, int np)
{
        int i, j, k, pi, pj, pk, pl;
        int n1da, n1db;
        int d2 = norb * norb;
        int d3 = norb * norb * norb;
        uint64_t da, db, str1;
        double tmp;

        for (i = 0; i < np; i++) {
        for (j = 0; j < i; j++) {
                da = stra[i] ^ stra[j];
                db = strb[i] ^ strb[j];
                n1da = FCIpopcount_4(da);
                n1db = FCIpopcount_4(db);
                switch (n1da) {
                case 0: switch (n1db) {
                        case 2:
                        pi = first1(db & strb[i]);
                        pj = first1(db & strb[j]);
                        tmp = h1e_b[pi*norb+pj];
                        for (k = 0; k < norb; k++) {
                                if (stra[i] & (1ULL<<k)) {
                                        tmp += g2e_ab[pi*norb+pj+k*d3+k*d2];
                                }
                                if (strb[i] & (1ULL<<k)) {
                                        tmp += g2e_bb[pi*d3+pj*d2+k*norb+k]
                                             - g2e_bb[pi*d3+k*d2+k*norb+pj];
                                }
                        }
                        if (FCIparity(strb[j], strb[i]) > 0) {
                                h0[i*np+j] = tmp;
                        } else {
                                h0[i*np+j] = -tmp;
                        } break;

                        case 4:
                        pi = first1(db & strb[i]);
                        pj = first1(db & strb[j]);
                        pk = first1((db & strb[i]) ^ (1ULL<<pi));
                        pl = first1((db & strb[j]) ^ (1ULL<<pj));
                        str1 = strb[j] ^ (1ULL<<pi) ^ (1ULL<<pj);
                        if (FCIparity(strb[j], str1)
                           *FCIparity(str1, strb[i]) > 0) {
                                h0[i*np+j] = g2e_bb[pi*d3+pj*d2+pk*norb+pl]
                                           - g2e_bb[pi*d3+pl*d2+pk*norb+pj];
                        } else {
                                h0[i*np+j] =-g2e_bb[pi*d3+pj*d2+pk*norb+pl]
                                           + g2e_bb[pi*d3+pl*d2+pk*norb+pj];
                        } } break;
                case 2: switch (n1db) {
                        case 0:
                        pi = first1(da & stra[i]);
                        pj = first1(da & stra[j]);
                        tmp = h1e_a[pi*norb+pj];
                        for (k = 0; k < norb; k++) {
                                if (strb[i] & (1ULL<<k)) {
                                        tmp += g2e_ab[pi*d3+pj*d2+k*norb+k];
                                }
                                if (stra[i] & (1ULL<<k)) {
                                        tmp += g2e_aa[pi*d3+pj*d2+k*norb+k]
                                             - g2e_aa[pi*d3+k*d2+k*norb+pj];
                                }
                        }
                        if (FCIparity(stra[j], stra[i]) > 0) {
                                h0[i*np+j] = tmp;
                        } else {
                                h0[i*np+j] = -tmp;
                        } break;

                        case 2:
                        pi = first1(da & stra[i]);
                        pj = first1(da & stra[j]);
                        pk = first1(db & strb[i]);
                        pl = first1(db & strb[j]);
                        if (FCIparity(stra[j], stra[i])
                           *FCIparity(strb[j], strb[i]) > 0) {
                                h0[i*np+j] = g2e_ab[pi*d3+pj*d2+pk*norb+pl];
                        } else {
                                h0[i*np+j] =-g2e_ab[pi*d3+pj*d2+pk*norb+pl];
                        } } break;
                case 4: switch (n1db) {
                        case 0:
                        pi = first1(da & stra[i]);
                        pj = first1(da & stra[j]);
                        pk = first1((da & stra[i]) ^ (1ULL<<pi));
                        pl = first1((da & stra[j]) ^ (1ULL<<pj));
                        str1 = stra[j] ^ (1ULL<<pi) ^ (1ULL<<pj);
                        if (FCIparity(stra[j], str1)
                           *FCIparity(str1, stra[i]) > 0) {
                                h0[i*np+j] = g2e_aa[pi*d3+pj*d2+pk*norb+pl]
                                           - g2e_aa[pi*d3+pl*d2+pk*norb+pj];
                        } else {
                                h0[i*np+j] =-g2e_aa[pi*d3+pj*d2+pk*norb+pl]
                                           + g2e_aa[pi*d3+pl*d2+pk*norb+pj];
                        }
                        } break;
                }
        } }
}