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

   fail = syscon_read_system();
   fail = syscon_write_system();
   fail = syscon_number_of_polynomials(&n);

   test_symbol_table();

   printf("\nThe dimension of the system : %d\n",n);
   {
      LIST *p[n];
      int i;

      test_retrievals(n,p);

      fail = syscon_clear_system();

      for(i=0; i<n; i++)
      {
         printf("The terms in polynomial %d : \n", i+1);
         write_monomial_list(p[i],n);
      }

      test_additions(n,p);
   }
}
コード例 #2
0
ファイル: test.cpp プロジェクト: callmetaste/PHCpack
void ada_read_sys(PolySys& sys)
{
	int fail;
	std::cout << "testing reading and writing a system" << std::endl;
	//fail = syscon_read_system();
	std::cout << "the system is .." << std::endl;
	fail = syscon_write_system();

	// Get variable names
	int s_dim = 80;
	char *s = (char*) calloc(80,sizeof(char));
	fail = syscon_string_of_symbols(&s_dim, s);
	string* x_names;
	var_name(s, s_dim, x_names);

	int dim = 4;
	int i = 1;
	double c[2];
	int d[dim];

	int n_eq = 0;
	fail = syscon_number_of_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_terms(i,&nt);
		//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_term(i,j,dim,d,c);
			//std::cout << c[0] << " " << c[1] << std::endl;
			//for (int k=0; k<n; 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[1]);
				//std::cout << "constant " << c[0] \
				          << " " << c[1] << std::endl;
			}
			else{
コード例 #3
0
ファイル: lib_syscon.c プロジェクト: Jakobularius/PHCpack
void show_random_system ( void )
{
   int n,m,d,c;

   printf("\nGenerating a random system ...\n");
   printf("-> enter the dimension : "); scanf("%d", &n);
   printf("-> enter the number of monomials : "); scanf("%d", &m);
   printf("-> enter the degree bound : "); scanf("%d", &d);
   printf("-> enter the coefficient type : "); scanf("%d", &c);

   syscon_random_system(n,m,d,c);
   syscon_write_system();
}
コード例 #4
0
ファイル: phc_solve.c プロジェクト: Iamthewood/PHCpack
int input_output_on_files ( void )
{
   int fail,rc;

   fail = syscon_read_system();
   printf("\nThe system in the container : \n");
   fail = syscon_write_system();
   fail = solve_system(&rc);
   printf("\nThe root count : %d\n",rc);
   printf("\nThe solutions :\n");
   fail = solcon_write_solutions();

   return fail;
}
コード例 #5
0
ファイル: lib_usolve.c プロジェクト: Jakobularius/PHCpack
void standard_test ( void )
{
   int fail,max,nit;
   const double eps = 1.0e-12;

   fail = syscon_read_system();
   fail = syscon_write_system();
   
   printf("\nGive the maximum number of iterations : ");
   scanf("%d",&max);
   
   fail = solve_with_standard_doubles(max,eps,&nit);

   printf("\nNumber of iterations : %d\n",nit);
   fail = solcon_write_solutions();
}
コード例 #6
0
ファイル: lib_syscon.c プロジェクト: Jakobularius/PHCpack
void test_additions ( int n, LIST *p[n] )
{
   int i,fail;
   double *c;
   LIST *l;

   fail = syscon_initialize_number(n);
   for(i=0; i<n; i++)
      for(l=p[i]; l!=NULL; l=l->next)
      {
         double cf[2];
         cf[0] = l->rc;
         cf[1] = l->ic;
         fail = syscon_add_term(i+1,n,l->exp,cf);
      }
   printf("\nThe reconstructed system :\n");
   fail = syscon_write_system();
}
コード例 #7
0
ファイル: phc_solve.c プロジェクト: Iamthewood/PHCpack
int interactive_input_output ( void )
{
   int n,fail,k,nc,i,rc,len;
   char ch,p[800];

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

   fail = syscon_initialize_number(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_polynomial(nc,n,k,p);
   }
   printf("The system in the container : \n");
   syscon_write_system();
   fail = solve_system(&rc);
   printf("\nThe root count : %d\n",rc);
   /* printf("\nThe solutions :\n");
   fail = solcon_write_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_solution_string(k,&len);
      {
         char s[len];
         fail = solcon_write_solution_string(k,len,s);
         printf("\nSolution %d : \n%s",k,s);
      } 
   } while (k >= 0);

   return fail;
}