コード例 #1
0
ファイル: netconv.c プロジェクト: cesaro/cunf
void nc_create_unfolding()
{
	ls_init (&u.unf.conds);
	ls_init (&u.unf.events);
	u.unf.numcond = 0;
	u.unf.numev = 0;
	u.unf.numh = 0;

	u.unf.numcutoffs = 0;
	u.unf.numgen = 0;
	u.unf.numread = 0;
	u.unf.numcomp = 0;

	u.unf.numr = 0;
	u.unf.nums = 0;
	u.unf.numco = 0;
	u.unf.numrco = 0;
	u.unf.nummrk = 0;
	u.unf.numeblack = 0;
	u.unf.numegray = 0;
	u.unf.numewhite = 0;

	u.unf.numepost = 0;
	u.unf.numecont = 0;
	u.unf.numepre = 0;

	u.unf.e0 = 0;
}
コード例 #2
0
ファイル: netconv.c プロジェクト: cesaro/cunf
void nc_create_net()
{
	ls_init (&u.net.places);
	ls_init (&u.net.trans);
	u.net.numpl = u.net.numtr = 0;
	u.net.t0 = 0;
	u.net.isplain = 1;
}
コード例 #3
0
void StateMenu2::load()
{
    int cx = gdata.settings->getScreenWidth() / 2;
    int cy = gdata.settings->getScreenHeight() / 2;
    gdata.camera = &c;

    // set background data
    background.bubble_alpha_range.set(0,64);
    background.rec.setFillColor(sf::Color(16,33,57));
    background.bubble_color = sf::Color(0,0,0);
    background.num_circles = 60;
    background.init();

    font.setWindow(gdata.window);
    font.setFont(gdata.assets->getFont("segoe-ui-light-48"));

    title.setTexture(*gdata.assets->getTexture("title"));
    title.setOrigin( title.getTexture()->getSize().x / 2, 0 );

    mm_init();
    om_init();
    ls_init();

    if (!gdata.bg_music)
    {
        gdata.bg_music = gdata.audio->addMusic("Divider");
        gdata.bg_music->loop(true);
    }
}
コード例 #4
0
ファイル: _list.c プロジェクト: ChrisWhiten/VideoParser
list_t *  ls_getRow(list_t *row, list_t *il, int i, int cols)
{
  list_t rowPt;
  ls_getRowPt(ls_init(&rowPt), il, i, cols);

  ls_cpy(row, &rowPt);

  return (row);
}
コード例 #5
0
ファイル: _list.c プロジェクト: ChrisWhiten/VideoParser
LIST_TYPE ls_popLast(list_t *il, LIST_TYPE undef)
{
  LIST_TYPE x;
  if (LS_isNIL(il))
    return (undef);
  x = LS_LAST(il);
  ls_init(il);
  return (x);
}
コード例 #6
0
ファイル: unisex_bathroom.c プロジェクト: melias122/scratch
int main() {
  inits(&empty, 1);
  inits(&mpMale, 3);
  inits(&mpFemale, 3);
  ls_init(&lsMale);
  ls_init(&lsFemale);

  int i;
  pthread_t _man[5];
  pthread_t _woman[6];

  for (i=0;i<5;i++) {
    pthread_create(&_man[i], 0, man, 0);
  }

  for (i=0;i<6;i++) {
    pthread_create(&_woman[i], 0, woman, 0);
  }
  pthread_exit(0);
  
  return 0;
}
コード例 #7
0
ファイル: marking.c プロジェクト: marcelosousa/poet
void marking_init (void)
{
	int i;

	/* initialize the hash table; h.size is the size of the array h.tab;
	 * h.tab is a vector of lists; h.tab[i] is a singly-linked list storing
	 * all the pairs (marking,history) with the same marking */
	
	/* FIXME use prime numbers! */
	hash.size = 1 + u.net.numpl * 800;
	hash.tab = gl_malloc (hash.size * sizeof (struct ls));
	for (i = hash.size - 1; i >= 0; i--) ls_init (hash.tab + i);
}
コード例 #8
0
ファイル: netconv.c プロジェクト: cesaro/cunf
struct place * nc_create_place (void)
{
	struct place * p;
	
	p = ut_malloc (sizeof (struct place));
	ls_insert (&u.net.places, &p->nod);

	p->id = u.net.numpl++;
	al_init (&p->pre);
	al_init (&p->post);
	al_init (&p->cont);
	ls_init (&p->conds);
	p->m = 0;

	return p;
}
コード例 #9
0
ファイル: netconv.c プロジェクト: cesaro/cunf
struct trans * nc_create_transition (void)
{
	struct trans * t;

	t = ut_malloc (sizeof (struct trans));
	ls_insert (&u.net.trans, &t->nod);

