31 #include <MathAlgo/SVD.hh>
32 #include <MathAlgo/SVD3x3.hh>
33 #include <Base/Math/Random.hh>
34 #include <Base/Math/Matrix3x3.hh>
35 #include <Base/Math/Matrix.hh>
40 #define F_SVD_THRESH 0.1
46 F[0][0] =0.00075284066373225704;
47 F[0][1] =-0.099906426438442303;
48 F[0][2] =0.16267766990357244;
49 F[1][0] =0.10333163045064053;
50 F[1][1] =0.0014727467665194025;
51 F[1][2] =0.6803859609102173;
52 F[2][0] =-0.16234020366691171;
53 F[2][1] =-0.68087420277635458;
54 F[2][2] =0.0021896762792443826;
55 F.PrintPretty(cout,
"F");
58 SVD3x3 svdF3x3(F, F_SVD_THRESH);
60 for (
int i = 0; i < 3; i++)
61 S[i][i] = svdF3x3.GetS()[i];
63 cout << endl <<
"-- SVD3x3 --" << endl;
64 svdF3x3.GetU().PrintPretty(cout,
"U");
65 S.PrintPretty(cout,
"S");
66 svdF3x3.GetVT().PrintPretty(cout,
"VT");
71 cout << endl <<
"|F - U*S*VT| = " <<
Matrix<double>(F-USVT).NormL2() << endl
72 << endl <<
"NullspaceDim() = " << svdF3x3.NullspaceDim() << endl;
75 SVD svdF(F, F_SVD_THRESH);
76 for (
int i = 0; i < 3; i++)
77 S[i][i] = svdF.GetS()[i];
79 cout << endl <<
"-- SVD --" << endl;
80 svdF.GetU().PrintPretty(cout,
"U");
81 S.PrintPretty(cout,
"S");
82 svdF.GetVT().PrintPretty(cout,
"VT");
84 USVT = svdF.GetU() * S * svdF.GetVT();
87 cout << endl <<
"|F - U*S*VT| = " <<
Matrix<double>(F-USVT).NormL2() << endl
88 << endl <<
"NullspaceDim() = " << svdF3x3.NullspaceDim() << endl
std::ostream & PrintPretty(std::ostream &s, const std::string &name="", const int width=8, const bool alignLeft=true) const
computes and holds the singular value decomposition of a rectangular (not necessarily quadratic) Matr...
singular value decomposition for 3x3 matrices