title: Armadillo and C++ - Matrix initialization with 2D-array
body: <p>I need to initialize Armadillo matrix with the array of doubles. I've found this constructor in the original documentation:</p>
  
  <pre><code>mat(*aux_mem, n_rows, n_cols, copy_aux_mem = true, strict = true) 
  </code></pre>
  
  <p>and I've found the question about it here on SO:</p>
  
  <p><a href="https://stackoverflow.com/questions/19370110/armadillo-c-matrix-initialization-from-array">armadillo C++: matrix initialization from array</a></p>
  
  <p>The problem is, it appears that the constructor works only for initialization with one-dimensional arrays, not 2D. If I try it to use this way:</p>
  
  <pre><code>double **matrix = new double *[block_size];
  for(int i = 0; i &lt; block_size; i++) {
      matrix[i] = new double[block_size];
  }
  
  arma::mat arma_matrix( &amp;matrix[0][0], matrix_size, matrix_size, true, true );
  
  cout &lt;&lt; "am: " &lt;&lt; arma_matrix[1][0] &lt;&lt; endl;
  </code></pre>
  
  <p>I get the error:</p>
  
  <pre><code>fined_grain:103/init_function: In function ‘void place_user_fn_103(ca::Context&amp;, ca::TokenList&lt;double&gt;&amp;)’:
  fined_grain:103/init_function:61:42: error: invalid types ‘double[int]’ for array subscript
  </code></pre>
  
  <p>So, what's the ideal way to initialize Arma matrix with 2D-array? I prefer the fastest solution, because I need to use big matrices.</p>