Ejemplo n.º 1
0
void h1(int n, char a, char b, char c)
{
    if (n > 0) {
        h1(n - 1, a, c, b);
        std::cout << a << " --> " << c << std::endl;
        h1(n - 1, b, a, c);
    }
}
void CInfiniteAmortizedNoise3D::initEdgeTables(const int x0, const int y0, const int z0, const int n){ 
  //compute gradients at corner points
  float b0  = h1(x0,   y0, z0),   b1  = h1(x0,   y0+1, z0  ),
        b2  = h1(x0+1, y0, z0),   b3  = h1(x0+1, y0+1, z0  ),
        b4  = h1(x0,   y0, z0+1), b5  = h1(x0,   y0+1, z0+1),
        b6  = h1(x0+1, y0, z0+1), b7  = h1(x0+1, y0+1, z0+1),

        b8  = h2(x0,   y0, z0),   b9  = h2(x0,   y0+1, z0  ),
        b10 = h2(x0+1, y0, z0),   b11 = h2(x0+1, y0+1, z0  ),
        b12 = h2(x0,   y0, z0+1), b13 = h2(x0,   y0+1, z0+1),
        b14 = h2(x0+1, y0, z0+1), b15 = h2(x0+1, y0+1, z0+1);
  
  //fill inferred gradient tables from corner gradients

  FillUp(uax,  sinf(b0)*sinf(b8),  n); FillDn(vax,  sinf(b4)*sinf(b12), n);
  FillUp(ubx,  sinf(b1)*sinf(b9),  n); FillDn(vbx,  sinf(b5)*sinf(b13), n);
  FillUp(uay, -sinf(b0)*cosf(b8),  n); FillUp(vay, -sinf(b4)*cosf(b12), n);
  FillDn(uby, -sinf(b1)*cosf(b9),  n); FillDn(vby, -sinf(b5)*cosf(b13), n);

  FillUp(uaz,      cosf(b0),      n); FillUp(vaz,      cosf(b4),      n);
  FillUp(ubz,      cosf(b1),      n); FillUp(vbz,      cosf(b5),      n);
  FillUp(ucx,  sinf(b2)*sinf(b10), n); FillDn(vcx,  sinf(b6)*sinf(b14), n);
  FillUp(udx,  sinf(b3)*sinf(b11), n); FillDn(vdx,  sinf(b7)*sinf(b15), n);

  FillUp(ucy, -sinf(b2)*cosf(b10), n); FillUp(vcy, -sinf(b6)*cosf(b14), n);
  FillDn(udy, -sinf(b3)*cosf(b11), n); FillDn(vdy, -sinf(b7)*cosf(b15), n);
  FillDn(ucz,      cosf(b2),      n); FillDn(vcz,      cosf(b6),      n);
  FillDn(udz,      cosf(b3),      n); FillDn(vdz,      cosf(b7),      n); 
} //initEdgeTables
Ejemplo n.º 3
0
 Calendar* Hebrew::update_from_fixed (double date, Calendar* c)
 {    
   double approx = floor (98496.0f/35975351.0f * (date - rep_.d_epoch ())) + 1.0f;
   double y = approx - 1.0f;
   double mx = y;
   while (new_year (y) <= date)
     {
       y += 1.0f;
       if (y > mx)
         mx = y;
     }
   double year = mx;
   Hebrew h1 (year, NISAN, 1);
   Month start = date < h1.to_fixed_date () ? TISHRI : NISAN;
   double m = static_cast<double> (start);
   double mn = m;
   while (true)
     {
       Hebrew h2 (year, m, last_day_of_month (static_cast<Month> (m), year));               
       bool b = (date <= h2.to_fixed_date());
       if (m < mn) mn = m;
       if (b)
         break;
       m += 1.0f;        
     }
   double month = mn;
   Hebrew h3 (year, month, 1);
   double day = 1 + date - h3.to_fixed_date ();
   Hebrew* ret = dynamic_cast<Hebrew*> (c);
   ret->rep_ = ThreePartRepresentation (rep_.d_epoch (), year, month, day);
   return c;
 }
