[xiph-commits] r17939 - trunk/ghost/monty/chirp

xiphmont at svn.xiph.org xiphmont at svn.xiph.org
Thu Apr 28 02:10:56 PDT 2011


Author: xiphmont
Date: 2011-04-28 02:10:56 -0700 (Thu, 28 Apr 2011)
New Revision: 17939

Modified:
   trunk/ghost/monty/chirp/chirp.c
   trunk/ghost/monty/chirp/chirpgraph.c
   trunk/ghost/monty/chirp/chirptest.c
Log:
Ltest in svn


Modified: trunk/ghost/monty/chirp/chirp.c
===================================================================
--- trunk/ghost/monty/chirp/chirp.c	2011-04-28 01:36:20 UTC (rev 17938)
+++ trunk/ghost/monty/chirp/chirp.c	2011-04-28 09:10:56 UTC (rev 17939)
@@ -166,13 +166,6 @@
       float aC = cos(c->P);
       float aS = sin(c->P);
 
-      /* Not recentering dW allows potential simplification of the
-         nonlinear solver. This code is designed to recenter dW as
-         easily as not, so the following looks a bit silly.  The point
-         of the flag is to emulate/study the behavior of the simplified
-         algorithm */
-      float cdW = fit_recenter_dW ? c->dW : 0;
-
       for(j=0;j<len;j++){
 
         /* no part of the nonlinear algorithm requires double
@@ -195,16 +188,30 @@
         float c2,s2;
         float yy=r[j];
 
-        sincos((c->W + cdW*jj)*jj,&si,&co);
+        sincos((c->W + c->dW*jj)*jj,&si,&co);
 
         si*=window[j];
         co*=window[j];
-        c2 = co*co*jj;
-        s2 = si*si*jj;
 
         /* add the current estimate back to the residue vector */
         r[j] += (aC*co-aS*si) * (c->A + (c->dA + c->ddA*jj)*jj);
 
+        /* Not recentering dW allows potential simplification of the
+           nonlinear solver. This code is designed to recenter dW as
+           easily as not, so the following looks a bit silly.  The point
+           of the flag is to emulate/study the behavior of the simplified
+           algorithm */
+
+        if(!fit_recenter_dW){
+          sincos(c->W*jj,&si,&co);
+
+          si*=window[j];
+          co*=window[j];
+        }
+
+        c2 = co*co*jj;
+        s2 = si*si*jj;
+
         /* zero order projection */
         aP += co*yy;
         bP += si*yy;
@@ -274,9 +281,9 @@
 
       /* we're fitting to the remaining error; add the fit to date
          back in to relate our newest incremental results to the
-         global fit so far.  Note that this does not include W or dW,
-         as they're already 'subtracted' when the bases are recentered
-         each iteration */
+         global fit so far.  Note that this does not include W (or dW
+         if it is also recentered), as they're already 'subtracted'
+         when the bases are recentered each iteration */
       {
         float A = toAi(c->A, c->P);
         float B = toBi(c->A, c->P);
@@ -286,6 +293,10 @@
         dP += dAtoDi(A,B,c->dA);
         eP += ddAtoEi(A,B,c->ddA);
         fP += ddAtoFi(A,B,c->ddA);
+        if(!fit_recenter_dW){
+          eP += dWtoEi(A,B,c->dW);
+          fP += dWtoFi(A,B,c->dW);
+        }
 
         /* guard overflow; if we're this far out, assume we're never
            coming back. drop out now. */
@@ -337,11 +348,10 @@
 
       /* update the reconstruction/residue vectors with new fit */
       {
-        float cdW = fit_recenter_dW ? c->dW : 0;
         for(j=0;j<len;j++){
           double jj = j-len*.5+.5;
-          float a = c->A + c->dA*jj + c->ddA*jj*jj;
-          float v = a*cos(cdW*jj*jj + c->P + c->W*jj);
+          float a = c->A + (c->dA + c->ddA*jj)*jj;
+          float v = a*cos(c->P + (c->W + c->dW*jj)*jj);
           r[j] -= v*window[j];
           y[j] += v;
         }
@@ -687,9 +697,9 @@
   memset(y,0,sizeof(*y)*len);
   for(i=0;i<n;i++){
     for(j=0;j<len;j++){
-      float jj = j-len*.5+.5;
+      double jj = j-len*.5+.5;
       float a = c[i].A + (c[i].dA + c[i].ddA*jj)*jj;
-      y[j] += a*cosf((c[i].W + c[i].dW*jj)*jj + c[i].P);
+      y[j] += a*cos((c[i].W + c[i].dW*jj)*jj + c[i].P);
     }
   }
 

Modified: trunk/ghost/monty/chirp/chirpgraph.c
===================================================================
--- trunk/ghost/monty/chirp/chirpgraph.c	2011-04-28 01:36:20 UTC (rev 17938)
+++ trunk/ghost/monty/chirp/chirpgraph.c	2011-04-28 09:10:56 UTC (rev 17939)
@@ -52,6 +52,18 @@
   }
 }
 
+void set_iter_text_color(cairo_t *cC, int ret){
+  if (ret>75){
+    cairo_set_source_rgba(cC,0,0,0,1); /* black on white*/
+  }else if (ret>35){
+    cairo_set_source_rgba(cC,1,1,1,1); /* white on red/black  */
+  }else if (ret>3){
+    cairo_set_source_rgba(cC,0,0,0,1); /* black on cyan */
+  }else{
+    cairo_set_source_rgba(cC,1,1,1,1); /* white on dark */
+  }
+}
+
 void set_error_color(cairo_t *c, float err,float a){
   if(isnan(err) || fabs(err)>1.){
     cairo_set_source_rgba(c,1,1,1,a); /* white */
@@ -76,6 +88,23 @@
   }
 }
 
+void set_error_text_color(cairo_t *c, float err){
+  if(isnan(err) || fabs(err)>1.){
+    cairo_set_source_rgba(c,0,0,0,1); /* black on white */
+  }else{
+    err=fabs(err);
+    if(err>.5){
+      cairo_set_source_rgba(c,0,0,0,1); /* black on white */
+    }else if(err>.02){
+      cairo_set_source_rgba(c,1,1,1,1); /* white */
+    }else if(err>.000005){
+      cairo_set_source_rgba(c,0,0,0,1); /* black */
+    }else{
+      cairo_set_source_rgba(c,1,1,1,1); /* white */
+    }
+  }
+}
+
 /********* draw everything in the graph except the graph data itself *******/
 
 static float fontsize=12;
@@ -355,11 +384,8 @@
           snprintf(buf,80,"%d",i);
           cairo_text_extents(c, buf, &extents);
           cairo_move_to(c,px+w/2-extents.width*.5,legendy+toppad+legendh*.625+extents.height/2);
-          cairo_set_source_rgba(c,1,1,1,.9);
-          cairo_text_path (c, buf);
-          cairo_stroke_preserve(c);
-          cairo_set_source_rgb(c,0,0,0);
-          cairo_fill(c);
+          set_iter_text_color(c, i);
+          cairo_show_text(c, buf);
 
           break;
         }