	t->id = ++u.net.numtr;
	al_init (&t->pre);
	al_init (&t->post);
	al_init (&t->cont);
	ls_init (&t->events);
	t->m = 0;
	t->parikhcnt1 = 0;
	t->parikhcnt2 = 0;

	return t;
}
コード例 #10
0
void StateMenu2::mm_handleEvents()
{
    if (gdata.keys[sf::Keyboard::Up].isKeyPressed)
    {
        if (mm_selected > 0)
            --mm_selected;
    }
    if (gdata.keys[sf::Keyboard::Down].isKeyPressed)
    {
        if (mm_selected < mm_items.size()-1)
            ++mm_selected;
    }

    // handle mouse events (mouse over menu items)
    int h = gdata.settings->getScreenHeight();
    int w = gdata.settings->getScreenWidth();

    bool onItem = false;
    for (int i = 0; i < mm_items.size(); ++i)
    {
        int x = w-ITEM_WIDTH;
        int y = h-BOTTOM_BUFFER-(mm_items.size()-i)*ITEM_SPACING;

        if (utils::isTouching(gdata.mouse_raw,x-10,y+5,BOX_WIDTH,ITEM_SPACING))
        {
            mm_selected = i;
            onItem = true;
        }
    }

    //clicking menu items
    if ( gdata.keys[sf::Keyboard::Return].isKeyPressed || (gdata.keys[KEY_MOUSE_LEFT].isKeyPressed && onItem) )
    {
        if (mm_selected == 0)       {screen = 2;ls_init();}// go to level select
        else if (mm_selected == 1)  ;// go to achievements
        else if (mm_selected == 2)  {screen = 1;setApplied();}// go to settings
        else if (mm_selected == 3)  gdata.running = false;// exit
    }

    if (gdata.keys[sf::Keyboard::Escape].isKeyPressed)
        gdata.running = false;
}
コード例 #11
0
static int ls_probe(struct platform_device *pdev)
{
	int rc;
	rc = ls_init(pdev);
	return rc;
}
コード例 #12
0
ファイル: mpi2cell_s.c プロジェクト: Iamthewood/PHCpack
void distribute_cells ( int myid, int np, int nspt, int dim, int *nbpaths )
{
   int nbcell,*cell,nbsols,i,j,k,left[np],L,R,*m,sn,mysolnum;
   int count,labSize,cnt,dest;
   MPI_Status status;
   MPI_Comm com = MPI_COMM_WORLD;
   int length[nspt],*labels ;
   int fail,A[2],n;
   double normal[dim],sol[2*(dim-1)+5],*c;
   lisStack *s;
   int *a,*b;
   
   n=dim-1;A[0]=n;
   if(myid == 0)
   { 
      fail=celcon_number_of_cells(&nbcell);  /* get the number of cells */
      cell=(int*)calloc(nbcell,sizeof(int));
      for(i=0; i<nbcell; i++)
         fail = celcon_mixed_volume(i+1,&cell[i]);

      nbsols=0;
      for(i=0; i<nbcell; i++) nbsols=nbsols+cell[i];   
      if(v>0) printf("The number cells are %d\n",nbcell);
      if(v>0) print_cell(nbcell,cell);
      if(v>0) printf("The total solutions are %d\n",nbsols);
   }
   MPI_Bcast(&nbsols,1,MPI_INT,0,com);
   
   if(myid == 0)
   {
      if(v>0) printf("\n");
      left[0] = 0;
      for(i=1; i<np; i++)
         if(i <= (nbsols%(np-1))) 
            left[i] = nbsols/(np-1)+1; 
         else
            left[i] = nbsols/(np-1);
      if(v>0) printf("left:");
      if(v>0) Print_Integer_Array(np,left);
   }

   MPI_Scatter(left,1,MPI_INT,&mysolnum,1,MPI_INT,0,com);

   if(myid == 0)
   {
      fail = celcon_number_of_points_in_cell(1,nspt,length);
      labSize=0;
      for(i=0; i<nspt; i++) labSize = labSize+length[i];
      labSize = 1+nspt+labSize;
   }
   MPI_Bcast(&labSize,1,MPI_INT,0,MPI_COMM_WORLD);
   labels = (int*)calloc(labSize,sizeof(int));
   m=(int*)calloc(3,sizeof(int));

   if(myid==0)
   {
      L=1; R=np-1;
      for(i=0; i<nbcell; i++)
      { 
         m[0] = i+1;
         m[2] = labSize;
         celcon_retrieve_mixed_cell(dim,nspt,i+1,labels,normal);
         
         sn=1;
         while(cell[i]!=0)
         { 
            if(cell[i]>=left[L])
            {   
               m[1] = left[L]; m[2] = sn;      
	       MPI_Send(&m[1],2,MPI_INT,L,SEND_CELL,com);
               /*
               if(v>0)
                  printf("%2d paths from cell %d is sending to node %d\n",
                         m[1],m[0],L);
                */
               MPI_Send(labels,labSize,MPI_INT,L,SEND_SUPP,com);
               MPI_Send(normal,dim,MPI_DOUBLE,L,SEND_NORMAL,com) ;
               cell[i] = cell[i]-left[L]; sn = sn+left[L];
               L++;  
            }
            else if(cell[i]>=left[R])
            { 
               m[1] = left[R]; m[2] = sn;      
               MPI_Send(&m[1],2,MPI_INT,R,SEND_CELL,com);
               /*
               if(v>0)
                  printf("%2d paths from cell %d is sending to node %d\n",
                         m[1],m[0],R);
               */
               MPI_Send(labels,labSize,MPI_INT,R,SEND_SUPP,com);
               MPI_Send(normal,dim,MPI_DOUBLE,R,SEND_NORMAL,com) ;
               cell[i] = cell[i]-left[R]; sn = sn+left[R];
               R--;   
            }
            else
            {              
               m[1] = cell[i]; m[2] = sn;     
               MPI_Send(&m[1],2,MPI_INT,R,SEND_CELL,com);
               /*
               if(v>0)
                  printf("%2d paths from cell %d is sending to node %d\n",
                         m[1],m[0],R);
               */
               MPI_Send(labels,labSize,MPI_INT,R,SEND_SUPP,com);
               MPI_Send(normal,dim,MPI_DOUBLE,R,SEND_NORMAL,com);
               left[R]=left[R]-cell[i]; sn = sn+cell[i];
               cell[i]=0;  
            }
         }
      }
      if(v>0) printf("****************************************************\n");
      printf("writing random coefficient system and its solutions to file\n");
      fail = celcon_write_random_coefficient_system();
      fail = solcon_write_solution_dimensions_to_defined_output_file(nbsols,n);
      cnt = 0;
      for(k=1; k<=nbsols; k++)
      {
         MPI_Recv(&A[1],1,MPI_INT,MPI_ANY_SOURCE,SEND_MUL,
                  MPI_COMM_WORLD,&status);
         MPI_Recv(sol,2*n+5,MPI_DOUBLE,MPI_ANY_SOURCE,SEND_SOL,
                  MPI_COMM_WORLD,&status);
         fail = solcon_write_next_solution_to_defined_output_file
                  (&cnt,n,A[1],sol);
      }
      *nbpaths = nbsols;

   } /* myid=0 finish */
   else
   {  
      *nbpaths = mysolnum;
      if(v>0) printf("Node %d has %d paths\n",myid,mysolnum);
      s=(lisStack*)calloc(1,sizeof(lisStack));
      ls_init(s);
      count = 0; sn = 0;
      while(count < mysolnum)
      {  
         MPI_Recv(&m[1],2,MPI_INT,0,SEND_CELL,com,&status);
         sn++;
         m[0] = sn;
         ls_push(s,m);
         count = count+m[1];
         /*
     	 if(v>0) printf("Node %d is receving %2d paths from cell %d\n",
		        myid,m[1],m[0]);
         */
	 MPI_Recv(labels,labSize,MPI_INT,0,SEND_SUPP,com,&status) ;
	 MPI_Recv(normal,dim,MPI_DOUBLE,0,SEND_NORMAL,com,&status) ;
      	 fail = celcon_append_mixed_cell(dim,nspt,labSize,labels,normal);
      }
      fail = celcon_create_polyhedral_homotopy();
      
      for(i=1; i<=sn; i++)
      {
         m = ls_cur(s);
         fail = celcon_solve_start_system(m[0],&R);

         if(fail == 1)
         {
            printf("Solving start system failed.\n");
            printf("Node %d skips cell %d with volume %d...\n",myid,m[0],R);
         }
         else
         {
    /* printf("found %d start solutions from cell %d\n",R,m[0]); */

            fail=celcon_mixed_volume(m[0],&L);

    /* if(R==L)  printf("#start solutions equals mixed volume %d, OK\n",L);
       else  printf("#start solutions not equals mixed volume %d!!!, \n",L);
    */
            for(j=m[2]; j<m[1]+m[2]; j++)
            {          
               fail = celcon_track_solution_path(m[0],j,0);
               fail = solcon_clear_solutions();
               fail = celcon_copy_target_solution_to_container(m[0],j-m[2]+1);
               fail = solcon_retrieve_solution(n,1,&A[1],sol);
               MPI_Send(&A[1],1,MPI_INT,0,SEND_MUL,MPI_COMM_WORLD);
               MPI_Send(sol,2*n+5,MPI_DOUBLE,0,SEND_SOL,MPI_COMM_WORLD);
            }
         }
         ls_pop(s);
      }
   } /* end else */

 /*  MPI_Barrier(com);  */  
   if(myid == 0)
      free(cell);
   else
      free(s);
   free(labels);
   free(m);
}