From acb0cae08630e6280ec2069f0c5b71c10a8a2385 Mon Sep 17 00:00:00 2001 From: Davis King Date: Tue, 9 Dec 2008 02:54:49 +0000 Subject: [PATCH] Updated the matrix example to use operator<< for matrix initialization. --HG-- extra : convert_revision : svn%3Afdd8eb12-d10e-0410-9acb-85c331704f74/trunk%402714 --- examples/matrix_ex.cpp | 20 ++++++-------------- 1 file changed, 6 insertions(+), 14 deletions(-) diff --git a/examples/matrix_ex.cpp b/examples/matrix_ex.cpp index 07d04de06..5ecf8b534 100644 --- a/examples/matrix_ex.cpp +++ b/examples/matrix_ex.cpp @@ -58,22 +58,14 @@ int main() // now we need to initialize the y and M matrices and we can do so like this: - const double M_data[] = { - 54.2, 7.4, 12.1, - 1, 2, 3, - 5.9, 0.05, 1}; + M << 54.2, 7.4, 12.1, + 1, 2, 3, + 5.9, 0.05, 1; - const double y_data[] = { - 3.5, - 1.2, - 7.8}; + y << 3.5, + 1.2, + 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 x = inv(M)*y;