次の 2d ベクトル/マトリックスX
とベクトルY
があります。
std::vector<double> Y;
unsigned int ctr=2;
std::vector<std::vector<double> >X(ctr,Y);
X、つまり Xtrans の転置を作成したいので、以下のように宣言します。
std::vector<std::vector<double> >Xtrans(Y,ctr);
しかし、それは私に次のコンパイルエラーを与えます:
test.cpp:128:58: error: no matching function for call to ‘std::vector<std::vector<double> >::vector(std::vector<double>&, unsigned int&)’
/usr/include/c++/4.5/bits/stl_vector.h:241:7: note: candidates are: std::vector<_Tp, _Alloc>::vector(const std::vector<_Tp, _Alloc>&) [with _Tp = std::vector<double>, _Alloc = std::allocator<std::vector<double> >, std::vector<_Tp, _Alloc> = std::vector<std::vector<double> >]
/usr/include/c++/4.5/bits/stl_vector.h:227:7: note: std::vector<_Tp, _Alloc>::vector(std::vector::size_type, const value_type&, const allocator_type&) [with _Tp = std::vector<double>, _Alloc = std::allocator<std::vector<double> >, std::vector::size_type = unsigned int, value_type = std::vector<double>, allocator_type = std::allocator<std::vector<double> >]
/usr/include/c++/4.5/bits/stl_vector.h:215:7: note: std::vector<_Tp, _Alloc>::vector(const allocator_type&) [with _Tp = std::vector<double>, _Alloc = std::allocator<std::vector<double> >, allocator_type = std::allocator<std::vector<double> >]
/usr/include/c++/4.5/bits/stl_vector.h:207:7: note: std::vector<_Tp, _Alloc>::vector() [with _Tp = std::vector<double>, _Alloc = std::allocator<std::vector<double> >]
Xtrans を正しく宣言するにはどうすればよいですか?