title: How to copy data from C++ array to Eigen matrix or vector?
body: <p>I have some data in a C++ array, <code>double myData[10]</code>; I want to copy <code>n</code> elements of this array to a vector in Eigen, declared as <code>Eigen::MatrixXd myVector</code>. I could do them one at a time in a loop, but there must be a way to copy the entire array. I tried this code, but it gets a compile error (error C2106: '=': left operand must be l-value):</p>
  
  <pre><code>myVector.resize(4); myVector.data() = myData;
  </code></pre>
  
  <p>I do NOT want to map the array, as the C++ array will go out of scope, and the amount of extra memory to copy is trivial.</p>
  
  <p>What is the appropriate method for copying from the C++ array to the Eigen vector? From a 2-D C++ array to an Eigen matrix?</p>