Line | |
---|
1 | #include <Eigen/Dense>
|
---|
2 | #include <iostream>
|
---|
3 |
|
---|
4 | using namespace Eigen;
|
---|
5 | using namespace std;
|
---|
6 |
|
---|
7 | int main(int, char**)
|
---|
8 | {
|
---|
9 | cout.precision(3);
|
---|
10 | typedef Matrix<float,Dynamic,2> DataMatrix;
|
---|
11 | // let's generate some samples on the 3D plane of equation z = 2x+3y (with some noise)
|
---|
12 | DataMatrix samples = DataMatrix::Random(12,2);
|
---|
13 | VectorXf elevations = 2*samples.col(0) + 3*samples.col(1) + VectorXf::Random(12)*0.1;
|
---|
14 | // and let's solve samples * [x y]^T = elevations in least square sense:
|
---|
15 | Matrix<float,2,1> xy
|
---|
16 | = (samples.adjoint() * samples).llt().solve((samples.adjoint()*elevations));
|
---|
17 | cout << xy << endl;
|
---|
18 |
|
---|
19 | return 0;
|
---|
20 | }
|
---|
Note:
See
TracBrowser
for help on using the repository browser.