コード例 #1
0
int NeroMonteCarlo::analyze(const edm::Event& iEvent){

    if ( iEvent.isRealData() ) return 0;
    isRealData = iEvent.isRealData() ? 1 : 0 ; // private, not the one in the tree

    TStopwatch sw;
    if(VERBOSE)sw.Start();
    // maybe handle should be taken before
    iEvent.getByToken(info_token, info_handle);
    iEvent.getByToken(packed_token, packed_handle);
    iEvent.getByToken(pruned_token, pruned_handle);
    iEvent.getByToken(pu_token, pu_handle);
    iEvent.getByToken(jet_token, jet_handle);

    if ( not info_handle.isValid() ) cout<<"[NeroMonteCarlo]::[analyze]::[ERROR] info_handle is not valid"<<endl;
    if ( not packed_handle.isValid() ) cout<<"[NeroMonteCarlo]::[analyze]::[ERROR] packed_handle is not valid"<<endl;
    if ( not pruned_handle.isValid() ) cout<<"[NeroMonteCarlo]::[analyze]::[ERROR] pruned_handle is not valid"<<endl;
    if ( not pu_handle.isValid() ) cout<<"[NeroMonteCarlo]::[analyze]::[ERROR] pu_handle is not valid"<<endl;
    if ( not jet_handle.isValid() ) cout<<"[NeroMonteCarlo]::[analyze]::[ERROR] jet_handle is not valid"<<endl;

    if(VERBOSE){ sw.Stop() ; cout<<"[NeroMonteCarlo]::[analyze] getToken took "<<sw.CpuTime()<<" Cpu and "<<sw.RealTime()<<" RealTime"<<endl; sw.Reset(); sw.Start();}
    // INFO
    if(VERBOSE>1) cout<<"[NeroMonteCarlo]::[analyze]::[DEBUG] mcWeight="<<endl;
    mcWeight = info_handle -> weight();
    if(VERBOSE>1) cout<<"                                     mcWeight="<<mcWeight<<endl;
    //weights() 
    //---  scale
    if ( info_handle -> weights()  .size() >= 9){
        r1f2 = info_handle -> weights() [1] ;   
        r1f5 = info_handle -> weights() [2] ;   
        r2f1 = info_handle -> weights() [3] ;   
        r2f2 = info_handle -> weights() [4] ;   
        r5f1 = info_handle -> weights() [6] ;    
        r5f5 = info_handle -> weights() [8] ;     
    }

    if (info_handle -> weights().size() > 109)
        for( int pdfw = 9 ; pdfw<109 ;++pdfw)
        {
        pdfRwgt -> push_back( info_handle -> weights() [pdfw] );    
        }
    // --- fill pdf Weights
    //
    if(VERBOSE>1) cout<<"[NeroMonteCarlo]::[analyze]::[DEBUG] PDF="<<endl;
    if ( mParticleGun ) {
        qScale   = -999 ;
        alphaQED = -999 ;
        alphaQCD = -999 ;
        x1       = -999 ;
        x2       = -999 ;
        pdf1Id   = -999 ;
        pdf2Id   = -999 ;
        scalePdf = -999 ;
    }
    else {
        qScale   = info_handle -> qScale();
        alphaQED = info_handle -> alphaQED();
        alphaQCD = info_handle -> alphaQCD();
        x1       = info_handle -> pdf() -> x.first;
        x2       = info_handle -> pdf() -> x.second;
        pdf1Id   = info_handle -> pdf() -> id.first;
        pdf2Id   = info_handle -> pdf() -> id.second;
        scalePdf = info_handle -> pdf() -> scalePDF;
    }
    if(VERBOSE>1) cout<<"                                     PDF="<<qScale<<" "<< alphaQED<<endl;

    //PU
    if(VERBOSE>1){ cout<<endl<<"[NeroMonteCarlo]::[analyze] PU LOOP"<<endl;}
    puTrueInt = 0;
    for(const auto & pu : *pu_handle)
    {
        //Intime
        if (pu.getBunchCrossing() == 0)
            puTrueInt += pu.getTrueNumInteractions();
        //puInt += getPU_NumInteractions(); //old
        //Out-of-time
    }

    if(VERBOSE){ sw.Stop() ; cout<<"[NeroMonteCarlo]::[analyze] pu&info took "<<sw.CpuTime()<<" Cpu and "<<sw.RealTime()<<" RealTime"<<endl; sw.Reset(); sw.Start();}
    // GEN PARTICLES
    //TLorentzVector genmet(0,0,0,0);
    //for ( auto & gen : *packed_handle)
    for ( unsigned int i=0;i < packed_handle->size() ;++i)
    {
        const auto gen  = & (*packed_handle)[i];
        if (gen->pt()  < 5 ) continue;
        if (gen->pt() < mMinGenParticlePt ) continue;
        int pdg = gen->pdgId();
        int apdg = abs(pdg);

        //neutrinos
        // --- if ( (apdg != 12 and apdg !=14 and apdg != 16
        // ---       and apdg > 1000000  neutrinos and neutralinos
        // ---      )//SUSY
        // ---         and fabs(gen->eta() ) <4.7 
        // ---    )
        // --- { 
        // ---     TLorentzVector tmp( gen->px(),gen->py(),gen->pz(),gen->energy() ); 
        // ---     genmet += tmp;
        // --- }
        // --- genmet = -genmet;


        //FILL
        //    e mu photons
        if ( apdg == 11 or apdg == 13 or apdg == 22  // e - mu - gamma
                or (apdg >=12 and apdg<=16) // neutrinos
                or apdg > 1000000  // susy neutrinos and neutralinos
            )
        {
            new ( (*p4)[p4->GetEntriesFast()]) TLorentzVector(gen->px(), gen->py(), gen->pz(), gen->energy());
            pdgId -> push_back( pdg );
            flags -> push_back( ComputeFlags( *gen ) );
            // compute ISOLATION
            float iso=0;
            float isoFx=0;

            if (apdg == 22 or apdg ==11 or apdg ==13)
            {

                    TLorentzVector g1(gen->px(),gen->py(),gen->pz(),gen->energy());
                    vector< pair<float,float> > inIsoFx ; //isoFx, dR, pT
                    for ( unsigned int j=0;j < packed_handle->size() ;++j)
                    {
                        if (i==j) continue;
                        const auto gen2  = & (*packed_handle)[j];
                        if ( gen2->pt() ==0 ) continue;
                        if (gen2->pz() > 10e8 ) continue; // inf
                        TLorentzVector g2(gen2->px(),gen2->py(),gen2->pz(),gen2->energy());
                        if (g2.DeltaR(g1) <0.4){
                            iso += g2.Pt();
                            // isoFx containes the epsilon 
                            inIsoFx.push_back( pair<float,float>(g2.DeltaR(g1) ,g2.Pt() ) );
                         }
                    }

                    if (apdg==22){ // ONLY for photon Frixione isolation
                        sort(inIsoFx.begin(), inIsoFx.end() );  // sort in DR, first entry

                        float sumEtFx=0;
                        for( const auto & p : inIsoFx )
                        {
                               const float& pt= p.second ;
                               const float& delta = p.first;
                               sumEtFx += pt / gen->pt(); // relative iso
                               if (delta == 0 ) continue; // guard
                               float isoCandidate = sumEtFx * TMath::Power(  (1. - TMath::Cos(0.4) ) / (1. - TMath::Cos(delta ) ), 2) ;// n=2
                               if (isoFx < isoCandidate) isoFx = isoCandidate;
                        }
                    }
            
            }
            genIso -> push_back(iso);
            genIsoFrixione -> push_back(isoFx);
            // computed dressed objects
            //

            if (apdg == 11 or apdg == 13) { // only for final state muons and electrons
                    TLorentzVector dressedLepton(gen->px(),gen->py(),gen->pz(),gen->energy());
                    TLorentzVector lepton(dressedLepton); //original lepton for dR
                    for ( unsigned int j=0;j < packed_handle->size() ;++j)
                    {
                        const auto gen2  = & (*packed_handle)[j];
                        TLorentzVector photon(gen2->px(),gen2->py(),gen2->pz(),gen2->energy());
                        if (i != j and abs( gen->pdgId() ) ==22  and lepton.DeltaR( photon ) <0.1 ) dressedLepton += photon;
                    }
                    new ( (*p4)[p4->GetEntriesFast()]) TLorentzVector( dressedLepton );
                    pdgId -> push_back( pdg );
                    flags -> push_back( Dressed );
                    genIso -> push_back (0.) ;
                    genIsoFrixione -> push_back (0.) ;
                    // --- end of dressing
            }
             
        }

    } //end packed


    if(VERBOSE){ sw.Stop() ; cout<<"[NeroMonteCarlo]::[analyze] packed took "<<sw.CpuTime()<<" Cpu and "<<sw.RealTime()<<" RealTime"<<endl; sw.Reset(); sw.Start();}
    // LOOP over PRUNED PARTICLES
    //for (auto & gen : *pruned_handle)
    for (unsigned int i=0;i<pruned_handle->size() ;++i)
    {
        const auto gen = &(*pruned_handle)[i];
        if (gen->pt()  < 5 ) continue;
        if (gen->pt()  < mMinGenParticlePt ) continue;
        int pdg = gen->pdgId();
        int apdg = abs(pdg);
        if (gen->status() == 1) continue; //packed

        unsigned flag = ComputeFlags(*gen);

    
        if ( apdg == 15 or  // tau (15)
                (apdg >= 23 and apdg <26 ) or   // Z(23) W(24) H(25)
                apdg == 37 or // chHiggs: H+(37)
                apdg <= 6 or // quarks up (2) down (1)  charm (4) strange (3) top (6) bottom (5)
                apdg == 21 or // gluons (21)
                apdg > 1000000 // susy neutrinos,neutralinos, charginos ...  lightest neutralinos (1000022)
                or ( apdg == 11 and  ( flag &  HardProcessBeforeFSR) )
                or ( apdg == 11 and  ( flag &  HardProcess) )
                or ( apdg == 13 and  ( flag &  HardProcessBeforeFSR) )
                or ( apdg == 13 and  ( flag &  HardProcess) )
                )
        {
            new ( (*p4)[p4->GetEntriesFast()]) TLorentzVector(gen->px(), gen->py(), gen->pz(), gen->energy());
            pdgId -> push_back( pdg );
            flags -> push_back( flag );
            genIso -> push_back (0.) ;
            genIsoFrixione -> push_back (0.) ;
        }
    }

    if(VERBOSE){ sw.Stop() ; cout<<"[NeroMonteCarlo]::[analyze] pruned took "<<sw.CpuTime()<<" Cpu and "<<sw.RealTime()<<" RealTime"<<endl; sw.Reset(); sw.Start();}
    // GEN JETS
    for (const auto & j : *jet_handle)
    {
        if (j.pt() < 20 ) continue;
        if (j.pt() < mMinGenJetPt ) continue;
        // --- FILL
        new ( (*jetP4)[jetP4->GetEntriesFast()]) TLorentzVector(j.px(), j.py(), j.pz(), j.energy());
    }
    if(VERBOSE){ sw.Stop() ; cout<<"[NeroMonteCarlo]::[analyze] jets took "<<sw.CpuTime()<<" Cpu and "<<sw.RealTime()<<" RealTime"<<endl; sw.Reset();}
    return 0;
}
コード例 #2
0
/* { dg-options "-std=iso9899:1990 -pedantic-errors" } */

