/* $Id$
$State$
$Log$
+ Revision 1.183 2015/03/10 20:34:32 brouard
+ Summary: 0.98q0, trying with directest, mnbrak fixed
+
+ We use directest instead of original Powell test; probably no
+ incidence on the results, but better justifications;
+ We fixed Numerical Recipes mnbrak routine which was wrong and gave
+ wrong results.
+
Revision 1.182 2015/02/12 08:19:57 brouard
Summary: Trying to keep directest which seems simpler and more general
Author: Nicolas Brouard
#define POWELL /* Instead of NLOPT */
/* #define POWELLORIGINAL */ /* Don't use Directest to decide new direction but original Powell test */
+/* #define MNBRAKORIGINAL */ /* Don't use mnbrak fix */
#include <math.h>
#include <stdio.h>
printf("Warning you should use %s as a separator\n",DIRSEPARATOR);*/
/* get current working directory */
/* extern char* getcwd ( char *buf , int len);*/
- if ( getcwd( dirc, FILENAME_MAX ) == NULL ) {
+#ifdef WIN32
+ if (_getcwd( dirc, FILENAME_MAX ) == NULL ) {
+#else
+ if (getcwd(dirc, FILENAME_MAX) == NULL) {
+#endif
return( GLOCK_ERROR_GETCWD );
}
/* got dirc from getcwd*/
(*cx=10.098840694817, *fc=298946.631474258087), (*u=9.852501168332, fu=298948.773013752128, fparabu=298945.434711494134) */
/* In that case, there is no bracket in the output! Routine is wrong with many consequences.*/
#endif
-#ifdef MNBRAKORI
+#ifdef MNBRAKORIGINAL
#else
if (fu > *fc) {
#ifdef DEBUG
if (t < 0.0) { /* Then we use it for new direction */
#else
if (directest*t < 0.0) { /* Contradiction between both tests */
- printf("directest= %.12lf, t= %.12lf, f1= %.12lf,f2= %.12lf,f3= %.12lf, del= %.12lf\n",directest, t, fp,(*fret),fptt);
+ printf("directest= %.12lf, t= %.12lf, f1= %.12lf,f2= %.12lf,f3= %.12lf, del= %.12lf\n",directest, t, fp,(*fret),fptt,del);
printf("f1-2f2+f3= %.12lf, f1-f2-del= %.12lf, f1-f3= %.12lf\n",fp-2.0*(*fret)+fptt, fp -(*fret) -del, fp-fptt);
- fprintf(ficlog,"directest= %.12lf, t= %.12lf, f1= %.12lf,f2= %.12lf,f3= %.12lf, del= %.12lf\n",directest, t, fp,(*fret),fptt);
+ fprintf(ficlog,"directest= %.12lf, t= %.12lf, f1= %.12lf,f2= %.12lf,f3= %.12lf, del= %.12lf\n",directest, t, fp,(*fret),fptt, del);
fprintf(ficlog,"f1-2f2+f3= %.12lf, f1-f2-del= %.12lf, f1-f3= %.12lf\n",fp-2.0*(*fret)+fptt, fp -(*fret) -del, fp-fptt);
}
if (directest < 0.0) { /* Then we use it for new direction */
void syscompilerinfo()
{
/* #include "syscompilerinfo.h"*/
-
+ /* command line Intel compiler 64bit windows:
+ /GS /W3 /Gy /Zc:wchar_t /Zi /O2 /Fd"x64\Release\vc120.pdb" /D "WIN32"
+ /D "NDEBUG" /D "_CONSOLE" /D "_LIB" /D "_UNICODE" /D "UNICODE" /Qipo
+ /Zc:forScope /Oi /MD /Fa"x64\Release\" /EHsc /nologo
+ /Fo"x64\Release\" /Qprof-dir "x64\Release\" /Fp"x64\Release\IMaCh.pch" */
+ /*
+ /GS /W3 /Gy /Zc:wchar_t /Zi /O3 /Fd"x64\Release\vc120.pdb" /D "WIN32"
+ /D "NDEBUG" /D "_CONSOLE" /D "_LIB" /D "_UNICODE" /D "UNICODE" /Qipo
+ /Zc:forScope /Oi /MD /Fa"x64\Release\" /EHsc /nologo /Qparallel
+ /Fo"x64\Release\" /Qprof-dir "x64\Release\" /Fp"x64\Release\IMaCh.pch" */
#if defined __INTEL_COMPILER
#if defined(__GNUC__)
struct utsname sysInfo; /* For Intel on Linux and OS/X */
} /* Age */
/* was end of cptcod */
} /* cptcov */
+ return 0;
}
int hPijx(double *p, int bage, int fage){
}
/*}*/
}
+ return 0;
}
nberr=0; /* Number of errors and warnings */
nbwarn=0;
+#ifdef WIN32
+ _getcwd(pathcd, size);
+#else
getcwd(pathcd, size);
+#endif
printf("\n%s\n%s",version,fullversion);
if(argc <=1){
/* Split argv[1]=pathtot, parameter file name to get path, optionfile, extension and name */
split(pathtot,path,optionfile,optionfilext,optionfilefiname);
printf("\npathtot=%s,\npath=%s,\noptionfile=%s \noptionfilext=%s \noptionfilefiname=%s\n",pathtot,path,optionfile,optionfilext,optionfilefiname);
+#ifdef WIN32
+ _chdir(path); /* Can be a relative path */
+ if(_getcwd(pathcd,MAXLINE) > 0) /* So pathcd is the full path */
+#else
chdir(path); /* Can be a relative path */
- if(getcwd(pathcd,MAXLINE) > 0) /* So pathcd is the full path */
- printf("Current directory %s!\n",pathcd);
+ if (getcwd(pathcd, MAXLINE) > 0) /* So pathcd is the full path */
+#endif
+ printf("Current directory %s!\n",pathcd);
strcpy(command,"mkdir ");
strcat(command,optionfilefiname);
if((outcmd=system(command)) != 0){
strcpy(pathr,path);
strcat(pathr,optionfilefiname);
+#ifdef WIN32
+ _chdir(optionfilefiname); /* Move to directory named optionfile */
+#else
chdir(optionfilefiname); /* Move to directory named optionfile */
+#endif
+
/* Calculates basic frequencies. Computes observed prevalence at single age
and prints on file fileres'p'. */
printf("Before Current directory %s!\n",pathcd);
+#ifdef WIN32
+ if (_chdir(pathcd) != 0)
+ printf("Can't move to directory %s!\n",path);
+ if(_getcwd(pathcd,MAXLINE) > 0)
+#else
if(chdir(pathcd) != 0)
- printf("Can't move to directory %s!\n",path);
- if(getcwd(pathcd,MAXLINE) > 0)
+ printf("Can't move to directory %s!\n", path);
+ if (getcwd(pathcd, MAXLINE) > 0)
+#endif
printf("Current directory %s!\n",pathcd);
/*strcat(plotcmd,CHARSEPARATOR);*/
sprintf(plotcmd,"gnuplot");