source: trunk/test/pca_test.cc @ 1659

Last change on this file since 1659 was 1487, checked in by Jari Häkkinen, 13 years ago

Addresses #436. GPL license copy reference should also be updated.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 1.5 KB
Line 
1// $Id: pca_test.cc 1487 2008-09-10 08:41:36Z jari $
2
3/*
4  Copyright (C) 2003 Daniel Dalevi
5  Copyright (C) 2004 Jari Häkkinen
6  Copyright (C) 2005 Peter Johansson
7  Copyright (C) 2006 Jari Häkkinen
8  Copyright (C) 2007, 2008 Jari Häkkinen, Peter Johansson
9
10  This file is part of the yat library, http://dev.thep.lu.se/yat
11
12  The yat library is free software; you can redistribute it and/or
13  modify it under the terms of the GNU General Public License as
14  published by the Free Software Foundation; either version 3 of the
15  License, or (at your option) any later version.
16
17  The yat library is distributed in the hope that it will be useful,
18  but WITHOUT ANY WARRANTY; without even the implied warranty of
19  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
20  General Public License for more details.
21
22  You should have received a copy of the GNU General Public License
23  along with yat. If not, see <http://www.gnu.org/licenses/>.
24*/
25
26#include "Suite.h"
27
28#include "yat/utility/Matrix.h"
29#include "yat/utility/PCA.h"
30
31#include <cmath>
32#include <fstream>
33#include <string>
34#include <vector>
35
36
37int main(int argc, char* argv[])
38{
39  using namespace theplu::yat;
40  test::Suite suite(argc, argv);
41  utility::Matrix A( 3, 4 );
42  for( size_t i = 0; i < 3; ++i )
43    for( size_t j = 0; j < 4; ++j )
44      A(i,j)= sin( static_cast<double>(i+j+2+(i+1)*(j+1)) );
45  A.transpose();
46  utility::PCA pca(A);
47  for (size_t i=1; i<pca.eigenvalues().size(); ++i)
48    if (!suite.add(pca.eigenvalues()(i-1)>=pca.eigenvalues()(i)))
49      suite.err() << "eigenvalues not in non-increasing order\n";
50
51  return suite.return_value();
52}
53
Note: See TracBrowser for help on using the repository browser.