Multidimensional Buffer and linear access

Hello,
I try to write a 3D volumetric data set into a OptiX buffer.

optix::Buffer tex_buffer = context_->createBuffer(RT_BUFFER_INPUT, RT_FORMAT_FLOAT3, dimensions_.x, dimensions_.y, dimensions_.z);
optix::float3* tex_buffer_data = (optix::float3*)tex_buffer->map();

I create the buffer, but now the map() function will only get me access to a linear storage.
What exactly is the interleaving order for the multi dimensional buffer?

What I later want to do is, to use the buffer as a 3D texture buffer so I can sample from it using the GPU trilinear interpolation. So I want access using normalized texture coordinates.

So I have a three dimensional

std::vector<std::vector<std::vector<double> > > volume_data_;

That currently holds my data, how do I correctly put it into the Optix::Buffer?

Given a 3D index (x, y, z) the linear index is at (z * height * width + y * width + x).
Think slices of 2D images. Same as with any other 3D API.

There is no texture format supporting doubles so GPU trilinear interpolation won’t work with your input data. Using float in the example code. That’s what I’m using for density fields.

m_buffer = context->createBuffer(RT_BUFFER_INPUT, RT_FORMAT_FLOAT, m_width, m_height, m_depth);

  float* dst = static_cast<float*>(m_buffer->map());

  for (unsigned int z = 0; z < m_depth; ++z)
  {
    for (unsigned int y = 0; y < m_height; ++y)
    {
      for (unsigned int x = 0; x < m_width; ++x)
      {
        *dst++ = static_cast<float>(volume_data[z][y][x]);
      }
    }
  }
  m_buffer->unmap(); 

  m_sampler = context->createTextureSampler();
  m_sampler->setWrapMode(0, RT_WRAP_REPEAT);
  m_sampler->setWrapMode(1, RT_WRAP_REPEAT);
  m_sampler->setWrapMode(2, RT_WRAP_REPEAT);
  m_sampler->setFilteringModes(RT_FILTER_LINEAR, RT_FILTER_LINEAR, RT_FILTER_NONE);
  m_sampler->setIndexingMode(RT_TEXTURE_INDEX_NORMALIZED_COORDINATES);
  m_sampler->setReadMode(RT_TEXTURE_READ_ELEMENT_TYPE);
  m_sampler->setMaxAnisotropy(1.0f);
  m_sampler->setMipLevelCount(1);
  m_sampler->setArraySize(1);
  m_sampler->setBuffer(0, 0, m_buffer);

Thank you!
Actually the double was just a failure to write it here in the forum. My data uses floats.
I had some additional trouble with the textures because I accidently mixed formats but it seems to work now.