testsvd.cpp

Go to the documentation of this file.
00001 #include "VecMat.h"
00002 #include <iostream>
00003 #include "UniformRNG.h"
00004 using namespace std;
00005 int main()
00006 {
00007         const size_t n = 3;
00008         const size_t m = 4;
00009         UniformRNG Random;
00010         gplib::rmat A(m,n);
00011         for (size_t i = 0; i < m; ++i)
00012                 for(size_t j = 0; j < n; ++j)
00013                         A(i,j) = Random.GetNumber();
00014         cout << "A: " << endl << A << endl;
00015         gplib::rvec s(n);
00016         gplib::rmat u(m,n), vt(n,n);
00017         boost::numeric::bindings::lapack::gesvd(A,s,u,vt);
00018         cout << "A: " << endl << A << endl;
00019         cout << "s: " << endl << s << endl;
00020         cout << "u: " << endl << u << endl;
00021         cout << "vt: " << endl << vt << endl;
00022         boost::numeric::ublas::banded_matrix<double,boost::numeric::ublas::column_major> sm(n,n,0,0);
00023         for (size_t i = 0; i < n; ++i)
00024                 sm(i,i) = s(i);
00025                 boost::numeric::ublas::matrix<double,boost::numeric::ublas::column_major> temp =        prod(sm,vt);
00026         cout << "Mult: " << prod(u,temp) << endl;
00027 }

Generated on Mon Sep 15 12:54:34 2008 for GPLIB++ by  doxygen 1.5.5