Exemple #1
0
void ada_read_sols ( PolySys& start_sys, PolySolSet& sols )
{
   int fail, len;

   fail = solcon_number_of_dobldobl_solutions(&len);
   // printf("Number of start solutions : %d\n",len);
   int dim=start_sys.dim;
   sols.dim = dim;
   double sol[4*dim+10];

   for(int sol_idx=1; sol_idx<len+1; sol_idx++)
   {
      int mm,k,pos;
      T1 dd_sol[2*dim];
      T1 t_real,t_imag,err,rco,res;

      solcon_retrieve_next_dobldobl_solution(dim,&k,&mm,sol);
      //solcon_retrieve_solution(dim,sol_idx,&mm,sol);
      /*std::cout << sol[0] << " " << sol[1] << std::endl;
      for(int var_idx=0; var_idx<4; var_idx++)
         std::cout << sol[2+2*var_idx] << " " << sol[2+2*var_idx] << std::endl;
      std::cout << sol[2+2*dim] 
                << " " << sol[3+2*dim]
                << " " << sol[4+2*dim] << std::endl;*/
      t_real.x[0] = sol[0];
      t_real.x[1] = sol[1];
      t_imag.x[0] = sol[2];
      t_imag.x[1] = sol[3];
      pos = 4;
      for(int dd_sol_idx=0; dd_sol_idx<2*dim; dd_sol_idx++)
      {
         T1 sol_real,sol_imag;
         sol_real.x[0] = sol[pos++];
         sol_real.x[1] = sol[pos++];
         sol_imag.x[0] = sol[pos++];
         sol_imag.x[1] = sol[pos++];
         dd_sol[dd_sol_idx++] = sol_real;
         dd_sol[dd_sol_idx] = sol_imag;
      }
      err.x[0] = sol[4*dim+4];
      err.x[1] = sol[4*dim+5];
      rco.x[0] = sol[4*dim+6];
      rco.x[1] = sol[4*dim+7];
      res.x[0] = sol[4*dim+8];
      res.x[1] = sol[4*dim+9];
      PolySol* tmp_sol = new PolySol(dim,t_real,t_imag,dd_sol,err,rco,res);
      //tmp_sol->print_info(start_sys.pos_var);
      sols.add_sol(tmp_sol);
   }

   // std::cout << "sol finished" << std::endl;
}
Exemple #2
0
int dobldobl_laursys_write ( int topdim )
{
   int fail,dim,len;

   for(dim=0; dim<=topdim; dim++)
   {
      fail = copy_dobldobl_laursys_witset(dim);
      fail = solcon_number_of_dobldobl_solutions(&len);
      printf("-> number of points at dimension %d : %d\n",dim,len);
   }

   return fail;
}
Exemple #3
0
int call_initialize_dobldobl_homotopy ( int *index )
{
   int fail,len,fixed;

   fail = read_dobldobl_target_system(); /* no _without_solutions ! */
   fail = read_dobldobl_start_system();
   fail = copy_dobldobl_start_solutions_to_container();
   fail = solcon_number_of_dobldobl_solutions(&len);
   printf("Number of start solutions : %d\n",len);
   printf("-> give index of solution : "); scanf("%d",index);
   printf("Fixed gamma constant ? (1 = yes/0 = no) "); scanf("%d",&fixed);
   fail = initialize_dobldobl_homotopy(fixed);
   fail = initialize_dobldobl_solution(*index);

   return fail;
}
Exemple #4
0
void test_dobldobl_Newton_Laurent_step ( void )
{
   int fail,dim,len;

   printf("\nRunning Newton step with double double arithmetic ...\n");
   fail = syscon_read_dobldobl_Laurent_system();
   fail = syscon_number_of_dobldobl_Laurentials(&dim);
   printf("The system container has %d Laurent 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_Laurent_step();
   printf("The solutions after the Newton step :\n");
   fail = solcon_write_dobldobl_solutions();
}
Exemple #5
0
int named_input_files ( void )
{
   int n, fail, len;
   char inputfile[80];
   int mode = 7;
 /* reading target system :  0 for standard, 1 for double double,
                             2 for quad double, 3 for multiprecision
    reading start system :  4 for standard, 5 for double double,
                            6 for quad double, 7 for multiprecision */

   if(mode < 4) printf("\nReading the target system from file ...\n");
   if(mode > 3) printf("\nReading the start system from file ...\n");
   printf("Give the file name : "); scanf("%s", inputfile);
   n = (int) strlen(inputfile);

   if(mode == 0)
   {
      printf("\n... test reading in standard doubles ...\n");
      fail = read_standard_target_system_from_file(n, inputfile);
      fail = copy_container_to_target_system();
      printf("\nThe system read :\n"); fail = write_standard_target_system();
   }
   else if(mode == 1)
   {
      printf("\n... test reading in double doubles ...\n");
      fail = read_dobldobl_target_system_from_file(n, inputfile);
      fail = copy_dobldobl_container_to_target_system();
      printf("\nThe system read :\n"); fail = write_dobldobl_target_system();
   }
   else if(mode == 2)
   {
      printf("\n... test reading in quad doubles ...\n");
      fail = read_quaddobl_target_system_from_file(n, inputfile);
      fail = copy_quaddobl_container_to_target_system();
      printf("\nThe system read :\n"); fail = write_quaddobl_target_system();
   }
   else if(mode == 3)
   {
      printf("\n... test reading in multiprecision ...\n");
      fail = read_multprec_target_system_from_file(80, n, inputfile);
      fail = copy_multprec_container_to_target_system();
      printf("\nThe system read :\n"); fail = write_multprec_target_system();
   }
   else if(mode == 4)
   {
      printf("\n... test reading in standard doubles ...\n");
      fail = read_standard_start_system_from_file(n, inputfile);
      fail = copy_container_to_start_system();
      printf("\nThe system read :\n"); fail = write_standard_start_system();
      fail = solcon_number_of_solutions(&len);
      printf("\nNumber of start solutions in container : %d\n", len);
   }
   else if(mode == 5)
   {
      printf("\n... test reading in double doubles ...\n");
      fail = read_dobldobl_start_system_from_file(n, inputfile);
      fail = copy_dobldobl_container_to_start_system();
      printf("\nThe system read :\n"); fail = write_dobldobl_start_system();
      fail = solcon_number_of_dobldobl_solutions(&len);
      printf("\nNumber of start solutions in container : %d\n", len);
   }
   else if(mode == 6)
   {
      printf("\n... test reading in quad doubles ...\n");
      fail = read_quaddobl_start_system_from_file(n, inputfile);
      fail = copy_quaddobl_container_to_start_system();
      printf("\nThe system read :\n"); fail = write_quaddobl_start_system();
      fail = solcon_number_of_quaddobl_solutions(&len);
      printf("\nNumber of start solutions in container : %d\n", len);
   }
   else
   {
      printf("\n... test reading in multiprecision ...\n");
      fail = read_multprec_start_system_from_file(80, n, inputfile);
      fail = copy_multprec_container_to_start_system();
      printf("\nThe system read :\n"); fail = write_multprec_start_system();
      fail = solcon_number_of_multprec_solutions(&len);
      printf("\nNumber of start solutions in container : %d\n", len);
   }
   return 0;
}
Exemple #6
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;
}