title: Armadillo, how to grow a vector and get his size?
body: <p>In my last question, <em>Ilmari Karonen</em> propose to me to solve the <em>Laplace</em> equation in discret mode. I'm using a grid and the four closest neighbours at each node to compute the unknown heights.</p>
  
  <p><img src="https://i.stack.imgur.com/aOJYk.png" alt="enter image description here"></p>
  
  <p>So the system to solve can be written with matrix :</p>
  
  <p><strong>A(matrix nxn) * U(vector n, unknowns) = b(vector n, settled)</strong></p>
  
  <p>last evening I looked around the web about linear algebra for C++. My choice is <a href="http://arma.sourceforge.net/" rel="nofollow noreferrer">Armadillo</a>. But for now "U" and "b" are <code>std::map</code> :</p>
  
  <pre><code>std::map&lt;std::pair&lt;float,float&gt;,float&gt; b;
  std::map&lt;std::pair&lt;float,float&gt;,float&gt; U;
  .
  .
  .
  if(g/*grid*/-&gt;getNode(r,c)-&gt;status == TO_COMPUTE){
            U.insert(std::make_pair(std::make_pair(r,c),g-&gt;getNode(r,c)-&gt;y));
            /*right*/ if(g-&gt;getNode(r+1,c)-&gt;status == SETTLED) b.at(std::make_pair(r,c)) += g &gt;getNode(r+1,c)-&gt;y;
            /*left */ if(g-&gt;getNode(r-1,c)-&gt;status == SETTLED) b.at(std::make_pair(r,c)) += g-&gt;getNode(r-1,c)-&gt;y;
            /*down */ if(g-&gt;getNode(r,c+1)-&gt;status == SETTLED) b.at(std::make_pair(r,c)) += g-&gt;getNode(r,c+1)-&gt;y;
            /*up   */ if(g-&gt;getNode(r,c-1)-&gt;status == SETTLED) b.at(std::make_pair(r,c)) += g-&gt;getNode(r,c-1)-&gt;y;
          }
  </code></pre>
  
  <p>and I think I will have then to get the size of "U" to create <code>arma::vec</code> and to parse the whole map with an <code>std::iterator</code> to transfer the values in my <code>arma::vec</code>. So I would like to know how to grow a <code>arma::vec</code> I'm looking for something like <code>std::vector::push_back()</code>, then I will replace my <code>std::map</code>. Also how can I get the size for a <code>arma::vec</code>?</p>
  
  <p>note1 : the picture shows the contours and the points where I will compute the values, the grid with unknow value is at y=0, when the lower contour is at y=-0.2 and the upper contour at y=0.8</p>
  
  <p>note2 : when my little (LINUX) program will be ready I will release the code on my bitbucket as a very tiny example of use of discret <em>Laplace</em> operator</p>
  
  <h1>Update 26 Nov. 2013:</h1>
  
  <p>you can get the link to the code <a href="https://stackoverflow.com/questions/20106591/what-kind-of-algorithm-for-generating-height-map-from-contour-line">here</a></p>