void *p = (__SIZE_TYPE__)(void *)0; /* { dg-error "without a cast" } */
struct s { void *a; } q = { (__SIZE_TYPE__)(void *)0 }; /* { dg-error "without a cast" } */
void *
f (void)
{
  void *r;
  r = (__SIZE_TYPE__)(void *)0; /* { dg-error "without a cast" } */
  return (__SIZE_TYPE__)(void *)0; /* { dg-error "without a cast" } */
}
void g (void *); /* { dg-message "but argument is of type" } */
void
h (void)
{
  g ((__SIZE_TYPE__)(void *)0); /* { dg-error "without a cast" } */
}
void g2 (int, void *); /* { dg-message "but argument is of type" } */
void
h2 (void)
{
  g2 (0, (__SIZE_TYPE__)(void *)0); /* { dg-error "without a cast" } */
}
コード例 #3
0
ファイル: main.cpp プロジェクト: Jasonhcwong/blog
int main(void)
{
/***************************** Natrual Syntax ********************************/
  Base a;
  Base b;
  Base c;
  Derived aa;

  // test ordinary function
  functor<void( ) > g0(&test0);
  g0();

  functor<double (double)> g1;
  g1 = &test1;
  assert(12.123 == g1(12.123));

  // test member function
  functor<void (int)> g2(&Base::d);
  functor<int (int)> g3(&Base::static_b);
  functor<int (int, int, int, int, int, int, int, int, int)> g4(&Base::d9);
  functor<int (int)> g5(&Base::virtual_c);
  // operator =
  functor<int (int, int)> g6;
  g6 = &Derived::Derived_a2; 

  functor<int (int)> g7(&Derived::virtual_c);
  // copy constructor
  functor<int (int)> g7_2;
  g7_2 = g7;
  functor<int (int)> g7_3(g7);
  // reference 
  functor<int (int)> &g7_4 = g7;
  // pointer 
  functor<int (int)> *g7_5 = &g7;


  g2(&a, 18);
  assert(18 == a.getBase());
  assert(g3(29) == 29);
  assert(g4(&b, 1,2,3,4,5,6,7,8,9) == (1+2+3+4+5+6+7+8+9));
  assert(g5(&c, 5) == 5);
  assert(g6(&aa, 5, 6) == 5+6);
  assert(g7(&aa, 6) == 10+6);
  assert(g7_2(&aa, 6) == 10+6);
  assert(g7_3(&aa, 6) == 10+6);
  assert(g7_4(&aa, 6) == 10+6);
  assert((*g7_5)(&aa, 6) == 10+6);

/************************************* STL *************************************/
  int myints[] = {32,71,12,45,26,80,53,33};
  std::vector<int> myvector1(myints, myints+8);
  std::vector<int> myvector2(myints, myints+8);

  functor<bool (int, int)> functorCmp = &mycmp;

  std::sort(myvector1.begin(), myvector1.end());
  std::sort(myvector2.begin(), myvector2.end(), functorCmp);

  assert(myvector1.size() == myvector2.size());
  for (unsigned int i = 0; i < myvector1.size(); ++i) {
    assert(myvector1[i] == myvector2[i]);
  }

/***************************** Performance Test ********************************/
//  performanceTest (500000000);

  return 0;
}
コード例 #4
0
/*! \reimp */
void QCompactStyle::drawControl( ControlElement element, QPainter *p, const QWidget *widget, const QRect &r,
		  const QColorGroup &g, SFlags flags, const QStyleOption& opt )
{
    switch ( element ) {
    case CE_PopupMenuItem:
	{
	    if (! widget || opt.isDefault())
		break;

	    const QPopupMenu *popupmenu = (const QPopupMenu *) widget;
	    QMenuItem *mi = opt.menuItem();
	    if ( !mi )
		break;

	    int tab = opt.tabWidth();
	    int maxpmw = opt.maxIconWidth();
	    bool dis = !(flags & Style_Enabled);
	    bool checkable = popupmenu->isCheckable();
	    bool act = flags & Style_Active;
	    int x, y, w, h;
	    r.rect( &x, &y, &w, &h );

	    QColorGroup itemg = g;

	    if ( checkable )
		maxpmw = QMAX( maxpmw, 8 ); // space for the checkmarks

	    int checkcol	  =     maxpmw;

	    if ( mi && mi->isSeparator() ) {			// draw separator
		p->setPen( g.dark() );
		p->drawLine( x, y, x+w, y );
		p->setPen( g.light() );
		p->drawLine( x, y+1, x+w, y+1 );
		return;
	    }

	    QBrush fill = act? g.brush( QColorGroup::Highlight ) :
				    g.brush( QColorGroup::Button );
	    p->fillRect( x, y, w, h, fill);

	    if ( !mi )
		return;

	    if ( mi->isChecked() ) {
		if ( act && !dis ) {
		    qDrawShadePanel( p, x, y, checkcol, h,
				     g, TRUE, 1, &g.brush( QColorGroup::Button ) );
		} else {
		    qDrawShadePanel( p, x, y, checkcol, h,
				     g, TRUE, 1, &g.brush( QColorGroup::Midlight ) );
		}
	    } else if ( !act ) {
		p->fillRect(x, y, checkcol , h,
			    g.brush( QColorGroup::Button ));
	    }

	    if ( mi->iconSet() ) {		// draw iconset
		QIconSet::Mode mode = dis ? QIconSet::Disabled : QIconSet::Normal;
		if (act && !dis )
		    mode = QIconSet::Active;
		QPixmap pixmap;
		if ( checkable && mi->isChecked() )
		    pixmap = mi->iconSet()->pixmap( QIconSet::Small, mode, QIconSet::On );
		else
		    pixmap = mi->iconSet()->pixmap( QIconSet::Small, mode );
		int pixw = pixmap.width();
		int pixh = pixmap.height();
		if ( act && !dis ) {
		    if ( !mi->isChecked() )
			qDrawShadePanel( p, x, y, checkcol, h, g, FALSE,  1, &g.brush( QColorGroup::Button ) );
		}
		QRect cr( x, y, checkcol, h );
		QRect pmr( 0, 0, pixw, pixh );
		pmr.moveCenter( cr.center() );
		p->setPen( itemg.text() );
		p->drawPixmap( pmr.topLeft(), pixmap );

		QBrush fill = act? g.brush( QColorGroup::Highlight ) :
				      g.brush( QColorGroup::Button );
		p->fillRect( x+checkcol + 1, y, w - checkcol - 1, h, fill);
	    } else  if ( checkable ) {	// just "checking"...
		int mw = checkcol + motifItemFrame;
		int mh = h - 2*motifItemFrame;
		if ( mi->isChecked() ) {

		    SFlags cflags = Style_Default;
		    if (! dis)
			cflags |= Style_Enabled;
		    if (act)
			cflags |= Style_On;

		    drawPrimitive( PE_CheckMark, p, QRect(x + motifItemFrame + 2, y + motifItemFrame,
				    mw, mh), itemg, cflags, opt );
		}
	    }

	    p->setPen( act ? g.highlightedText() : g.buttonText() );

	    QColor discol;
	    if ( dis ) {
		discol = itemg.text();
		p->setPen( discol );
	    }

	    int xm = motifItemFrame + checkcol + motifItemHMargin;

	    if ( mi->custom() ) {
		int m = motifItemVMargin;
		p->save();
		if ( dis && !act ) {
		    p->setPen( g.light() );
		    mi->custom()->paint( p, itemg, act, !dis,
					 x+xm+1, y+m+1, w-xm-tab+1, h-2*m );
		    p->setPen( discol );
		}
		mi->custom()->paint( p, itemg, act, !dis,
				     x+xm, y+m, w-xm-tab+1, h-2*m );
		p->restore();
	    }
	    QString s = mi->text();
	    if ( !s.isNull() ) {			// draw text
		int t = s.find( '\t' );
		int m = motifItemVMargin;
		const int text_flags = AlignVCenter|ShowPrefix | DontClip | SingleLine;
		if ( t >= 0 ) {				// draw tab text
		    if ( dis && !act ) {
			p->setPen( g.light() );
			p->drawText( x+w-tab-windowsRightBorder-motifItemHMargin-motifItemFrame+1,
				     y+m+1, tab, h-2*m, text_flags, s.mid( t+1 ));
			p->setPen( discol );
		    }
		    p->drawText( x+w-tab-windowsRightBorder-motifItemHMargin-motifItemFrame,
				 y+m, tab, h-2*m, text_flags, s.mid( t+1 ) );
		    s = s.left( t );
		}
		if ( dis && !act ) {
		    p->setPen( g.light() );
		    p->drawText( x+xm+1, y+m+1, w-xm+1, h-2*m, text_flags, s, t );
		    p->setPen( discol );
		}
		p->drawText( x+xm, y+m, w-xm-tab+1, h-2*m, text_flags, s, t );
	    } else if ( mi->pixmap() ) {			// draw pixmap
		QPixmap *pixmap = mi->pixmap();
		if ( pixmap->depth() == 1 )
		    p->setBackgroundMode( OpaqueMode );
		p->drawPixmap( x+xm, y+motifItemFrame, *pixmap );
		if ( pixmap->depth() == 1 )
		    p->setBackgroundMode( TransparentMode );
	    }
	    if ( mi->popup() ) {			// draw sub menu arrow
		int dim = (h-2*motifItemFrame) / 2;
		if ( act ) {
		    if ( !dis )
			discol = white;
		    QColorGroup g2( discol, g.highlight(),
				    white, white,
				    dis ? discol : white,
				    discol, white );
		    drawPrimitive(PE_ArrowRight, p, QRect(x+w - motifArrowHMargin - motifItemFrame - dim, y + h / 2 - dim / 2, dim, dim),
				  g2, Style_Enabled);
		} else {
		    drawPrimitive(PE_ArrowRight, p, QRect(x+w - motifArrowHMargin - motifItemFrame - dim, y + h / 2 - dim / 2, dim, dim),
				  g, !dis ? Style_Enabled : Style_Default);
		}
	    }
	}
	break;

    default:
	QWindowsStyle::drawControl( element, p, widget, r, g, flags, opt );
	break;
    }
}
コード例 #5
0
ファイル: LL.C プロジェクト: bellan/VVXAnalysis
void LL(){

  //y0 = 0.000135096401209 sigma_y0 = 0.000103896581837 x0 = 0.000446013873443 sigma_x0 =1.81384394011e-06
  //0.014108652249 0.0168368471049 0.0219755396247 0.000120423865262 1.5575931164 1.55759310722 3.41637854038
  //0.072569437325 0.084063541977 0.0376693978906 0.000284216132439 0.51908074913 0.519080758095 1.12037749267
 // double d = 0.014108652249;
 //  double sd = 0.0168368471049;
 //  double mc = 0.0219755396247;
 //  double smc = 0.000120423865262;
 //  double r0 = d/mc;

  double d = 0.072569437325;
  double sd =  0.084063541977;
  double mc =  0.0376693978906;
  double smc =  0.00028421613243;
  double r0 = d/mc;

  RooRealVar x("x","x",mc*0.9,mc*1.1);
  RooRealVar x0("x0","x0",mc);
  RooRealVar sx("sx","sx",smc);

  RooRealVar r("r","r",r0,0.,5.);
  RooRealVar y0("y0","y0",d); 
  RooRealVar sy("sy","sy",sd); 
  
  RooProduct rx("rx","rx",RooArgList(r,x));

  RooGaussian g1("g1","g1",x,x0,sx);
  RooGaussian g2("g2","g2",rx,y0,sy);

  RooProdPdf LL("LL","LL",g1,g2);

  RooArgSet obs(x0,y0); //observables
  RooArgSet poi(r); //parameters of interest
  RooDataSet data("data", "data", obs);
  data.add(obs); //actually add the data


  RooFitResult* res = LL.fitTo(data,RooFit::Minos(poi),RooFit::Save(),RooFit::Hesse(false));
  if(res->status()==0) {
    r.Print();
    x.Print();
    cout << r.getErrorLo() << " " << r.getErrorHi() << endl;
  } else {
    cout << "Likelihood maximization failed" << endl;
  }
  
  RooAbsReal* nll = LL.createNLL(data); 
  RooPlot* frame = r.frame();
  RooAbsReal* pll = nll->createProfile(poi);
  pll->plotOn(frame);//,RooFit::LineColor(ROOT::kRed));
  frame->Draw();

  r.setVal(0.);
  cout << pll->getVal() << endl; 

  return;
    
    


}
コード例 #6
0
ファイル: overload2.C プロジェクト: kostyll/gccpy
// Core 1321
// { dg-options -std=c++0x }
// Two dependent names are equivalent even if the overload sets found by
// phase 1 lookup are different.  Merging them keeps the earlier set.

