version 1.4, 2002/05/02 02:51:37 |
version 1.5, 2002/05/02 11:54:33 |
|
|
/* phc6.c , yama:1999/sm1-prog/phc6.c */ |
/* phc6.c , yama:1999/sm1-prog/phc6.c */ |
/* $OpenXM: OpenXM/src/phc/phc6.c,v 1.3 2000/10/31 12:22:05 takayama Exp $ */ |
/* $OpenXM: OpenXM/src/phc/phc6.c,v 1.4 2002/05/02 02:51:37 takayama Exp $ */ |
/* This is a simple C interface to the black-box solver of phc. |
/* This is a simple C interface to the black-box solver of phc. |
** Requirements: |
** Requirements: |
** 1) executable version of phc will be searched in the following order: |
** 1) executable version of phc will be searched in the following order: |
Line 251 struct phc_object phc_scan_solutions(FILE *fp, int npa |
|
Line 251 struct phc_object phc_scan_solutions(FILE *fp, int npa |
|
double *imagparts; |
double *imagparts; |
char buf[BUFSIZE]; |
char buf[BUFSIZE]; |
nsols = 0; |
nsols = 0; |
realparts = (double *)sGC_malloc(sizeof(double)*npaths*dim+1); |
realparts = (double *)sGC_malloc(sizeof(double)*(npaths*dim+1)); |
imagparts = (double *)sGC_malloc(sizeof(double)*npaths*dim+1); |
imagparts = (double *)sGC_malloc(sizeof(double)*(npaths*dim+1)); |
while ((ch = fgetc(fp)) != EOF) |
while ((ch = fgetc(fp)) != EOF) |
{ |
{ |
fnd = phc_scan_for_string(fp,"start residual :"); |
fnd = phc_scan_for_string(fp,"start residual :"); |
if (fnd==1) |
if (fnd==1) |
{ |
{ |
fscanf(fp,"%le",&res); |
fgets(buf,BUFSIZE-1,fp); |
/* printf(" residual = "); printf("%E\n",res); */ |
sscanf(buf,"%le",&res); |
|
if (phc_verbose) { |
|
fprintf(stderr,"res in string: %s\n",buf); |
|
fprintf(stderr," residual = "); fprintf(stderr,"%le\n",res); |
|
} |
if (res < 1.0E-12) { |
if (res < 1.0E-12) { |
nsols = nsols+1; |
nsols = nsols+1; |
if (nsols > npaths) { |
if (nsols > npaths) { |
Line 281 struct phc_object phc_scan_solutions(FILE *fp, int npa |
|
Line 285 struct phc_object phc_scan_solutions(FILE *fp, int npa |
|
{ |
{ |
/*realparts[nsols-1][i] = realpart; |
/*realparts[nsols-1][i] = realpart; |
imagparts[nsols-1][i] = imagpart;*/ |
imagparts[nsols-1][i] = imagpart;*/ |
realparts[(nsols-1)*npaths+i] = realpart; |
realparts[(nsols-1)*dim+i] = realpart; |
imagparts[(nsols-1)*npaths+i] = imagpart; |
imagparts[(nsols-1)*dim+i] = imagpart; |
} |
} |
} |
} |
} |
} |
Line 291 struct phc_object phc_scan_solutions(FILE *fp, int npa |
|
Line 295 struct phc_object phc_scan_solutions(FILE *fp, int npa |
|
rob = phc_newObjectArray(nsols); |
rob = phc_newObjectArray(nsols); |
for (i=0;i<nsols;i++) |
for (i=0;i<nsols;i++) |
{ |
{ |
/* fprintf(stderr,"Solution %i :\n",i+1); */ |
if (phc_verbose) fprintf(stderr,"Solution %i :\n",i+1); |
sob = phc_newObjectArray(dim); |
sob = phc_newObjectArray(dim); |
for (j=0;j<dim;j++) |
for (j=0;j<dim;j++) |
{ |
{ |
Line 299 struct phc_object phc_scan_solutions(FILE *fp, int npa |
|
Line 303 struct phc_object phc_scan_solutions(FILE *fp, int npa |
|
printf("%20.14le",realparts[i][j]); printf(" "); |
printf("%20.14le",realparts[i][j]); printf(" "); |
printf("%20.14le",imagparts[i][j]); printf("\n"); |
printf("%20.14le",imagparts[i][j]); printf("\n"); |
*/ |
*/ |
|
if (phc_verbose) { |
|
printf("%20.14le",realparts[i*dim+j]); printf(" "); |
|
printf("%20.14le",imagparts[i*dim+j]); printf("\n"); |
|
} |
|
|
printf("%20.14le",realparts[i*npaths+j]); printf(" "); |
|
printf("%20.14le",imagparts[i*npaths+j]); printf("\n"); |
|
|
|
/*phc_putoa(sob,j,phc_complexTo(realparts[i][j],imagparts[i][j]));*/ |
/*phc_putoa(sob,j,phc_complexTo(realparts[i][j],imagparts[i][j]));*/ |
phc_putoa(sob,j,phc_complexTo(realparts[i*npaths+j], |
phc_putoa(sob,j,phc_complexTo(realparts[i*dim+j], |
imagparts[i*npaths+j])); |
imagparts[i*dim+j])); |
} |
} |
phc_putoa(rob,i,sob); |
phc_putoa(rob,i,sob); |
} |
} |