matrix declaration

I am going through some code and I see the following:
std::vector<std::vector<double> > x;
does that mean x is a matrix?
Yes, x can be thought of as a matrix.

e.g.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
std::vector<std::vector<double>> M;

//Make M a 3x3 matrix with the first row all 1's,
//the second row all 2's and the third row all 3's
M.push_back(std::vector<double>(3, 1.0));
M.push_back(std::vector<double>(3, 2.0));
M.push_back(std::vector<double>(3, 3.0));

std::vector<std::vector<double>> Jagged;

//Make Jagged a jagged 2D array with the
//Jagged[0] being an array of size 3,
//Jagged[1] an array of size 7, and Jagged[2]
//an array of size 10
Jagged.push_back(std::vector<double>(3));
Jagged.push_back(std::vector<double>(7));
Jagged.push_back(std::vector<double>(10));
thanks shacktar, that example helps
so, that makes Jagged a 3x1 matrix, isn't it?
No, Jagged is a set of three vectors, with the first vector having length 3, the second vector having length 7, and the third vector having length 10. The point of my example was to show that std::vector<std::vector<double> > x; can be thought of as a Matrix in the MxN collection of numbers sense, but it could also be something else (as in a jagged 2D array which doesn't fit the "Matrix" requirement).
understood...thanks!
Topic archived. No new replies allowed.