 }
 
 // float3 utilities
-__device__ float3 cross(float3 a, float3 b){
+__device__ __host__ float3 cross(float3 a, float3 b){
   float3 c;
   c.x = a.y*b.z - a.z*b.y;
   c.y = a.z*b.x - a.x*b.z;

  return c;
}

__device__ float3 normalize(float3 v){
  float l = sqrt(v.x*v.x + v.y*v.y + v.z*v.z);
  v.x /= l;
  v.y /= l;

}

// Indexing function (note the argument order)
__device__ __host__ int index(int z, int y, int x){
  return z * DATA_DIM*DATA_DIM + y*DATA_DIM + x;
}

// Trilinear interpolation
__device__ __host__ float value_at(float3 pos, unsigned char* data){
  if(!inside(pos)){
    return 0;
  }
