How can one create a 2D vector
in C++ and find its length
and coordinates
?
In this case, how are the vector elements filled with values?
Thanks.
If your goal is to do matrix computations, use Boost::uBLAS. This library has many linear algebra functions and will probably be a lot faster than anything you build by hand.
If you are a masochist and want to stick with std::vector
, you'll need to do something like the following:
std::vector<std::vector<double> > matrix;
matrix.resize(10);
matrix[0].resize(20);
// etc