@@ -384,41 +410,51 @@
         case 0:
           buf=(per_p?".0001%":".000001");
           set_error_color(c, 0., 1.);
+          cairo_fill(c);
+          set_error_text_color(c, 0.);
           break;
         case 1:
           buf=(per_p?".001%":".00001");
           set_error_color(c, .00001, 1.);
+          cairo_fill(c);
+          set_error_text_color(c, .00001);
           break;
         case 2:
           buf=(per_p?".01%":".0001");
           set_error_color(c, .0001, 1.);
+          cairo_fill(c);
+          set_error_text_color(c, .0001);
           break;
         case 3:
           buf=(per_p?".1%":".001");
           set_error_color(c, .001, 1.);
+          cairo_fill(c);
+          set_error_text_color(c, .001);
           break;
         case 4:
           buf=(per_p?"1%":".01");
           set_error_color(c, .01, 1.);
+          cairo_fill(c);
+          set_error_text_color(c, .01);
           break;
         case 5:
           buf=(per_p?"10%":".1");
           set_error_color(c, .1, 1.);
+          cairo_fill(c);
+          set_error_text_color(c, .1);
           break;
         case 6:
           buf=(per_p?"100%":"1");
           set_error_color(c, 1., 1.);
+          cairo_fill(c);
+          set_error_text_color(c, 1.);
           break;
         }
-        cairo_fill(c);
 
         cairo_text_extents(c, buf, &extents);
         cairo_move_to(c,px+w/2-extents.width*.5,legendy+toppad+legendh*.625+extents.height/2);
-        cairo_set_source_rgba(c,1,1,1,.9);
-        cairo_text_path (c, buf);
-        cairo_stroke_preserve(c);
-        cairo_set_source_rgb(c,0,0,0);
-        cairo_fill(c);
+        cairo_show_text(c,buf);
+
       }
       cairo_text_extents(c, legend_label, &extents);
       cairo_move_to(c,px-extents.width-legendh*.75,toppad+legendy+legendh*.625+extents.height*.5);

Modified: trunk/ghost/monty/chirp/chirptest.c
===================================================================
--- trunk/ghost/monty/chirp/chirptest.c	2011-04-28 01:36:20 UTC (rev 17938)
+++ trunk/ghost/monty/chirp/chirptest.c	2011-04-28 09:10:56 UTC (rev 17939)
@@ -1116,7 +1116,7 @@
     /* xaxis label */   "W (cycles/block)",
     /* yaxis label */   "dW (cycles/block)",
 
-    /* blocksize */     256,
+    /* blocksize */     128,
     /* threads */       8,
 
     /* window */        window_functions.sine,
@@ -1154,7 +1154,7 @@
     /* ch P range */    0.,1.-1./32.,
     /* ch W range */    0.,10.,
     /* ch dA range */   0.,0.,
-    /* ch dW range */   -2.4,2.4,
+    /* ch dW range */   -2.5,2.5,
     /* ch ddA range */  0.,0.,
 
     /* converge max */    1,
@@ -1182,16 +1182,14 @@
   w_e("partial-nonlinear-dW-vs-W",&arg);
   arg.subtitle1="Full nonlinear estimation, no ddA fit",
   arg.fit_nonlinear=2;
-  //arg.fit_dW_alpha=1.75;
   w_e("full-nonlinear-dW-vs-W",&arg);
-  //arg.fit_dW_alpha=1.;
 
   arg.subtitle1="Linear estimation, no ddA fit",
   arg.fit_nonlinear=0;
   arg.yaxis_label="initial distance from W (cycles/block)";
   arg.y_dim = DIM_ESTIMATE_W;
-  arg.min_est_W = -1.2;
-  arg.max_est_W =  1.2;
+  arg.min_est_W = -2.5;
+  arg.max_est_W =  2.5;
   arg.min_chirp_dW=0.;
   arg.max_chirp_dW=0.;
 
@@ -1201,9 +1199,7 @@
   w_e("partial-nonlinear-estW-vs-W",&arg);
   arg.subtitle1="Full nonlinear estimation, no ddA fit",
   arg.fit_nonlinear=2;
-  //arg.fit_dW_alpha=1.75;
   w_e("full-nonlinear-estW-vs-W",&arg);
-  //arg.fit_dW_alpha=1.;
   arg.fit_nonlinear=0;
 
   return 0;



More information about the commits mailing list