Updated the matrix example to use operator<< for matrix initialization.

--HG--
extra : convert_revision : svn%3Afdd8eb12-d10e-0410-9acb-85c331704f74/trunk%402714
This commit is contained in:
Davis King 2008-12-09 02:54:49 +00:00
parent 3ad81a5a64
commit acb0cae086
1 changed files with 6 additions and 14 deletions

View File

@ -58,22 +58,14 @@ int main()
// now we need to initialize the y and M matrices and we can do so like this: // now we need to initialize the y and M matrices and we can do so like this:
const double M_data[] = { M << 54.2, 7.4, 12.1,
54.2, 7.4, 12.1, 1, 2, 3,
1, 2, 3, 5.9, 0.05, 1;
5.9, 0.05, 1};
const double y_data[] = { y << 3.5,
3.5, 1.2,
1.2, 7.8;
7.8};
// Load these matrices up with their data. Note that you can only load a matrix
// with a C style array if the matrix is statically dimensioned as the M and y
// matrices are. You couldn't do it for x since x = M_data would be ambiguous.
// (e.g. should the data be interpreted as a 3x3 matrix or a 9x1 matrix?)
M = M_data;
y = y_data;
// the solution can be obtained now by multiplying the inverse of M with y // the solution can be obtained now by multiplying the inverse of M with y
x = inv(M)*y; x = inv(M)*y;