Example for singular value decomposition of a 3x3 matrix , SVD
- Author
- woelk 07/2004
#include <MathAlgo/SVD.hh>
#include <MathAlgo/SVD3x3.hh>
#include <Base/Math/Random.hh>
#include <Base/Math/Matrix3x3.hh>
#include <Base/Math/Matrix.hh>
using namespace BIAS;
using namespace std;
#define F_SVD_THRESH 0.1
int main()
{
F[0][0] =0.00075284066373225704;
F[0][1] =-0.099906426438442303;
F[0][2] =0.16267766990357244;
F[1][0] =0.10333163045064053;
F[1][1] =0.0014727467665194025;
F[1][2] =0.6803859609102173;
F[2][0] =-0.16234020366691171;
F[2][1] =-0.68087420277635458;
F[2][2] =0.0021896762792443826;
SVD3x3 svdF3x3(F, F_SVD_THRESH);
for (int i = 0; i < 3; i++)
S[i][i] = svdF3x3.
GetS()[i];
cout << endl << "-- SVD3x3 --" << endl;
cout << endl <<
"|F - U*S*VT| = " <<
Matrix<double>(F-USVT).NormL2() << endl
<< endl <<
"NullspaceDim() = " << svdF3x3.
NullspaceDim() << endl;
SVD svdF(F, F_SVD_THRESH);
for (int i = 0; i < 3; i++)
S[i][i] = svdF.
GetS()[i];
cout << endl << "-- SVD --" << endl;
cout << endl <<
"|F - U*S*VT| = " <<
Matrix<double>(F-USVT).NormL2() << endl
<< endl <<
"NullspaceDim() = " << svdF3x3.
NullspaceDim() << endl
<< endl;
return 0;
}