   pcaCalculateYMatrix(d_inMatrix, inRows, inCols, d_Y);
 
   // Perform SVD on Y.
-  pcaSVD(d_Y, inRows, inCols, d_PC);
+  pcaSVD(d_Y, inCols, inRows, d_PC);
 
-  // DEBUG_PRINT_DEVICE(d_PC, inCols * inCols);
+  DEBUG_PRINT_DEVICE(d_PC, inRows * inRows);
+  DEBUG_PRINT_DEVICE(d_inMatrix, inRows * inCols);
 
   // Calculate signals.
   pcaCalculateSignals(d_PC, d_inMatrix, inRows, inCols, d_outMatrix);

  cublasHandle_t handle;
  cublasCreate(&handle);

  float m = inCols;
  float n = inRows;
  float k = inCols;
  float lda = k;
  float ldb = inCols;
  float ldc = m;

  cublasSgemm(handle, CUBLAS_OP_T, CUBLAS_OP_T, m, k, n, &alpha,
      d_PC, lda, d_inMatrix, ldb, &beta, d_Signals, ldc);

  cublasDestroy(handle);

  float h_averageX, h_averageY;
  cudaMemcpy(&h_averageX, d_averageX, sizeof(float), cudaMemcpyDeviceToHost);
  cudaMemcpy(&h_averageY, d_averageY, sizeof(float), cudaMemcpyDeviceToHost);
  h_averageX /= inCols;
  h_averageY /= inCols;

  utilVectorAddScalar(&d_inMatrix[0], -1 * h_averageX, inCols);
  utilVectorAddScalar(&d_inMatrix[inCols], -1 * h_averageY, inCols);
