source: trunk/test/normalization_test.cc @ 1445

Last change on this file since 1445 was 1445, checked in by Peter, 15 years ago

adding Centralizer

  • Property svn:eol-style set to native
  • Property svn:keywords set to Id
File size: 2.1 KB
Line 
1// $Id: normalization_test.cc 1445 2008-08-27 22:53:11Z peter $
2
3/*
4  Copyright (C) 2008 Peter Johansson
5
6  This file is part of the yat library, http://trac.thep.lu.se/yat
7
8  The yat library is free software; you can redistribute it and/or
9  modify it under the terms of the GNU General Public License as
10  published by the Free Software Foundation; either version 2 of the
11  License, or (at your option) any later version.
12
13  The yat library is distributed in the hope that it will be useful,
14  but WITHOUT ANY WARRANTY; without even the implied warranty of
15  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16  General Public License for more details.
17
18  You should have received a copy of the GNU General Public License
19  along with this program; if not, write to the Free Software
20  Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
21  02111-1307, USA.
22*/
23
24#include "Suite.h"
25
26#include "yat/normalization/QuantileNormalizer.h"
27#include "yat/normalization/Centralizer.h"
28
29#include "yat/utility/Matrix.h"
30
31#include <vector>
32
33using namespace theplu::yat;
34void test_centralizer(test::Suite&);
35void test_quantile_normalize(test::Suite&);
36
37int main(int argc, char* argv[])
38{ 
39  test::Suite suite(argc, argv);
40  suite.err() << "testing normalizations ... " << std::endl;
41
42  test_centralizer(suite);
43  test_quantile_normalize(suite);
44
45  return suite.return_value();
46}
47
48
49void test_centralizer(test::Suite& suite)
50{
51  suite.err() << "Testing Centralizer\n";
52  std::vector<double> vec;
53  vec.push_back(1);
54  vec.push_back(2);
55  vec.push_back(3);
56  normalization::Centralizer<> c;
57  c(vec.begin(), vec.end(), vec.begin());
58  for (size_t i=0; i<vec.size(); ++i)
59    suite.add(suite.equal(vec[i], static_cast<double>(i)-1.0));
60}
61
62
63void test_quantile_normalize(test::Suite& suite)
64{
65  suite.err() << "Testing QuantileNormalizer\n";
66 
67  utility::Matrix m(2,2);
68  m(0,0) = 0;
69  m(0,1) = 10;
70  m(1,0) = 2;
71  m(1,1) = 4;
72  normalization::QuantileNormalizer qn;
73  qn(m);
74  suite.err() << "Testing m(0,0)\n";
75  suite.add(suite.equal(m(0,0), 2));
76  suite.err() << "Testing m(0,1)\n";
77  suite.add(suite.equal(m(0,1), 6));
78  suite.err() << "Testing m(1,0)\n";
79  suite.add(suite.equal(m(1,0), 6));
80  suite.err() << "Testing m(1,1)\n";
81  suite.add(suite.equal(m(1,1), 2));
82}
83
Note: See TracBrowser for help on using the repository browser.