コード例 #1
0
ファイル: GLCM.cpp プロジェクト: thacdtd/PGLCM
void GLCM::Print_An_Itemset(ItemSet IS)
{
	list<ItemSet>::iterator it;
	cout << " [";
	for (int i = 0; i < IS.size(); i++)
	{
		if ((IS.getItemAt(i) % 2) == 0) cout << IS.getItemAt(i)/2 +1 << "+";
					else cout << IS.getItemAt(i)/2 +1 << "-";
	}
	cout << "]" << endl;
}
コード例 #2
0
ファイル: GLCM.cpp プロジェクト: thacdtd/PGLCM
void GLCM::dumpItemset(std::ostream &os, ItemSet itemset, int freq){

	//os << "[ ";
	for (int i = 0 ; i < itemset.size() ; i++)
	{
		if ((itemset.getItemAt(i) % 2) == 0) os << itemset.getItemAt(i)/2 +1 << "+ ";
		else os << itemset.getItemAt(i)/2 +1 << "- ";
	}
	//os << "] ";
	os<<" ("<<freq<<")\n";
}
コード例 #3
0
ファイル: GLCM.cpp プロジェクト: thacdtd/PGLCM
void GLCM::calG(ItemSet is, const vector<BinaryMatrix *> & vBM, BinaryMatrix& res)
{
	int isSize = is.size();
	if (isSize == 0)
        return;

    res = *vBM[is.getItemAt(0)];

	for (int i = 1; i < isSize; i++)
        res &= *vBM[is.getItemAt(i)];
}
コード例 #4
0
ファイル: GLCM.cpp プロジェクト: thacdtd/PGLCM
void GLCM::Print_All_Closed_Pattern()
{
	list<ItemSet>::iterator it;
	cout << "Print all Closed Item set" << endl;
	for (it = ClosedItemSetList.begin (); it != ClosedItemSetList.end (); it++)
	{
		ItemSet itSet = *it;
		for (int i = 0 ; i < itSet.size() ; i++)
		{
			if ((itSet.getItemAt(i) % 2) == 0) cout << itSet.getItemAt(i)/2 +1 << "+ ";
			else cout << itSet.getItemAt(i)/2 +1 << "- ";
		}
		cout << endl;
	}
}
コード例 #5
0
ファイル: GLCM.cpp プロジェクト: thacdtd/PGLCM
void GLCM::write_to_file(string freType)//const char * filename
{
	TimeTracker tt2;
	tt2.Start();
	//print to file
	string st = "OUT/out";
	time_t tim=time(NULL);
	tm *now=localtime(&tim);
	stringstream ssm,ssd,ssh,ssmi,sss;//create a stringstream
	ssm << now->tm_mon + 1;//add number to the stream
	ssd << now->tm_mday;
	ssh << now->tm_hour;
	ssmi << now->tm_min;
	sss << now->tm_sec;
	st = st + ssm.str() + ssd.str() + ssh.str() + ssmi.str() + sss.str();

	char * filename = (char*) st.c_str();

	ofstream outf(filename);
	outf << ClosedItemSetList.size() <<" closed gradual frequent Item sets" << endl;

	list<ItemSet>::iterator it;
	for (it = ClosedItemSetList.begin (); it != ClosedItemSetList.end (); it++)
	{
		outf << "[ ";
		ItemSet itSet = *it;
		for (int i = 0 ; i < itSet.size() ; i++)
		{
			if ((itSet.getItemAt(i) % 2) == 0) outf << itSet.getItemAt(i)/2 +1 << "+ ";
			else outf << itSet.getItemAt(i)/2 +1 << "- ";
		}
		outf << "]" << endl;
	}

	outf.close();
	cout << "All Item sets have been written to file: " << st << endl;

	double ts2 = tt2.Stop();
	cout << endl << "Writing took " << setw(5) << ts2 << " sec" << endl;

	ostringstream ost1;
	ost1 << getpid ();
	string cmd1="ps -p "+ost1.str ()+" -o rss";
	cout << "Memory usage at writing step: " << endl;
	//system(cmd1.c_str());
	cout << endl;
}