         detail::legendre( px, xn[row], n, forward);
         
         int offset = row;
-        unsigned col_begin = celln[row]*n;
         for(int k=0; k<n; k++)
         {
-            Aj[offset] = col_begin + k*n;
+            Aj[offset] = cellx[row]*n + k
             Av[offset] = px[k];
             offset +=pitch;
         }

 */
cusp::ell_matrix<int, double, cusp::device_memory> ell_interpolation( const thrust::device_vector<double>& x, const thrust::device_vector<double>& y, const Grid2d<double>& g  )
{
    assert( x.size() == y.size());
    //allocate ell matrix storage
    cusp::ell_matrix<int, double, cusp::device_memory> A( x.size(), g.size(), x.size()*g.n()*g.n(), g.n()*g.n());

 __global__ void interpolation_kernel1d( 
         const int num_rows, 
         const int n, 
         const int* cellx, const double* xn, 
         const int pitch, int* Aj, double* Av, 
         const double* forward)
{
