STK++ 0.9.13
tutoSvd.cpp
Go to the documentation of this file.
1#include <STKpp.h>
2using namespace STK;
4int main(int argc, char** argv)
5{
6 ArrayXX a(5,4), usvt;
7 a << 0, 1, 2, 3,
8 2, 3, 4, 5,
9 2, 1, 6, 7,
10 0, 3,-1, 2,
11 3,-1, 1, 1;
12 stk_cout << _T("STK++ Svd decomposition:\n");
13 stk_cout << _T("------------------------\n");
14 Svd<ArrayXX> s(a); s.run();
15 stk_cout << _T("Singular values:\n");
16 stk_cout << s.D();
17 stk_cout << _T("\nUDV^T matrix:\n");
18 stk_cout << s.U()*s.D()*s.V().transpose();
19 stk_cout << _T("\nlapack Svd decomposition:\n");
20 stk_cout << _T("---------------------------\n");
21 lapack::Svd ls(a); ls.run();
22 stk_cout << _T("Singular values:\n");
23 stk_cout << ls.D().transpose();
24 stk_cout << _T("\nUDV^T matrix:\n");
25 stk_cout << ls.U()*ls.D().diagonalize()*ls.V().transpose();
26 return 0;
27}
#define stk_cout
Standard stk output stream.
#define _T(x)
Let x unmodified.
This file include all the header files of the STK++ project.
virtual bool run()
implement the run method
Definition STK_ISvd.h:155
ArrayD const & D() const
Definition STK_ISvd.h:152
ArrayU const & U() const
Definition STK_ISvd.h:148
ArrayV const & V() const
Definition STK_ISvd.h:150
The class Svd compute the Singular Value Decomposition of a Array with the Golub-Reinsch Algorithm.
Definition STK_Svd.h:117
The namespace STK is the main domain space of the Statistical ToolKit project.
int main(int argc, char **argv)
Definition tutoSvd.cpp:4