コード例 #1
0
ファイル: lib_syscon.c プロジェクト: Jakobularius/PHCpack
void test_dobldobl_container ( void )
{
   int fail,n,i,t,deg;

   fail = syscon_read_dobldobl_system();
   fail = syscon_write_dobldobl_system();
   fail = syscon_number_of_dobldobl_polynomials(&n);
   printf("number of polynomials : %d\n",n);
   printf("number of terms in each polynomial :");
   for(i=1; i<=n; i++)
   {
      fail = syscon_number_of_dobldobl_terms(i,&t);
      printf(" %d",t);
   }
   printf("\ndegree of each polynomial :");
   for(i=1; i<=n; i++)
   {
      fail = syscon_degree_of_dobldobl_polynomial(i,&deg);
      printf(" %d",deg);
   }
   printf("\nthe polynomials as strings :\n");
   for(i=1; i<=n; i++)
   {
      char buffer[2000];
      int nc;
      fail = syscon_load_dobldobl_polynomial(i,&nc,buffer);
      printf("polynomial %d : %s\n",i,buffer);
   }
   printf("\n");
   test_symbol_table();
}
コード例 #2
0
ファイル: lib_usolve.c プロジェクト: Jakobularius/PHCpack
void dobldobl_test ( void )
{
   int fail,max,nit;
   const double eps = 1.0e-24;

   fail = syscon_read_dobldobl_system();
   fail = syscon_write_dobldobl_system();
   
   printf("\nGive the maximum number of iterations : ");
   scanf("%d",&max);
   
   fail = solve_with_double_doubles(max,eps,&nit);

   printf("\nNumber of iterations : %d\n",nit);
   fail = solcon_write_dobldobl_solutions();
}
コード例 #3
0
ファイル: phc_solve.c プロジェクト: callmetaste/PHCpack
int dobldobl_interactive_input_output ( void )
{
   int n,fail,k,nc,i,rc,len,nbtasks;
   char ch,p[800];

   printf("\nGive the number of polynomials in the system : ");
   scanf("%d",&n);

   fail = syscon_initialize_number_of_dobldobl_polynomials(n);
   printf("\nReading %d polynomials, ",n);
   printf("terminate each with ; (semicolon)...\n");
   for(k=1; k<=n; k++)
   { 
      printf("-> polynomial %d : ",k);
      ch = getchar();    /* skip previous newline symbol */
      read_poly(&nc,p);
     /* printf("  p[%d] = ",k); 
        for(i=0; i<nc; i++) printf("%c",p[i]);
        printf("\n"); */
      fail = syscon_store_dobldobl_polynomial(nc,n,k,p);
   }
   printf("The system in the container : \n");
   syscon_write_dobldobl_system();
   printf("\nGive the number of tasks : "); scanf("%d",&nbtasks);
   fail = solve_dobldobl_system(&rc,nbtasks);
   printf("\nThe root count : %d\n",rc);
   /* printf("\nThe solutions :\n");
   fail = solcon_write_dobldobl_solutions(); */
   printf("interactive selection of solutions... \n");
   do
   {
      printf("\nGive an index to a solution (-1 to exit) : ");
      scanf("%d",&k);
      if(k < 0) break;
      fail = solcon_length_dobldobl_solution_string(k,&len);
      {
         char s[len];
         fail = solcon_write_dobldobl_solution_string(k,len,s);
         printf("\nSolution %d : \n%s",k,s);
      } 
   } while (k >= 0);

   return fail;
}
コード例 #4
0
ファイル: lib_member.c プロジェクト: callmetaste/PHCpack
int dobldobl_membership_test ( void )
{
   int fail,n,dim,deg,nv;
   char ans;

   printf("\nReading a witness set ...\n");
   fail = read_dobldobl_witness_set(&n,&dim,&deg);
   nv = n - dim;

   if(verbose>0)  /* only in verbose mode */
   {
      printf("\nThe ambient dimension : %d.\n",n);
      printf("The dimension of the solution set : %d.\n",dim);
      printf("The degree of the solution set : %d.\n",deg);
      printf("\nDo you want to see the embedded system ? (y/n) ");
      scanf("%c",&ans);
      if(ans == 'y')
      {
         printf("\nThe system read :\n");
         fail = syscon_write_dobldobl_system();
      }
      scanf("%c",&ans); /* skip end of line character */
      printf("\nDo you want to see the solutions ? (y/n) ");
      scanf("%c",&ans);
      if(ans == 'y')
      {
         printf("\nThe solutions read :\n");
         fail = solcon_write_dobldobl_solutions();
      }
      scanf("%c",&ans); /* skip end of line character */
   }
   {
      int fail,onsys,onset;
      double tpt[4*nv];
      const double restol = 1.0e-6;
      const double homtol = 1.0e-10;
      printf("\nReading the coordinates of the test point x ...\n");
      dobldobl_read_point(nv,tpt);
      fail = dobldobl_homotopy_membership_test
               (1,nv,dim,restol,homtol,tpt,&onsys,&onset);
   }

   return 0;
}
コード例 #5
0
ファイル: lib_factor.c プロジェクト: callmetaste/PHCpack
int dobldobl_test ( void )
{
   int fail,n,dim,deg,nbloops,kind;
   char ans;

   printf("\nReading a witness set ...\n");
   fail = read_dobldobl_witness_set(&n,&dim,&deg);
   printf("\nMENU for the kind of output :\n");
   printf("  0. remain silent with no intermediate output;\n");
   printf("  1. all intermediate output goes to screen;\n");
   printf("  2. give a file name for all intermediate output.\n");
   printf("Type 0, 1, or 2 to make a choice : "); scanf("%d",&kind);

   scanf("%c",&ans); /* skip end of line character */

   if(kind == 0) fail = set_state_to_silent();
   if(kind == 2) fail = define_output_file();

   if(verbose>0)  /* only in verbose mode */
   {
      printf("\nThe ambient dimension : %d.\n",n);
      printf("The dimension of the solution set : %d.\n",dim);
      printf("The degree of the solution set : %d.\n",deg);
      printf("\nDo you wish to see the embedded system ? (y/n) ");
      scanf("%c",&ans);
      if(ans == 'y')
      {
         printf("\nThe system read :\n");
         fail = syscon_write_dobldobl_system();
      }
   }

   fail = dobldobl_assign_labels(n,deg);

   printf("\nGive the number of loops : ");
   scanf("%d",&nbloops);

   fail = dobldobl_monodromy_breakup(nbloops,n,dim,deg);

   if(kind == 2) printf("See the output file for results.\n");

   return 0;
}
コード例 #6
0
ファイル: phc_solve.c プロジェクト: callmetaste/PHCpack
int input_output_on_files ( int precision )
{
   int fail,rc,nbtasks;

   if(precision == 0)
   {
      fail = syscon_read_standard_system();
      printf("\nThe system in the container : \n");
      fail = syscon_write_standard_system();
      printf("\nGive the number of tasks : "); scanf("%d",&nbtasks);
      fail = solve_system(&rc,nbtasks);
      printf("\nThe root count : %d\n",rc);
      printf("\nThe solutions :\n");
      fail = solcon_write_standard_solutions();
   }
   else if(precision == 1)
   {
      fail = syscon_read_dobldobl_system();
      printf("\nThe system in the container : \n");
      fail = syscon_write_dobldobl_system();
      printf("\nGive the number of tasks : "); scanf("%d",&nbtasks);
      fail = solve_dobldobl_system(&rc,nbtasks);
      printf("\nThe root count : %d\n",rc);
      printf("\nThe solutions :\n");
      fail = solcon_write_dobldobl_solutions();
   }
   else if(precision == 2)
   {
      fail = syscon_read_quaddobl_system();
      printf("\nThe system in the container : \n");
      fail = syscon_write_quaddobl_system();
      printf("\nGive the number of tasks : "); scanf("%d",&nbtasks);
      fail = solve_quaddobl_system(&rc,nbtasks);
      printf("\nThe root count : %d\n",rc);
      printf("\nThe solutions :\n");
      fail = solcon_write_quaddobl_solutions();
   }

   return fail;
}
コード例 #7
0
ファイル: ada_test_dd.cpp プロジェクト: callmetaste/PHCpack
void ada_read_sys ( int verbose, PolySys& sys )
{
   int fail,nbsym;

   fail = syscon_number_of_symbols(&nbsym);

   if(verbose > 0)
   {
      std::cout << "the system is .." << std::endl;
      fail = syscon_write_dobldobl_system();
      std::cout << "the number of symbols : " << nbsym << std::endl;
   }
   int s_dim = 80*nbsym;
   char *s = (char*) calloc(s_dim,sizeof(char));
   fail = syscon_string_of_symbols(&s_dim, s);

   string* x_names;
   int dim = 0;
   var_name(s, s_dim, x_names, dim);
   int i = 1;
   if(verbose > 0) std::cout << "dim = " << dim << std::endl;

   double c[4]; /* two consecutive double doubles are real and imag parts */
   int d[dim];

   int n_eq = 0;
   fail = syscon_number_of_dobldobl_polynomials(&n_eq);

   sys.n_eq = n_eq;
   sys.dim  = dim;
   sys.eq_space = new PolyEq[n_eq];
   sys.pos_var = x_names;

   PolyEq* tmp_eq = sys.eq_space;

   for(int i=1; i<n_eq+1; i++)
   {
      int nt;
      fail = syscon_number_of_dobldobl_terms(i,&nt);
      if(verbose > 0)
         std::cout << " #terms in polynomial " << i << " : " << nt << std::endl;
      tmp_eq->n_mon = nt;
      tmp_eq->dim = dim;
      for(int j=1; j<=nt; j++)
      {
         fail = syscon_retrieve_dobldobl_term(i,j,dim,d,c);
         if(verbose > 0)
         {
            std::cout << c[0] << " " << c[2] << std::endl;
            for (int k=0; k<dim; k++) std::cout << " " << d[k];
            std::cout << std::endl;
         }
         bool constant_term = true;
         for(int k=0; k<dim; k++)
            if(d[k]!=0) constant_term = false;

         if(constant_term==true)
         {
            tmp_eq->n_mon--;
            tmp_eq->constant += CT(c[0],c[2]);
         }
         else
         {
            T1 cffs[2];
            T1 realpcff;
            T1 imagpcff;
            realpcff.x[0] = c[0];
            realpcff.x[1] = c[1];
            imagpcff.x[0] = c[2];
            imagpcff.x[1] = c[3];
            cffs[0] = realpcff;
            cffs[1] = imagpcff;
            PolyMon* a = new PolyMon(dim,d,cffs);
            tmp_eq->mon.push_back(a);
         }
      }
      if(verbose > 0) tmp_eq->print(x_names);
      sys.eq.push_back(tmp_eq);
      tmp_eq++;
   }
   if(verbose > 0)
   {
      sys.print();
      std::cout << "End" << std::endl;
   }
}