title: How to write/read an Eigen matrix from binary file
body: <p>To write Eigen::Matrix to file I really like to use the following:</p>
  
  <pre><code>typedef Eigen::Matrix&lt;Scalar, Eigen::Dynamic, Eigen::Dynamic&gt; Matrix_MxN;
  Matrix_MxN J = Matrix_MxN::Zeros(10,10);      
  std::ofstream("matrix.txt") &lt;&lt; J;
  </code></pre>
  
  <p>But unfortunately, something that can do the opposite is not defined:</p>
  
  <pre><code>std::ifstream("matrix.txt") &gt;&gt; J;
  </code></pre>
  
  <p>To circumvent this problem, <strong>how can you read/write an Eigen::Matrix to binary file instead</strong>?</p>