예제 #1
0
void read_cells_and_create_start_system ( void )
{
   int dim,n,fail,*d,r,len,k,nbsols,mv;
   double *c;
   char ans = 'y';

   fail = celcon_read_mixed_cell_configuration();
   printf("\nReading a system to initialize the symbol table...");
   fail = read_standard_target_system();
   fail = celcon_dimension_of_points(&dim);
   printf("dimension of the lifted points : %d\n",dim);
   fail = show_mixture(dim,&r);
   fail = celcon_standard_random_coefficient_system();
   printf("The random coefficient start system :\n");
   fail = celcon_write_standard_random_coefficient_system();
   fail = celcon_standard_polyhedral_homotopy();

   fail = celcon_number_of_cells(&len);
   while (ans == 'y')
   {
      printf("Give a number to a mixed cell (<= %d) : ", len);
      scanf("%d",&k);
      fail = celcon_solve_standard_start_system(k,&nbsols);
      printf(" -> found %d start solutions from cell %d\n",nbsols,k);
      fail = celcon_mixed_volume(k,&mv);
      if (nbsols == mv)
         printf("#start solutions equals mixed volume %d, ok\n",mv);
      else
         printf("#start solutions does not equal mixed volume %d!!!\n",mv);
      printf("Do you wish to test another cell (y/n) ");
      scanf("%c",&ans); /* skip new line symbol */
      ans = getchar();
   }
}
예제 #2
0
void solve_standard_start_system ( int len ) 
{
   int fail,nb,tnb,k,tmv,mv,i;

   printf("creating a random coefficient system ...\n");

   fail = celcon_standard_random_coefficient_system();
   fail = celcon_standard_polyhedral_homotopy();

   printf("solving the binomial start systems ...\n");
   tnb = 0; tmv = 0;
   for(k=1; k<=len; k++)
   {
      fail = celcon_solve_standard_start_system(k,&nb);
      printf(" -> found %d start solutions from cell %d\n",nb,k);
      fail = celcon_mixed_volume(k,&mv);
      if (nb == mv)
         printf("#start solutions equals mixed volume %d, OK\n",mv);
      else
         printf("#start solutions does not equal mixed volume %d!!!\n",mv);
      tnb += nb; tmv += mv;
   }
   if (tnb == tmv)
      printf("Total #start solutions : %d = %d mixed volume, OK.\n",tnb,tmv);
   else
      printf("Total #start solutions : %d /= %d mixed volume!!!\n",tnb,tmv);

   printf("tracking the solution paths ...\n");
   for(k=1; k<=len; k++)
   {
      fail = celcon_mixed_volume(k,&mv);
      for(i=1; i<=mv; i++)
      {
         printf("Tracking path %d corresponding to cell %d ...\n",i,k);
         fail = celcon_track_standard_solution_path(k,i,0);
      }
   }
   printf("copying the target solutions to the solution container ...\n");
   for(k=1; k<=len; k++)
   {
      fail = celcon_mixed_volume(k,&mv);
      for(i=1; i<=mv; i++)
         fail = celcon_copy_target_standard_solution_to_container(k,i);
   }
   printf("writing random coefficient system and its solutions to file ...\n");
   fail = celcon_write_standard_random_coefficient_system();
   fail = solcon_write_standard_solutions();
}
예제 #3
0
int query_cell ( int n, int r, int *cellnb, int tosolve )
{
    int k,fail,*b,i,j,mv,nl[r],kk,mvcell;
    double *c,normal[n],pt[n];
    char ch;

    printf("Give a cell number : ");
    scanf("%d", &k);

    if(tosolve == 1)
    {
        fail = celcon_standard_random_coefficient_system();
        fail = celcon_standard_polyhedral_homotopy();
    }

    fail = celcon_get_inner_normal(n,k,normal);
    if (fail==1)
        printf("an error happened...\n");
    else
    {
        *cellnb = k;
        printf("inner normal for cell %d :\n", k);
        for(i=0; i<n; i++) printf("%.15le\n", normal[i]);
        fail = celcon_number_of_points_in_cell(k,r,nl);
        printf("number of points in supports :");
        for(i=0; i<r; i++) printf(" %d",nl[i]);
        printf("\n");
        scanf("%c",&ch); /* get previous new line symbol */
        printf("Hit enter to continue.");
        scanf("%c",&ch); /* catch new line symbol */
        printf("points in the supports :\n");
        for(i=0; i<r; i++)
        {
            for(j=0; j<nl[i]; j++)
            {
                fail = celcon_get_point_in_cell(n,k,i+1,j+1,pt);
                for(kk=0; kk<n-1; kk++) printf(" %d",(int) pt[kk]);
                printf(" %.15le\n", pt[n-1]);
            }
        }
        fail = celcon_mixed_volume(k,&mv);
        printf("mixed volume : %d\n",mv);
        printf("Hit enter to continue.");
        scanf("%c",&ch); /* catch new line symbol */
        if(tosolve == 1)
        {
            fail = celcon_solve_standard_start_system(k,&mvcell);
            printf("The number of solutions : %d\n", mvcell);
            printf("Hit enter to continue.");
            scanf("%c",&ch); /* catch new line symbol */
        }
        {
            int cl[1+r+2*n];
            double inner_normal[n];

            fail = celcon_retrieve_mixed_cell(n,r,k,cl,inner_normal);
            printf("the inner normal for cell %d : \n", k);
            for(i=0; i<n; i++) printf(" %.15le\n", inner_normal[i]);
            printf("total number of points in supports : %d\n",cl[0]);
            printf("number of points in supports : ");
            for(i=1; i<=r; i++) printf(" %d", cl[i]);
            printf("\n");
            printf("labels of points : ");
            kk=r;
            for(i=1; i<=r; i++)
            {
                for(j=0; j<cl[i]; j++) printf(" %d", cl[++kk]);
                printf(" | ");
            }
            printf("\n");
            printf("Hit enter to continue.");
            scanf("%c",&ch); /* catch new line symbol */
        }
    }
    return fail;
}