예제 #1
0
파일: Grid.cpp 프로젝트: Dopelust/SP4-10
void Grid::PopulateCells(Entity* ent)
{
	BoxCollider* box = ent->GetComponent<BoxCollider>();

	if (box)
	{
		box->cell = cell;

		box->part.clear();
		
		Vector3 min = box->GetMinCoord();
		Vector3 max = box->GetMaxCoord();

		min.x /= GridWidth;
		min.x *= NumberOfPartitionsX;

		max.x /= GridWidth;
		max.x *= NumberOfPartitionsX;

		min.y /= GridHeight;
		min.y *= NumberOfPartitionsY;

		max.y /= GridHeight;
		max.y *= NumberOfPartitionsY;


		for (int i = min.x; i <= max.x; ++i)
			for (int j = min.y; j <= max.y; ++j)
			{
				Partition* c = GetPartition(i, j);

				if (c)
				{
					c->Add(ent);
					box->part.push_back(c);
				}
			}
	}

	for (auto &child : ent->GetChildren())
	{
		if (child->IsActive())
			PopulateCells(child);
	}
}
예제 #2
0
void main(void) {
	
	int n, k, r;

	//ofstream data_file;
	//data_file.open("Answer5.txt");
	n = 4;
	for(k = 2; k <= n-2; k++) {

	
	
	// We first loop through all partitions of n
	list<Partition> pars;
	pars = Par(n);

	// for latter use
	list<RankSet> ranks;
	ranks = ComputeRanks(n, k);
	for(list<Partition>::iterator lambda = pars.begin(); lambda != pars.end(); ++lambda) {
		
		Partition theta;
		for(int junk = 1; junk <= (*lambda).Size(); junk++) {
			theta.Add(1);
		}
		tableau t = standard(*lambda, theta);
		
		
		list<Perm> colgroup = C(t);
		list<Perm> rowgroup = R(t);
		vector<Perm> YS;
		vector<int> signs;
		int YSl = 0;
		// we scroll through col * sign and the row
		for(list<Perm>::iterator sigma = colgroup.begin(); sigma != colgroup.end(); ++sigma) {
			for (list<Perm>::iterator tau = rowgroup.begin(); tau != rowgroup.end(); ++tau) {
				YS.push_back((*sigma) * (*tau));
				signs.push_back(sign(*sigma));
				YSl++;
			}
		}


		vector<Matrix> MatList(n-1);
		vector<bool> exists(n-1);
		for(int o = 0; o < n-1; o++) {
			exists[o] = false;
		}
		// Now we loop through all possible ranks-sets
		// Answers store our multiplicity calculations
		vector<int> Answers(n-1);
		// Before we begin we need to get all possible SSYT to create an ordered basis
		vector<RankSet> images;
		for(list<RankSet>::const_iterator tempiter = ranks.begin(); tempiter != ranks.end(); ++tempiter) {
			images.push_back(*tempiter);
		}
		// get a list  of SSYT
		// where each element of the list is a SSYT 
		// of each possible image
		
		vector<chain> posschains;
		for(vector<RankSet>::iterator image = images.begin(); image != images.end(); ++image) {
			list<tableau> temptablist = SSYT(*lambda, *image);
			
			if(temptablist.size() != 0) {
				// convert each tableau to a chain
				list<chain> tempchainlist;
				for(list<tableau>::const_iterator tabby = temptablist.begin(); tabby != temptablist.end(); ++tabby) {
					Partition gamma2;
					for (RankSet::const_iterator iter = (*image).begin(); iter != (*image).end(); ++iter) {
						gamma2.Add(*iter);
					}
					tabloid tempoid;
					tempoid = TableauToTabloid(*tabby, gamma2);
					chain c = ConvertFromTabloid(tempoid);
					posschains.push_back(c);
				}
			}
		}
		// So now posschains contains all possible image chains
			// this stores the dimension of the range
		int rangedim = posschains.size();
		// for each possible image chain, apply the 
		// Young symmetrizer. We will get a result of type basis.
		vector<basis> vecofimages;
		for(vector<chain>::const_iterator c = posschains.begin(); c != posschains.end(); ++c) {
			vecofimages.push_back(e(YS, signs, YSl,  *c));
		}
		//vecofimages now contains all the symmetrized images.
		for(list<RankSet>::iterator u = ranks.begin(); u != ranks.end(); ++u) {
			// We need to get possible ranges of u

			list<tableau> tableaulist = SSYT(*lambda, *u);
			// convert to chains
			list<chain> domain;
			
			Partition gamma;
			for (RankSet::const_iterator iter = (*u).begin(); iter != (*u).end(); ++iter) {
				gamma.Add(*iter);
			}

			for(list<tableau>::const_iterator tabby = tableaulist.begin(); tabby != tableaulist.end(); ++tabby) {				
				domain.push_back(ConvertFromTabloid(TableauToTabloid(*tabby, gamma)));
			}
			
			// So now domain contains all chains which we need to compute the image of
			// Now get all images of *u
			//Test code:
		


			

			// for each chain in the domain apply delta
			vector<basis> domainchains;
			list<chain>::iterator c1;
			for(c1 = domain.begin(); c1 != domain.end(); ++c1) {
				domainchains.push_back(Delta(k, *c1));
			}

			// then apply the Young symmetrizer of shape lambda
			// and standard to the images of delta
			vector<basis> Answer;
			vector<basis>::const_iterator X;
			for(X = domainchains.begin(); X != domainchains.end(); ++X) {
				Answer.push_back(e(YS, signs, YSl,  *X));
			}
			
			// then get the projection of our result onto each 
			// possible image
			if(rangedim == 0) {
				Answers[(*u).size()-2] = Answers[(*u).size()-2] + domainchains.size();
	//			cout << "\nWith lambda = " << *lambda;
	//			cout << "\nAnd u = " << *u;
	//			cout << "We add nullity " << domainchains.size();
	//			cout << "\nPress any key to continue";
	//			char ch = getchar(); 
				
			}
			else {
				Matrix Mat = MatList[(*u).size()-2];
				int newrow = Mat.col() + 1;
				for(int count = newrow; count < newrow + Answer.size(); count++) {
					// store this as a column in our matrix.
					vector<double> tempvec = project(Answer[count-newrow], vecofimages);
					Mat.ColumnSet(count, tempvec);
				}
				
				MatList[(*u).size() - 2] = Mat;
				exists[(*u).size()-2] = true;
			}
		}
		for(r = 0; r <= n-2; r++) {
//			cout << "\nWith lambda = " << *lambda;
//			cout << "\nand r = " << r;
//			cout << "\nWe get the matrix" << MatList[r];
//			cout << "With nullity = " << MatList[r].Nullity();
//			cout << " and rank = " << MatList[r].Rank();
//			cout << "\nOther contributions give " << Answers[r];
			// we adjust the multiplicity vector
			if (exists[r]) {
				Answers[r] += MatList[r].Nullity();
				Answers[r-1] -= MatList[r].Rank();
			}
//			
		
		}
		for(r = 0; r <= n-2; r++) {
			cout << "\nThe multiplicity of ";
			cout << (*lambda);
			cout << " in H" << r << " is: " << Answers[r];
			cout << endl;
		}
		cout << "\nPress any key to continue";
		char ch = getchar();
	}

	}

	
//	data_file.close();	
}
예제 #3
0
void main(void) {
	cout << "\nTesting blank constructor";
	tabloid t;

	cout << "\nTesting constructor of a tabloid of shape 311";
	Partition lambda;
	lambda.Add(3);
	lambda.Add(2);
	lambda.Add(1);
	tabloid s(lambda);
	
	cout << "\nGetting the standard tabloid of shape 311";
	s = standardoid(lambda);

	cout << "\nTesting output";
	cout << s;

	cout << "\nTesting Sn action";
	Perm sigma(6);
	sigma[1]=6;
	sigma[2]=3;
	sigma[3]=1;
	sigma[4]=2;
	sigma[5]=5;
	sigma[6]=4;
		cout << "\nApplying ";
	    cout << sigma;
		cout << sigma * s;

	
	cout << "\nNote that ";
	cout << s;
	cout << " has " << s.RowNumber() << " of rows";

	cout << " and the second row is \n";
	rows temp = s.Row(2);
	for (rows::const_iterator iter2 = temp.begin(); iter2 != temp.end(); ++iter2) {
		cout << " " << *iter2;
	}


// reorder the rows of a tabloid Note it no longer have the shape of a paritition

	Perm tau(3);
	tau[1]=2;
	tau[2]=3;
	tau[3]=1;
	
	cout << "\nReordering rows of ";
	cout << s;
	cout << " with ";
	cout << tau;
	tabloid q = reorderrows(tau, s);
	cout << q;

//	void insert(const vector<int> row);
	cout << "\nNow we insert a row of 7, 8, 9";
	vector<int> rowtemp;
	rowtemp.push_back(7);
	rowtemp.push_back(8);
	rowtemp.push_back(9);
	q.insert(rowtemp);
	cout << q;

//	void Add(const int row, const int value);
	cout << "\nNow we add a 10 to row 2";
	q.Add(2,10);
	cout << q;
	int crap;
	cin >> crap;
}