void Dirac_DomainWall_4D::
BprojCore_dag(double* f1,double* fN,const double* f) const{

  // f1 = f5(0), fN = f5(N5_-1)
  for(int c=0; c<NC_; ++c){
    double fup_r = 0.5*(f[r0(c)] +f[r2(c)]);
    double fup_i = 0.5*(f[i0(c)] +f[i2(c)]);
    double fdn_r = 0.5*(f[r1(c)] +f[r3(c)]);
    double fdn_i = 0.5*(f[i1(c)] +f[i3(c)]);

    fN[r0(c)] = fup_r;   fN[i0(c)] = fup_i;
    fN[r1(c)] = fdn_r;   fN[i1(c)] = fdn_i;
    fN[r2(c)] = fup_r;   fN[i2(c)] = fup_i;
    fN[r3(c)] = fdn_r;   fN[i3(c)] = fdn_i;

    fup_r -= f[r2(c)]; //0.5*(f[r0(c)] -f[r2(c)])
    fup_i -= f[i2(c)]; //0.5*(f[i0(c)] -f[i2(c)])
    fdn_r -= f[r3(c)]; //0.5*(f[r1(c)] -f[r3(c)])
    fdn_i -= f[i3(c)]; //0.5*(f[i1(c)] -f[i3(c)])

    f1[r0(c)] = fup_r;   f1[i0(c)] = fup_i;
    f1[r1(c)] = fdn_r;   f1[i1(c)] = fdn_i;
    f1[r2(c)] =-fup_r;   f1[i2(c)] =-fup_i;
    f1[r3(c)] =-fdn_r;   f1[i3(c)] =-fdn_i;
  }
}
Exemple #2
0
static A jttayamp(J jt,A w,B nf,A x,A h){A y;B ng=!nf;I j,n;V*v=VAV(h);
 ASSERT(AR(x)<=(nf?v->lr:v->rr),EVRANK);
 switch(v->id){
  case CPLUS:  R tpoly(over(x,one));
  case CMINUS: R tpoly(nf?over(x,num[-1]):over(negate(x),one));
  case CSTAR:  R tpoly(over(zero,x));
  case CDIV:   ASSERT(ng,EVDOMAIN); R tpoly(over(zero,recip(x)));
  case CJDOT:  R tpoly(nf?over(x,a0j1):over(jdot1(x),one));
  case CPOLY:  ASSERT(nf,EVDOMAIN); R tpoly(BOX&AT(x)?poly1(x):x);
  case CHGEOM: ASSERT(nf,EVDOMAIN); RE(j=i0(x)); ASSERT(0<=j,EVDOMAIN);
               y=IX(j);
               R tpoly(divide(hgcoeff(y,h),fact(y)));
  case CBANG:  ASSERT(nf,EVDOMAIN); RE(j=i0(x)); ASSERT(0<=j,EVDOMAIN); 
               R tpoly(divide(poly1(box(iota(x))),fact(x)));
  case CEXP:   if(nf)R eva(x,"(^.x)&^ % !");
               RE(n=i0(x));   
               R 0<=n?tpoly(over(reshape(x,zero),one)):atop(ds(CDIV),amp(h,sc(-n))); 
  case CFIT:   ASSERT(nf&&CPOLY==ID(v->f),EVDOMAIN);
               y=over(x,IX(IC(x)));
               R tpoly(mdiv(df2(x,y,h),atab(CEXP,y,IX(IC(x)))));
  case CCIRCLE:
   switch(i0(x)){
    case 1:    R eval("{&0 1 0 _1@(4&|) % !");
    case -3:   R eval("{&0 1 0 _1@(4&|) % ]");
    case 2:    R eval("{&1 0 _1 0@(4&|) % !");
    case 5:    R eval("2&|    % !");
    case -7:   R eval("2&|    % ]");
    case 6:    R eval("2&|@>: % !");
    case -1:   R eval("(2&|              % ]) * ([: */ (1&+ % 2&+)@(i.@<.&.-:))\"0");
    case -5:   R eval("({&0 1 0 _1@(4&|) % ]) * ([: */ (1&+ % 2&+)@(i.@<.&.-:))\"0");
 }}
 ASSERT(0,EVDOMAIN);
}
void GammaMatrix::isigma24core(double* w,const double* f)const{
  for(int c=0; c<Ncol_; ++c){
    w[r0(c)] = f[r3(c)];  w[i0(c)] = f[i3(c)];
    w[r1(c)] =-f[r2(c)];  w[i1(c)] =-f[i2(c)];
    w[r2(c)] = f[r1(c)];  w[i2(c)] = f[i1(c)];
    w[r3(c)] =-f[r0(c)];  w[i3(c)] =-f[i0(c)];
  }
}
void DiracWilsonLike::gamma5core(double* w,const double* f)const{
  for(int c=0; c<N; ++c){
    w[r0(c)] = f[r2(c)];  w[i0(c)] = f[i2(c)];
    w[r1(c)] = f[r3(c)];  w[i1(c)] = f[i3(c)];
    w[r2(c)] = f[r0(c)];  w[i2(c)] = f[i0(c)];
    w[r3(c)] = f[r1(c)];  w[i3(c)] = f[i1(c)];
  }
}
SysDDec kaiser70SincWin(long const n, long const M) {
	SysDDec const beta = 6.9;
	static SysDDec const i0beta_rec = 1.0 / i0(beta);

	SysDDec x = static_cast<SysDDec>(n * 2) / M - 1.0;
	x = x * x;
	x = beta * std::sqrt(1.0 - x);

	return i0(x) * i0beta_rec;
}
Exemple #6
0
double kaiser70SincWin(long const n, long const M) {
    double const beta = 6.9;
    static double const i0beta_rec = 1.0 / i0(beta);

    double x = static_cast<double>(n * 2) / M - 1.0;
    x = x * x;
    x = beta * std::sqrt(1.0 - x);

    return i0(x) * i0beta_rec;
}
void GammaMatrix::projMcore(double* w,const double* f)const{
  for(int c=0; c<Ncol_; ++c){
    double fup_r = 0.5*(f[r0(c)] -f[r2(c)]);
    double fup_i = 0.5*(f[i0(c)] -f[i2(c)]);
    double fdn_r = 0.5*(f[r1(c)] -f[r3(c)]);
    double fdn_i = 0.5*(f[i1(c)] -f[i3(c)]);
    w[r0(c)] = fup_r;   w[i0(c)] = fup_i;
    w[r1(c)] = fdn_r;   w[i1(c)] = fdn_i;
    w[r2(c)] =-fup_r;   w[i2(c)] =-fup_i;
    w[r3(c)] =-fdn_r;   w[i3(c)] =-fdn_i;
  }
}
void DiracWilsonLike::projMcore(double* w,const double* f)const{
  for(int c=0; c<N; ++c){
    double fup_r = 0.5*(f[r0(c)] -f[r2(c)]);
    double fup_i = 0.5*(f[i0(c)] -f[i2(c)]);
    double fdn_r = 0.5*(f[r1(c)] -f[r3(c)]);
    double fdn_i = 0.5*(f[i1(c)] -f[i3(c)]);
    w[r0(c)] = fup_r;   w[i0(c)] = fup_i;
    w[r1(c)] = fdn_r;   w[i1(c)] = fdn_i;
    w[r2(c)] =-fup_r;   w[i2(c)] =-fup_i;
    w[r3(c)] =-fdn_r;   w[i3(c)] =-fdn_i;
  }
}
Exemple #9
0
double Denoise::hypergeom(double theta)
{
    if(theta < 7.389056)
	return exp(-theta/2.0)*(1.0+theta*i0(theta/2.0)+theta*i1(theta/2.0));
    else
	return exp(0.09379 + 0.50447*log(theta));
}
void DW5dMatrix::BprojCore(double* f,const double* f1,const double* fN)const{
  for(int c=0; c<Ncol_; ++c){
    double fupNr = 0.5*(fN[r0(c)] +fN[r2(c)]);
    double fupNi = 0.5*(fN[i0(c)] +fN[i2(c)]);
    double fdnNr = 0.5*(fN[r1(c)] +fN[r3(c)]);
    double fdnNi = 0.5*(fN[i1(c)] +fN[i3(c)]);

    double fup1r = 0.5*(f1[r0(c)] -f1[r2(c)]);
    double fup1i = 0.5*(f1[i0(c)] -f1[i2(c)]);
    double fdn1r = 0.5*(f1[r1(c)] -f1[r3(c)]);
    double fdn1i = 0.5*(f1[i1(c)] -f1[i3(c)]);

    f[r0(c)] = fupNr +fup1r;   f[i0(c)] = fupNi +fup1i;
    f[r1(c)] = fdnNr +fdn1r;   f[i1(c)] = fdnNi +fdn1i;
    f[r2(c)] = fupNr -fup1r;   f[i2(c)] = fupNi -fup1i;
    f[r3(c)] = fdnNr -fdn1r;   f[i3(c)] = fdnNi -fdn1i;
  }
}
Exemple #11
0
TEST(LRUCacheTest, TestInert) {
  lru_type lru;
  CacheItem i0(1, 1);
  lru.insert(&i0);
  EXPECT_EQ(size_t(1), lru.size());
  EXPECT_EQ(&i0, lru.find(1));
  EXPECT_EQ(1, lru.victim()->k);
  EXPECT_EQ(size_t(0), lru.size());
}
void Dirac_DomainWall_4D::
BprojCore(double* f,const double* f1,const double* fN)const{ 
  for(int c=0; c<NC_; ++c){
    double fupNr = 0.5*(fN[r0(c)] +fN[r2(c)]);
    double fupNi = 0.5*(fN[i0(c)] +fN[i2(c)]);
    double fdnNr = 0.5*(fN[r1(c)] +fN[r3(c)]);
    double fdnNi = 0.5*(fN[i1(c)] +fN[i3(c)]);

    double fup1r = 0.5*(f1[r0(c)] -f1[r2(c)]);
    double fup1i = 0.5*(f1[i0(c)] -f1[i2(c)]);
    double fdn1r = 0.5*(f1[r1(c)] -f1[r3(c)]);
    double fdn1i = 0.5*(f1[i1(c)] -f1[i3(c)]);

    f[r0(c)] = fupNr +fup1r;   f[i0(c)] = fupNi +fup1i;
    f[r1(c)] = fdnNr +fdn1r;   f[i1(c)] = fdnNi +fdn1i;
    f[r2(c)] = fupNr -fup1r;   f[i2(c)] = fupNi -fup1i;
    f[r3(c)] = fdnNr -fdn1r;   f[i3(c)] = fdnNi -fdn1i;
  }
}
Exemple #13
0
static A jttcoamp(J jt,A w,B nf,A x,A h){I j;V*v=VAV(h);
 ASSERT(AR(x)<=v->mr,EVRANK);
 switch(v->id){
  case CEXP:   
   if(nf)R amp(logar1(x),ds(CEXP)); break;
  case CHGEOM: 
   ASSERT(nf,EVDOMAIN); RE(j=i0(x)); ASSERT(0<=j,EVDOMAIN);
   R tpoly(hgcoeff(IX(j),h));
 }
 R facit(tayamp(w,nf,x,h));
}
Exemple #14
0
void testgammasparse()
{
	std::ostringstream o0;
	libmaus::gamma::SparseGammaGapEncoder SE0(o0);
	std::ostringstream o1;
	libmaus::gamma::SparseGammaGapEncoder SE1(o1);
	
	SE0.encode(4, 7);
	SE0.encode(6, 3);
	SE0.term();
	
	SE1.encode(0, 1);
	SE1.encode(2, 5);
	SE1.encode(6, 2);
	SE1.encode(8, 7);
	SE1.term();
	
	std::cerr << "o0.size()=" << o0.str().size() << std::endl;
	std::cerr << "o1.size()=" << o1.str().size() << std::endl;
	
	std::istringstream i0(o0.str());
	libmaus::gamma::SparseGammaGapDecoder SD0(i0);
	std::istringstream i1(o1.str());
	libmaus::gamma::SparseGammaGapDecoder SD1(i1);
	
	for ( uint64_t i = 0; i < 10; ++i )
		std::cerr << SD0.decode() << ";";
	std::cerr << std::endl;
	for ( uint64_t i = 0; i < 10; ++i )
		std::cerr << SD1.decode() << ";";
	std::cerr << std::endl;

	std::istringstream mi0(o0.str());
	std::istringstream mi1(o1.str());
	std::ostringstream mo;
	
	libmaus::gamma::SparseGammaGapMerge::merge(mi0,mi1,mo);
	
	std::istringstream mi(mo.str());
	libmaus::gamma::SparseGammaGapDecoder SDM(mi);

	for ( uint64_t i = 0; i < 10; ++i )
		std::cerr << SDM.decode() << ";";
	std::cerr << std::endl;
}
Exemple #15
0
std::string
Basics::
print(size_t indent) const
{
    std::string i0(indent * 4, ' ');
    std::string i1(++indent * 4, ' ');

    std::stringstream ss;

    ss << "{\n"
        << i1 << "boolean: " << boolean << '\n'
        << i1 << "integer: " << integer << '\n'
        << i1 << "floating: " << floating << '\n'
        << i1 << "string: " << string << '\n'
        << i1 << "stringPtr: " << printPtr(stringPtr) << '\n'
        << i1 << "stringShared: " << printPtr(stringShared) << '\n'
        << i1 << "nullPtr: " << printPtr(nullPtr) << '\n'
        << i1 << "nullShared: " << printPtr(nullShared) << '\n'
        << i1 << "skip: " << skip << '\n'
        << i1 << "alias: " << alias << '\n'
        << i1 << "custom: " << custom.print() << '\n';

    ss << i1 << "vector: " << vector.size() << "[ ";
    for (const auto& item : vector) ss << item << ' ';
    ss << "]\n";

    ss << i1 << "vectorPtr: " << vectorPtr.size() << "[ ";
    for (const auto& item : vectorPtr) ss << printPtr(item) << ' ';
    ss << "]\n";

    ss << i1 << "map: " << map.size() << "[ ";
    for (const auto& entry : map) ss << entry.first << ':' << entry.second << ' ';
    ss << "]\n";

    ss << i1 << "mapPtr: " << mapPtr.size() << "[ ";
    for (const auto& entry : mapPtr) ss << entry.first << ':' << printPtr(entry.second) << ' ';
    ss << "]\n";

    ss << i1 << "next: " << (next ? next->print(indent) : "nil") << '\n';

    ss << i0 << "}";
    return ss.str();
}
Exemple #16
0
double k0(double x)
{
double y, z;

if( x <= 0.0 )
        /*
	{
	mtherr( "k0", DOMAIN );
	return( MAXNUM );
	}
	*/
	assert(0);

if( x <= 2.0 )
	{
	y = x * x - 2.0;
	y = chbevl( y, A_k0, 10 ) - log( 0.5 * x ) * i0(x);
	return( y );
	}
z = 8.0/x - 2.0;
y = exp(-x) * chbevl( z, B_k0, 25 ) / sqrt(x);
return(y);
}
Exemple #17
0
// Create the derived verb for a fork.  Insert in-placeable flags based on routine, and asgsafe based on fgh
A jtfolk(J jt,A f,A g,A h){A p,q,x,y;AF f1=jtfolk1,f2=jtfolk2;B b;C c,fi,gi,hi;I flag,j,m=-1;V*fv,*gv,*hv,*v;
 RZ(f&&g&&h);
 gv=VAV(g); gi=gv->id;
 hv=VAV(h); hi=hv->id;
 // Start flags with ASGSAFE (if g and h are safe), and with INPLACEOK to match the setting of f1,f2
 flag=(VINPLACEOK1|VINPLACEOK2)+((gv->flag&hv->flag)&VASGSAFE);  // We accumulate the flags for the derived verb.  Start with ASGSAFE if all descendants are.
 if(NOUN&AT(f)){  /* y {~ x i. ] */
  // Temporarily raise the usecount of the noun.  Because we are in the same tstack frame as the parser, the usecount will stay
  // raised until any inplace decision has been made regarding this derived verb, protecting the derived verb if the
  // assigned name is the same as a name appearing here.  If the derived verb is used in another sentence, it must first be
  // assigned to a name, which will protects values inside it.
  rat1s(f);  // This justifies keeping the result ASGSAFE
  f1=jtnvv1;
  if(LIT&AT(f)&&1==AR(f)&&gi==CTILDE&&CFROM==ID(gv->f)&&hi==CFORK){
   x=hv->f;
   if(LIT&AT(x)&&1==AR(x)&&CIOTA==ID(hv->g)&&CRIGHT==ID(hv->h)){f1=jtcharmapa;  flag &=~(VINPLACEOK1);}
  }
  R fdef(CFORK,VERB, f1,jtnvv2, f,g,h, flag, RMAX,RMAX,RMAX);
 }
 fv=VAV(f); fi=fv->id; if(fi!=CCAP)flag &= fv->flag|~VASGSAFE;  // remove ASGSAFE if f is unsafe
 switch(fi){
  case CCAP:                      f1=jtcork1; f2=jtcork2;  break; /* [: g h */
  case CTILDE: if(NAME&AT(fv->f)){f1=jtcorx1; f2=jtcorx2;}  break; /* name g h */
  case CSLASH: if(gi==CDIV&&hi==CPOUND&&CPLUS==ID(fv->f)){f1=jtmean; flag|=VIRS1; flag &=~(VINPLACEOK1);} break;  /* +/%# */
  case CAMP:   /* x&i.     { y"_ */
  case CFORK:  /* (x i. ]) { y"_ */
   if(hi==CQQ&&(y=hv->f,LIT&AT(y)&&1==AR(y))&&equ(ainf,hv->g)&&
       (x=fv->f,LIT&AT(x)&&1==AR(x))&&CIOTA==ID(fv->g)&&
       (fi==CAMP||CRIGHT==ID(fv->h))){f1=jtcharmapb; flag &=~(VINPLACEOK1);} break;
  case CAT:    /* <"1@[ { ] */
   if(gi==CLBRACE&&hi==CRIGHT){                                   
    p=fv->f; q=fv->g; 
    if(CLEFT==ID(q)&&CQQ==ID(p)&&(v=VAV(p),x=v->f,CLT==ID(x)&&equ(one,v->g))){f2=jtsfrom; flag &=~(VINPLACEOK2);}
 }}
 switch(fi==CCAP?gi:hi){
  case CQUERY:  if(hi==CDOLLAR||hi==CPOUND){f2=jtrollk; flag &=~(VINPLACEOK2);}  break;
  case CQRYDOT: if(hi==CDOLLAR||hi==CPOUND){f2=jtrollkx; flag &=~(VINPLACEOK2);} break;
  case CICAP:   m=7; if(fi==CCAP){if(hi==CNE)f1=jtnubind; else if(FIT0(CNE,hv)){f1=jtnubind0; flag &=~(VINPLACEOK1);}} break;
  case CSLASH:  c=ID(gv->f); m=c==CPLUS?4:c==CPLUSDOT?5:c==CSTARDOT?6:-1; 
                if(fi==CCAP&&vaid(gv->f)&&vaid(h)){f2=jtfslashatg; flag &=~(VINPLACEOK2);}
                break;
  case CFCONS:  if(hi==CFCONS){x=hv->h; j=*BAV(x); m=B01&AT(x)?(gi==CIOTA?j:gi==CICO?2+j:-1):-1;} break;
  case CRAZE:   if(hi==CLBRACE){f2=jtrazefrom; flag &=~(VINPLACEOK2);}
                else if(hi==CCUT){
                 j=i0(hv->g);
                 if(CBOX==ID(hv->f)&&!j){f2=jtrazecut0; flag &=~(VINPLACEOK2);}
                 else if(boxatop(h)&&j&&-2<=j&&j<=2){f1=jtrazecut1; f2=jtrazecut2; flag &=~(VINPLACEOK1|VINPLACEOK2);}
 }}
 if(0<=m){
  v=4<=m?hv:fv; b=CFIT==v->id&&equ(zero,v->g);
  switch(b?ID(v->f):v->id){
   case CEQ:   f2=b?jtfolkcomp0:jtfolkcomp; flag|=0+8*m; flag &=~(VINPLACEOK1|VINPLACEOK2); break;
   case CNE:   f2=b?jtfolkcomp0:jtfolkcomp; flag|=1+8*m; flag &=~(VINPLACEOK1|VINPLACEOK2); break;
   case CLT:   f2=b?jtfolkcomp0:jtfolkcomp; flag|=2+8*m; flag &=~(VINPLACEOK1|VINPLACEOK2); break;
   case CLE:   f2=b?jtfolkcomp0:jtfolkcomp; flag|=3+8*m; flag &=~(VINPLACEOK1|VINPLACEOK2); break;
   case CGE:   f2=b?jtfolkcomp0:jtfolkcomp; flag|=4+8*m; flag &=~(VINPLACEOK1|VINPLACEOK2); break;
   case CGT:   f2=b?jtfolkcomp0:jtfolkcomp; flag|=5+8*m; flag &=~(VINPLACEOK1|VINPLACEOK2); break;
   case CEBAR: f2=b?jtfolkcomp0:jtfolkcomp; flag|=6+8*m; flag &=~(VINPLACEOK1|VINPLACEOK2); break;
   case CEPS:  f2=b?jtfolkcomp0:jtfolkcomp; flag|=7+8*m; flag &=~(VINPLACEOK1|VINPLACEOK2); break;
 }}
 // If this fork is not a special form, set the flags to indicate whether the f verb does not use an
 // argument.  In that case h can inplace the unused aegument.
 if(f1==jtfolk1 && f2==jtfolk2) flag |= atoplr(f);
 R fdef(CFORK,VERB, f1,f2, f,g,h, flag, RMAX,RMAX,RMAX);
}
Exemple #18
0
Complex getL(Complex w, double ky, double kx, double kx_, double *X,  double Ls,  double Ln, const int Nx,
            const double q, const double mass, const double T, const double eta) 
{

  Complex R= 0.;

  const double t = 0.;

         // We can ignore  terms with kx - kx_ >> 1, as integration over x is 0 due to oscillating term std::exp( ii * (kx - kx_) * X[x]);
         // ignore modes to far away as physically no connection but numerical problems
         // if(std::abs(kx-kx_) > 5.) continue;

         const double kp2    = ky*ky + kx * kx ;
         const double kp2_   = ky*ky + kx_* kx_;
     
         const double Omega  =  - q  / mass;

         const double v_th   = sqrt(2. * T / mass);
         //const double v_th   = sqrt(T / mass);
         const double rho    = v_th / Omega ;

         const double w_star = ky * T / ( Omega * mass * Ln );
         const double w_D    = 0. ;//#- w_star * Ln / LB;
     
         const double b  = kp2  * rho*rho / 2.;
         const double b_ = kp2_ * rho*rho / 2.;
         
         // Note : b_a >= b_g for every b,b_
         const double b_a = (b + b_) / 2.; // arithmetic mean
         const double b_g = sqrt(b * b_);  // geometric  mean
    
         // need asymptoctic approximation otherwise it fails, (points corresponds where
         // errors from double precision are large than due to expansion.
         const double G0 = (b_g < 10.) ? i0(b_g) * exp(-b_a) 
                                       : exp(b_g - b_a)/sqrt(2.*M_PI*b_g) * ( 1. + 1./(8.*b_g) +  9./(128.*b_g*b_g));
         const double G1 = (b_g < 10.) ? i1(b_g) * exp(-b_a)
                                       : exp(b_g - b_a)/sqrt(2.*M_PI*b_g) * ( 1. - 3./(8.*b_g) - 15./(128.*b_g*b_g));


         //use Sinh-Tanh Rule
         const double x_i[Nx], w_i[Nx];

  
         // Integrate over x, using fixed kx, kx_
   for(int x = 0; x < Nx; x++) {
         if(X[x] == 0.) continue;
         const double k_p    = (X[x]/Ls) * ky;


         const Complex  zeta   = (w - w_D * t) / (v_th * fabs(k_p));
         const Complex  Z      = PlasmaDispersion(zeta) ;
     
              
         const Complex z = w_star/w; 
         const Complex zeta2 = zeta*zeta;

         const Complex    Lq  =  (1.   - z) * zeta * Z * G0  
                                - eta * z * (zeta2 + (zeta2 -3./2.) * zeta * Z) * G0 
                                - eta * z * zeta * Z * ((1. - b_a) * G0 + b_g * G1);

         // Note : int_0^2\pi exp(1.j * x) = 0.
         R += Lq *  cexp( 1.0I * (kx_ - kx) * X[x]);
  } 
  
  return R;

};
Exemple #19
0
static DF2(jtfitexp2){
 F2RANK(0,0,jtfitexp2,self);
 ASSERT(0<=i0(w)&&!jt->jerr,EVDOMAIN);
 R aslash(CSTAR,plus(a,df2(iota(w),VAV(self)->g,slash(ds(CSTAR)))));
}    /* a ^!.s w */
Exemple #20
0
int map_test()
{
   typedef typename MyBoostMap::key_type    IntType;
   typedef container_detail::pair<IntType, IntType>         IntPairType;
   typedef typename MyStdMap::value_type  StdPairType;
   const int max = 100;

   BOOST_TRY{
      MyBoostMap *boostmap = new MyBoostMap;
      MyStdMap *stdmap = new MyStdMap;
      MyBoostMultiMap *boostmultimap = new MyBoostMultiMap;
      MyStdMultiMap *stdmultimap = new MyStdMultiMap;

      //Test construction from a range  
      {
         //This is really nasty, but we have no other simple choice
         IntPairType aux_vect[50];
         for(int i = 0; i < 50; ++i){
            IntType i1(i/2);
            IntType i2(i/2);
            new(&aux_vect[i])IntPairType(boost::move(i1), boost::move(i2));
         }

         typedef typename MyStdMap::value_type StdValueType;
         typedef typename MyStdMap::key_type StdKeyType;
         typedef typename MyStdMap::mapped_type StdMappedType;
         StdValueType aux_vect2[50];
         for(int i = 0; i < 50; ++i){
            new(&aux_vect2[i])StdValueType(StdKeyType(i/2), StdMappedType(i/2));
         }

         IntPairType aux_vect3[50];
         for(int i = 0; i < 50; ++i){
            IntType i1(i/2);
            IntType i2(i/2);
            new(&aux_vect3[i])IntPairType(boost::move(i1), boost::move(i2));
         }

         MyBoostMap *boostmap2 = new MyBoostMap
               ( boost::make_move_iterator(&aux_vect[0])
               , boost::make_move_iterator(aux_vect + 50));
         MyStdMap *stdmap2 = new MyStdMap(aux_vect2, aux_vect2 + 50);
         MyBoostMultiMap *boostmultimap2 = new MyBoostMultiMap
               ( boost::make_move_iterator(&aux_vect3[0])
               , boost::make_move_iterator(aux_vect3 + 50));
         MyStdMultiMap *stdmultimap2 = new MyStdMultiMap(aux_vect2, aux_vect2 + 50);
         if(!CheckEqualContainers(boostmap2, stdmap2)) return 1;
         if(!CheckEqualContainers(boostmultimap2, stdmultimap2)) return 1;

         //ordered range insertion
         //This is really nasty, but we have no other simple choice
         for(int i = 0; i < 50; ++i){
            IntType i1(i);
            IntType i2(i);
            new(&aux_vect[i])IntPairType(boost::move(i1), boost::move(i2));
         }

         for(int i = 0; i < 50; ++i){
            new(&aux_vect2[i])StdValueType(StdKeyType(i), StdMappedType(i));
         }

         for(int i = 0; i < 50; ++i){
            IntType i1(i);
            IntType i2(i);
            new(&aux_vect3[i])IntPairType(boost::move(i1), boost::move(i2));
         }
         if(!CheckEqualContainers(boostmap2, stdmap2)) return 1;
         if(!CheckEqualContainers(boostmultimap2, stdmultimap2)) return 1;

         MyBoostMap *boostmap3 = new MyBoostMap
               ( ordered_unique_range
               , boost::make_move_iterator(&aux_vect[0])
               , boost::make_move_iterator(aux_vect + 50));
         MyStdMap *stdmap3 = new MyStdMap(aux_vect2, aux_vect2 + 50);
         MyBoostMultiMap *boostmultimap3 = new MyBoostMultiMap
               ( ordered_range
               , boost::make_move_iterator(&aux_vect3[0])
               , boost::make_move_iterator(aux_vect3 + 50));
         MyStdMultiMap *stdmultimap3 = new MyStdMultiMap(aux_vect2, aux_vect2 + 50);

         if(!CheckEqualContainers(boostmap3, stdmap3)){
            std::cout << "Error in construct<MyBoostMap>(MyBoostMap3)" << std::endl;
            return 1;
         }
         if(!CheckEqualContainers(boostmultimap3, stdmultimap3)){
            std::cout << "Error in construct<MyBoostMultiMap>(MyBoostMultiMap3)" << std::endl;
            return 1;
         }

         {
            IntType i0(0);
            boostmap2->erase(i0);
            boostmultimap2->erase(i0);
            stdmap2->erase(0);
            stdmultimap2->erase(0);
         }
         {
            IntType i0(0);
            IntType i1(1);
            (*boostmap2)[::boost::move(i0)] = ::boost::move(i1);
         }
         {
            IntType i1(1);
            (*boostmap2)[IntType(0)] = ::boost::move(i1);
         }
         (*stdmap2)[0] = 1;
         if(!CheckEqualContainers(boostmap2, stdmap2)) return 1;

         delete boostmap2;
         delete boostmultimap2;
         delete stdmap2;
         delete stdmultimap2;
         delete boostmap3;
         delete boostmultimap3;
         delete stdmap3;
         delete stdmultimap3;
      }
      {
         //This is really nasty, but we have no other simple choice
         IntPairType aux_vect[max];
         for(int i = 0; i < max; ++i){
            IntType i1(i);
            IntType i2(i);
            new(&aux_vect[i])IntPairType(boost::move(i1), boost::move(i2));
         }
         IntPairType aux_vect3[max];
         for(int i = 0; i < max; ++i){
            IntType i1(i);
            IntType i2(i);
            new(&aux_vect3[i])IntPairType(boost::move(i1), boost::move(i2));
         }

         for(int i = 0; i < max; ++i){
            boostmap->insert(boost::move(aux_vect[i]));
            stdmap->insert(StdPairType(i, i));
            boostmultimap->insert(boost::move(aux_vect3[i]));
            stdmultimap->insert(StdPairType(i, i));
         }

         if(!CheckEqualPairContainers(boostmap, stdmap)) return 1;
         if(!CheckEqualPairContainers(boostmultimap, stdmultimap)) return 1;

         typename MyBoostMap::iterator it = boostmap->begin();
         typename MyBoostMap::const_iterator cit = it;
         (void)cit;

         boostmap->erase(boostmap->begin());
         stdmap->erase(stdmap->begin());
         boostmultimap->erase(boostmultimap->begin());
         stdmultimap->erase(stdmultimap->begin());
         if(!CheckEqualPairContainers(boostmap, stdmap)) return 1;
         if(!CheckEqualPairContainers(boostmultimap, stdmultimap)) return 1;

         boostmap->erase(boostmap->begin());
         stdmap->erase(stdmap->begin());
         boostmultimap->erase(boostmultimap->begin());
         stdmultimap->erase(stdmultimap->begin());
         if(!CheckEqualPairContainers(boostmap, stdmap)) return 1;
         if(!CheckEqualPairContainers(boostmultimap, stdmultimap)) return 1;

         //Swapping test
         MyBoostMap tmpboostemap2;
         MyStdMap tmpstdmap2;
         MyBoostMultiMap tmpboostemultimap2;
         MyStdMultiMap tmpstdmultimap2;
         boostmap->swap(tmpboostemap2);
         stdmap->swap(tmpstdmap2);
         boostmultimap->swap(tmpboostemultimap2);
         stdmultimap->swap(tmpstdmultimap2);
         boostmap->swap(tmpboostemap2);
         stdmap->swap(tmpstdmap2);
         boostmultimap->swap(tmpboostemultimap2);
         stdmultimap->swap(tmpstdmultimap2);
         if(!CheckEqualPairContainers(boostmap, stdmap)) return 1;
         if(!CheckEqualPairContainers(boostmultimap, stdmultimap)) return 1;
      }
      //Insertion from other container
      //Initialize values
      {
         //This is really nasty, but we have no other simple choice
         IntPairType aux_vect[50];
         for(int i = 0; i < 50; ++i){
            IntType i1(-1);
            IntType i2(-1);
            new(&aux_vect[i])IntPairType(boost::move(i1), boost::move(i2));
         }
         IntPairType aux_vect3[50];
         for(int i = 0; i < 50; ++i){
            IntType i1(-1);
            IntType i2(-1);
            new(&aux_vect3[i])IntPairType(boost::move(i1), boost::move(i2));
         }

         boostmap->insert(boost::make_move_iterator(&aux_vect[0]), boost::make_move_iterator(aux_vect + 50));
         boostmultimap->insert(boost::make_move_iterator(&aux_vect3[0]), boost::make_move_iterator(aux_vect3 + 50));
         for(std::size_t i = 0; i != 50; ++i){
            StdPairType stdpairtype(-1, -1);
            stdmap->insert(stdpairtype);
            stdmultimap->insert(stdpairtype);
         }
         if(!CheckEqualPairContainers(boostmap, stdmap)) return 1;
         if(!CheckEqualPairContainers(boostmultimap, stdmultimap)) return 1;

         for(int i = 0, j = static_cast<int>(boostmap->size()); i < j; ++i){
            boostmap->erase(IntType(i));
            stdmap->erase(i);
            boostmultimap->erase(IntType(i));
            stdmultimap->erase(i);
         }
         if(!CheckEqualPairContainers(boostmap, stdmap)) return 1;
         if(!CheckEqualPairContainers(boostmultimap, stdmultimap)) return 1;
      }
      {
         IntPairType aux_vect[50];
         for(int i = 0; i < 50; ++i){
            IntType i1(-1);
            IntType i2(-1);
            new(&aux_vect[i])IntPairType(boost::move(i1), boost::move(i2));
         }

         IntPairType aux_vect3[50];
         for(int i = 0; i < 50; ++i){
            IntType i1(-1);
            IntType i2(-1);
            new(&aux_vect3[i])IntPairType(boost::move(i1), boost::move(i2));
         }

         IntPairType aux_vect4[50];
         for(int i = 0; i < 50; ++i){
            IntType i1(-1);
            IntType i2(-1);
            new(&aux_vect4[i])IntPairType(boost::move(i1), boost::move(i2));
         }

         IntPairType aux_vect5[50];
         for(int i = 0; i < 50; ++i){
            IntType i1(-1);
            IntType i2(-1);
            new(&aux_vect5[i])IntPairType(boost::move(i1), boost::move(i2));
         }

         boostmap->insert(boost::make_move_iterator(&aux_vect[0]), boost::make_move_iterator(aux_vect + 50));
         boostmap->insert(boost::make_move_iterator(&aux_vect3[0]), boost::make_move_iterator(aux_vect3 + 50));
         boostmultimap->insert(boost::make_move_iterator(&aux_vect4[0]), boost::make_move_iterator(aux_vect4 + 50));
         boostmultimap->insert(boost::make_move_iterator(&aux_vect5[0]), boost::make_move_iterator(aux_vect5 + 50));

         for(std::size_t i = 0; i != 50; ++i){
            StdPairType stdpairtype(-1, -1);
            stdmap->insert(stdpairtype);
            stdmultimap->insert(stdpairtype);
            stdmap->insert(stdpairtype);
            stdmultimap->insert(stdpairtype);
         }
         if(!CheckEqualPairContainers(boostmap, stdmap)) return 1;
         if(!CheckEqualPairContainers(boostmultimap, stdmultimap)) return 1;

         boostmap->erase(boostmap->begin()->first);
         stdmap->erase(stdmap->begin()->first);
         boostmultimap->erase(boostmultimap->begin()->first);
         stdmultimap->erase(stdmultimap->begin()->first);
         if(!CheckEqualPairContainers(boostmap, stdmap)) return 1;
         if(!CheckEqualPairContainers(boostmultimap, stdmultimap)) return 1;
      }

      {
         //This is really nasty, but we have no other simple choice
         IntPairType aux_vect[max];
         for(int i = 0; i < max; ++i){
            IntType i1(i);
            IntType i2(i);
            new(&aux_vect[i])IntPairType(boost::move(i1), boost::move(i2));
         }
         IntPairType aux_vect3[max];
         for(int i = 0; i < max; ++i){
            IntType i1(i);
            IntType i2(i);
            new(&aux_vect3[i])IntPairType(boost::move(i1), boost::move(i2));
         }

         for(int i = 0; i < max; ++i){
            boostmap->insert(boost::move(aux_vect[i]));
            stdmap->insert(StdPairType(i, i));
            boostmultimap->insert(boost::move(aux_vect3[i]));
            stdmultimap->insert(StdPairType(i, i));
         }

         if(!CheckEqualPairContainers(boostmap, stdmap)) return 1;
         if(!CheckEqualPairContainers(boostmultimap, stdmultimap)) return 1;

         for(int i = 0; i < max; ++i){
            IntPairType intpair;
            {
               IntType i1(i);
               IntType i2(i);
               new(&intpair)IntPairType(boost::move(i1), boost::move(i2));
            }
            boostmap->insert(boostmap->begin(), boost::move(intpair));
            stdmap->insert(stdmap->begin(), StdPairType(i, i));
            //PrintContainers(boostmap, stdmap);
            {
               IntType i1(i);
               IntType i2(i);
               new(&intpair)IntPairType(boost::move(i1), boost::move(i2));
            }
            boostmultimap->insert(boostmultimap->begin(), boost::move(intpair));
            stdmultimap->insert(stdmultimap->begin(), StdPairType(i, i));
            //PrintContainers(boostmultimap, stdmultimap);
            if(!CheckEqualPairContainers(boostmap, stdmap))
               return 1;
            if(!CheckEqualPairContainers(boostmultimap, stdmultimap))
               return 1;
            {
               IntType i1(i);
               IntType i2(i);
               new(&intpair)IntPairType(boost::move(i1), boost::move(i2));
            }
            boostmap->insert(boostmap->end(), boost::move(intpair));
            stdmap->insert(stdmap->end(), StdPairType(i, i));
            {
               IntType i1(i);
               IntType i2(i);
               new(&intpair)IntPairType(boost::move(i1), boost::move(i2));
            }
            boostmultimap->insert(boostmultimap->end(), boost::move(intpair));
            stdmultimap->insert(stdmultimap->end(), StdPairType(i, i));
            if(!CheckEqualPairContainers(boostmap, stdmap))
               return 1;
            if(!CheckEqualPairContainers(boostmultimap, stdmultimap))
               return 1;
            {
               IntType i1(i);
               IntType i2(i);
               new(&intpair)IntPairType(boost::move(i1), boost::move(i2));
            }
            boostmap->insert(boostmap->lower_bound(IntType(i)), boost::move(intpair));
            stdmap->insert(stdmap->lower_bound(i), StdPairType(i, i));
            //PrintContainers(boostmap, stdmap);
            {
               IntType i1(i);
               IntType i2(i);
               new(&intpair)IntPairType(boost::move(i1), boost::move(i2));
            }
            {
               IntType i1(i);
               boostmultimap->insert(boostmultimap->lower_bound(boost::move(i1)), boost::move(intpair));
               stdmultimap->insert(stdmultimap->lower_bound(i), StdPairType(i, i));
            }

            //PrintContainers(boostmultimap, stdmultimap);
            if(!CheckEqualPairContainers(boostmap, stdmap))
               return 1;
            if(!CheckEqualPairContainers(boostmultimap, stdmultimap))
               return 1;
            {  //Check equal_range
               std::pair<typename MyBoostMultiMap::iterator, typename MyBoostMultiMap::iterator> bret =
                  boostmultimap->equal_range(boostmultimap->begin()->first);

               std::pair<typename MyStdMultiMap::iterator, typename MyStdMultiMap::iterator>   sret =
                  stdmultimap->equal_range(stdmultimap->begin()->first);
        
               if( std::distance(bret.first, bret.second) !=
                   std::distance(sret.first, sret.second) ){
                  return 1;
               }
            }
            {
               IntType i1(i);
               boostmap->insert(boostmap->upper_bound(boost::move(i1)), boost::move(intpair));
               stdmap->insert(stdmap->upper_bound(i), StdPairType(i, i));
            }
            //PrintContainers(boostmap, stdmap);
            {
               IntType i1(i);
               IntType i2(i);
               new(&intpair)IntPairType(boost::move(i1), boost::move(i2));
            }
            {
               IntType i1(i);
               boostmultimap->insert(boostmultimap->upper_bound(boost::move(i1)), boost::move(intpair));
               stdmultimap->insert(stdmultimap->upper_bound(i), StdPairType(i, i));
            }
            //PrintContainers(boostmultimap, stdmultimap);
            if(!CheckEqualPairContainers(boostmap, stdmap))
               return 1;
            if(!CheckEqualPairContainers(boostmultimap, stdmultimap))
               return 1;

            map_test_rebalanceable(*boostmap
               , container_detail::bool_<has_member_function_callable_with_rebalance<MyBoostMap>::value>());
            if(!CheckEqualContainers(boostmap, stdmap)){
               std::cout << "Error in boostmap->rebalance()" << std::endl;
               return 1;
            }
            map_test_rebalanceable(*boostmultimap
               , container_detail::bool_<has_member_function_callable_with_rebalance<MyBoostMultiMap>::value>());
            if(!CheckEqualContainers(boostmultimap, stdmultimap)){
               std::cout << "Error in boostmultimap->rebalance()" << std::endl;
               return 1;
            }
         }

         //Compare count with std containers
         for(int i = 0; i < max; ++i){
            if(boostmap->count(IntType(i)) != stdmap->count(i)){
               return -1;
            }

            if(boostmultimap->count(IntType(i)) != stdmultimap->count(i)){
               return -1;
            }
         }

         //Now do count exercise
         boostmap->erase(boostmap->begin(), boostmap->end());
         boostmultimap->erase(boostmultimap->begin(), boostmultimap->end());
         boostmap->clear();
         boostmultimap->clear();

         for(int j = 0; j < 3; ++j)
         for(int i = 0; i < 100; ++i){
            IntPairType intpair;
            {
            IntType i1(i), i2(i);
            new(&intpair)IntPairType(boost::move(i1), boost::move(i2));
            }
            boostmap->insert(boost::move(intpair));
            {
               IntType i1(i), i2(i);
               new(&intpair)IntPairType(boost::move(i1), boost::move(i2));
            }
            boostmultimap->insert(boost::move(intpair));
            if(boostmap->count(IntType(i)) != typename MyBoostMultiMap::size_type(1))
               return 1;
            if(boostmultimap->count(IntType(i)) != typename MyBoostMultiMap::size_type(j+1))
               return 1;
         }
      }

      delete boostmap;
      delete stdmap;
      delete boostmultimap;
      delete stdmultimap;
   }
   BOOST_CATCH(...){
      BOOST_RETHROW;
   }
   BOOST_CATCH_END

   if(map_test_copyable<MyBoostMap, MyStdMap, MyBoostMultiMap, MyStdMultiMap>
      (container_detail::bool_<boost::container::test::is_copyable<IntType>::value>())){
      return 1;
   }
   return 0;
}
void
VBSHeadFurthestSubReq::complete()
{
    if (m_cnsm.empty())
    {
        LOG(lgr, 6, *this << ' ' << "UPCALL ERROR");
        if (m_cmpl)
            m_cmpl->hnt_error(m_argp,
                              NotFoundError("no starting seed found"));
    }
    else
    {
        // Compute the intersection of all children's sets of
        // furthest nodes (the set all children have).
        //
        ChildNodeSetMap::const_iterator it = m_cnsm.begin();
        m_cmnnodes.assign(it->second.begin(), it->second.end());
        for (++it; it!= m_cnsm.end(); ++it)
        {
            HeadNodeSeq i0(it->second.begin(), it->second.end());
            HeadNodeSeq i1;
            set_intersection(i0.begin(), i0.end(),
                             m_cmnnodes.begin(), m_cmnnodes.end(),
                             back_inserter(i1));
            m_cmnnodes = i1;
        }

        // For each of the children, compute the unique nodes.
        for (it = m_cnsm.begin(); it != m_cnsm.end(); ++it)
        {
            HeadNodeSeq diff;
            HeadNodeSet const & hns = it->second;
            set_difference(hns.begin(), hns.end(),
                           m_cmnnodes.begin(), m_cmnnodes.end(),
                           back_inserter(diff));
            if (!diff.empty())
            {
                LOG(lgr, 6, "CHILD " << it->first->instname()
                    << " HAS UNIQUE NODES:");
                for (unsigned ii = 0; ii < diff.size(); ++ii)
                {
                    utp::HeadNode const & hn = diff[ii];
                    LOG(lgr, 6, hn);
                }

                m_unqnodes[it->first].insert(diff.begin(), diff.end());
            }
        }

        // NOTE - This subrequest type doesn't bother making hnt_node
        // calls; we presume the parent request will access the common
        // and unique collections directly ...
        //
        LOG(lgr, 6, *this << ' ' << "UPCALL GOOD");
        m_cmpl->hnt_complete(m_argp);
    }

    // This likely results in our destruction, do it last and
    // don't touch anything afterwards!
    //
    LOG(lgr, 6, *this << ' ' << "DONE");
    done();
}
Exemple #22
0
static double kaiser (double n, double m, double beta)
{
	double alpha = m / 2;
	return i0 (beta * sqrt (1 - sqr((n - alpha) / alpha))) / i0(beta);
}
Exemple #23
0
//jfm
double besseli0(double x) {
	return i0(x);
}
Exemple #24
0
void GraphObject::prerender(void)
{
    QImage i0(1, 1, QImage::Format_ARGB32);
    QPainter p0(&i0);
    this->render(p0);
}