blob: 7095d2cc39ea1542d7eee78ceeea5e6d6b2b035b [file] [log] [blame]
Gael Guennebaud765219a2008-10-13 15:53:27 +00001typedef Matrix<float,Dynamic,2> DataMatrix;
2// let's generate some samples on the 3D plane of equation z = 2x+3y (with some noise)
3DataMatrix samples = DataMatrix::Random(12,2);
4VectorXf elevations = 2*samples.col(0) + 3*samples.col(1) + VectorXf::Random(12)*0.1;
5// and let's solve samples * [x y]^T = elevations in least square sense:
Benoit Jacob6b48e932009-10-29 21:11:05 -04006Matrix<float,2,1> xy
7 = (samples.adjoint() * samples).llt().solve((samples.adjoint()*elevations));
Gael Guennebaud765219a2008-10-13 15:53:27 +00008cout << xy << endl;