The Essential Math Module provides linear algebra classes to solve sets of simultaneous linear equations via LU factorization for any numeric field type, including double, float, and double precision complex. The requirements for a numeric type to use the linear algebra classes are detailed in Section 2.2.1, "Defining a New Numeric Type." These classes use a templatized version of the Linpack algorithms. (See the reference to Dongarra (1979) in Appendix B, "Bibliography," in the Essential Math Module Reference Guide.)
Using these classes is very easy and can even be completely transparent to the user. For example, here is the code to invert a matrix:
#include <rw/math/genfact.h> #include <rw/math/genmat.h> int main() { RWGenMat<double> A; std::cin >> A; // Read in a matrix // Invert it: RWGenMat<double> Ainv = inverse(A); }
Here is how you would solve a set of linear equations Ax = b, assuming that A has been read in as above:
// Read in the vector b: RWMathVec<double> b; std::cin >> b; // "x" will contain the solution: RWMathVec<double> x = solve(A, b);
© 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.