Ejemplo n.º 4
0
// Player choses new game or to load the previous one
void Choice(GameEngine &gm)
{
	cout<<" New game -> 1\n Load game -> 2\n";
	int choice;
	cin >> choice;
	switch (choice)
	{
	case 1:
		{
			Map m1(1);
			gm.setMap(m1);
			break;
		}
	case 2:
		{
			Map m2(0);		// Putting '0' in the Map's constructor loades the saved map
			gm.setMap(m2);
			ifstream file("Save.dat", std::ios::binary);
			Hero h1(file);
			gm.hero = h1;
			break;
		}
	default:
		cout<<"	Please restart the game and press correct number !!!\n";
		fail = true;
		isRunning = false;
		break;
	}
}
void draw_grid(int i,int j,int k)                       //This draws the grid and changes the color the grid according to the player
{   beginFrame();
    Line h1(0,0,600,0),h2(0,100,600,100),               // "h" is the horizontal lines and "v" is the vertical lines
    h3(0,200,600,200),h4(0,300,600,300),
    h5(0,400,600,400),h6(0,500,600,500),
    h7(0,600,600,600),h8(0,700,600,700),
    h9(0,800,600,800);
    Line v1(0,0,0,800),v2(100,0,100,800),
    v3(200,0,200,800),v4(300,0,300,800),
    v5(400,0,400,800),v6(500,0,500,800),
    v7(600,0,600,800);
    h1.setColor(COLOR(255*i,255*j,255*k)),h2.setColor(COLOR(255*i,255*j,255*k)),
    h3.setColor(COLOR(255*i,255*j,255*k)),h4.setColor(COLOR(255*i,255*j,255*k)),
    h5.setColor(COLOR(255*i,255*j,255*k)),h6.setColor(COLOR(255*i,255*j,255*k)),
    h7.setColor(COLOR(255*i,255*j,255*k)),h8.setColor(COLOR(255*i,255*j,255*k)),
    h9.setColor(COLOR(255*i,255*j,255*k));
    v1.setColor(COLOR(255*i,255*j,255*k)),v2.setColor(COLOR(255*i,255*j,255*k)),
    v3.setColor(COLOR(255*i,255*j,255*k)),v4.setColor(COLOR(255*i,255*j,255*k)),
    v5.setColor(COLOR(255*i,255*j,255*k)),v6.setColor(COLOR(255*i,255*j,255*k)),
    v7.setColor(COLOR(255*i,255*j,255*k));
    h1.imprint(),h2.imprint(),
    h3.imprint(),h4.imprint(),
    h5.imprint(),h6.imprint(),
    h7.imprint(),h8.imprint(),h9.imprint();
    v1.imprint(),v2.imprint(),
    v3.imprint(),v4.imprint(),
    v5.imprint(),v6.imprint(),v7.imprint();
    endFrame();
}
Ejemplo n.º 6
0
int parallel_fib( int n, int cutof)
{
	if ( n < cutof) return serial_fib( n);
	else
	{
		BOOST_ASSERT( boost::this_task::runs_in_pool() );
		tsk::task< int > t1(
			parallel_fib,
			n - 1,
			cutof);
		tsk::task< int > t2(
			parallel_fib,
			n - 2,
			cutof);
		tsk::handle< int > h1(
			tsk::async(
				boost::move( t1),
				tsk::as_sub_task() ) ) ;
		tsk::handle< int > h2(
			tsk::async(
				boost::move( t2),
				tsk::as_sub_task() ) );
		return h1.get() + h2.get();
	}
}
Ejemplo n.º 7
0
float greedy::h(Model& m,Node* currentNode){
    if( type == 1){
        return h1(m,currentNode);
    }else{
        return h2(m,currentNode);
    }
}
Ejemplo n.º 8
0
int main()
{
  f();
  g();
  h1();
  return 0;
}
Ejemplo n.º 9
0
int main()
{
  decltype(auto) i = f();
  same_type<decltype(i),int&>();
  decltype(auto) i2 = i;
  same_type<decltype(i2),int&>();
  decltype(auto) i3 = ::i;
  same_type<decltype(i3),int>();
  decltype(auto) i4 = (::i);
  same_type<decltype(i4),int&>();
  decltype(auto) i5 = a.i;
  same_type<decltype(i5),int>();
  decltype(auto) i6 = (a.i);
  same_type<decltype(i6),int&>();
  decltype(auto) i7 = true ? ::i : ::i;
  same_type<decltype(i7),int&>();

  same_type<decltype(g()),int&>();
  same_type<decltype(h1()),int>();
  same_type<decltype(h2()),int&>();
  same_type<decltype(h2a()),int&>();
  same_type<decltype(h3()),int>();
  same_type<decltype(h4()),int&>();
  same_type<decltype(h5(a)),int>();
  same_type<decltype(h6(a)),int&>();
}
Ejemplo n.º 10
0
Archivo: basic.C Proyecto: Y--/root
void basic() {
// read file $ROOTSYS/tutorials/tree/basic.dat
// this file has 3 columns of float data
   TString dir = gROOT->GetTutorialsDir();
   dir.Append("/tree/");
   dir.ReplaceAll("/./","/");
   ifstream in;
   in.open(Form("%sbasic.dat",dir.Data()));

   Float_t x,y,z;
   Int_t nlines = 0;
   auto f = TFile::Open("basic.root","RECREATE");
   TH1F h1("h1","x distribution",100,-4,4);
   TNtuple ntuple("ntuple","data from ascii file","x:y:z");

   while (1) {
      in >> x >> y >> z;
      if (!in.good()) break;
      if (nlines < 5) printf("x=%8f, y=%8f, z=%8f\n",x,y,z);
      h1.Fill(x);
      ntuple.Fill(x,y,z);
      nlines++;
   }
   printf(" found %d points\n",nlines);

   in.close();

   f->Write();
}
Ejemplo n.º 11
0
int
run_main (int, ACE_TCHAR *[])
{
  ACE_START_TEST (ACE_TEXT ("Sig_Handlers_Test"));

  ACE_Sig_Handlers multi_handlers;
  ACE_Select_Reactor reactor_impl (&multi_handlers);
  ACE_Reactor reactor (&reactor_impl);
  ACE_Reactor::instance (&reactor);

  // Create a bevy of handlers.

  Test_SIGINT_Handler h1 (ACE_Reactor::instance (), "h1");
  Test_SIGINT_Handler h2 (ACE_Reactor::instance (), "h2");
  Test_SIGINT_Handler h3 (ACE_Reactor::instance (), "h3");
  Test_SIGINT_Handler h4 (ACE_Reactor::instance (), "h4");
  Test_SIGINT_Handler h5 (ACE_Reactor::instance (), "h5");
  Test_SIGINT_Handler h6 (ACE_Reactor::instance (), "h6");
  Test_SIGINT_Handler h7 (ACE_Reactor::instance (), "h7");
  Test_SIGINT_Handler h8 (ACE_Reactor::instance (), "h8");

  Test_SIGINT_Shutdown_Handler h0 (ACE_Reactor::instance ());

  // Wait for user to type SIGINT.
  while (!ACE_Reactor::instance ()->reactor_event_loop_done ())
    {
      ACE_DEBUG ((LM_DEBUG,"\nwaiting for SIGINT\n"));
      if (ACE_Reactor::instance ()->handle_events () == -1)
        ACE_ERROR ((LM_ERROR,"%p\n","handle_events"));
    }

  ACE_END_TEST;
  return 0;
}
Ejemplo n.º 12
0
// lookup whether 'key' is inside 'table'
// returns true if found, false if not
bool xuckoo_hash_table_lookup(XuckooHashTable *table, int64 key) {
	assert(table);
	int start_time = clock(); // Start timing
	
	// Calculate the address on the first and second table for this key
	int address_table1 = rightmostnbits(table->table1->depth, h1(key));
	int address_table2 = rightmostnbits(table->table2->depth, h2(key));
	
	// Look for the key in that bucket (unless it's empty)

	// Check the key at the first table
	if (table->table1->buckets[address_table1]->full &&
		table->table1->buckets[address_table1]->key == key) {
		table->stats.time += clock() - start_time; // Add time elapsed
		return FOUND;
	}
	
	// Check the key at the second table
	if (table->table2->buckets[address_table2]->full &&
		table->table2->buckets[address_table2]->key == key) {
		table->stats.time += clock() - start_time; // Add time elapsed
		return FOUND;
	}
	
	return NOT_FOUND;
}
Ejemplo n.º 13
0
int main()
{

	Student s1("Jan", "Nowak", male, 20, 123456, 1, "ICT", "Electronic dept.");
	s1.show();
	s1.info();

	Human h1("Jan", "Kowalski", male, 30);
	h1.show();

	Tutor t1("Halina", "Kowalska", female, 50, "Professor", 30);
	t1.show();
	t1.info();

	{
		Tutor t2("x", "y", male, 60, "Professor", 25); //zakres lokalny do sprawdzenia dzialania destruktora i poprawnosci zliczania
	}
	
	cout << "Meter: " << Human::meter << "\t" << h1.meter << "\t" << s1.meter << "\t" << t1.meter << "\n\n";

	h1 = s1;
	h1.show();

	s1.set_last_name("Brzeczyszczykiewicz");
	cout << s1.get_last_name();

	_getch();
}
Ejemplo n.º 14
0
int h(int bitpos)
{
	if (getbit(bitpos))
		return h1(bitpos+1);
	else
		return h0(bitpos+1);
}
Ejemplo n.º 15
0
// lookup whether 'key' is inside 'table'
// returns true if found, false if not
bool xtndbln_hash_table_lookup(XtndblNHashTable *table, int64 key) {
	assert(table);
	int start_time = clock(); // Start timing
	
	// Calculate table address for this key
	int address = rightmostnbits(table->depth, h1(key));
	
	// Look for the key in that bucket (unless it's empty)
	if (table->buckets[address]->nkeys > 0) {
		
		// Iterate through the keys in this bucket
		int i, no_keys = table->buckets[address]->nkeys;
		for (i = 0; i < no_keys; i++) {
			
			// We have found the key!!
			if (table->buckets[address]->keys[i] == key) {
				
				// Add time elapsed to total CPU time before returning result
				table->stats.time += clock() - start_time;
				return FOUND;
			}
		}
	}
	
	// Add time elapsed to total CPU time before returning result
	table->stats.time += clock() - start_time;
	return NOT_FOUND;
}
Ejemplo n.º 16
0
 ST Hermite(ST m0, ST y0, ST y1, ST m1, FT t)
 {
     return
         m0 * h3(t) +
         y0 * h1(t) +
         y1 * h2(t) +
         m1 * h4(t);
 }
