3190 |
30 Mar 14 |
peter |
// $Id$ |
3190 |
30 Mar 14 |
peter |
2 |
|
3190 |
30 Mar 14 |
peter |
3 |
/* |
3190 |
30 Mar 14 |
peter |
Copyright (C) 2014 Peter Johansson |
3190 |
30 Mar 14 |
peter |
5 |
|
3190 |
30 Mar 14 |
peter |
This file is part of the yat library, http://dev.thep.lu.se/yat |
3190 |
30 Mar 14 |
peter |
7 |
|
3190 |
30 Mar 14 |
peter |
The yat library is free software; you can redistribute it and/or |
3190 |
30 Mar 14 |
peter |
modify it under the terms of the GNU General Public License as |
3190 |
30 Mar 14 |
peter |
published by the Free Software Foundation; either version 3 of the |
3190 |
30 Mar 14 |
peter |
License, or (at your option) any later version. |
3190 |
30 Mar 14 |
peter |
12 |
|
3190 |
30 Mar 14 |
peter |
The yat library is distributed in the hope that it will be useful, |
3190 |
30 Mar 14 |
peter |
but WITHOUT ANY WARRANTY; without even the implied warranty of |
3190 |
30 Mar 14 |
peter |
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
3190 |
30 Mar 14 |
peter |
General Public License for more details. |
3190 |
30 Mar 14 |
peter |
17 |
|
3190 |
30 Mar 14 |
peter |
You should have received a copy of the GNU General Public License |
3190 |
30 Mar 14 |
peter |
along with yat. If not, see <http://www.gnu.org/licenses/>. |
3190 |
30 Mar 14 |
peter |
20 |
*/ |
3190 |
30 Mar 14 |
peter |
21 |
|
3190 |
30 Mar 14 |
peter |
22 |
#include <config.h> |
3190 |
30 Mar 14 |
peter |
23 |
|
3190 |
30 Mar 14 |
peter |
24 |
#include "Suite.h" |
3190 |
30 Mar 14 |
peter |
25 |
|
3190 |
30 Mar 14 |
peter |
26 |
#include "yat/utility/KernelMatrix.h" |
3190 |
30 Mar 14 |
peter |
27 |
|
3190 |
30 Mar 14 |
peter |
28 |
#include <boost/range.hpp> |
3190 |
30 Mar 14 |
peter |
29 |
|
3190 |
30 Mar 14 |
peter |
30 |
#include <functional> |
3190 |
30 Mar 14 |
peter |
31 |
#include <string> |
3190 |
30 Mar 14 |
peter |
32 |
|
3190 |
30 Mar 14 |
peter |
33 |
using namespace theplu::yat; |
3190 |
30 Mar 14 |
peter |
34 |
using utility::KernelMatrix; |
3190 |
30 Mar 14 |
peter |
35 |
|
3190 |
30 Mar 14 |
peter |
36 |
struct CharCompare : std::binary_function<char, char, double> |
3190 |
30 Mar 14 |
peter |
37 |
{ |
3190 |
30 Mar 14 |
peter |
38 |
double operator()(char a, char b) const |
3190 |
30 Mar 14 |
peter |
39 |
{ |
3190 |
30 Mar 14 |
peter |
40 |
if (a==b) |
3190 |
30 Mar 14 |
peter |
41 |
return 1.0; |
3190 |
30 Mar 14 |
peter |
42 |
return -3.0; |
3190 |
30 Mar 14 |
peter |
43 |
} |
3190 |
30 Mar 14 |
peter |
44 |
}; |
3190 |
30 Mar 14 |
peter |
45 |
|
3190 |
30 Mar 14 |
peter |
46 |
int main(int argc, char* argv[]) |
3190 |
30 Mar 14 |
peter |
47 |
{ |
3190 |
30 Mar 14 |
peter |
48 |
test::Suite suite(argc, argv); |
3190 |
30 Mar 14 |
peter |
49 |
|
3190 |
30 Mar 14 |
peter |
50 |
std::string str1("An example string"); |
3190 |
30 Mar 14 |
peter |
51 |
std::string str2("An even longer string"); |
3190 |
30 Mar 14 |
peter |
52 |
|
3190 |
30 Mar 14 |
peter |
53 |
CharCompare comp; |
3190 |
30 Mar 14 |
peter |
54 |
KernelMatrix<std::string, std::string, CharCompare> km(str1, str2, comp); |
3190 |
30 Mar 14 |
peter |
55 |
suite.test_concept_container2d(km); |
3190 |
30 Mar 14 |
peter |
56 |
|
3190 |
30 Mar 14 |
peter |
57 |
suite.out() << "rows: " << km.rows() << "\n"; |
3190 |
30 Mar 14 |
peter |
58 |
suite.add(km.rows() == str1.size()); |
3190 |
30 Mar 14 |
peter |
59 |
suite.out() << "columns: " << km.rows() << "\n"; |
3190 |
30 Mar 14 |
peter |
60 |
suite.add(km.columns() == str2.size()); |
3190 |
30 Mar 14 |
peter |
61 |
suite.out() << km(3,3) << "\n"; |
3190 |
30 Mar 14 |
peter |
62 |
suite.add(km(3,3) == 1.0); |
3190 |
30 Mar 14 |
peter |
63 |
|
3190 |
30 Mar 14 |
peter |
64 |
return suite.return_value(); |
3190 |
30 Mar 14 |
peter |
65 |
} |