예제 #1
0
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{
예제 #2
0
void test_retrievals ( int n, LIST *p[n] )
{
   int i,j,k,nt,fail;
   double c[2];
   int d[n];

   for(i=1; i<=n; i++)
   {
      fail = syscon_number_of_terms(i,&nt);
      printf("  #terms in polynomial %d : %d\n", i, nt);

      p[i-1] = NULL;
      for(j=1; j<=nt; j++)
      {
         fail = syscon_retrieve_term(i,j,n,d,c);
         printf(" %.15f  %.15f", c[0], c[1]);
         for (k=0; k<n; k++) printf(" %d", d[k]);
         printf("\n");
         p[i-1] = push(p[i-1],n,c,d);
      }
   }
}