int main ( int argc, char *argv[] ) { int fail,choice; adainit(); printf("\nMENU for the precision and type of system :\n"); printf(" 0. standard double precision on a polynomial system\n"); printf(" 1. standard double precision on a Laurent polynomial system\n"); printf(" 2. double double precision on a polynomial system\n"); printf(" 3. double double precision on a Laurent polynomial system\n"); printf(" 4. quad double precision on a polynomial system\n"); printf(" 5. quad double precision on a Laurent polynomial system\n"); printf("Type 0, 1, 2, 3, 4, or 5 : "); scanf("%d", &choice); if(choice == 0) fail = standard_polysys_solver(); else if(choice == 1) fail = standard_laursys_solver(); else if(choice == 2) fail = dobldobl_polysys_solver(); else if(choice == 3) fail = dobldobl_laursys_solver(); else if(choice == 4) fail = quaddobl_polysys_solver(); else if(choice == 5) fail = quaddobl_laursys_solver(); else printf("invalid choice\n"); adafinal(); return 0; }
int main(void) { int choice; printf("\nMENU for testing the systems containers :\n"); printf(" 0. show a random polynomial system;\n"); printf(" 1. test with standard double coefficients;\n"); printf(" 2. test with double double coefficients;\n"); printf(" 3. test with quad double coefficients;\n"); printf(" 4. test with multiprecision coefficients.\n"); printf("Type 1, 2, 3, or 4 to select the precision : "); scanf("%d",&choice); adainit(); if(choice == 0) show_random_system(); else if(choice == 1) test_standard_container(); else if(choice == 2) test_dobldobl_container(); else if(choice == 3) test_quaddobl_container(); else if(choice == 4) test_multprec_container(); else printf("invalid choice, please try again...\n"); adafinal(); return 0; }
void read_data_system ( int n, int m, int monsum, int moncnt[m] ) { int dimsup = n*monsum; int dimcff = 2*monsum; int sup[dimsup]; double cff[dimcff]; int i,j,k,indsup,indcff; indsup = 0; indcff = 0; for(i=0; i<m; i++) { printf("Reading the support and coefficients"); printf(" of polynomial %d ...\n", i+1); for(j=0; j<moncnt[i]; j++) { printf(" give exponents of monomial %d : ", j+1); for(k=0; k<n; k++) scanf("%d", &sup[indsup++]); printf(" give two doubles : "); scanf("%lf", &cff[indcff++]); scanf("%lf", &cff[indcff++]); } } adainit(); _ada_phc_solver(n,m,moncnt,dimsup,sup,dimcff,cff); adafinal(); }
int main ( int argc, char *argv[] ) { char ans; int precision,fail; int seed = time(NULL); adainit(); srand(seed); /* monodromy loops are probabilistic ! */ printf("Seed for the random number generators : %d.\n",seed); printf("\nMENU for the working precision :\n"); printf(" 0. standard double precision;\n"); printf(" 1. double double precision;\n"); printf(" 2. quad double precision.\n"); printf("Type 0, 1, or 2 to make a choice : "); scanf("%d",&precision); scanf("%c",&ans); /* skip end of line character */ if(precision == 0) fail = standard_test(); else if(precision == 1) fail = dobldobl_test(); else if(precision == 2) fail = quaddobl_test(); else printf("Selected precision level is not supported.\n"); adafinal(); return 0; }
int main ( int argc, char *argv[] ) { int myid,numprocs,n,nbsols,mysolnum; MPI_Status status; adainit(); MPI_Init(&argc,&argv); MPI_Comm_size(MPI_COMM_WORLD,&numprocs); MPI_Comm_rank(MPI_COMM_WORLD,&myid); dimension_broadcast(myid,&n); monomials_broadcast(myid,n); copy_broadcast(myid); start_system_broadcast(myid,n,&nbsols); MPI_Bcast(&nbsols,1,MPI_INT,0,MPI_COMM_WORLD); solutions_distribute(myid,nbsols,n,numprocs,&mysolnum); // if(myid == 1) print_homotopy(); MPI_Finalize(); adafinal(); return 0; }
int main(void) { int choice; printf("\nMENU for testing univariate root finding :\n"); printf(" 0. in standard double precision;\n"); printf(" 1. in double double precision;\n"); printf(" 2. in quad double precision.\n"); printf(" 3. in arbitrary multiprecision.\n"); printf("Type 0, 1, 2, or 3 to select the precision : "); scanf("%d",&choice); adainit(); if(choice == 0) standard_test(); else if(choice == 1) dobldobl_test(); else if(choice == 2) quaddobl_test(); else if(choice == 3) multprec_test(); else printf("invalid choice, please try again...\n"); adafinal(); return 0; }
int main(void) { int option; char ch; printf("\nMENU to test operations in solutions container :\n"); printf(" 1. test main operations in the container;\n"); printf(" 2. incremental read/write of solutions from/to file;\n"); printf(" 3. test container for double double solutions;\n"); printf(" 4. test container for quad double solutions.\n"); printf("Type 1, 2, 3, or 4 to make your choice : "); scanf("%d",&option); scanf("%c",&ch); /* skip new line character */ printf("\n"); adainit(); if(option == 1) test_standard_solution_container(); else if(option == 2) test_incremental_read_and_write(); else if(option == 3) test_dobldobl_solution_container(); else if(option == 4) test_quaddobl_solution_container(); else printf("%d is wrong choice. Please try again...\n"); adafinal(); return 0; }
int main ( void ) { int r; printf("\nTesting linear-product root counts and systems...\n"); adainit(); printf("MENU for computing Bezout bounds :\n"); printf(" 1. test m-homogeneous Bezout numbers;\n"); printf(" 2. test general linear-product root counts.\n"); printf("Type 1 or 2 to make your choice : "); scanf("%d",&r); if(r == 1) { compute_m_homogeneous_Bezout_number(&r); } else if(r == 2) { compute_root_count(&r); construct_start_system(r); clear_set_structure(); } else printf("Wrong choice, please try again...\n"); adafinal(); return 0; }
int main ( int argc, char *argv[] ) { int choice,fail,prec; adainit(); greetings(); prec = prompt_for_precision(); printf("\nWelcome to the blackbox solver in PHCpack :\n"); printf(" 1. the input polynomial system will be typed in; or\n"); printf(" 2. the system typed in is a Laurent polynomial system; or\n"); printf(" 3. an input file contains the input polynomial system; or\n"); printf(" 4. the input Laurent system is on an input file.\n"); printf("Type 1, 2, 3, or 4 to make your choice : "); scanf("%d",&choice); if(choice == 1) fail = interactive_input_output(prec); else if (choice == 2) fail = interactive_Laurent_input_output(prec); else if (choice == 3) fail = input_output_on_files(prec); else fail = Laurent_input_output_on_files(prec); adafinal(); return 0; }
int main ( int argc, char *argv[] ) { char ans; int precision,fail; adainit(); printf("\nMENU for the working precision :\n"); printf(" 0. standard double precision;\n"); printf(" 1. double double precision;\n"); printf(" 2. quad double precision.\n"); printf("Type 0, 1, or 2 to make a choice : "); scanf("%d",&precision); scanf("%c",&ans); /* skip end of line character */ if(precision == 0) fail = standard_membership_test(); else if(precision == 1) fail = dobldobl_membership_test(); else if(precision == 2) fail = quaddobl_membership_test(); else printf("Selected precision level is not supported.\n"); adafinal(); return 0; }
int main ( int argc, char *argv[] ) { const int verbose = 0; // set to 1 for more info int myid,numprocs,precision,fail,ns; char* filename; adainit(); MPI_Init(&argc,&argv); MPI_Comm_size(MPI_COMM_WORLD,&numprocs); MPI_Comm_rank(MPI_COMM_WORLD,&myid); if(verbose > 0) { printf("\nHello from process %d!\n", myid); MPI_Barrier(MPI_COMM_WORLD); } if(myid == 0) precision = prompt_for_precision(); MPI_Bcast(&precision,1,MPI_INT,0,MPI_COMM_WORLD); if(verbose > 0) printf("\nProcess %d has %d as precision.\n", myid, precision); MPI_Barrier(MPI_COMM_WORLD); filename = (char*)calloc(80,sizeof(char)); if(myid == 0) { char nl; printf("\nReading the name of the output file ..."); printf("\nGive a string of characters : "); scanf("%s",filename); scanf("%c",&nl); /* skip newline symbol for next reading ...*/ if(verbose > 0) printf("\nThe output file is \"%s\".\n", filename); ns = strlen(filename); fail = define_output_file_with_string(ns,filename); } MPI_Bcast(&ns,1,MPI_INT,0,MPI_COMM_WORLD); MPI_Bcast(filename,ns,MPI_CHAR,0,MPI_COMM_WORLD); if(verbose > 0) printf("\nNode %d has filename \"%s\".\n", myid, filename); MPI_Barrier(MPI_COMM_WORLD); switch(precision) { case 0: fail = standard_run(myid,numprocs,ns,filename,verbose); break; case 1: fail = dobldobl_run(myid,numprocs,ns,filename,verbose); break; case 2: fail = quaddobl_run(myid,numprocs,ns,filename,verbose); break; default: printf("Invalid choice of precision.\n"); } MPI_Finalize(); adafinal(); return 0; }
int main ( int argc, char *argv[] ) { adainit(); // input_argument_free(); named_input_files(); adafinal(); return 0; }
void main(void) { adainit(); int i = 0; while (NULL != someStrings[i]) { printf("%s ", someStrings[i]); i++; } adafinal(); };
int main ( void ) { printf("\nComputing the powers of t in a polyhedral homotopy...\n"); adainit(); compute_mixed_volume(); read_and_retrieve(); adafinal(); return 0; }
int main ( int argc, char *argv[] ) { int choice; char ch; adainit(); printf("\nMENU to run Newton's method : \n"); printf(" 0. test plain validation on a start system;\n"); printf(" 1. run Newton step with standard double arithmetic;\n"); printf(" 2. run Newton step with double double arithmetic;\n"); printf(" 3. run Newton step with quad double arithmetic;\n"); printf(" 4. run Newton step with multiprecision arithmetic;\n"); printf(" 5. standard double precision deflation with defaults;\n"); printf(" 6. standard double Newton step on Laurent system;\n"); printf(" 7. double double Newton step on Laurent system;\n"); printf(" 8. quad double Newton step on Laurent system;\n"); printf(" 9. multiprecision Newton step on Laurent system.\n"); printf("Type 0, 1, 2, 3, 4, 5, 6, 7, 8, or 9 to select : "); scanf("%d",&choice); scanf("%c",&ch); /* skip newline symbol */ if(choice == 0) test_validate(); else if(choice == 1) test_standard_Newton_step(); else if(choice == 2) test_dobldobl_Newton_step(); else if(choice == 3) test_quaddobl_Newton_step(); else if(choice == 4) test_multprec_Newton_step(); else if(choice == 5) test_deflate(); else if(choice == 6) test_standard_Newton_Laurent_step(); else if(choice == 7) test_dobldobl_Newton_Laurent_step(); else if(choice == 8) test_quaddobl_Newton_Laurent_step(); else if(choice == 9) test_multprec_Newton_Laurent_step(); else printf("invalid selection, please try again\n"); adafinal(); return 0; }
int main ( void ) { char ans; printf("\nTesting the Operations in the Cells Container...\n\n"); adainit(); printf("Choose one of the following testing options :\n"); printf(" 0. read a polynomial system and compute its mixed volume;\n"); printf(" 1. read a mixed-cell configuration, test retrievals;\n"); printf(" 2. create a mixed-cell configuration interactively;\n"); printf(" 3. read a mixed-cell configuration and create start system;\n"); printf(" 4. polyhedral homotopies solve a random coefficient system;\n"); printf(" 5. test operations on integer cells container.\n"); printf("Type 1, 2, 3, 4, or 5 to make your choice : "); ans = getchar(); if(ans == '0') compute_mixed_volume(); else if(ans == '1') { scanf("%c",&ans); /* skip end of line symbol */ read_and_retrieve(); } else if(ans == '2') read_and_construct(); else if(ans == '3') { scanf("%c",&ans); read_cells_and_create_start_system(); } else if(ans == '4') { scanf("%c",&ans); read_cells_and_solve_start_system(); } else if(ans == '5') { scanf("%c",&ans); test_intcelcon(); } else printf("\nOption %c unknown. Please come again.\n\n", ans); adafinal(); return 0; }
int main() { int m,p,q; int root_number; printf("Give the dimension of the input planes : "); scanf("%d",&m); printf("Give the dimension of the output planes : "); scanf("%d",&p); printf("Give the degree of the maps : "); scanf("%d",&q); adainit(); root_number = _ada_pieri_count(m,p,q); adafinal(); printf("The number of the roots : %d\n", root_number); return 0; }
int main ( int argc, char *argv[] ) { int fail,i; double v[34],x; adainit(); printf("\nTuning the Continuation parameters in PHCpack...\n"); /* fail = tune_continuation_parameters(); */ printf("\n"); do { fail = retrieve_continuation_parameters(v); write_continuation_parameters(v); printf("Give index of parameter to change (0 to quit) : "); scanf("%d",&i); if (i > 0) { printf("Give value for parameter %d : ",i); scanf("%lf",&x); v[i-1] = x; set_continuation_parameters(v); { char ans = 'y'; do { fail = get_value_of_continuation_parameter(i,&x); printf("-> the value for parameter %d : %.3e.\n",i,x); printf("-> change value of index ? (y/n) "); scanf("%d",&ans); /* skip previous newline symbol */ scanf("%c",&ans); if(ans != 'y') break; scanf("%c",&ans); /* skip the new line */ printf("-> give value for index %d : ",i); scanf("%lf",&x); fail = set_value_of_continuation_parameter(i,&x); } while (ans != 0); } } } while ( i > 0); adafinal(); return 0; }
int main() { int m,p,q,nb,level,n,dimpts,dimpla,i,nbsols; double *points,*planes; char filename[80]; printf("\nTesting the call to Pieri homotopies...\n\n"); printf("Give the name of the output file : "); scanf("%s", filename); printf("The output file name is %s.\n", filename); printf("Give the dimension of the input planes : "); scanf("%d",&m); printf("Give the dimension of the output planes : "); scanf("%d",&p); printf("Give the degree of the maps : "); scanf("%d",&q); printf("Give the number of maps wanted (<0 for all) : "); scanf("%d",&nb); printf("Give the amount of intermediate output : \n"); printf(" 0. no intermediate output;\n"); printf(" 1. only final determinant validation;\n"); printf(" 2. + validation of all intermediate determinants;\n"); printf(" 3. + intermediate output of all path trackers.\n"); printf("Type 0, 1, 2, or 3 to select output level : "); scanf("%d", &level); n = m*p + q*(m+p); dimpts = 2*n; points = (double*) calloc(dimpts,sizeof(double)); for(i=0; i<dimpts; i++) points[i] = cos(rand()); dimpla = 2*n*m*p; planes = (double*) calloc(dimpla,sizeof(double)); for(i=0; i<dimpla; i++) planes[i] = cos(rand()); adainit(); nbsols = _ada_pieri_solver(m,p,q,nb,level,points,planes,filename); adafinal(); printf("The number of solutions : %d\n", nbsols); return 0; }
int main(void) { printf("\nTesting Reading of Polynomial Systems\n"); adainit(); { int i; double *p; double *s = (double*) calloc(buffer_size,sizeof(double)); s = _ada_phc_sys_rw(0,buffer_size,s); fflush(stdout); printf("\nHere is the system :\n"); p = _ada_phc_sys_rw(1,buffer_size,s); } adafinal(); return 0; }
int main(void) { printf("\nTesting Reading of Solution Lists\n"); adainit(); { int i; double *p; double *s = (double*) calloc(buffer_size,sizeof(double)); s = _ada_phc_sol_rw(0,buffer_size,s); fflush(stdout); printf("\nHere is the solution list :\n"); p = _ada_phc_sol_rw(1,buffer_size,s); } adafinal(); return 0; }
int main ( int argc, char *argv[] ) { double *c; int fail,choice,i; char skip_newline,ch; printf("\nTesting if phc can C strings...\n"); adainit(); { int n,*s; do { printf("Give the number of elements : "); scanf("%d",&n); s = (int*)calloc(n,sizeof(int)); skip_newline = getchar(); printf("Give %d characters : ",n); for(i=0; i<n; i++) { scanf("%c",&ch); s[i] = (int) ch; } printf("The array of integers : "); for(i=0; i<n; i++) printf(" %d",s[i]); printf("\n"); printf("The array of characters : "); for(i=0; i<n; i++) { ch = (char) s[i]; printf(" %c",ch); } printf("\n"); fail = _ada_use_c2phc(158,&n,s,c); printf("use_c2phc returned %d as fail value\n",fail); printf("Give a number (1 to continue, 0 to exit) : "); scanf("%d",&choice); skip_newline = getchar(); free(s); } while (choice > 0); } adafinal(); return 0; }
int main ( int argc, char *argv[] ) { int fail,nbsol; adainit(); int level = prompt_for_precision(); if(level == 0) { fail = call_initialize_standard_homotopy(&nbsol); fail = call_standard_path_tracker(nbsol); fail = clear_standard_tracker(); } else if(level == 1) { fail = call_initialize_dobldobl_homotopy(&nbsol); fail = call_dobldobl_path_tracker(nbsol); fail = clear_dobldobl_tracker(); } else if(level == 2) { fail = call_initialize_quaddobl_homotopy(&nbsol); fail = call_quaddobl_path_tracker(nbsol); fail = clear_quaddobl_tracker(); } else if(level == 3) { fail = call_initialize_multprec_homotopy(&nbsol); fail = call_multprec_path_tracker(nbsol); fail = clear_multprec_tracker(); } else { fail = call_initialize_varbprec_homotopy(&nbsol); fail = call_varbprec_path_tracker(); fail = clear_varbprec_tracker(); } adafinal(); return 0; }
int main(void) { printf("\nTesting C to PHCpack...\n"); adainit(); { int fail,choice = 0; char skip_newline; do { fail = _ada_c_to_phcpack(choice); printf("Give a number (0 for menu, -1 to exit) : "); scanf("%d",&choice); skip_newline = getchar(); } while (choice >= 0); } adafinal(); return 0; }
int main ( int argc, char *argv[] ) { int np,myid,dim,nspt,nbpaths,*mysol; double startwtime,endwtime,wtime,*time; MPI_Status status; adainit(); MPI_Init(&argc,&argv); MPI_Comm_size(MPI_COMM_WORLD,&np); MPI_Comm_rank(MPI_COMM_WORLD,&myid); if(myid == 0) { time = (double*)calloc(np,sizeof(double)); mysol = (int*)calloc(np,sizeof(int)); startwtime = MPI_Wtime(); } else startwtime = MPI_Wtime(); retrieve_dimensions(myid,&nspt,&dim); supports_broadcast(myid,nspt,dim); system_broadcast(myid,dim-1); distribute_cells(myid,np,nspt,dim,&nbpaths); endwtime = MPI_Wtime(); wtime = endwtime-startwtime; MPI_Gather(&wtime,1,MPI_DOUBLE,time,1,MPI_DOUBLE,0,MPI_COMM_WORLD); MPI_Gather(&nbpaths,1,MPI_INT,mysol,1,MPI_INT,0,MPI_COMM_WORLD); if(myid == 0) { printf("\nTotal wall time = %lf seconds on %d processors\n", time[0],np); write_time_and_paths_to_defined_output_file(np,time,mysol); free(time); free(mysol); } MPI_Finalize(); adafinal(); return 0; }
int main(void) { printf("\nTesting Solutions Pool...\n"); adainit(); { int n,s,fail,*b; double *c; printf("\nGive the size of the pool : "); scanf("%d",&n); fail = _ada_use_solpool(0,&n,b,c); /* initialize pool size*/ fail = _ada_use_solpool(1,&s,b,c); /* get the pool size */ printf("The size of the pool after initialization : %d\n",s); } adafinal(); return 0; }
int main ( int argc, char *argv[] ) { int myid,numprocs,n,dim,deg,nbloops,fail; double startwtime,trackwtime,wtime,*mytime; MPI_Status status; adainit(); MPI_Init(&argc,&argv); MPI_Comm_size(MPI_COMM_WORLD,&numprocs); MPI_Comm_rank(MPI_COMM_WORLD,&myid); srand(time(NULL)); /* for different random gamma constant */ if(myid == 0) { mytime = (double*) calloc(numprocs, sizeof(double)); startwtime = MPI_Wtime(); fail = read_witness_set(&n,&dim,°); fail = define_output_file(); printf("Give the number of loops : "); scanf("%d",&nbloops); } else trackwtime = MPI_Wtime(); MPI_Barrier(MPI_COMM_WORLD); /* wait for node 0 */ dimension_broadcast(myid,&n); MPI_Bcast(&nbloops,1,MPI_INT,0,MPI_COMM_WORLD); fail = monodromy_breakup(myid,n,dim,deg,nbloops,numprocs,&trackwtime); MPI_Barrier(MPI_COMM_WORLD); if(myid == 0) wtime = MPI_Wtime() - startwtime; else wtime = trackwtime; MPI_Gather(&wtime,1,MPI_DOUBLE,mytime,1,MPI_DOUBLE,0,MPI_COMM_WORLD); if(myid == 0) print_time(mytime,numprocs); MPI_Finalize(); adafinal(); return 0; }
void feedback(int n, int m, int p, int q, int nb, int output_level, int nn, int input, char *ifn, char *ofn) { dcmplx A[n][n], B[n][m], C[p][n]; dcmplx s[nn], Is[n][n], Is_A[n][n], tmp[p][n], M[p][m]; double a[nn*2], b[nn*p*m*2], *points, *planes, r; int i, j, k, start, nbsols; FILE *ifp, *ofp; timer t_phc; ofp=fopen(ofn, "w"); /*open for writing*/ fprintf(ofp, "n=%d\n", n); fprintf(ofp, "m=%d\n", m); fprintf(ofp, "p=%d\n", p); fprintf(ofp, "q=%d\n", q); if(input == 0) { ifp=fopen(ifn, "r"); /*open for reading*/ skip(ifp); read_dcmatrix0(n, n, A, ifp); printf( "The given matrix A(%d*%d) is:\n", n, n); print_dcmatrix(n, n, A); read_dcmatrix0(n, m, B, ifp); printf("The given matrix B(%d*%d) is:\n", n, m); print_dcmatrix(n, m, B); read_dcmatrix0(p, n, C, ifp); printf("The given matrix C(%d*%d) is:\n", p, n); print_dcmatrix(p, n, C); for(i=0; i<n+q; i++) read_dcmplx0(&s[i], ifp); for(i=n+q; i<nn; i++) /*generate more poles as interpolation points */ { s[i] = create1(cos(rand())); if(s[i].re>0) s[i] = min_dcmplx(s[i]); } fclose(ifp); } if(input == 1) { ifp=fopen(ifn, "r"); /*open for reading*/ skip(ifp); read_dcmatrix2(n, n, A, ifp); printf( "The given matrix A(%d*%d) is:\n", n, n); print_dcmatrix(n, n, A); read_dcmatrix2(n, m, B, ifp); printf("The given matrix B(%d*%d) is:\n", n, m); print_dcmatrix(n, m, B); read_dcmatrix2(p, n, C, ifp); printf("The given matrix C(%d*%d) is:\n", p, n); print_dcmatrix(p, n, C); for(i=0; i<n+q; i++) read_dcmplx1(&s[i], ifp); for(i=n+q; i<nn; i++) /*generate more poles as interpolation points */ { s[i] = create1(cos(rand())); if(s[i].re>0) s[i] = min_dcmplx(s[i]); } fclose(ifp); } if(input==2) { random_dcmatrix ( n, n, A); printf("\nThe random generated matrix A is:\n"); print_dcmatrix(n, n, A); random_dcmatrix ( n, m, B); printf("\nThe random generated matrix B is:\n"); print_dcmatrix(n, m, B); random_dcmatrix ( p, n, C); printf("\nThe random generated matrix C is:\n"); print_dcmatrix(p, n, C); s[0] = create2(-0.23423423423, 0); /* fix one pole for testing realization */ for(i=1; i<nn; i++) { r = rand(); s[i] = create2(cos(r), sin(r)); if(s[i].re>0) s[i] = min_dcmplx(s[i]); s[++i] = conjugate(s[i]); if(i==(nn-2)) { if((nn%2)==0) s[++i] = create1(-1.0); } } printf("\nThe random generated poles are:\n"); for(i=0; i<nn; i++) writeln_dcmplx(s[i]); } if(input==3) { random_dcmatrix0 ( n, n, A); printf("\nThe random generated matrix A is:\n"); print_dcmatrix(n, n, A); random_dcmatrix0 ( n, m, B); printf("\nThe random generated matrix B is:\n"); print_dcmatrix(n, m, B); random_dcmatrix0 ( p, n, C); printf("\nThe random generated matrix C is:\n"); print_dcmatrix(p, n, C); s[0] = create2(-0.23423423423, 0); /* fix one pole for test */ for(i=1; i<nn; i++) { r = rand(); s[i] = create2(cos(r), sin(r)); if(s[i].re>0) s[i] = min_dcmplx(s[i]); s[++i] = conjugate(s[i]); if(i==(nn-2)) { if((nn%2)==0) s[++i] = create1(-1.0); } } printf("\nThe random generated poles are:\n"); for(i=0; i<nn; i++) writeln_dcmplx(s[i]); } if(input == 4) { ifp=fopen(ifn, "r"); /*open for reading*/ skip(ifp); read_dcmatrix0(n, n, A, ifp); printf( "The given matrix A(%d*%d) is:\n", n, n); print_dcmatrix(n, n, A); read_dcmatrix0(n, m, B, ifp); printf("The given matrix B(%d*%d) is:\n", n, m); print_dcmatrix(n, m, B); read_dcmatrix0(p, n, C, ifp); printf("The given matrix C(%d*%d) is:\n", p, n); print_dcmatrix(p, n, C); for(i=0; i<n+q; i++) read_dcmplx1(&s[i], ifp); for(i=n+q; i<nn; i++) /*generate more poles as interpolation points */ { s[i] = create1(cos(rand())); if(s[i].re>0) s[i] = min_dcmplx(s[i]); } fclose(ifp); } /* print the input matrices in matlab format for further study */ fprintf(ofp,"A=[\n"); print_dcmatrix1(n, n, A, ofp); fprintf(ofp,"]\n"); fprintf(ofp,"B=[\n"); print_dcmatrix1(n, m, B, ofp); fprintf(ofp,"]\n"); fprintf(ofp,"C=[\n"); print_dcmatrix1(p, n, C, ofp); fprintf(ofp,"]\n"); fprintf(ofp, "\nPoles=["); for(i=0; i<nn; i++) { write_dcmplx1(s[i], ofp); if(i!=(nn-1)) fprintf(ofp, ","); } fprintf(ofp, "]\n"); /* end of input */ j = 0; for(i=0; i<nn; i++) { a[j++] = s[i].re; a[j++] = s[i].im; } start = 0; for(k=0; k<n+q; k++) { for(i=0; i<n; i++) for(j=0; j<n; j++) { if(i==j) Is[i][j] = s[k]; else Is[i][j] = zero; } sub_dcmatrix(n, n, Is, A, Is_A); dcinverse(n, Is_A); multiply_dcmatrix(p, n, n, C, Is_A, tmp); multiply_dcmatrix(p, n, m, tmp, B, M); c2ada_dc_matrix( p, m, M, nn*p*m*2, b, start); start = start + p*m*2; } /* generate some random planes */ for( i=start ; i<nn*p*m*2; i++ ) { b[i++] = cos(rand()); b[i] = 0.0; } fflush(stdout); fflush(ofp); printf("\nComputing the feedback law with PHC ...\n"); tstart(&t_phc); adainit(); nbsols = _ada_pieri_solver(m, p, q, nb, output_level, a, b, ofn); adafinal(); tstop(&t_phc); /* This subroutine spends almost all the time */ tprint(t_phc); printf("\nSee %s for the realization of the output feedbacks.\n", ofn); fclose(ofp); }
int main ( int argc, char *argv[] ) { int myid, stages, numbprocs, *TaskCount, total=0, remainder[2][2], remainder_pos=-1, remainderjob=0, cnt_index=0, NUM_GROUP, NUM_VARS, num_group=0, cnt_stage=1, i, slv, count, r, c; double startwtime,slavewtime,wtime,*mytime, stagewtime; char filename[50], ans; WSET *ws; MPI_Init(&argc,&argv); MPI_Comm_size(MPI_COMM_WORLD,&numbprocs); MPI_Comm_rank(MPI_COMM_WORLD,&myid); adainit(); if(myid == 0) { printf("Give a file name (less than 50 characters) : "); scanf("%s",filename); scanf("%c",&ans); /* skip current new line symbol */ printf("\n# of eqn. group :"); scanf("%d",&NUM_GROUP); scanf("%c",&ans); printf("\n# of vars :"); scanf("%d",&NUM_VARS); scanf("%c",&ans); } /* broadcast data */ MPI_Barrier(MPI_COMM_WORLD); if(myid == 0) printf("\nManager broadcast data. \n"); MPI_Bcast(filename,50*sizeof(char),MPI_CHAR,0,MPI_COMM_WORLD); MPI_Bcast(&NUM_GROUP,sizeof(int),MPI_INT,0,MPI_COMM_WORLD); MPI_Bcast(&NUM_VARS,sizeof(int),MPI_INT,0,MPI_COMM_WORLD); MPI_Barrier(MPI_COMM_WORLD); num_group = NUM_GROUP; stages = (int)ceil(log(NUM_GROUP)/log(2)); if(myid == 0) { /* TaskCount = (int*) calloc(numbprocs-1, sizeof(int));*/ TaskCount = (int*) malloc(sizeof(int)*(numbprocs-1)); ws = (WSET*) calloc(NUM_GROUP*(stages+1), sizeof(WSET)); /* mytime = (double*) calloc(numbprocs, sizeof(double)); */ mytime = (double*) malloc(sizeof(double)*numbprocs); /* initialize TaskCount & remainder array */ cnt_index=0; for(slv=1;slv<=numbprocs-1;slv++) { *(TaskCount+slv-1)=0; } remainder_pos = -1; for(i=1;i<=2;i++) { remainder[i-1][0] = 0; remainder[i-1][1] = 0; } } /* initialization */ if(myid == 0) { startwtime = MPI_Wtime(); manager_initialize(ws, NUM_GROUP, stages, numbprocs, filename); } else { slavewtime = MPI_Wtime(); slave_initialize(myid, NUM_GROUP, filename); } /* Initialization phase and mainloop initialization are DONE */ if(myid == 0) { if((int)fmod(num_group,2)==1) /* there is a remainder */ { remainder_pos++; remainder[remainder_pos][0] = num_group-1; remainder[remainder_pos][1] = 0; printf("record remainder. ws[%d][%d]\n", remainder[remainder_pos][0], remainder[remainder_pos][1]); } } num_group = (int)floor(num_group/2); /* stages */ for(cnt_stage=1;cnt_stage<=stages;cnt_stage++) { if(myid == 0) { printf("*********** stage %d **************** \n", cnt_stage); stagewtime = MPI_Wtime(); } compute_witness_sets(myid,stages,cnt_stage,numbprocs,NUM_GROUP,NUM_VARS, num_group,ws,TaskCount,&cnt_index,filename, &remainder_pos,remainder); MPI_Barrier(MPI_COMM_WORLD); /* once all groups are finished, clear cnt_index */ if(myid == 0) { printf("outside of compute_witness_sets\n"); printf("remainder_pos=%d\n", remainder_pos); cnt_index = 0; if((int)fmod(num_group,2)==1 && cnt_stage!=stages) /* there is a remainder */ { remainder_pos++; remainder[remainder_pos][0] = num_group-1; remainder[remainder_pos][1] = cnt_stage; printf("record remainder: ws[%d][%d]\n", remainder[remainder_pos][0], remainder[remainder_pos][1]); printf("remainder_pos=%d\n", remainder_pos); } } num_group = (int)floor(num_group/2); if(num_group==0 && cnt_stage!=stages) num_group=1; /* print out remainders info. */ if(v>0) { if(myid == 0) { if(remainder_pos==1) /* two remainders exist */ {printf("remainders:\n"); printf("ws[%d][%d] and ws[%d][%d]\n", remainder[0][0],remainder[0][1], remainder[1][0],remainder[1][1]); } if(remainder_pos==0 && cnt_stage!=stages) { printf("remainder:\n"); printf("ws[%d][%d] \n", remainder[0][0],remainder[0][1]); } } } if(myid == 0) { printf("stage %d: %lf seconds\n", cnt_stage, MPI_Wtime()-stagewtime); } }/* cnt_stage, stages */ if(myid == 0) wtime = MPI_Wtime()-startwtime; else wtime = MPI_Wtime()-slavewtime; MPI_Gather(&wtime,1,MPI_DOUBLE,mytime,1,MPI_DOUBLE,0,MPI_COMM_WORLD); if(myid == 0) { print_time(mytime,numbprocs); printf("\nTask tallies:\n"); for(slv=1;slv<=numbprocs-1;slv++) { total = total + *(TaskCount+slv-1); printf("Node %d ----- %d jobs \n",slv, *(TaskCount+slv-1)); } printf("----------------------\n"); printf(" %d jobs! \n", total); /* clean up */ free(TaskCount); free(mytime); for(r=0;r<NUM_GROUP;r++) for(c=0;c<=stages;c++) kill_ws(ws+r*(stages+1)+c); } adafinal(); MPI_Finalize(); return 0; }
void main(void) { adainit(); printf("%s\n", &adaString); adafinal(); };