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.
The Rogue Wave name and logo, and SourcePro, are registered trademarks of Rogue Wave Software. All other trademarks are the property of their respective owners.
Provide feedback to Rogue Wave about its documentation.