title: Finding dimensional index in a multi-dimensional array in R
body: <p>Am looking at say 3-dimensional array M: <code>M&lt;-dim(3,3,3)</code></p>
  
  <p>I want to find an efficient way to populate M with the following rule: 
      <em>M[i,j,k] = i/10 + j^2 + sqrt(k)</em>, 
  ideally without having to write a loop with a <code>for</code> statemenet. </p>
  
  <p>For clarification, there is a simple way to accomplishing this if M were 2-dimensional. If i wanted to have 
      <em>M[i,j] = i/10 + j^2</em>, 
  then i could just do
      <code>M&lt;-row(M)/10 + col(M)*col(M)</code></p>
  
  <p>Is there something equivalent for 3-or-higher dimensional arrays?</p>