                          1,
                          nMaterials);
 
-  for (unsigned int r=0; r<nEnergies; r++)
-    attenuationFactors[r] = std::exp(-attenuationFactors[r]);
+  for (unsigned int e=0; e<nEnergies; e++)
+    attenuationFactors[e] = std::exp(-attenuationFactors[e]);
 
   // Get the expected photon counts through these attenuations
   float expectedCounts[nBins];


  // Compute the efficient spectrum at the current pixel
  float efficientSpectrum[nBins * nEnergies];
  for (unsigned int r=0; r<nBins; r++)
    for (unsigned int c=0; c<nEnergies; c++)
      efficientSpectrum[c + nEnergies * r] = pSpectrum[c + nEnergies * first_proj_idx] * c_binnedDetectorResponse[c + nEnergies * r];

  // Get attenuation factors at each energy from material projections
  float attenuationFactors[nEnergies];

#include <cublas_v2.h>
#include <cuda_runtime.h>

#define IDX2D(r,c,cols) ((r)*(cols)+(c))

// CONSTANTS //////////////////////////////////////////////////////////////
__constant__ int3 c_projSize;
