Exemple #1
0
int main()
{
    {
        std::istringstream inf1("abc");
        std::istringstream inf2("def");
        std::istreambuf_iterator<char> i1(inf1);
        std::istreambuf_iterator<char> i2(inf2);
        std::istreambuf_iterator<char> i3;
        std::istreambuf_iterator<char> i4;

        assert( (i1 == i1));
        assert( (i1 == i2));
        assert(!(i1 == i3));
        assert(!(i1 == i4));

        assert( (i2 == i1));
        assert( (i2 == i2));
        assert(!(i2 == i3));
        assert(!(i2 == i4));

        assert(!(i3 == i1));
        assert(!(i3 == i2));
        assert( (i3 == i3));
        assert( (i3 == i4));

        assert(!(i4 == i1));
        assert(!(i4 == i2));
        assert( (i4 == i3));
        assert( (i4 == i4));
    }
    {
        std::wistringstream inf1(L"abc");
        std::wistringstream inf2(L"def");
        std::istreambuf_iterator<wchar_t> i1(inf1);
        std::istreambuf_iterator<wchar_t> i2(inf2);
        std::istreambuf_iterator<wchar_t> i3;
        std::istreambuf_iterator<wchar_t> i4;

        assert( (i1 == i1));
        assert( (i1 == i2));
        assert(!(i1 == i3));
        assert(!(i1 == i4));

        assert( (i2 == i1));
        assert( (i2 == i2));
        assert(!(i2 == i3));
        assert(!(i2 == i4));

        assert(!(i3 == i1));
        assert(!(i3 == i2));
        assert( (i3 == i3));
        assert( (i3 == i4));

        assert(!(i4 == i1));
        assert(!(i4 == i2));
        assert( (i4 == i3));
        assert( (i4 == i4));
    }
}
Exemple #2
0
int main()
{
    std::istringstream inf1(" 1 23");
    std::istringstream inf2(" 1 23");
    std::istream_iterator<int> i1(inf1);
    std::istream_iterator<int> i2(inf1);
    std::istream_iterator<int> i3(inf2);
    std::istream_iterator<int> i4;
    std::istream_iterator<int> i5;
    assert(i1 == i1);
    assert(i1 == i2);
    assert(i1 != i3);
    assert(i1 != i4);
    assert(i1 != i5);

    assert(i2 == i2);
    assert(i2 != i3);
    assert(i2 != i4);
    assert(i2 != i5);

    assert(i3 == i3);
    assert(i3 != i4);
    assert(i3 != i5);

    assert(i4 == i4);
    assert(i4 == i5);
}
Inf1 mergeTree(int treetype, Data *d, string fs,long testmax,long hcsteps, double corfactor,double betamod,vector<double> bvec,
	       int datainference,int modeltype, State *startstate, Data *dlength, bool havefullxmlinput,bool fixK,int treescale,bool verbose) {
	if(verbose) cout<<"MERGE PHASE"<<endl;

	FsXml *infile=new FsXml(fs);
//	InfExtract iext(d,infile,verbose);
//	delete(infile);
//	infile=new FsXml(fs);
	Inf1 * inf1_i=NULL;
	InfExtract2 * iext2=NULL;
	InfMCMC * infHillClimb=NULL;
	State * state2;
	if(havefullxmlinput){
		iext2=new InfExtract2(d,infile,bvec,1.0,betamod,corfactor,verbose,dlength,datainference,modeltype);
		if(treetype==TREETYPE_USEOBSSTATE){
			state2=new State(iext2->getState());
			inf1_i=new Inf1(d,iext2->getState(),dlength,datainference,verbose,testmax,treescale);
		}else if(treetype==TREETYPE_USEMERGESTATE) {
			inf1_i=new Inf1(d,iext2->getState(),dlength,datainference,verbose,testmax,treescale);
			try{inf1_i->mergeHillClimb(NULL,true,false);}catch(std::string x){cout<<x<<endl;exit(0);}
			state2=new State(inf1_i->getState());

		}else if(treetype==TREETYPE_USEHILLCLIMBSTATE) {
			try{infHillClimb=new InfMCMC(d,iext2->getState(),dlength,datainference,0,verbose);
			//infHillClimb->hillClimb(0,opt().burnin);
			if(fixK)  infHillClimb->fixK();
			infHillClimb->metropolis(0,hcsteps);
			state2=new State(infHillClimb->getState());
			}catch(std::string x){cout<<x<<endl;exit(0);}
		}else {cerr<<"Invalid tree type (-T option): "<<treetype<<endl;exit(0);}
		delete(infile);
	}else {
		if(treetype==TREETYPE_USEOBSSTATE){
			inf1_i=new Inf1(d,startstate,dlength,datainference,verbose,testmax,treescale);
			state2=new State(startstate);
		}else if(treetype==TREETYPE_USEMERGESTATE) {
			inf1_i=new Inf1(d,startstate,dlength,datainference,verbose,testmax,treescale);
			try{inf1_i->mergeHillClimb(NULL,true,false);}catch(std::string x){cout<<x<<endl;exit(0);}
			state2=new State(inf1_i->getState());

		}else if(treetype==TREETYPE_USEHILLCLIMBSTATE){
			try{infHillClimb=new InfMCMC(d,startstate,dlength,datainference,0,verbose);
			infHillClimb->hillClimb(0,hcsteps);
			state2=new State(infHillClimb->getState());
			}catch(std::string x){cout<<x<<endl;exit(0);}
		}else {cerr<<"Invalid tree type (-t option)."<<endl;exit(0);}
	};
	//	state2->iterPrint(&cout);
	Inf1 inf1(d,state2,dlength,datainference,verbose,testmax,treescale);
	//	inf1.getState()->iterPrint(&cout);
	return(inf1);
/*	inf1.exportXmlHead(&os);
	inf1.exportXmlComment(&os,comment);
	try{inf1.mergeHillClimb(NULL,false,treesuper);}catch(std::string x){cout<<x<<endl;exit(0);}
	if(opt().verbose) cout<<"Assigning certainty"<<endl;
	infile=new FsXml(fs);
	InfExtract3 iext3(d,infile,inf1.getNodes(),opt().verbose);
	delete(infile);
	if(opt().verbose) cout<<"Diagonalise tree"<<endl;
	inf1.diagonaliseOnM(d->getMatrix(),false);
*/
}