FILENAME: example2.cpp
Program:
/*
* Example program showing the use of matrix classes * to multiply a double precision matrix by a vector. */
// Include the header files for double precision matrices // and vectors: #include <rw/math/mathvec.h> #include <rw/math/genmat.h> #include <iostream.h>
main() { // Define the vector and the matrix: RWMathVec<double> vector; RWGenMat<double> matrix;
// Read in the vector, then the matrix: cin >> vector >> matrix;
// Matrix multiply (the inner product): RWMathVec<double> answer = product(matrix, vector);
// Print out the results: cout << "answer = \n" << answer << "\n"; }
Sample Input:
[ 45.2 -2.4 78.91 ] 3X3 [ 1 0 1 2 1 1 2 0 -1 ]
Sample Output:
answer = [ 124.1 166.9 11.5 ]>
©Copyright 1999, Rogue Wave Software, Inc.
Contact Rogue Wave about documentation or support issues.