I saved a sample of $N$ Cartesian locations $\{x_i, y_j, z_k\}$ inside a one-dimensional array $\mathbf{a} = \{a_l\}_{l = 1}^N$. How can I access back (efficiently) the $l$-location of the array $\mathbf{a}$ knowing just the three $i,j,k$ Cartesian indices?

(Fortran/C++ examples would be helpful)

  • $\begingroup$ Are your samples equispaced in x, y and z? $\endgroup$ – nicoguaro Nov 1 '19 at 14:40
  • $\begingroup$ no, the sample is fully unstructured once it is saved in the array. Even the grid is not equispaced $\endgroup$ – John Snow Nov 1 '19 at 15:14
  • $\begingroup$ Are you allowed to use some libraries specially written in C++? I suggest VTK and have a look at vtkPoints, which basically gives you very efficient access to unstructured point cloud. $\endgroup$ – Alone Programmer Nov 1 '19 at 16:16

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.