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> int main() { // Define the vector and the matrix: RWMathVec<double> vector; RWGenMat<double> matrix; // Read in the vector, then the matrix: std::cin >> vector >> matrix; // Matrix multiply (the inner product): RWMathVec<double> answer = product(matrix, vector); // Print out the results: std::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 Rogue Wave Software, Inc. All Rights Reserved.
Rogue Wave and SourcePro are registered trademarks of Rogue Wave Software, Inc. in the United States and other countries. All other trademarks are the property of their respective owners.
Contact Rogue Wave about documentation or support issues.