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

   fail = syscon_read_quaddobl_system();
   fail = syscon_write_quaddobl_system();
   fail = syscon_number_of_quaddobl_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_quaddobl_terms(i,&t);
      printf(" %d",t);
   }
   printf("\ndegree of each polynomial :");
   for(i=1; i<=n; i++)
   {
      fail = syscon_degree_of_quaddobl_polynomial(i,&deg);
      printf(" %d",deg);
   }
   printf("\nthe polynomials as strings :\n");
   for(i=1; i<=n; i++)
   {
      char buffer[4000];
      int nc;
      fail = syscon_load_quaddobl_polynomial(i,&nc,buffer);
      printf("polynomial %d : %s\n",i,buffer);
   }
   printf("\n");
   test_symbol_table();
}
コード例 #2
0
ファイル: parallel_phcpack.c プロジェクト: sommars/PHCpack
void quaddobl_dimensions_broadcast ( int myid, int *nbequ, int *nbvar )
{
   int fail,m;

   if(v>0) printf("Node %d has entered dimensions_broadcast.\n", myid);

   MPI_Bcast(nbequ,1,MPI_INT,0,MPI_COMM_WORLD);  
   MPI_Bcast(nbvar,1,MPI_INT,0,MPI_COMM_WORLD);  

   if(myid != 0)
   {
      if(v>0) 
      {
          printf("Node %d has the number of equations as %d.\n", myid, *nbequ);
          printf("Node %d has the number of variables as %d.\n", myid, *nbvar);
      }
      /* initialize container */
      fail = syscon_initialize_number_of_quaddobl_polynomials(*nbequ);
      if(v>0)
      {  /* get dimension as test */
         fail = syscon_number_of_quaddobl_polynomials(&m);
         printf("  and initialized container with dimension %d.\n", m);
      }
   }

   if(v>0) printf("Node %d is leaving dimensions_broadcast.\n", myid);
}
コード例 #3
0
ファイル: lib_witsols.c プロジェクト: janverschelde/PHCpack
int quaddobl_polysys_solver ( void )
{
   int fail,nbq,nbtasks,topdim,filter,factor,verbose;

   fail = syscon_read_quaddobl_system();
   fail = syscon_number_of_quaddobl_polynomials(&nbq);
   printf("-> read %d polynomials\n", nbq);
   printf("\n");
   read_solver_options(&nbtasks,&topdim,&filter,&factor,&verbose);

   printf("\nCalling the solver ...\n\n");
   fail = quaddobl_polysys_solve(nbtasks,topdim,filter,factor,verbose);
   fail = quaddobl_polysys_write(topdim);

   return fail;
}
コード例 #4
0
ファイル: lib_newton.c プロジェクト: Jakobularius/PHCpack
void test_quaddobl_Newton_step ( void )
{
   int fail,dim,len;

   printf("\nRunning Newton step with quad double arithmetic ...\n");
   fail = syscon_read_quaddobl_system();
   fail = syscon_number_of_quaddobl_polynomials(&dim);
   printf("The system container has %d polynomials.\n",dim);
   fail = solcon_read_quaddobl_solutions();
   fail = solcon_number_of_quaddobl_solutions(&len);
   printf("The solution container has size %d.\n",len);
   fail = solcon_dimension_of_quaddobl_solutions(&dim);
   printf("The solutions in the container have dimension %d.\n",dim);
   fail = quaddobl_Newton_step();
   printf("The solutions after the Newton step :\n");
   fail = solcon_write_quaddobl_solutions();
}
コード例 #5
0
ファイル: mpi2padcon.c プロジェクト: janverschelde/PHCpack
int quaddobl_run ( int myid, int nbrp, int nbc, char* outfile, int verbose )
{
   int fail,dim,nbsols,mysolnum,len,*nbpaths;
   double startwtime,endwtime,wtime,*time;

   startwtime = MPI_Wtime();
   if(myid == 0)
   {
      time = (double*)calloc(nbrp,sizeof(double));
      nbpaths = (int*)calloc(nbrp,sizeof(int));
      fail = read_quaddobl_target_system_without_solutions();
      fail = copy_quaddobl_target_system_to_container();
      fail = syscon_number_of_quaddobl_polynomials(&dim);
      fail = write_quaddobl_target_system();
   }
   quaddobl_dimensions_broadcast(myid,&dim,&dim);

   if(verbose > 0) printf("Process %d has dimension %d.\n",myid,dim);

   quaddobl_monomials_broadcast(myid,dim);

   if(myid != 0) fail = copy_quaddobl_container_to_target_system();

   if(verbose > 0)
      if(myid == 1) fail = write_quaddobl_target_system();

   if(myid == 0)
   {
      fail = read_quaddobl_start_system();
      fail = copy_quaddobl_start_system_to_container();
      fail = write_quaddobl_start_system(); // writes to file
      fail = write_quaddobl_start_solutions(); // writes solutions to file
      fail = copy_quaddobl_start_solutions_to_container();
      fail = solcon_number_of_quaddobl_solutions(&nbsols);
      if(verbose>0) printf("Read %d start solutions.\n",nbsols);
   }
   else
      fail = syscon_initialize_number_of_quaddobl_polynomials(dim);

   quaddobl_monomials_broadcast(myid,dim); // broadcast start system

   if(myid != 0) fail = copy_quaddobl_container_to_start_system();

   if(verbose > 0)
      if(myid == 1) fail = write_quaddobl_start_system();

   parameters_broadcast(myid,nbrp,1);

   MPI_Bcast(&nbsols,1,MPI_INT,0,MPI_COMM_WORLD);
   quaddobl_solutions_distribute(myid,nbsols,dim,nbrp,&mysolnum,verbose);

   fail = solcon_number_of_quaddobl_solutions(&len);
   if(verbose > 0) printf("Node %d has %d solutions.\n",myid,len);

   if(myid > 0)
   {
      fail = copy_quaddobl_container_to_start_solutions();
      fail = quaddobl_track_paths(myid,nbrp,nbc,outfile,verbose);
   }
   quaddobl_solutions_collect(myid,nbsols,dim,nbrp,mysolnum);

   if(myid == 0)
   {
      fail = copy_quaddobl_container_to_target_solutions();
      fail = write_quaddobl_target_solutions();
   }
   endwtime = MPI_Wtime();
   wtime = endwtime-startwtime;
   MPI_Gather(&wtime,1,MPI_DOUBLE,time,1,MPI_DOUBLE,0,MPI_COMM_WORLD);
   MPI_Gather(&mysolnum,1,MPI_INT,nbpaths,1,MPI_INT,0,MPI_COMM_WORLD);

   if(myid == 0)
   {
      nbpaths[0] = nbsols;
      write_time_and_paths_to_defined_output_file(nbrp,time,nbpaths);
      free(time); free(nbpaths);
   }
   return 0;
}
コード例 #6
0
ファイル: ada_test_qd.cpp プロジェクト: janverschelde/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_quaddobl_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[8]; /* two consecutive quad doubles are real and imag parts */
    int d[dim];

    int n_eq = 0;
    fail = syscon_number_of_quaddobl_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_quaddobl_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_quaddobl_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[4]);
                //std::cout << "constant " << c[0] << " " << c[1] << std::endl;
            }
            else
            {
                T1 cffs[4];
                T1 realpcff;
                T1 imagpcff;
                realpcff.x[0] = c[0];
                realpcff.x[1] = c[1];
                realpcff.x[2] = c[2];
                realpcff.x[3] = c[3];
                imagpcff.x[0] = c[4];
                imagpcff.x[1] = c[5];
                imagpcff.x[2] = c[6];
                imagpcff.x[3] = c[7];
                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;
    }
}