     //}
     float err = 0.0;
     for (int i = 0; i < N*Q; i++){
-        for (int j = 0; j < N*Q; j++){
+        int j;
+        //std::cout << std::endl << i << ' ';
+        for (j = 0; j < N*Q; j++){
             err += (cov_mat_from_d[i*N*Q + j] - cov_mat[i*N*Q + j]) / N*Q;
-        }
-    }
-    std::cout << err << std::endl;
+            //std::cout << ' ' << j <<  '/' << cov_mat_from_d[i*N*Q + j] << '/' << cov_mat[i*N*Q + j];
+        }
+    }
+    std::cout << std::endl << err << std::endl;
 
     return 0;
 }


    // calculate column-wise amino acid frequencies
    float* f_single = (float*) std::malloc(Q*N * sizeof(float));
    getFreqSingle(alignment, f_single, B, N);

    // calculate column-wise amino acid frequencies
    // for each possible pair of amino acids and columns
    float* f_pair = (float*) std::malloc(Q*N * Q*N * sizeof(float));
    getFreqPair(alignment, f_pair, B, N);

    // calculate covariance matrix from frequencies
    float* cov_mat = (float*) std::malloc(Q*N * Q*N * sizeof(float));

    printf("\nTiming:\nFull: %f\nHost: %f\nDevice: %f\n\n", t_full, t_host, t_dev);


    std::cout << B << ' ' << N << ' ' << Q << std::endl;
    //for (int i = 0; i < B; i++){
    //    for (int j = 0; j < N; j++){
    //        std::cout << aln[i*N +j] << ' ';
    //    }
    //    std::cout << std::endl;
    //}
