transposing a 2Dvector/matrix
<p>I have the following 2d vector/matrix <code>X</code> and a vector <code>Y</code> as below:</p>

<pre><code>std::vector&lt;double&gt; Y; 
unsigned int ctr=2;
std::vector&lt;std::vector&lt;double&gt; &gt;X(ctr,Y);
</code></pre>

<p>I now want to create a transpose of X,i.e. Xtrans, so am declaring it as below </p>

<pre><code>std::vector&lt;std::vector&lt;double&gt; &gt;Xtrans(Y,ctr);
</code></pre>

<p>but it gives me the following compilation error:</p>

<pre><code>test.cpp:128:58: error: no matching function for call to ‘std::vector&lt;std::vector&lt;double&gt; &gt;::vector(std::vector&lt;double&gt;&amp;, unsigned int&amp;)’
/usr/include/c++/4.5/bits/stl_vector.h:241:7: note: candidates are: std::vector&lt;_Tp, _Alloc&gt;::vector(const std::vector&lt;_Tp, _Alloc&gt;&amp;) [with _Tp = std::vector&lt;double&gt;, _Alloc = std::allocator&lt;std::vector&lt;double&gt; &gt;, std::vector&lt;_Tp, _Alloc&gt; = std::vector&lt;std::vector&lt;double&gt; &gt;]
/usr/include/c++/4.5/bits/stl_vector.h:227:7: note:                 std::vector&lt;_Tp, _Alloc&gt;::vector(std::vector::size_type, const value_type&amp;, const allocator_type&amp;) [with _Tp = std::vector&lt;double&gt;, _Alloc = std::allocator&lt;std::vector&lt;double&gt; &gt;, std::vector::size_type = unsigned int, value_type = std::vector&lt;double&gt;, allocator_type = std::allocator&lt;std::vector&lt;double&gt; &gt;]
/usr/include/c++/4.5/bits/stl_vector.h:215:7: note:                 std::vector&lt;_Tp, _Alloc&gt;::vector(const allocator_type&amp;) [with _Tp = std::vector&lt;double&gt;, _Alloc = std::allocator&lt;std::vector&lt;double&gt; &gt;, allocator_type = std::allocator&lt;std::vector&lt;double&gt; &gt;]
/usr/include/c++/4.5/bits/stl_vector.h:207:7: note:                 std::vector&lt;_Tp, _Alloc&gt;::vector() [with _Tp = std::vector&lt;double&gt;, _Alloc = std::allocator&lt;std::vector&lt;double&gt; &gt;]
</code></pre>

<p>How do I go about declaring Xtrans correctly?</p>
