title: How should I initialize the contents of a large matrix in Eigen?
body: <p>I am trying to initialize a matrix (using the Eigen library) to have a nonzero value when I create it. <strong>Is there a nice way to do this without a for loop?</strong></p>
  
  <p>For example, if I wanted to initialize the whole matrix to 1.0, I would like to do something like:</p>
  
  <pre><code>Eigen::MatrixXd mat(i,j) = 1.0;
  </code></pre>
  
  <p>or</p>
  
  <pre><code>Eigen::MatrixXd mat(i,j);
  mat += 1.0;
  </code></pre>
  
  <p>(I am used to this type of thing in MATLAB, and it would make Eigen even nicer to use than it already is. I suspect there is a built-in method somewhere that does this, that I have not found.)</p>
  
  <p>A sub-question to this question would be how to set a block of matrix elements to a set value, something ilke:</p>
  
  <pre><code>mat.block(i,j,k,l) = 1.0;
  </code></pre>