int g1(int);
template <class T> decltype(g1(T())) f1();
int g1();
template <class T> decltype(g1(T())) f1()
{
    return g1(T());
}
int i1 = f1<int>();	    // OK, g1(int) was declared before the first f1

template <class T> decltype(g2(T())) f2(); // { dg-error "g2. was not declared" }
int g2(int);
template <class T> decltype(g2(T())) f2()
{
    return g2(T());
}
int i2 = f2<int>();			  // { dg-error "no match" }

int g3();
template <class T> decltype(g3(T())) f3(); // { dg-error "too many arguments" }
int g3(int);
template <class T> decltype(g3(T())) f3()
{
    return g3(T());
}
int i3 = f3<int>();			  // { dg-error "no match" }
/* { dg-options "-std=iso9899:1990 -pedantic-errors" } */

__extension__ typedef __SIZE_TYPE__ size_t;

void *p = (size_t)(void *)0; /* { dg-error "without a cast" } */
struct s { void *a; } q = { (size_t)(void *)0 }; /* { dg-error "without a cast" } */
void *
f (void)
{
  void *r;
  r = (size_t)(void *)0; /* { dg-error "without a cast" } */
  return (size_t)(void *)0; /* { dg-error "without a cast" } */
}
void g (void *); /* { dg-message "but argument is of type" } */
void
h (void)
{
  g ((size_t)(void *)0); /* { dg-error "without a cast" } */
}
void g2 (int, void *); /* { dg-message "but argument is of type" } */
void
h2 (void)
{
  g2 (0, (size_t)(void *)0); /* { dg-error "without a cast" } */
}
コード例 #8
0
ファイル: jecplots.C プロジェクト: CMSROMA/HggAnalysis
void jecplots(){

  gROOT->SetStyle("Plain");
   
  gStyle->SetPalette(1);
  gStyle->SetOptStat(1111111);  // Show overflow, underflow + SumOfWeights 
  gStyle->SetOptFit(111110); 
  gStyle->SetOptFile(1); 
  
  gStyle->SetMarkerStyle(20);
  gStyle->SetMarkerSize(.3);
  gStyle->SetMarkerColor(1);

  TCanvas* c0 = new TCanvas("c0"," ",200,10,500,500);
  c0->Clear();

  TFile g("/tmp/delre/vbf.root");
  TFile g1("/tmp/delre/vbf1.root");
  TFile g2("/tmp/delre/vbf2.root");
  TFile g3("/tmp/delre/vbf3.root");
  TFile g4("/tmp/delre/vbf4.root");
  TFile h("/tmp/delre/vh.root");
  TFile h1("/tmp/delre/vh1.root");
  TFile h2("/tmp/delre/vh2.root");
  TFile h3("/tmp/delre/vh3.root");
  TFile h4("/tmp/delre/vh4.root");

  g.cd();
  JECresovbf->SetTitle("");
  JECresovbf->SetStats(0);
  JECresovbf->SetXTitle("(p_{T}^{meas}-p_{T}^{gen}))/p_{T}^{gen}");
  JECresovbf->Draw();
  g1.cd();
  JECresovbf->SetLineColor(kRed);
  JECresovbf->Draw("same");
  g2.cd();
  JECresovbf->SetLineColor(kBlue);
  JECresovbf->Draw("same");
  
  c0->SaveAs("JECsyst_vbf.png");
  
  h.cd();
  JECresovh->SetTitle("");
  JECresovh->SetStats(0);
  JECresovh->SetXTitle("(p_{T}^{meas}-p_{T}^{gen}))/p_{T}^{gen}");
  JECresovh->Draw();
  h1.cd();
  JECresovh->SetLineColor(kRed);
  JECresovh->Draw("same");
  h2.cd();
  JECresovh->SetLineColor(kBlue);
  JECresovh->Draw("same");
  
  c0->SaveAs("JECsyst_vh.png");
   
  g4.cd();
  JECresovbf->SetLineColor(kRed);
  JECresovbf->SetTitle("");
  JECresovbf->SetStats(0);
  JECresovbf->SetXTitle("(p_{T}^{meas}-p_{T}^{gen}))/p_{T}^{gen}");
  JECresovbf->Draw();
  g.cd();
  JECresovbf->Draw("same");
  g3.cd();
  JECresovbf->SetLineColor(kBlue);
  JECresovbf->Draw("same");
  
  c0->SaveAs("JERsyst_vbf.png");
  
  h4.cd();
  JECresovh->SetTitle("");
  JECresovh->SetLineColor(kRed);
  JECresovh->SetStats(0);
  JECresovh->SetXTitle("(p_{T}^{meas}-p_{T}^{gen}))/p_{T}^{gen}");
  JECresovh->Draw();
  h.cd();
  JECresovh->Draw("same");
  h3.cd();
  JECresovh->SetLineColor(kBlue);
  JECresovh->Draw("same");
  
  c0->SaveAs("JERsyst_vh.png");
   

}
コード例 #9
0
ファイル: main.cpp プロジェクト: TripleWhy/Carcasum
int main(int argc, char *argv[])
{
	QCoreApplication a(argc, argv);
	jcz::TileFactory * tileFactory = new jcz::TileFactory();
	RandomNextTileProvider rntp;
	Game * game = new Game(&rntp);
	
	qDebug("NODE_VARIANT: " STR(NODE_VARIANT));
	if (false)
	{
		qDebug() << "CONTROL_GAME" << CONTROL_GAME;
		for (int i = 0; i < 10000; ++i)
		{
			qDebug() << "================================\nRUN" << i;
			Game g1(&rntp), g2(&rntp), g3(&rntp), g4(&rntp), g5(&rntp);
			Q_ASSERT(g1.equals(g2));
			Q_ASSERT(g2.equals(g1));

			g1.addPlayer(&RandomPlayer::instance);
			g1.addPlayer(&RandomPlayer::instance);
//			g1.addPlayer(new jcz::JCZPlayer(tileFactory));

			for (Player * p : g1.getPlayers())
			{
				g2.addPlayer(p->clone());
				g3.addPlayer(p->clone());
				g4.addPlayer(p->clone());
				g5.addPlayer(p->clone());
			}
			Q_ASSERT(g1.equals(g2));
			Q_ASSERT(g2.equals(g1));
			g1.newGame(Tile::BaseGame, tileFactory);
			g2.newGame(Tile::BaseGame, tileFactory);
			g4.newGame(Tile::BaseGame, tileFactory);
			g5.newGame(Tile::BaseGame, tileFactory);
			Q_ASSERT(g1.equals(g2));
			Q_ASSERT(g2.equals(g1));
			
			int steps = 0;
			bool notDone = true;
			//for ( ; steps < 23; ++steps)
			for ( ; notDone; ++steps)
			{
				notDone = g1.step();
				MoveHistoryEntry const & e = g1.getMoveHistory().back();
				g4.simStep(e);

				g5.simPartStepChance(e.tileIndex);
				g5.simPartStepTile(e.move.tileMove);
				g5.simPartStepMeeple(e.move.meepleMove);

				Q_ASSERT(g1.equals(g4));
				Q_ASSERT(g4.equals(g1));
				Q_ASSERT(g1.equals(g5));
				Q_ASSERT(g5.equals(g1));
#if CONTROL_GAME
				g3.newGame(Tile::BaseGame, tileFactory, g1.getMoveHistory());
				Q_ASSERT(g1.equals(g3));
				Q_ASSERT(g3.equals(g1));
#endif
			}
			for (int i = 0; i < steps; ++i)
			{
				g1.simUndo();
				g4.simUndo();

				g5.simPartUndoMeeple();
				g5.simPartUndoTile();
				g5.simPartUndoChance();

				Q_ASSERT(g1.equals(g4));
				Q_ASSERT(g4.equals(g1));
				Q_ASSERT(g1.equals(g5));
				Q_ASSERT(g5.equals(g1));
#if CONTROL_GAME
				g3.newGame(Tile::BaseGame, tileFactory, g1.getMoveHistory());
				Q_ASSERT(g1.equals(g3));
				Q_ASSERT(g3.equals(g1));
#endif
			}
			Q_ASSERT(g1.equals(g2));
			Q_ASSERT(g2.equals(g1));
		}
		
		return 0;
	}

	if (true)
	{
		static int const playouts = 5000;
		Game g(&rntp);
		g.addPlayer(&RandomPlayer::instance);
		g.addPlayer(&RandomPlayer::instance);
//		g.addPlayer(new jcz::JCZPlayer(tileFactory));
//		g.addPlayer(new jcz::JCZPlayer(tileFactory));
//		g.addPlayer(new SimplePlayer());

		QTime t;
		t.start();
		for (int i = 0; i < playouts; ++i)
		{
			g.newGame(Tile::BaseGame, tileFactory);
			int steps = 0;
			do
			{
				++steps;
			} while (g.step());
		}
		int e = t.elapsed();
		std::cout << playouts << "p / " << e << "ms = " << playouts / (e / 1000.0) << " pps" << std::endl;
//		return 0;
	}

	if (true)
	{
		static int const playouts = 5000;
		Game g(&rntp);
		g.addPlayer(&RandomPlayer::instance);
		g.addPlayer(&RandomPlayer::instance);
//		g.addPlayer(new SimplePlayer());
		g.newGame(Tile::BaseGame, tileFactory);

		QTime t;
		t.start();
		for (int i = 0; i < playouts; ++i)
		{
			int steps = 0;
			do
			{
				++steps;
			} while (g.step());

			for (; steps > 0; --steps)
			{
				g.simUndo();
			}
		}
		int e = t.elapsed();
		std::cout << playouts << "p / " << e << "ms = " << playouts / (e / 1000.0) << " pps" << std::endl;
		return 0;
	}
	

	if (false)
	{
		Player * p1 = &RandomPlayer::instance;
//		auto * p2 = new MonteCarloPlayer<>(tileFactory);
		auto * p2 = new MonteCarloPlayer2<>(tileFactory);

		game->addPlayer(p1);
		game->addPlayer(p2);

		QTime t;
		int const n = 5;
		t.start();
		for (int i = 0; i < n; ++i)
		{
#if !COUNT_PLAYOUTS
			t.start();
#endif
			game->newGame(Tile::BaseGame, tileFactory);

			for (int ply = 0; game->step(); ++ply)
			{
//				std::cout << ply << std::endl;
			}
			int e = t.elapsed();
#if COUNT_PLAYOUTS
			std::cout << i << "   " << p2->playouts << "p / " << e << "ms = " << (p2->playouts) / (e / 1000.0) << " pps" << std::endl;
#else
			std::cout << i << "   " << e << std::endl;
#endif
		}
		std::cout << (t.elapsed() / n) << std::endl;
		return 0;
	}


	if (true)
	{
		Player * p1 = &RandomPlayer::instance;
		auto * p2 = new MCTSPlayer<>(tileFactory);

		game->addPlayer(p1);
		game->addPlayer(p2);

		QTime t;
		int const n = 5;
		t.start();
		for (int i = 0; i < n; ++i)
		{
#if !COUNT_PLAYOUTS
			t.start();
#endif
			game->newGame(Tile::BaseGame, tileFactory);

			for (int ply = 0; game->step(); ++ply)
			{
//				std::cout << "ply " << ply << std::endl;
			}
			int e = t.elapsed();
#if COUNT_PLAYOUTS
			std::cout << i << "   " << p2->playouts << "p / " << e << "ms = " << (p2->playouts) / (e / 1000.0) << " pps" << std::endl;
#else
			std::cout << i << "   " << e << std::endl;
#endif
#if MCTS_COUNT_EXPAND_HITS
			std::cout << i << "   " << p2->hit << "hits / " << p2->miss << "misses = " << (p2->hit / qreal(p2->miss)) << std::endl;
#endif
		}
		std::cout << (qreal(t.elapsed()) / qreal(n)) << std::endl;
		return 0;
	}

	if (false)
	{
		SimplePlayer3 s3;
		game->addPlayer(&s3);
		game->newGame(Tile::BaseGame, tileFactory);

		forever
		{
			game->simStep(&RandomPlayer::instance);
			if (game->getPlayerMeeples(0) <= 0)
				break;
		}
		qDebug() << game->getPlayerMeeples(0);

		forever
		{
			game->simStep(&s3);
			if (game->getPlayerMeeples(0) > 0)
				break;
		}
		qDebug() << game->getPlayerMeeples(0);

		qDebug();
		MoveHistoryEntry h = game->getMoveHistory().back();
		game->undo();
		qDebug() << "m" << game->getPlayerMeeples(0);
//		qDebug() << "r" << game->getPlayerReturnMeeples(0);
		game->simStep(h);
		qDebug() << "m" << game->getPlayerMeeples(0);
//		qDebug() << "r" << game->getPlayerReturnMeeples(0);
		game->undo();
		qDebug() << "m" << game->getPlayerMeeples(0);
//		qDebug() << "r" << game->getPlayerReturnMeeples(0);

		qDebug();
		qDebug("simPartStepChance");
		game->simPartStepChance(h.tileIndex);
		qDebug() << "m" << game->getPlayerMeeples(0);
//		qDebug() << "r" << game->getPlayerReturnMeeples(0);
		qDebug("simPartStepTile");
		game->simPartStepTile(h.move.tileMove);
		qDebug() << "m" << game->getPlayerMeeples(0);
//		qDebug() << "r" << game->getPlayerReturnMeeples(0);
		qDebug() << "placements" << game->getPossibleMeeplePlacements(0, game->simTile).size();
		qDebug("simPartStepMeeple");
		game->simPartStepMeeple(h.move.meepleMove);
		qDebug() << "m" << game->getPlayerMeeples(0);
//		qDebug() << "r" << game->getPlayerReturnMeeples(0);

		qDebug();
		qDebug();
		qDebug("simPartUndoMeeple");
		game->simPartUndoMeeple();
		qDebug() << "m" << game->getPlayerMeeples(0);
//		qDebug() << "r" << game->getPlayerReturnMeeples(0);
		qDebug() << "placements" << game->getPossibleMeeplePlacements(0, game->simTile).size();
		qDebug("simPartUndoTile");
		game->simPartUndoTile();
		qDebug() << "m" << game->getPlayerMeeples(0);
//		qDebug() << "r" << game->getPlayerReturnMeeples(0);
		qDebug("simPartUndoChance");
		game->simPartUndoChance();
		qDebug() << "m" << game->getPlayerMeeples(0);
//		qDebug() << "r" << game->getPlayerReturnMeeples(0);
	}
コード例 #10
0
ファイル: rec_nasty.c プロジェクト: 8l/insieme
int f2(int v) {
	if ( v < 10 )
		return 10 + g2(v);
	return v;
}
コード例 #11
0
struct S { void g2 (void (*) (...)); void h2 () { g2 (f); } };// { dg-error "match" "match" } 
コード例 #12
0
ファイル: skipjack.c プロジェクト: BlueFireworks/rtems-libbsd
void
skipjack_forwards(u_int8_t *plain, u_int8_t *cipher, u_int8_t **key_tables)
{
	u_int8_t wh1 = plain[0];  u_int8_t wl1 = plain[1];
	u_int8_t wh2 = plain[2];  u_int8_t wl2 = plain[3];
	u_int8_t wh3 = plain[4];  u_int8_t wl3 = plain[5];
	u_int8_t wh4 = plain[6];  u_int8_t wl4 = plain[7];

	u_int8_t * k0 = key_tables [0];
	u_int8_t * k1 = key_tables [1];
	u_int8_t * k2 = key_tables [2];
	u_int8_t * k3 = key_tables [3];
	u_int8_t * k4 = key_tables [4];
	u_int8_t * k5 = key_tables [5];
	u_int8_t * k6 = key_tables [6];
	u_int8_t * k7 = key_tables [7];
	u_int8_t * k8 = key_tables [8];
	u_int8_t * k9 = key_tables [9];

	/* first 8 rounds */
	g0 (wh1,wl1, wh1,wl1); wl4 ^= wl1 ^ 1; wh4 ^= wh1;
	g4 (wh4,wl4, wh4,wl4); wl3 ^= wl4 ^ 2; wh3 ^= wh4;
	g8 (wh3,wl3, wh3,wl3); wl2 ^= wl3 ^ 3; wh2 ^= wh3;
	g2 (wh2,wl2, wh2,wl2); wl1 ^= wl2 ^ 4; wh1 ^= wh2;
	g6 (wh1,wl1, wh1,wl1); wl4 ^= wl1 ^ 5; wh4 ^= wh1;
	g0 (wh4,wl4, wh4,wl4); wl3 ^= wl4 ^ 6; wh3 ^= wh4;
	g4 (wh3,wl3, wh3,wl3); wl2 ^= wl3 ^ 7; wh2 ^= wh3;
	g8 (wh2,wl2, wh2,wl2); wl1 ^= wl2 ^ 8; wh1 ^= wh2;

	/* second 8 rounds */
	wh2 ^= wh1; wl2 ^= wl1 ^ 9 ; g2 (wh1,wl1, wh1,wl1);
	wh1 ^= wh4; wl1 ^= wl4 ^ 10; g6 (wh4,wl4, wh4,wl4);
	wh4 ^= wh3; wl4 ^= wl3 ^ 11; g0 (wh3,wl3, wh3,wl3);
	wh3 ^= wh2; wl3 ^= wl2 ^ 12; g4 (wh2,wl2, wh2,wl2);
	wh2 ^= wh1; wl2 ^= wl1 ^ 13; g8 (wh1,wl1, wh1,wl1);
	wh1 ^= wh4; wl1 ^= wl4 ^ 14; g2 (wh4,wl4, wh4,wl4);
	wh4 ^= wh3; wl4 ^= wl3 ^ 15; g6 (wh3,wl3, wh3,wl3);
	wh3 ^= wh2; wl3 ^= wl2 ^ 16; g0 (wh2,wl2, wh2,wl2);

	/* third 8 rounds */
	g4 (wh1,wl1, wh1,wl1); wl4 ^= wl1 ^ 17; wh4 ^= wh1;
	g8 (wh4,wl4, wh4,wl4); wl3 ^= wl4 ^ 18; wh3 ^= wh4;
	g2 (wh3,wl3, wh3,wl3); wl2 ^= wl3 ^ 19; wh2 ^= wh3;
	g6 (wh2,wl2, wh2,wl2); wl1 ^= wl2 ^ 20; wh1 ^= wh2;
	g0 (wh1,wl1, wh1,wl1); wl4 ^= wl1 ^ 21; wh4 ^= wh1;
	g4 (wh4,wl4, wh4,wl4); wl3 ^= wl4 ^ 22; wh3 ^= wh4;
	g8 (wh3,wl3, wh3,wl3); wl2 ^= wl3 ^ 23; wh2 ^= wh3;
	g2 (wh2,wl2, wh2,wl2); wl1 ^= wl2 ^ 24; wh1 ^= wh2;

	/* last 8 rounds */
	wh2 ^= wh1; wl2 ^= wl1 ^ 25; g6 (wh1,wl1, wh1,wl1);
	wh1 ^= wh4; wl1 ^= wl4 ^ 26; g0 (wh4,wl4, wh4,wl4);
	wh4 ^= wh3; wl4 ^= wl3 ^ 27; g4 (wh3,wl3, wh3,wl3);
	wh3 ^= wh2; wl3 ^= wl2 ^ 28; g8 (wh2,wl2, wh2,wl2);
	wh2 ^= wh1; wl2 ^= wl1 ^ 29; g2 (wh1,wl1, wh1,wl1);
	wh1 ^= wh4; wl1 ^= wl4 ^ 30; g6 (wh4,wl4, wh4,wl4);
	wh4 ^= wh3; wl4 ^= wl3 ^ 31; g0 (wh3,wl3, wh3,wl3);
	wh3 ^= wh2; wl3 ^= wl2 ^ 32; g4 (wh2,wl2, wh2,wl2);

	/* pack into byte vector */
	cipher [0] = wh1;  cipher [1] = wl1;
	cipher [2] = wh2;  cipher [3] = wl2;
	cipher [4] = wh3;  cipher [5] = wl3;
	cipher [6] = wh4;  cipher [7] = wl4;
}
コード例 #13
0
int main(){
	
	Scalar a("a",STRING,"Hello");
	Scalar b("b",STRING,"World");
	std::cout << " a                      : " << a << std::endl;
	std::cout << " b                      : " << b << std::endl; 
	Scalar c("c",STRING,"Hello");
	std::cout << " c                      : " << c << std::endl;
	std::cout << " a == b                 : " << (a == b) << std::endl;
	std::cout << " a == c                 : " << (a == c) << std::endl;
	std::cout << " a  < b                 : " << (a < b) << std::endl;
	std::cout << " c  < a                 : " << (c < a) << std::endl;
	std::cout << " b  < a                 : " << (b < a) << std::endl; 
	Scalar ga("ga",BOOLEAN,"M");
	Scalar gb("gb",BOOLEAN,"F");
	Scalar gc("gc",BOOLEAN,"F");
	Scalar d("d",STRING,"M");
	std::cout << " ga                     : " << ga << std::endl;
	std::cout << " gb                     : " << gb << std::endl;
	std::cout << " gc                     : " << gc << std::endl;
	std::cout << " d                      : " << d << std::endl;
	std::cout << " (ga == gb)             : " << (ga == gb) << std::endl;
	std::cout << " (gb == gc)             : " << (gb == gc) << std::endl;
	std::cout << " (ga == d)              : " << (ga == d) << std::endl;
	std::cout << " (gb < gc)              : " << (gb < gc) << std::endl;
	std::cout << " (ga < gc)              : " << (ga < gc) << std::endl;
	std::cout << " (gc < ga)              : " << (gc < ga) << std::endl;
	std::cout << " (ga < a)               : " << (ga < a) << std::endl;
	std::cout << " (b < gb)               : " << (b < gb) << std::endl;
	std::cout << "Testing Assignment and Copy operators" << std::endl;
	Scalar copy1(ga);
	std::cout << " copy1 of ga            : " << copy1 << std::endl;  
	std::cout << " name and type          : " << copy1.getName() << " = " << copy1.getValueType() << std::endl;
	Scalar e("e",STRING,"Namaste");
	std::cout << " e                      : " << e << std::endl;
	e=ga;
	std::cout << " e=ga                   : " << e << std::endl;
	std::cout << " name and type          : " << e.getName() << " = " << e.getValueType() << std::endl;
	e=a;
	std::cout << " e=a                    : " << e << std::endl;
	std::cout << " name and type          : " << e.getName() << " = " << e.getValueType() << std::endl;
	ga=a;
	std::cout << " ga=a                   : " << ga << std::endl;
	std::cout << " name and type          : " << ga.getName() << " = " << ga.getValueType() << std::endl;
	std::cout << "Testing Scalar variables of type ANY" << std::endl;
	Scalar anyVar("anyVar");
	std::cout << " name and type          : " << anyVar.getName() << " = " << anyVar.getValueType() << std::endl;
	std::cout << " anyVar                 : " << anyVar << std::endl;
	std::cout << " anyVar < ga            : " << (anyVar < ga) << std::endl;
	std::cout << " a < anyVar             : " << (a < anyVar) << std::endl;
	std::cout << " a == anyVar            : " << (a == anyVar) << std::endl;
	anyVar.set(STRING,"Wow");
	std::cout << " anyVar=Wow             : " << anyVar << std::endl;
	Scalar anyVar1("anyVar1");
	std::cout << " anyVar1                : " << anyVar1 << std::endl;
	std::cout << " name and type          : " << anyVar1.getName() << " = " << anyVar1.getValueType() << std::endl;
	anyVar1 = anyVar;
	std::cout << " anyVar1=anyVar         : " << anyVar1 << std::endl;
	std::cout << " name and type          : " << anyVar1.getName() << " = " << anyVar1.getValueType() << std::endl;
	Scalar anyVar2("anyVar2");
	std::cout << " anyVar2                : " << anyVar2 << std::endl;
	std::cout << " name and type          : " << anyVar2.getName() << " = " << anyVar2.getValueType() << std::endl;
	anyVar = anyVar2;
	std::cout << " anyVar=anyVar2         : " << anyVar << std::endl;
	std::cout << " anyVar name and type   : " << anyVar.getName() << " = " << anyVar.getValueType() << std::endl;
	std::cout << " anyVar2 name and type  : " << anyVar2.getName() << " = " << anyVar2.getValueType() << std::endl;
	Scalar anyType("anyType",ANY,"Testing Any");
	std::cout << " anyType                : " << anyType << std::endl;
	std::cout << " name and type          : " << anyType.getName() << " = " << anyType.getValueType() << std::endl;
	std::cout << " anyVar2 < anyType      : " << (anyVar2 < anyType) << std::endl;
	std::cout << " anyVar2 == anyType     : " << (anyVar2 == anyType) << std::endl;
	Scalar g1("g1",GENOTYPE,"120/120");
	Scalar g2("g2",GENOTYPE,"120/120");
	Scalar g3("g3",GENOTYPE,"112/118");
	Scalar g4("g4",GENOTYPE,"C/T");
	Scalar g5("g5",GENOTYPE,"A/A");
	std::cout << " g1                     : " << g1 << std::endl;
	std::cout << " name and type          : " << g1.getName() << " = " << g1.getValueType() << std::endl;
	anyVar2 = g1;
	std::cout << " anyVar2=g1             : " << anyVar2 << std::endl;
	std::cout << " name and type          : " << anyVar2.getName() << " = " << anyVar2.getValueType() << std::endl;
	std::cout << " g2                     : " << g2 << std::endl;
	std::cout << " g3                     : " << g3 << std::endl;
	std::cout << " g4                     : " << g4 << std::endl;
	std::cout << " g5                     : " << g5 << std::endl;
	std::cout << " name and type          : " << g5.getName() << " = " << g5.getValueType() << std::endl;
	std::cout << " g1 < g2                : " << (g1 < g2) << std::endl;
	std::cout << " g2 == g1               : " << (g2 == g1) << std::endl;
	std::cout << " g5 < g4                : " << (g5 < g4) << std::endl;
	std::cout << " g2 < g4                : " << (g2 < g4) << std::endl;
	std::cout << " g2 < e                 : " << (g2 < e) << std::endl;
	std::cout << " ga == g2               : " << (ga == g2) << std::endl;
	Scalar f("f",STRING,"123/125");
	Scalar g6Any("g6Any");
	std::cout << " g6Any                  : " << g6Any << std::endl;
	std::cout << " name and type          : " << g6Any.getName() << " = " << g6Any.getValueType() << std::endl;
	g6Any = f;
	std::cout << " g6Any=f                : " << g6Any << std::endl;
	std::cout << " name and type          : " << g6Any.getName() << " = " << g6Any.getValueType() << std::endl;
	g3 = g6Any;
	std::cout << " g3=g6Any               : " << g3 << std::endl;
	std::cout << " name and type          : " << g3.getName() << " = " << g3.getValueType() << std::endl;
	Scalar g7Inv("g7Inv");
	g7Inv.set(GENOTYPE,"0/0");
	std::cout << " g7Inv                  : " << g7Inv << std::endl;
	std::cout << " name and type          : " << g7Inv.getName() << " = " << g7Inv.getValueType() << std::endl;
	Scalar d1("d1",DATE,"1987-08-23");
	Scalar d2("d2",DATE,"1987-08");
	Scalar d3("d3",DATE,"[1987-1990]");
	Scalar d4("d4",DATE,"~2000-02-13");
	Scalar d5("d5",DATE,"1948");
	Scalar d6Any("d6Any");
	std::cout << " d1                     : " << d1 << std::endl;
	std::cout << " name and type          : " << d1.getName() << " = " << d1.getValueType() << std::endl;
	std::cout << " d6Any                  : " << d6Any << std::endl;
	std::cout << " name and type          : " << d6Any.getName() << " = " << d6Any.getValueType() << std::endl;
	d6Any = d1;
	std::cout << " d6Any=d1               : " << d6Any << std::endl;
	std::cout << " name and type          : " << d6Any.getName() << " = " << d6Any.getValueType() << std::endl;
	std::cout << " d2                     : " << d2 << std::endl;
	std::cout << " d3                     : " << d3 << std::endl;
	std::cout << " d4                     : " << d4 << std::endl;
	std::cout << " d5                     : " << d5 << std::endl;
	Scalar d7Inv("d7Inv");
	d7Inv.set(DATE,"2003-[03-04-12");
	std::cout << " d7Inv                  : " << d7Inv << std::endl;
	std::cout << " name and type          : " << d7Inv.getName() << " = " << d7Inv.getValueType() << std::endl;
	std::cout << " d1 < d2                : " << (d1 < d2) << std::endl;
	std::cout << " d2 == d1               : " << (d2 == d1) << std::endl;
	std::cout << " d2 == d3               : " << (d2 == d3) << std::endl;
	std::cout << " d3 < d2                : " << (d3 < d2) << std::endl;
	std::cout << " d5 < d4                : " << (d5 < d4) << std::endl;
	std::cout << " d2 < d4                : " << (d2 < d4) << std::endl;
	std::cout << " d2 < e                 : " << (d2 < e) << std::endl;
	std::cout << " ga == d2               : " << (ga == d2) << std::endl;
	Scalar d8Copy(d4);
	std::cout << " Copy of d4             : " << d8Copy << std::endl;
	std::cout << " name and type          : " << d8Copy.getName() << " = " << d8Copy.getValueType() << std::endl;
	std::cout << " d4 == d8Copy           : " << (d4 == d8Copy) << std::endl;
	
	Scalar n1("n1",NUMBER,"19-23");
	Scalar n2("n2",NUMBER,"18-38");
	Scalar n3("n3",NUMBER,"17");
	Scalar n4("n4",NUMBER,"~20");
	Scalar n5("n5",NUMBER,"48");
	Scalar n6Any("n6Any");
	std::cout << " n1                     : " << n1 << std::endl;
	std::cout << " name and type          : " << n1.getName() << " = " << n1.getValueType() << std::endl;
	std::cout << " n6Any                  : " << n6Any << std::endl;
	std::cout << " name and type          : " << n6Any.getName() << " = " << n6Any.getValueType() << std::endl;
	n6Any = n1;
	std::cout << " n6Any=n1               : " << n6Any << std::endl;
	std::cout << " name and type          : " << n6Any.getName() << " = " << n6Any.getValueType() << std::endl;
	std::cout << " n2                     : " << n2 << std::endl;
	std::cout << " n3                     : " << n3 << std::endl;
	std::cout << " n4                     : " << n4 << std::endl;
	std::cout << " n5                     : " << n5 << std::endl;
	Scalar n7Inv("n7Inv");
	n7Inv.set(NUMBER,"2003-[");
	std::cout << " n7Inv                  : " << n7Inv << std::endl;
	std::cout << " name and type          : " << n7Inv.getName() << " = " << n7Inv.getValueType() << std::endl;
	std::cout << " n1 < n2                : " << (n1 < n2) << std::endl;
	std::cout << " n2 == n1               : " << (n2 == n1) << std::endl;
	std::cout << " n2 == n3               : " << (n2 == n3) << std::endl;
	std::cout << " n3 < n2                : " << (n3 < n2) << std::endl;
	std::cout << " n5 < n4                : " << (n5 < n4) << std::endl;
	std::cout << " n2 < n4                : " << (n2 < n4) << std::endl;
	std::cout << " n2 < e                 : " << (n2 < e) << std::endl;
	std::cout << " ga == n2               : " << (ga == n2) << std::endl;
	Scalar n8Copy(n4);
	std::cout << " Copy of n4             : " << n8Copy << std::endl;
	std::cout << " name and type          : " << n8Copy.getName() << " = " << n8Copy.getValueType() << std::endl;
	std::cout << " n4 == n8Copy           : " << (n4 == n8Copy) << std::endl;
	Number::addNumberMissingValue("99");
	std::cout << "Added 99 as Number missing value" << std::endl;
	Scalar n8("n8",NUMBER,"99");
	std::cout << " n8=99                  : " << n8 << std::endl;
	return 0;
	
} 
コード例 #14
0
// Incomplete struct pointer used as function argument.
void f7() {
  struct s2 *p = __builtin_alloca(10);
  g2(p);
}
コード例 #15
0
ファイル: para3.cpp プロジェクト: colemonnahan/admb
void function_minimizer::hess_routine_master()
{

  int nvar=initial_params::nvarcalc(); // get the number of active parameters
  //if (adjm_ptr) set_labels_for_hess(nvar);
  independent_variables x(1,nvar);
  initial_params::xinit(x);        // get the initial values into the x vector
  double f;
  double delta=1.e-6;
  dvector g1(1,nvar);
  dvector g2(1,nvar);
  dvector gbest(1,nvar);
  dvector hess(1,nvar);
  dvector hess1(1,nvar);
  dvector hess2(1,nvar);
  double eps=.1;
  gradient_structure::set_YES_DERIVATIVES();
  gbest.fill_seqadd(1.e+50,0.);

  adstring tmpstring="admodel.hes";
  if (ad_comm::wd_flag)
     tmpstring = ad_comm::adprogram_name + ".hes";
  uostream ofs((char*)tmpstring);

  ofs << nvar;
  {
    pvm_master_function_evaluation(f,x,g1,nvar);
    double sdelta1;
    double sdelta2;
    for (int i=1;i<=nvar;i++)
    {
      hess_calcreport(i,nvar);

      double f=0.0;
      double xsave=x(i);
      sdelta1=x(i)+delta;
      useless(sdelta1);
      sdelta1-=x(i);
      x(i)=xsave+sdelta1;

      pvm_master_function_evaluation(f,x,g1,nvar);

      sdelta2=x(i)-delta;
      useless(sdelta2);
      sdelta2-=x(i);
      x(i)=xsave+sdelta2;

      pvm_master_function_evaluation(f,x,g2,nvar);

      x(i)=xsave;
      hess1=(g1-g2)/(sdelta1-sdelta2);

      sdelta1=x(i)+eps*delta;
      useless(sdelta1);
      sdelta1-=x(i);
      x(i)=xsave+sdelta1;

      pvm_master_function_evaluation(f,x,g1,nvar);

      x(i)=xsave-eps*delta;
      sdelta2=x(i)-eps*delta;
      useless(sdelta2);
      sdelta2-=x(i);
      x(i)=xsave+sdelta2;

      pvm_master_function_evaluation(f,x,g2,nvar);

      x(i)=xsave;

      dvariable vf=initial_params::reset(dvar_vector(x));
      double eps2=eps*eps;
      hess2=(g1-g2)/(sdelta1-sdelta2);
      hess=(eps2*hess1-hess2) /(eps2-1.);

      ofs << hess;
      //if (adjm_ptr) ad_update_hess_stats_report(nvar,i);
    }
  }
  gradient_structure::set_NO_DERIVATIVES();
}
コード例 #16
0
int main() {
	// Ошибка: f() создает константный временный объект:
	//! g1(f());
	// Можно: g2 получает ссылку на константу
	g2(f());
} ///:~
コード例 #17
0
 void f() {
   const Enum v2 = v;
   Enum e = false ? g() : v;
   Enum e2 = false ? v2 : v;
   Enum e3 = false ? g2() : v;
 }
コード例 #18
0
void
_test_surface_neighbors_3_cube(const Triangul &, const Transformation&
			       transform, const int n = 75,
			       typename Triangul::Geom_traits::FT tolerance
			       = typename Triangul::Geom_traits::FT(1e-29),
			       bool grid=true)
{
  Triangul T;

  int m=10;
  double r = 3;

  typedef typename Triangul::Geom_traits          Gt;
  typedef typename Gt::FT                         Coord_type;
  typedef typename Gt::Point_3                    Point;
  typedef typename Gt::Point_2                    Point_2;
  typedef typename Gt::Vector_3                   Vector;

  //data points: generate random points in a square of length r
  std::vector<Point_2> points_2_data;
  points_2_data.reserve(n);
    	

  if(grid)
    CGAL::points_on_square_grid_2
      (r,n,std::back_inserter(points_2_data),
       CGAL::Creator_uniform_2<Coord_type,Point_2>());
  else{
    CGAL::Random_points_in_square_2<Point_2> g(r);
    CGAL::cpp11::copy_n( g, n, std::back_inserter(points_2_data));
  }
  for(int i=0; i < n; i++){
    T.insert(transform(Point(points_2_data[i].x(),points_2_data[i].y(), -r)));
    T.insert(transform(Point(points_2_data[i].x(),points_2_data[i].y(), r)));
    T.insert(transform(Point(-r, points_2_data[i].x(),points_2_data[i].y())));
    T.insert(transform(Point(r, points_2_data[i].x(), points_2_data[i].y())));
    T.insert(transform(Point(points_2_data[i].x(), -r, points_2_data[i].y())));
    T.insert(transform(Point(points_2_data[i].x(), r, points_2_data[i].y())));
  }

  //test_points: generate random points in a square of length r
  std::vector<Point_2> points_2_test;
  points_2_test.reserve(m);
  CGAL::Random_points_in_square_2<Point_2> g2(r-1.0);
  CGAL::cpp11::copy_n( g2, m, std::back_inserter(points_2_test));

  int k=0;
  for(int i=0;i<m;i++){
    //test point on z=r plane:
    test_coords_and_neighbors(T,transform(Point(points_2_test[i].x(),
						points_2_test[i].y(), r)),
			      transform(Vector(0,0,1)),tolerance, ++k % 8);
    //test point on x=-r plane:
    test_coords_and_neighbors(T,transform(Point(-r, points_2_test[i].x(),
						points_2_test[i].y())),
			      transform(Vector(-1,0,0)),tolerance, ++k % 8 );
    //test point on x=r plane:
    test_coords_and_neighbors(T,transform(Point(r, points_2_test[i].x(),
						points_2_test[i].y())),
			      transform(Vector(1,0,0)),tolerance,++k % 8 );
    //test point on y=-r plane:
    test_coords_and_neighbors(T,transform(Point(points_2_test[i].x(),
						-r,points_2_test[i].y())),
			      transform(Vector(0,-1,0)),tolerance,++k % 8 );
    //test point on y=r plane:
    test_coords_and_neighbors(T,transform(Point(points_2_test[i].x(),
						r,points_2_test[i].y())),
			      transform(Vector(0,1,0)),tolerance,++k % 8);
  }

  //test a sample point:
  //with Delaunay triangulation filering:
  test_coords_and_neighbors(T,transform(Point(points_2_data[n/2].x(),
					      points_2_data[n/2].y(), r)),
	      transform(Vector(0,0,1)),Coord_type(0),0);
  //considering all points:
  test_coords_and_neighbors(T,transform(Point(points_2_data[n/2].x(),
				 points_2_data[n/2].y(), r)),
	       transform(Vector(0,0,1)),Coord_type(0),4);
}
コード例 #19
0
ファイル: overload2.C プロジェクト: kostyll/gccpy
template <class T> decltype(g2(T())) f2()
{
    return g2(T());
}
コード例 #20
0
ファイル: mem_fn_test.cpp プロジェクト: devangb/hpx
 int g3(int a1, int a2, int a3) const { g2(a1, a2); g1(a3); return 0; }
コード例 #21
0
 void h() {
   g2(17);
 }
コード例 #22
0
ファイル: encrypt.c プロジェクト: 0x64616E69656C/supercop
int crypto_aead_decrypt(
                        unsigned char *m,unsigned long long *mlen,          // message
                        unsigned char *nsec,                                // not relavent to CLOC or SLIC
                        const unsigned char *c,unsigned long long clen,     // ciphertext
                        const unsigned char *ad,unsigned long long adlen,   // associated data
                        const unsigned char *npub,                          // nonce
                        const unsigned char *k                              // the master key
                        )
{
    block estate, tstate, tmp;  // encryption state, tag state, and temporary state
    estate = SETZERO();
    unsigned char ltag[16];     // local copy of temporary tag value
    unsigned long long i, lastblocklen,j;
    
    /* set ciphertext length */
    *mlen = clen - CRYPTO_ABYTES;
    
    /* generate round keys from master key */
    AES128_KeyExpansion(k);
    
    
    /* process the first (partial) block of ad */
    load_partial_block(&estate, ad, (adlen>STATE_LEN)?STATE_LEN:adlen, ONE_ZERO_PADDING);
    fix0(estate);
    AES128_encrypt(estate, estate);
    if((ad[0] & 0x80) || (adlen == 0)){
        // appy h
        h(estate);
    }
    else{
        // do nothing
    }
    
    if(adlen > STATE_LEN){ // ad is of moer than one block
        i = STATE_LEN;
        
        /* process the middle ad blocks, excluding the first and last (partial) block */
        while((i+STATE_LEN) < adlen)
        {
            tmp = LOAD(ad+i);
            estate = XOR(estate, tmp);
            AES128_encrypt(estate, estate);
            i += STATE_LEN;
        }
        
        /* process the last (partial) ad block */
        load_partial_block(&tmp, ad+i, adlen - i, ONE_ZERO_PADDING);
        estate = XOR(estate, tmp);
        AES128_encrypt(estate, estate);
    }
    
    
    /* process the nonce */
    load_partial_block(&tmp, npub, CRYPTO_NPUBBYTES, PARAM_OZP);
    estate = XOR(estate, tmp);
    
    if((adlen % STATE_LEN) || (adlen == 0)){
        /* apply f2 */
        f2(estate);
    }
    else{
        /* apply f1 */
        f1(estate);
    }
    
    /* process ciphertext */
    
    tstate = estate;
    AES128_encrypt(estate, estate);
    
    if(*mlen){
        /* apply g2 to tag state */
        g2(tstate);
    }
    else{
        /* apply g1 to tag state */
        g1(tstate);
    }
    AES128_encrypt(tstate, tstate);
    
    
    
    i = 0;
    /* process all the message except for the last message/ciphertext block */
    while((i + STATE_LEN) < (*mlen)){
        tmp = LOAD(c+i);
        estate = XOR(estate, tmp);
        STORE(m+i, estate);
        tstate = XOR(tmp, tstate);
        AES128_encrypt(tstate, tstate);
        fix1(tmp);
        print_state("after applying fix1\n", estate);
        AES128_encrypt(tmp, estate);
        i += STATE_LEN;
    }
    
    /* process the last block of the message/ciphetext */
    lastblocklen = (*mlen) - i;
    
    if(lastblocklen > 0){
        load_partial_block(&tmp, c+i, lastblocklen, ZERO_APPEND);
        estate = XOR(estate, tmp);
        print_state("after xoring last partial message block\n", estate);
        store_partial_block(m+i, estate, lastblocklen);
        unsigned char shift_bytes = (STATE_LEN - (unsigned char)lastblocklen);
        tmp = AND(SHR(_mm_set1_epi8(0xff), shift_bytes), tmp);
        tstate = XOR(tstate, tmp);
        /* add the one zero padding */
        tstate = XOR(tstate, SHL(_mm_set_epi8(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0x80), lastblocklen));
        
        if((*mlen) % STATE_LEN){
            /* apply f2 */
            f2(tstate);
        }
        else{
            /* apply f1 */
            f1(tstate);
        }
        AES128_encrypt(tstate, tstate);
    }
    
    /* compare tag and output message */
    STORE(ltag, tstate);
    for(j = 0; j < CRYPTO_ABYTES; j++){
        if(ltag[j] != c[clen - CRYPTO_ABYTES + j])
            return RETURN_TAG_NO_MATCH;
    }
    return RETURN_SUCCESS;

}
コード例 #23
0
ファイル: t121.C プロジェクト: 0day-ci/gcc
struct S { void g2 (void (*) (...)); void h2 () { g2 (f); } };// { dg-error "invalid conversion" "match" }
コード例 #24
0
ファイル: cloc.c プロジェクト: 0x64616E69656C/supercop
/*
 * plaintext, message length in byte, ciphertext, associated data, and associated data length in byte tag, and tag length in byte
 */
int ae_encrypt(ae_cxt* cxt, byte* pt, unsigned long long mlen, byte* ct, byte* tag, unsigned long long tlen, int enc_dec)
{
	cxt->pt = pt;
	cxt->ptlen = mlen;
	cxt->ct = ct;
	cxt->ctlen = mlen;
	cxt->tag = tag;
	cxt->tlen = tlen;

	byte* es = cxt->es;
	byte* ts = cxt->ts;

	word* wd = (word*) ts;
	if(mlen != 0){
		g2(wd[0], wd[1], wd[2], wd[3]);
		Encode(cxt->ts, cxt->ts);
	}
	else{
		g1(wd[0], wd[1], wd[2], wd[3]);
		Encode(cxt->ts, cxt->ts);
		memcpy(tag, ts, tlen);
		return SUCCESS;
	}


	unsigned long long pc = 0;
	while((pc + STATE_LEN) < mlen){
		if(enc_dec == ENC){ // encryption
			xor_bytes(es, pt+pc, STATE_LEN);
			pstate2("After xoring message block:", es);
			memcpy(ct+pc, es, STATE_LEN);
		}
		else{ // decryption
			xor_bytes2(pt+pc, ct+pc, es, STATE_LEN);
			pstate2("After xoring ciphertext block:", es);
			memcpy(es, ct+pc, STATE_LEN);
		}
		xor_bytes(ts, es, STATE_LEN);
		Encode(ts, ts);
		/* apply fix1 */
		es[0] |= 0x80;
		pstate2("After applying fix1:", es);
		Encode(es, es);
		pc += STATE_LEN;
	}

	/* process the last block */
	unsigned long long lastblocklen = mlen - pc;
	if(enc_dec == ENC){ // encryption
		xor_bytes(es, pt+pc, lastblocklen);
		pstate2("After xoring last partial message block:", es);
		memcpy(ct+pc, es, lastblocklen);
	}
	else{ // decryption
		xor_bytes2(pt+pc, ct+pc, es, lastblocklen);
		pstate2("After xoring last partial ciphertext block:", es);
		memcpy(es, ct+pc, lastblocklen);
	}
	xor_bytes(ts, es, lastblocklen);
	pstate2("tag state:", ts);
	if(lastblocklen != STATE_LEN){ // apply f2
		/* apply padding only when last message block is not full */
		ts[lastblocklen] ^= 0x80;
		word* wd = (word*) ts;
		f2(wd[0], wd[1], wd[2], wd[3]);
	}
	else{ // apply f1
		word* wd = (word*) ts;
		f1(wd[0], wd[1], wd[2], wd[3]);
	}

	pstate2("After applying f1/f2:", ts);
	Encode(ts, ts);
	memcpy(tag, ts, tlen);

	return SUCCESS;
}
コード例 #25
0
ファイル: diag_e_metric_test.cpp プロジェクト: actuariat/stan
TEST(McmcDiagEMetric, gradients) {
  rng_t base_rng(0);
  
  Eigen::VectorXd q = Eigen::VectorXd::Ones(11);
  
  stan::mcmc::diag_e_point z(q.size());
  z.q = q;
  z.p.setOnes();
  
  std::fstream data_stream(std::string("").c_str(), std::fstream::in);
  stan::io::dump data_var_context(data_stream);
  data_stream.close();

  std::stringstream model_output, metric_output;
  
  funnel_model_namespace::funnel_model model(data_var_context, &model_output);
  
  stan::mcmc::diag_e_metric<funnel_model_namespace::funnel_model, rng_t> metric(model, &metric_output);
  
  double epsilon = 1e-6;
  
  metric.update(z);
  
  Eigen::VectorXd g1 = metric.dtau_dq(z);
  
  for (int i = 0; i < z.q.size(); ++i) {
    
    double delta = 0;
    
    z.q(i) += epsilon;
    metric.update(z);
    delta += metric.tau(z);
    
    z.q(i) -= 2 * epsilon;
    metric.update(z);
    delta -= metric.tau(z);
    
    z.q(i) += epsilon;
    metric.update(z);
    
    delta /= 2 * epsilon;
    
    EXPECT_NEAR(delta, g1(i), epsilon);
    
  }
  
  Eigen::VectorXd g2 = metric.dtau_dp(z);
  
  for (int i = 0; i < z.q.size(); ++i) {
    
    double delta = 0;
    
    z.p(i) += epsilon;
    delta += metric.tau(z);
    
    z.p(i) -= 2 * epsilon;
    delta -= metric.tau(z);
    
    z.p(i) += epsilon;
    
    delta /= 2 * epsilon;
    
    EXPECT_NEAR(delta, g2(i), epsilon);
    
  }
  
  Eigen::VectorXd g3 = metric.dphi_dq(z);
  
  for (int i = 0; i < z.q.size(); ++i) {
    
    double delta = 0;
    
    z.q(i) += epsilon;
    metric.update(z);
    delta += metric.phi(z);
    
    z.q(i) -= 2 * epsilon;
    metric.update(z);
    delta -= metric.phi(z);
    
    z.q(i) += epsilon;
    metric.update(z);
    
    delta /= 2 * epsilon;
    
    EXPECT_NEAR(delta, g3(i), epsilon);
    
  }

  EXPECT_EQ("", model_output.str());
  EXPECT_EQ("", metric_output.str());
}
コード例 #26
0
ファイル: d-tree-call.c プロジェクト: mycoboco/beluga
void f2(void) { void h2(int, double); void g2(); h2(0, 1); g2(0, 1); }    /* prototype vs. non-prototype */
コード例 #27
0
bool rspfOgrVectorTileSource::open()
{
   const char* MODULE = "rspfOgrVectorTileSource::open";
  
   if (isOgrVectorDataSource() == false)
   {
      close();
      return false;
   }
   if(isOpen())
   {
      close();
   }
   theDataSource = OGRSFDriverRegistrar::Open(theImageFile,
                                              false);
   if (theDataSource)
   {
      int layerCount = theDataSource->GetLayerCount();
      theLayerVector.resize(layerCount);
      if(layerCount)
      {
         for(int i = 0; i < layerCount; ++i)
         {
            OGRLayer* layer = theDataSource->GetLayer(i);
            if(layer)
            {
               OGRSpatialReference* spatialReference = layer->GetSpatialRef();
               if(!spatialReference)
               {
                  if(traceDebug())
                  {
                     rspfNotify(rspfNotifyLevel_NOTICE)
                        << MODULE
                        << " No spatial reference given, assuming geographic"
                        << endl;
                  }
               }
            }
            else
            {
               if(traceDebug())
               {
                  rspfNotify(rspfNotifyLevel_NOTICE)
                     << MODULE
                     << " layer " << i << " is null." << endl;
               }
            }
            if (layer)
            {
               layer->GetExtent(&theBoundingExtent, true);
               rspfRefPtr<rspfProjection> proj = createProjFromReference(layer->GetSpatialRef());
               rspfRefPtr<rspfImageGeometry> imageGeometry = 0;
               bool isDefaultProjection = false;
               if(proj.valid())
               {
                  imageGeometry = new rspfImageGeometry(0, proj.get());
               }
               rspfMapProjection* mapProj = 0;
               if(imageGeometry.valid())
               {
                  mapProj = PTR_CAST(rspfMapProjection, imageGeometry->getProjection());
               }
               else
               {
                  mapProj = createDefaultProj();
                  imageGeometry = new rspfImageGeometry(0, mapProj);
                  isDefaultProjection = true;
               }
               if(mapProj)
               {
                  rspfDrect rect(theBoundingExtent.MinX,
                                  theBoundingExtent.MaxY,
                                  theBoundingExtent.MaxX,
                                  theBoundingExtent.MinY,
                                  RSPF_RIGHT_HANDED);
            
                  std::vector<rspfGpt> points;
                  if (isDefaultProjection || mapProj->isGeographic())
                  {
                     rspfGpt g1(rect.ul().y, rect.ul().x);
                     rspfGpt g2(rect.ur().y, rect.ur().x);
                     rspfGpt g3(rect.lr().y, rect.lr().x);
                     rspfGpt g4(rect.ll().y, rect.ll().x);
                     points.push_back(g1);
                     points.push_back(g2);
                     points.push_back(g3);
                     points.push_back(g4);
                  }
                  else
                  {
                     rspfGpt g1 = mapProj->inverse(rect.ul());
                     rspfGpt g2 = mapProj->inverse(rect.ur());
                     rspfGpt g3 = mapProj->inverse(rect.lr());
                     rspfGpt g4 = mapProj->inverse(rect.ll());
                     points.push_back(g1);
                     points.push_back(g2);
                     points.push_back(g3);
                     points.push_back(g4);
                  }
            
                  std::vector<rspfDpt> rectTmp;
                  rectTmp.resize(4);
                  for(std::vector<rspfGpt>::size_type index=0; index < 4; ++index)
                  {
                     imageGeometry->worldToLocal(points[(int)index], rectTmp[(int)index]);
                  }
                  rspfDrect rect2 = rspfDrect(rectTmp[0],
                                                rectTmp[1],
                                                rectTmp[2],
                                                rectTmp[3]);
                  theLayerVector[i] = new rspfOgrVectorLayerNode(rect2);
                  theLayerVector[i]->setGeoImage(imageGeometry);
                  if (i == 0)
                     theImageGeometry = imageGeometry;
               }
            }
         }
      }
   }
   else
   {
      delete theDataSource;
      theDataSource = 0;
      return false;
   }
   return (theDataSource!=0);
}
コード例 #28
0
QT_END_NAMESPACE


void tst_QButtonGroup::arrowKeyNavigation()
{
    if (!qt_tab_all_widgets())
        QSKIP("This test requires full keyboard control to be enabled.");

    QDialog dlg(0);
    QHBoxLayout layout(&dlg);
    QGroupBox g1("1", &dlg);
    QHBoxLayout g1layout(&g1);
    QRadioButton bt1("Radio1", &g1);
    QPushButton pb("PB", &g1);
    QLineEdit le(&g1);
    QRadioButton bt2("Radio2", &g1);
    g1layout.addWidget(&bt1);
    g1layout.addWidget(&pb);
    g1layout.addWidget(&le);
    g1layout.addWidget(&bt2);

    // create a mixed button group with radion buttons and push
    // buttons. Not very useful, but it tests borderline cases wrt
    // focus handling.
    QButtonGroup bgrp1(&g1);
    bgrp1.addButton(&bt1);
    bgrp1.addButton(&pb);
    bgrp1.addButton(&bt2);

    QGroupBox g2("2", &dlg);
    QVBoxLayout g2layout(&g2);
    // we don't need a button group here, because radio buttons are
    // auto exclusive, i.e. they group themselves in he same parent
    // widget.
    QRadioButton bt3("Radio3", &g2);
    QRadioButton bt4("Radio4", &g2);
    g2layout.addWidget(&bt3);
    g2layout.addWidget(&bt4);

    layout.addWidget(&g1);
    layout.addWidget(&g2);

    dlg.show();
    qApp->setActiveWindow(&dlg);
    QVERIFY(QTest::qWaitForWindowActive(&dlg));

    bt1.setFocus();

    QTRY_VERIFY(bt1.hasFocus());

    QTest::keyClick(&bt1, Qt::Key_Right);
    QVERIFY(pb.hasFocus());
    QTest::keyClick(&pb, Qt::Key_Right);
    QVERIFY(bt2.hasFocus());
    QTest::keyClick(&bt2, Qt::Key_Right);
    QVERIFY(bt2.hasFocus());
    QTest::keyClick(&bt2, Qt::Key_Left);
    QVERIFY(pb.hasFocus());
    QTest::keyClick(&pb, Qt::Key_Left);
    QVERIFY(bt1.hasFocus());

    QTest::keyClick(&bt1, Qt::Key_Tab);
    QVERIFY(pb.hasFocus());
    QTest::keyClick(&pb, Qt::Key_Tab);

    QVERIFY(le.hasFocus());
    QCOMPARE(le.selectedText(), le.text());
    QTest::keyClick(&le, Qt::Key_Tab);

    QVERIFY(bt2.hasFocus());
    QTest::keyClick(&bt2, Qt::Key_Tab);
    QVERIFY(bt3.hasFocus());

    QTest::keyClick(&bt3, Qt::Key_Down);
    QVERIFY(bt4.hasFocus());
    QTest::keyClick(&bt4, Qt::Key_Down);
    QVERIFY(bt4.hasFocus());

    QTest::keyClick(&bt4, Qt::Key_Up);
    QVERIFY(bt3.hasFocus());
    QTest::keyClick(&bt3, Qt::Key_Up);
    QVERIFY(bt3.hasFocus());
}
コード例 #29
0
ファイル: p2.cpp プロジェクト: jvesely/clang
  void test() {
	  M::S s;
    f(s);    // ok
    g1(s);   // expected-error {{use of undeclared}}
    g2(s);   // expected-error {{use of undeclared}}
  }
コード例 #30
0
ファイル: app.cpp プロジェクト: BrainDestroyer/hw
bool App::init() {
    _scene = new Scene;

    _core = new Core;
    _core->initialize();

    connect(_core, SIGNAL(exit()), this, SLOT(quit()));


    // delete later
    _background = new GraphicObject;

    _background->setSurface(_core->getSurface("background.png"));
    SDL_Rect backRect = {0, 0, 1500, 843};
    _background->setRect(backRect);
    qsrand(time(NULL));
    _scene->setBack(_background);

    connect(_core->getEH(), SIGNAL(eventMsg(SDL_Event*)),
            this, SLOT(event(SDL_Event*)));

    // creating state ------------------------------
    Battle *battle = new Battle;
    Scene *batScene = new Scene;
    battle->setScene(_scene);


    loadUnits(battle);

    // gates
    SDL_Rect gateRect;
    gateRect.x = 0;
    gateRect.y = 0;
    gateRect.w = 30;
    gateRect.h = 30;
    CombinedAnimation gateAnLeft;
    gateAnLeft.setSurface(_core->getSurface("leftgate.png"));
    gateAnLeft.setFrameLines(2);
    gateAnLeft.setMaxFrames(7);
    gateAnLeft.setFrames(0, 4);
    gateAnLeft.setFrames(1, 7);
    CombinedAnimation gateAnRight;
    gateAnRight.setSurface(_core->getSurface("rightgate.png"));
    gateAnRight.setFrameLines(2);
    gateAnRight.setMaxFrames(7);
    gateAnRight.setFrames(0, 4);
    gateAnRight.setFrames(1, 7);
    gateAnRight.flipHorizontal();
    DamageableItem g1(1000, Position(310, SPAWN_LINE),Size(100, 90), 9);
    DamageableItem g2(1000, Position(1200, SPAWN_LINE),Size(100, 90), 19);

    // left castle
    SDL_Rect wallRect = {0, 0, 297, 230};
    Animation leftWallAn;
    leftWallAn.setSurface(_core->getSurface("castle.png"));
    leftWallAn.setFrames(1);
    leftWallAn.setRect(wallRect);
    leftWallAn.flipHorizontal();
    AreaItem leftWallItem(147, SPAWN_LINE, 220, 195);
    QSharedPointer<Castle> lCastle = QSharedPointer<Castle>(new Castle(leftWallItem, g1, leftWallAn, gateAnLeft, Position(100, SPAWN_LINE), 5, 1, 1500));
    battle->setLeftCastle(lCastle);

    // right castle

    Animation wallAn;
    wallAn.setSurface(_core->getSurface("castle.png"));
    wallAn.setFrames(1);
    wallAn.setRect(wallRect);
    AreaItem wallItem(1365, SPAWN_LINE, 220, 195);
    QSharedPointer<Castle> rCastle = QSharedPointer<Castle>(new Castle(wallItem, g2, wallAn, gateAnRight, Position(1400, SPAWN_LINE), 5, 0, 1500));
    battle->setRightCastle(rCastle);

    // Player stats
    QList<SDL_Surface*> iconSurfs;
    iconSurfs << _core->getSurface("warrior_icon.png");
    iconSurfs << _core->getSurface("ranger_icon.png");
    iconSurfs << _core->getSurface("rangerwall_icon.png");
    iconSurfs << _core->getSurface("knight_icon.png");
    iconSurfs << _core->getSurface("evilwarrior_icon.png");
    iconSurfs << _core->getSurface("evilranger_icon.png");
    iconSurfs << _core->getSurface("evilrangerwall_icon.png");
    iconSurfs << _core->getSurface("evilknight_icon.png");
    PlayerStats *stats = new PlayerStats(iconSurfs);

    battle->setPlayerStats(stats);

    // barrier floor
    QSharedPointer<AreaItem> floor
            = QSharedPointer<AreaItem>(new AreaItem(450, SPAWN_LINE + 700,
                                                    3000, 699, 0, true, true));
    battle->setFloor(floor);

    // win sets
    GraphicObject *right = new GraphicObject();
    GraphicObject *left = new GraphicObject();
    GraphicObject *draw = new GraphicObject();
    right->setSurface(_core->getSurface("rightwin.png"));
    left->setSurface(_core->getSurface("leftwin.png"));
    draw->setSurface(_core->getSurface("draw.png"));

    SDL_Rect winrect = {500, 300, 500, 200};
    right->setRect(winrect);
    left->setRect(winrect);
    draw->setRect(winrect);

    battle->setWinPics(*left, *right, *draw);

    // starting
    _core->pushState(battle);

    _core->startStateTimer(17);
    int id = _core->addTimer();

    _core->getTimer(id)->start(17);


    connect(_core->getTimer(id), SIGNAL(timeout()),
            this, SLOT(draw()));
    //----------------------------------------------

    return true;
}