chiark / gitweb /
Revert "simplex wip: compiles"
[moebius3.git] / findcurve.c
index 58f74720868a245ddbb811b7e176f1571a93c7c8..055018f3bfb6abf87e5dba0aabbcf8dcb59dc906 100644 (file)
@@ -26,24 +26,43 @@ static int NP;
 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) {
@@ -69,17 +88,6 @@ static double cb_metric(void *xp, void *yp) {
   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");