예제 #1
0
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
void dobldobl_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_dobldobl_polynomials(*nbequ);
      if(v>0)
      {  /* get dimension as test */
         fail = syscon_number_of_dobldobl_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
int dobldobl_polysys_solver ( void )
{
   int fail,nbq,nbtasks,topdim,filter,factor,verbose;

   fail = syscon_read_dobldobl_system();
   fail = syscon_number_of_dobldobl_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 = dobldobl_polysys_solve(nbtasks,topdim,filter,factor,verbose);
   fail = dobldobl_polysys_write(topdim);

   return fail;
}
예제 #4
0
void test_dobldobl_Newton_step ( void )
{
   int fail,dim,len;

   printf("\nRunning Newton step with double double arithmetic ...\n");
   fail = syscon_read_dobldobl_system();
   fail = syscon_number_of_dobldobl_polynomials(&dim);
   printf("The system container has %d polynomials.\n",dim);
   fail = solcon_read_dobldobl_solutions();
   fail = solcon_number_of_dobldobl_solutions(&len);
   printf("The solution container has size %d.\n",len);
   fail = solcon_dimension_of_dobldobl_solutions(&dim);
   printf("The solutions in the container have dimension %d.\n",dim);
   fail = dobldobl_Newton_step();
   printf("The solutions after the Newton step :\n");
   fail = solcon_write_dobldobl_solutions();
}
예제 #5
0
int dobldobl_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_dobldobl_target_system_without_solutions();
      fail = copy_dobldobl_target_system_to_container();
      fail = syscon_number_of_dobldobl_polynomials(&dim);
      fail = write_dobldobl_target_system();
   }
   dobldobl_dimensions_broadcast(myid,&dim,&dim);

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

   dobldobl_monomials_broadcast(myid,dim);

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

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

   if(myid == 0)
   {
      fail = read_dobldobl_start_system();
      fail = copy_dobldobl_start_system_to_container();
      fail = write_dobldobl_start_system(); // writes to file
      fail = write_dobldobl_start_solutions(); // writes solutions to file
      fail = copy_dobldobl_start_solutions_to_container();
      fail = solcon_number_of_dobldobl_solutions(&nbsols);
      if(verbose>0) printf("Read %d start solutions.\n",nbsols);
   }
   else
      fail = syscon_initialize_number_of_dobldobl_polynomials(dim);

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

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

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

   parameters_broadcast(myid,nbrp,verbose);

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

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

   if(myid > 0)
   {
      fail = copy_dobldobl_container_to_start_solutions();
      fail = dobldobl_track_paths(myid,nbrp,nbc,outfile,verbose);
   }
   MPI_Barrier(MPI_COMM_WORLD);
   dobldobl_solutions_collect(myid,nbsols,dim,nbrp,mysolnum);

   if(myid == 0)
   {
      fail = copy_dobldobl_container_to_target_solutions();
      fail = write_dobldobl_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
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;
   }
}