By @rpinho

Refereed correctness bugs in open-source research software, with patches and links to upstream PRs

bf54d4b / bentoayr-Efficient-Projection-onto-the-Perfect-Phylogeny-Model/patches/BENTO-001.patch

Raw
diff --git a/InputDataExample b/InputDataExample
index 8924422..ffdc55f 100644
--- a/InputDataExample
+++ b/InputDataExample
@@ -1,5 +1,5 @@
 15 3
-0.725942 0.914536 0.308994 0.392671 0.198900 0.253965 0.851543 0.807238 0.545593 0.678674 0.052032 0.853709 0.382302 0.481751 0.261292 0.903785 0.658011 0.716039 0.689065 0.203522 0.136643 0.120160 0.019725 0.904464 0.844093 0.311264 0.908844 0.423654 0.403077 0.635268 0.246974 0.686403 0.827763 0.670399 0.737255 0.382183 0.415822 0.301698 0.051210 0.421497 0.278440 0.401550 0.699321 0.616997 0.744629
+0.725942 0.392671 0.851543 0.678674 0.382302 0.903785 0.689065 0.120160 0.844093 0.423654 0.246974 0.670399 0.415822 0.421497 0.699321 0.914536 0.198900 0.807238 0.052032 0.481751 0.658011 0.203522 0.019725 0.311264 0.403077 0.686403 0.737255 0.301698 0.278440 0.616997 0.308994 0.253965 0.545593 0.853709 0.261292 0.716039 0.136643 0.904464 0.908844 0.635268 0.827763 0.382183 0.051210 0.401550 0.744629
 0.214419 0.960675 0.384667 0.161183 0.372724 0.045426 0.302500 0.079298 0.467268 0.966597 0.985513 0.698576 0.736572 0.406475 0.929228
 0
 1 2 2 2 2 2 3 1 2 2 3 1 2 1 2
diff --git a/project_onto_PPM.c b/project_onto_PPM.c
index 6524535..17b353b 100644
--- a/project_onto_PPM.c
+++ b/project_onto_PPM.c
@@ -967,7 +967,7 @@ int main(int argc, const char * argv[]) {
     // read the F data
     realnumber *data = (realnumber *) malloc(num_nodes*T*sizeof(realnumber));
     for (int i = 0; i < num_nodes*T - 1; i++){
-        fscanf(fptr, "%f ", &Dbuff); data[i] = (realnumber) Dbuff;
+        fscanf(fptr, "%f ", &Dbuff); data[(i % num_nodes)*T + i / num_nodes] = (realnumber) Dbuff;
     }
     fscanf(fptr, "%f\n", &Dbuff); data[num_nodes*T - 1] = (realnumber) Dbuff;
     // read the diagonal data
diff --git a/test_against_CVX_matlab.m b/test_against_CVX_matlab.m
index fc6e275..86277e8 100644
--- a/test_against_CVX_matlab.m
+++ b/test_against_CVX_matlab.m
@@ -41,7 +41,7 @@ variable M(n,time_points)
     fid = fopen('inputdata.txt','w');
 
     fprintf(fid, '%d %d\n',n,time_points);
-    F_T = F';
+    F_T = F; % Write F in the documented column-major order.
     fprintf(fid, '%1.6f ',F_T(1:end-1)); fprintf(fid, '%1.6f\n',F_T(end));
     fprintf(fid, '%1.6f ',D(1:n+1:end-1));fprintf(fid, '%1.6f\n',D(end));
     fprintf(fid, '0\n');