title: How to iterate over indices of a matrix?
body: <p>In Python when we want to iterate over a matrix with an arbitrary dimension, we can use this line of code:</p>
  <pre><code>for index in np.ndindex(data.shape[2:]):
  </code></pre>
  <p>for example :</p>
  <pre><code>&gt; for index in np.ndindex(3, 2, 1):
  &gt;     print(index) (0, 0, 0) (0, 1, 0) (1, 0, 0) (1, 1, 0) (2, 0, 0) (2, 1, 0)
  </code></pre>
  <p>in java, in an easy way, we can do it with a determined number of for loop, but the prerequisite is knowledge about the dimension. But in arbitrary dimensions, the algorithm must be more complicated.</p>
  <p>Is there any built-in method in ND4J lib for iterating over indices?</p>