Пример #1
0
void quaddobl_monomials_broadcast ( int myid, int n )
{
   double cff[8];
   int i,j,exp[n],mm,fail;

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

   for(i=1; i<=n; i++)
   {
      if(myid == 0)
      {
         fail = syscon_number_of_quaddobl_terms(i,&mm); /* get #monomials */
         if(v>1) printf("Polynomial %d has %d monomials.\n",i,mm);
      }

      MPI_Bcast(&mm,1,MPI_INT,0,MPI_COMM_WORLD);

      for(j=1; j<=mm; j++)    /* broadcast j-th term of i-th polynomial */
      {
         if(myid == 0) fail = syscon_retrieve_quaddobl_term(i,j,n,exp,cff); 
         MPI_Bcast(cff,8,MPI_DOUBLE,0,MPI_COMM_WORLD); 
         MPI_Bcast(exp,n,MPI_INT,0,MPI_COMM_WORLD); 
         if(myid != 0) fail = syscon_add_quaddobl_term(i,n,exp,cff);
      }
   }

   if(v>0) printf("Node %d is about to leave monomials_broadcast.\n", myid);
}
Пример #2
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_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;
    }
}