Ejemplo n.º 17
0
void AutoPtr()
{
	//study the auto_ptr 
	std::auto_ptr<TH1F> h1 (new TH1F("H1","TEST HIST",100,0,100));

	TH1*  h2 = FillSome(h1,10);
	h2->Draw();
}
Ejemplo n.º 18
0
int main() {
  S1<int> s1;
  S2<int, int> s2;
  f(0);
  g(0, 1);
  h0((int*)0);
  h1((int*)0);
  h2((int*)0);
}
Ejemplo n.º 19
0
void NullForm()
{
  html_begin("Null Form Submitted");
  h1("Null Form Submitted");
  printf("You have sent an empty form.  Please go back and fill out\r\n");
  printf("the form properly, or email <i>%s</i>\r\n",WEBADMIN);
  printf("if you are having difficulty.\r\n");
  html_end();
}
Ejemplo n.º 20
0
void convertHFShowerLibrary() {
  TFile *nF=new TFile("david.root","RECREATE","hiThere",1);
  TTree *nT=new TTree("HFSimHits","HF simple tree");
  std::vector<float> *parts=new std::vector<float>();
  std::vector<float> *partsHad=new std::vector<float>();
  nT->Branch("emParticles", &parts);
  nT->GetBranch("emParticles")->SetBasketSize(1);
  nT->Branch("hadParticles", &partsHad);
  nT->GetBranch("hadParticles")->SetBasketSize(1);

  TDirectory *target=gDirectory;
  TFile *oF=TFile::Open("HFShowerLibrary_npmt_noatt_eta4_16en_v3_orig.root");
  TTree *t=(TTree*)oF->Get("HFSimHits");
  TTreeReader fReader(t);
  TTreeReaderArray<Float_t> b1(fReader, "emParticles.position_.fCoordinates.fX");
  TTreeReaderArray<Float_t> b2(fReader, "emParticles.position_.fCoordinates.fY");
  TTreeReaderArray<Float_t> b3(fReader, "emParticles.position_.fCoordinates.fZ");
  TTreeReaderArray<Float_t> b4(fReader, "emParticles.lambda_");
  TTreeReaderArray<Float_t> b5(fReader, "emParticles.time_");

  TTreeReaderArray<Float_t> h1(fReader, "hadParticles.position_.fCoordinates.fX");
  TTreeReaderArray<Float_t> h2(fReader, "hadParticles.position_.fCoordinates.fY");
  TTreeReaderArray<Float_t> h3(fReader, "hadParticles.position_.fCoordinates.fZ");
  TTreeReaderArray<Float_t> h4(fReader, "hadParticles.lambda_");
  TTreeReaderArray<Float_t> h5(fReader, "hadParticles.time_");


  target->cd();
  while ( fReader.Next() ) {
    parts->clear();
    unsigned int s=b1.GetSize();
    parts->resize(5*s);
    for ( unsigned int i=0; i<b1.GetSize(); i++) {
      (*parts)[i]=(b1[i]);
      (*parts)[i+1*s]=(b2[i]);
      (*parts)[i+2*s]=(b3[i]);
      (*parts)[i+3*s]=(b4[i]);
      (*parts)[i+4*s]=(b5[i]);
    }  

    partsHad->clear();
    s=h1.GetSize();
    partsHad->resize(5*s);
    for ( unsigned int i=0; i<h1.GetSize(); i++) {
      (*partsHad)[i]=(h1[i]);
      (*partsHad)[i+1*s]=(h2[i]);
      (*partsHad)[i+2*s]=(h3[i]);
      (*partsHad)[i+3*s]=(h4[i]);
      (*partsHad)[i+4*s]=(h5[i]);
    }  

    nT->Fill();
  }

  nT->Write();
  nF->Close();
}
Ejemplo n.º 21
0
int main( int argc, char** argv )
{
  Hello h1( "world" );

  HelloWorld h2;
  h2.print();

  return 0;
}
// check wait in new thread
void test_case_1()
{
	boost::uint32_t n = 3;
	tsk::spin::manual_reset_event ev;

	tsk::handle< boost::uint32_t > h1(
			tsk::async(
				tsk::make_task(
					wait_fn,
					n, boost::ref( ev) ),
				tsk::new_thread() ) );
	tsk::handle< boost::uint32_t > h2(
			tsk::async(
				tsk::make_task(
					wait_fn,
					n, boost::ref( ev) ),
				tsk::new_thread() ) );

	boost::this_thread::sleep( pt::millisec( 250) );
	BOOST_CHECK( ! h1.is_ready() );
	BOOST_CHECK( ! h2.is_ready() );

	ev.set();

	boost::this_thread::sleep( pt::millisec( 250) );
	BOOST_CHECK( h1.is_ready() );
	BOOST_CHECK( h2.is_ready() );
	BOOST_CHECK_EQUAL( h1.get(), n);
	BOOST_CHECK_EQUAL( h2.get(), n);

	ev.reset();

	tsk::handle< boost::uint32_t > h3(
			tsk::async(
				tsk::make_task(
					wait_fn,
					n, boost::ref( ev) ),
				tsk::new_thread() ) );
	tsk::handle< boost::uint32_t > h4(
			tsk::async(
				tsk::make_task(
					wait_fn,
					n, boost::ref( ev) ),
				tsk::new_thread() ) );

	boost::this_thread::sleep( pt::millisec( 250) );
	BOOST_CHECK( ! h3.is_ready() );
	BOOST_CHECK( ! h4.is_ready() );

	ev.set();

	boost::this_thread::sleep( pt::millisec( 250) );
	BOOST_CHECK( h3.is_ready() );
	BOOST_CHECK( h4.is_ready() );
	BOOST_CHECK_EQUAL( h3.get(), n);
	BOOST_CHECK_EQUAL( h4.get(), n);
}
Ejemplo n.º 23
0
/* sub-density function (integrates to < 1) between bounds at interim
   analysis for group sequential design */
