Пример #1
0
num PComplex<C,BT>::makeFromComplex(const Complex<C,BT>& topers, bool truncate = false)
{
	Cell<C,BT>* curcell; // cell from complex topers
	PCell<C,BT>* percell; // persistent cell, to be made

	PCMAP corr; // correspondence between cell and persistent cell


	// loop over the complex: this requires iterators
	typename COMPLEX::const_iterator cit;
	FRAME* curf;
	typename FRAME::const_iterator fit;
	CLIST* curl;
	typename CLIST::const_iterator lit;

    num topdim = topers.getTopDim().first;
    if (topdim == 0) truncate = false;

	// loop over all frames
	for (cit = topers.clist.begin(); cit != topers.clist.end(); ++cit)
	{
		curf = cit->second; // extract current frame
		// loop over current frame
		for (fit = curf->begin(); fit != curf->end(); ++fit)
		{
			curl = fit->second; //extract current list
			// finally, loop over list
			for (lit = curl->begin(); lit != curl->end(); ++lit)
			{
				curcell = *lit; // extract current cell
				if (curcell == NULL) continue; // check nullity
				if (!(curcell->isIn))
				{
				    cout<<" \n wtf, cell missing??? : "<<*curcell;
				    cin.get();
				    continue; // and removedness
				}
				// check truncation! if cell has max dim...
				if (truncate && curcell->getDim() == topdim)
				{
				    // and empty boundary...
				    if (curcell->getBD().size()==0)
				    continue; // then ignore it.
				}

				// okay, use cell to make percell
				percell = new PCell<C,BT>;
				percell->makeFromCell(curcell);
				corr[curcell] = percell;
				klist.push_back(percell);
				percell->kindex = klist.size()-1;
				//cout<<"\n made "<<*percell<<" from "<<*curcell;
			}
		}
	}
	PCVEC(klist).swap(klist);
	makeBDChains(corr);
	return klist.size();
}
Пример #2
0
void PComplex<C,BT>::initPersData(const Complex<C,BT>& other)
{
	// first we initialize our interval and betti number structures:
	ints.clear();
	betti.clear();	// betti numbers, for each birth-stage

	// initialize persistence intervals
	for (num dim = 0; dim <= other.getTopDim().first; dim++)
	{
		//cout<<"ints vec populated to: "<<this->getTopDim().first;
		ints[dim] = new INTVEC;
	}

	// initialize betti number junk
	typename COMPLEX::const_iterator i;
	for(i=other.clist.begin(); i != other.clist.end() ; ++i)
	{
		// for this frame, create betti numbers initialized to 0
		//cout<<"\nmade betti ptr for "<<i->first;
		betti[i->first] = new vector<BT>;
		betti[i->first]->insert(betti[i->first]->begin(),other.getTopDim().first + 1, 0);   // fill with zeros for now
	}
}