title: How to insert an element into ublas matrix with dynamic size
body: <p>Run time error while trying to insert element in a matrix with size not specified initially.</p>
  
  <p>The below code runs finr for m1 but throws error for <strong>m2</strong>.</p>
  
  <pre><code>#include &lt;iostream&gt;
  #include &lt;boost/numeric/ublas/matrix.hpp&gt;
  #include &lt;boost/numeric/ublas/io.hpp&gt;    
  
  int main () {
      boost::numeric::ublas::matrix&lt;double&gt; m1 (1,1);
      boost::numeric::ublas::matrix&lt;double&gt; m2;
      unsigned int i = 0;
      m1(i,i)=9;  // This works completely
      m2(i,i)=9;  // This one throws error
      return 0;
  }
  </code></pre>
  
  <p>If someone can provide an alternative to achieve this, i shall be highly grateful.</p>