Diff of /src/multi_class.cc [r75] .. [r76]  Maximize  Restore

  Switch to side-by-side view

--- a/src/multi_class.cc
+++ b/src/multi_class.cc
@@ -273,6 +273,7 @@
 
     //create the mapping:
     imap=gsl_matrix_alloc(2*nmodel+1, this->ncls);
+    gsl_matrix_set_zero(imap);
     //the sum of the conditional probabilities should always equal 1:
     for (int i=0; i<this->ncls; i++) gsl_matrix_set(imap, nmodel*2, i, 1.);
 
@@ -295,20 +296,19 @@
     //now we find the inverse of this matrix:
     u=gsl_matrix_alloc(2*nmodel+1, this->ncls);
     gsl_matrix_memcpy(u, imap);
+    print_gsl_matrix(stdout, u);
     vt=gsl_matrix_alloc(this->ncls, this->ncls);
     s=gsl_vector_alloc(this->ncls);
     work=gsl_vector_alloc(this->ncls);
     gsl_linalg_SV_decomp(u, vt, s, work);
     //gsl_linalg_SV_decomp_jacobi(u, vt, s);
 
-    /*
     printf("U:\n");
     print_gsl_matrix(stdout, u);
     printf("S:\n");
     for (int i=0; i<s->size; i++) printf("%10.5g ", gsl_vector_get(s, i));
     printf("\nV^T:\n");
     print_gsl_matrix(stdout, vt);
-    */
 
     map=allocate_matrix<real, cls_t>(this->ncls, 2*nmodel+1);
     for (int i=0; i<this->ncls; i++) {
@@ -372,11 +372,11 @@
     //printf("multiclass raw pdfs: ");
     for (int i=0; i<nmodel; i++) {
       twoclass[i]->classify(x, rawpdf+i*2);
-      //printf(" %6.4f %6.4f", rawpdf[i*2], rawpdf[i*2+1]);
+      printf(" %6.4f %6.4f", rawpdf[i*2], rawpdf[i*2+1]);
       gsl_vector_set(b, i*2, rawpdf[i*2]);
       gsl_vector_set(b, i*2+1, rawpdf[i*2+1]);
     }
-    //printf("\n");
+    printf("\n");
     rawpdf[nmodel*2]=0;
 
     gsl_linalg_SV_solve(u, vt, s, b, p);
@@ -388,6 +388,9 @@
       pdf[i]=gsl_vector_get(p, i);
       if (pdf[i]>pdf[cls]) cls=i;
     }
+
+    for (int i=0; i<this->ncls; i++) printf("%g ", pdf[i]);
+    printf("\n");
 
     gsl_vector_free(b);
     gsl_vector_free(p);