Eigen matrix library and a test program

Dependencies:   Eigen mbed

main.cpp

Committer:
ykuroda
Date:
2016-10-13
Revision:
1:ad6e79769c8f
Parent:
0:5971b11ad8ff

File content as of revision 1:ad6e79769c8f:

#include "mbed.h"
#include <iostream>
#include <Eigen/Dense.h>
using namespace std;
using namespace Eigen;

int main() {

    Matrix3f A;
    Vector3f b;
    A << 1,2,3, 4,5,6, 7,8,10;
    b << 3, 3, 4;
    cout << "Here is the matrix A:\n" << A << endl;
    cout << "Here is the vector b:\n" << b << endl;
    Vector3f x = A.colPivHouseholderQr().solve(b);
    //Vector3f x = A.inverse() * b;
    cout << "The solution is:\n" << x << endl;
    //printf("b[%g,%g,%g]\n", x(0),x(1),x(2));
}