void gsdensity(double *den, int *xnanal, int *ntheta, double *xtheta,
			   double *I, double *a, double *b, double *xz,
			   int *zlen, int *xr)
{   int r, i, j, k, m1, m2, nanal, nz;
    double z, mu, theta;
    double *zwk,*wwk,*hwk,*zwk2,*wwk2,*hwk2;
    double *z1,*z2,*w1,*w2,*h,*h2,*tem;
    void h1(double,int,double *,double,double *, double *);
    void hupdate(double,double *,int,double,double *, double *,
                                 int,double,double *, double *);
    int gridpts(int, double,double,double,double *, double *);
    r=xr[0]; nanal=xnanal[0]; nz=zlen[0];
/* if density is at 1st analysis, just return normal density */
    if (nanal < 1) return;
    if (nanal == 1)
    {   j = 0;
        for(k=0; k < ntheta[0]; k++)
        {   mu = sqrt(I[0]) * xtheta[k];
            for(i=0; i < nz; i++) 
            {   z = xz[i] - mu;
                den[j++] = exp(-z*z/2)/2.506628275;
        }   }
        return;
    } 
/* otherwise, compute density like in probrej */
	zwk = (double *) R_alloc(r * 12 - 3, sizeof(double));
	wwk = (double *) R_alloc(r * 12 - 3, sizeof(double));
	hwk = (double *) R_alloc(r * 12 - 3, sizeof(double));
	zwk2 = (double *) R_alloc(r * 12 - 3, sizeof(double));
	wwk2 = (double *) R_alloc(r * 12 - 3, sizeof(double));
	hwk2 = (double *) R_alloc(r * 12 - 3, sizeof(double));
    for(k=0; k < ntheta[0]; k++)
    {   theta=xtheta[k];
        mu = theta * sqrt(I[0]);
/* compute h1 */
        z1=zwk; w1=wwk; h=hwk;
        m1=gridpts(r,mu,a[0],b[0],z1,w1);
        h1(theta,m1,w1,I[0],z1,h);
        z2=zwk2; w2=wwk2; h2=hwk2;
/* update h and compute rejection probabilities at each interim */
       for(i=1;i<nanal;i++)
       {   mu=theta*sqrt(I[i]);
           if (i < nanal - 1) 
			   m2 = gridpts(r, mu, a[i], b[i], z2, w2);
           else
           {   m2 = nz - 1; z2 = xz; h2 = den + k * nz;
               for(j = 0; j < nz; j++) w2[j]=1.;
           }
           hupdate(theta,w2,m1,I[i-1],z1,h,m2,I[i],z2,h2);
           m1=m2;
           tem=z1; z1=z2; z2=tem;
           tem=w1; w1=w2; w2=tem;
           tem=h;  h=h2;  h2=tem;
       }
    }
}
Ejemplo n.º 24
0
void testObj::test<6>(void)
{
  MCryptHandle h1(MCRYPT_RIJNDAEL_256, MCRYPT_CFB);
  MCryptHandle h2(MCRYPT_RIJNDAEL_256, MCRYPT_CFB);
  MCRYPT p1 = h1.get();
  MCRYPT p2 = h2.get();
  swap(h1, h2);
  ensure("invalid pointer 1", h1.get()==p2 );
  ensure("invalid pointer 2", h2.get()==p1 );
}
Ejemplo n.º 25
0
void testObj::test<3>(void)
{
  MCryptHandle h1(MCRYPT_RIJNDAEL_256, MCRYPT_CFB);
  MCryptHandle h2( std::move(h1) );         // cp c-tor
  ensure("cp c-ton failed /1", h1.get()==MCRYPT_FAILED );
  ensure("cp c-ton failed /2", h2.get()!=MCRYPT_FAILED );
  h1 = std::move(h2);                       // cp assignment
  ensure("assignment failed /1", h2.get()==MCRYPT_FAILED );
  ensure("assignment failed /2", h1.get()!=MCRYPT_FAILED );
}
Ejemplo n.º 26
0
int main(int argc, char **argv)
{
 PetscInitialize(&argc,&argv,PETSC_NULL,PETSC_NULL);
 //PetscInitializeNoArguments();

 string meshFile = "2bubbles.msh";
 
 const char *vtkFolder  = "./vtk/";
 const char *datFolder  = "./dat/";
 string meshDir = (string) getenv("DATA_DIR");
 meshDir += "/gmsh/3d/2bubbles/" + meshFile;
 const char *mesh = meshDir.c_str();

 Model3D m1;

 m1.readMSH(mesh);
 m1.setInterfaceBC();
 m1.setTriEdge();
 m1.mesh2Dto3D();
 m1.setMapping();
 m1.setMiniElement();
 m1.setSurfaceConfig();

 // Point's distribution
 Helmholtz3D h1(m1);
 h1.setBC();
 h1.initMicro();
 h1.assemble();
 h1.setk(3.8);
 h1.matMountC();
 h1.setUnCoupledCBC(); 
 h1.setCRHS();
 h1.unCoupledC();
 h1.saveVTK(vtkFolder,"edge1",0);
 h1.saveChordalEdge(datFolder,"edge1",0);

 h1.setk(1.2);
 h1.matMountC();
 h1.setUnCoupledCBC(); 
 h1.setCRHS();
 h1.unCoupledC();
 h1.saveVTK(vtkFolder,"edge2",0);
 h1.saveChordalEdge(datFolder,"edge2",0);

 h1.setk(0.03);
 h1.matMountC();
 h1.setUnCoupledCBC(); 
 h1.setCRHS();
 h1.unCoupledC();
 h1.saveVTK(vtkFolder,"edge3",0);
 h1.saveChordalEdge(datFolder,"edge3",0);

 PetscFinalize();
 return 0;
}
Ejemplo n.º 27
0
main(int argc, char **argv)
{
	fieldinfos fis;
	fix_document doc1(10);
	dyn_document doc2;

	document_helper h1(&doc1, fis);
	document_helper h2(&doc2, fis);

	return 0;
}
Ejemplo n.º 28
0
// Helper function to reinsert a key into the specified hash table after 
// splitting a bucket
static void reinsert_key(InnerTable *innertable, int64 key, int table_no) {
	int address, hash = h1(key);

	if (table_no == 2) {
		hash = h2(key);	
	}
	
	address = rightmostnbits(innertable->depth, hash);
	innertable->buckets[address]->key = key;
	innertable->buckets[address]->full = true;
}
// check wait in pool
void test_case_2()
{
	tsk::static_pool<
		tsk::unbounded_fifo
	> pool( tsk::poolsize( 3) );

	boost::uint32_t n = 3;
	tsk::spin::auto_reset_event ev;

	tsk::handle< boost::uint32_t > h1(
			tsk::async(
				tsk::make_task(
					wait_fn,
					n, boost::ref( ev) ),
				pool) );
	tsk::handle< boost::uint32_t > h2(
			tsk::async(
				tsk::make_task(
					wait_fn,
					n, boost::ref( ev) ),
				pool) );
	boost::this_thread::sleep( pt::millisec( 250) );
	BOOST_CHECK( ! h1.is_ready() );
	BOOST_CHECK( ! h2.is_ready() );

	ev.set();

	boost::this_thread::sleep( pt::millisec( 250) );
	BOOST_CHECK( h1.is_ready() || h2.is_ready() );
	if ( h1.is_ready() )
	{
		BOOST_CHECK_EQUAL( h1.get(), n);
		BOOST_CHECK( ! h2.is_ready() );

		ev.set();

		boost::this_thread::sleep( pt::millisec( 250) );
		BOOST_CHECK( h2.is_ready() );
		BOOST_CHECK_EQUAL( h2.get(), n);
	}
	else
	{
		BOOST_CHECK( h2.is_ready() );
		BOOST_CHECK_EQUAL( h2.get(), n);
		BOOST_CHECK( ! h1.is_ready() );

		ev.set();

		boost::this_thread::sleep( pt::millisec( 250) );
		BOOST_CHECK( h1.is_ready() );
		BOOST_CHECK_EQUAL( h1.get(), n);
	
	}
}
int main(int argc, char* argv[])
{
	
	printf("Hello World!\n");

	HashTable  ht(7);

	for(int i=0;i<20;i++){
		CStruct* pS = new CStruct;
		pS->structID = i;
		ht.insert(pS);
	}
	ht.ShowAllStruct();

	CStruct* pSt = ht.find(5);
	printf("find  struct %d\n", pSt->structID);

//	ht.ShowAllStruct();


	ht.Rehash(25);
	ht.ShowAllStruct();

	pSt = ht.find(5);
	printf("find  struct %d  after rehash\n", pSt->structID);

	ht.ShowAllStruct();

//	HashTable ht1(ht);
//	pSt = ht1.find(56);
	if(pSt==NULL)
		printf(" struct not found\n");
	else
		printf(" find struct %d !\n", pSt->structID);

//	ht.remove(pSt);
	//ht.remove(56);
/*	pSt = ht.find(56);
	if(pSt==NULL)
		printf(" struct not found\n");
	else
		printf(" find struct %d !\n", pSt->structID);

	ht.ShowAllStruct();
*/
	HashTable h1(ht);
	pSt = h1.find(5);
	printf("find  struct %d  in h1 \n", pSt->structID);


	return 0;
}