 
   for (int i = 0; i < iD; ++i)
   {
-   	sum = 0;
-   	for(int j=0; j <= i; j++) {
-   	  sum += *sigma++ * (data[j] - mean[j]);
-   	}
-   	discrim += sum * sum;
+    sum = 0;
+    for(int j=0; j <= i; j++) {
+      sum += *sigma++ * (data[j] - mean[j]);
+    }
+    discrim += sum * sum;
   }
   return log(mult) - 0.5 * (discrim + logdet + LOG_2_PI * (float) iD);
 }

            for(int i=0; i<D; i++) {
                float sum = 0;
                for(int j=0; j<=i; j++) {
				  // printf("%d %d %f %f %f\n", i, j, *tSigma, tData[j], tMean[j]);
				  sum += *tSigma * (tData[j] - tMean[j]); // xx[j] is always calculated since j <= i
				  tSigma++;
                }

                discrim += sum * sum;
            }

            float d = log(tP) - 0.5 * (discrim + tLogDet + (LOG_2_PI*(float) D));
			// printf("discrim: %f\n", discrim);
			// printf("tP: %f\n", tP);
			// printf("tLogDet: %f\n", tLogDet);
			// printf("d: %f\n", d);
			// printf("idx: %d\n", obs * T + component);
            output[obs * T + component] = d;
        }
    }
	free(xx);
}




__device__ int next_multiple(int k, int mult) {
  if (k % mult)
    return k + (mult - k % mult);
  else
    return k;
}

__device__ float compute_pdf(float* data, float* params, int iD) {
