c++ - Using Cramers rule with the Eigen library -


i using eigen linear algebra library , solve 3x3 matrix. in past have used cramer's rule. know if can use cramer's rule in eigen or need program myself?

i using c++ 11 , linux. cannot use other external libraries, boost etc..

yes. can use eigen. take @ documentation here

http://eigen.tuxfamily.org/dox/group__tutoriallinearalgebra.html

the example given quite short , simple:

#include <iostream> #include <eigen/dense> using namespace std; using namespace eigen; int main() {    matrix3f a;    vector3f b;    << 1,2,3,  4,5,6,  7,8,10;    b << 3, 3, 4;    cout << "here matrix a:\n" << << endl;    cout << "here vector b:\n" << b << endl;    vector3f x = a.colpivhouseholderqr().solve(b);    cout << "the solution is:\n" << x << endl; } 

output:

here matrix a:  1  2  3  4  5  6  7  8 10 here vector b: 3 3 4 solution is: -2  1  1 

it guaranteed work faster hand-made solver using cramer's rule.


Comments

Popular posts from this blog

javascript - AngularJS custom datepicker directive -

javascript - jQuery date picker - Disable dates after the selection from the first date picker -