static double *INPUT; /* dyanmic array, on main's stack */
static double PREP[NPREP];
+static void printcore(const double *X) {
+ int i, j;
+ DECLARE_F_G;
+ CALCULATE_F_G;
+ printf("[");
+ for (i=0; i<NP; i++)
+ for (j=0; j<3; j++)
+ printf(" %25.18g,", POINT(i)[j]);
+ printf(" ]\n");
+}
+
static void prepare(double X[] /* startpoint */) {
/* fills in PREP and startpoint */
PREPARE;
}
+//#define DEBUG
+
static double cb_Efunc(void *xp) {
const double *X = xp;
+ int P;
DECLARE_F_G;
CALCULATE_F_G;
- double e = 0;
- int P;
- for (P=0; P<NP-3; P++) {
- double P_cost;
- CALCULATE_COST;
- e += P_cost;
+#ifdef DEBUG
+ int i,j;
+ printf(" Efunc\n");
+ for (j=0; j<3; j++) {
+ for (P=0; P<NP; P++)
+ printf(" %7.4f", POINT(P)[j]);
+ printf("\n");
}
- return e;
+ printf(" ");
+#endif
+
+ CALCULATE_COST;
+ return cost;
}
static void cb_step(const gsl_rng *rng, void *xp, double step_size) {
return sqrt(s);
}
-static void printcore(const double *X) {
- int i, j;
- DECLARE_F_G;
- CALCULATE_F_G;
- printf("[");
- for (i=0; i<NP; i++)
- for (j=0; j<3; j++)
- printf(" %.18g,", POINT(i)[i]);
- printf(" ]\n");
-}
-
static void __attribute__((unused)) cb_print(void *xp) {
const double *x = xp;
printf("\n");
int i;
NP = atoi(argv[1]);
+ epsilon = atof(argv[2]);
gsl_rng *rng = gsl_rng_alloc(gsl_rng_ranlxd2);
/* NINPUT + 1 doubles: startpoint, epsilon for residual */
for (i=0; i<NINPUT; i++)
INPUT[i] = scan1double();
- epsilon = scan1double();
gsl_rng_set(rng,0);