SHOGUN  v1.1.0
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
CustomKernel.cpp
Go to the documentation of this file.
1 /*
2  * This program is free software; you can redistribute it and/or modify
3  * it under the terms of the GNU General Public License as published by
4  * the Free Software Foundation; either version 3 of the License, or
5  * (at your option) any later version.
6  *
7  * Written (W) 1999-2009 Soeren Sonnenburg
8  * Copyright (C) 1999-2009 Fraunhofer Institute FIRST and Max-Planck-Society
9  */
10 
11 #include <shogun/lib/common.h>
15 #include <shogun/io/SGIO.h>
16 
17 using namespace shogun;
18 
19 void
20 CCustomKernel::init()
21 {
22  m_parameters->add(&kmatrix, "kmatrix", "Kernel matrix.");
23  m_parameters->add(&upper_diagonal, "upper_diagonal");
24 }
25 
27 : CKernel(10), kmatrix(), upper_diagonal(false)
28 {
29  init();
30 }
31 
33 : CKernel(10)
34 {
36 }
37 
39 : CKernel(10), upper_diagonal(false)
40 {
41  init();
43 }
44 
46 {
47  cleanup();
48 }
49 
50 bool CCustomKernel::dummy_init(int32_t rows, int32_t cols)
51 {
52  return init(new CDummyFeatures(rows), new CDummyFeatures(cols));
53 }
54 
55 bool CCustomKernel::init(CFeatures* l, CFeatures* r)
56 {
57  CKernel::init(l, r);
58 
59  SG_DEBUG( "num_vec_lhs: %d vs num_rows %d\n", l->get_num_vectors(), kmatrix.num_rows);
60  SG_DEBUG( "num_vec_rhs: %d vs num_cols %d\n", r->get_num_vectors(), kmatrix.num_cols);
63  return init_normalizer();
64 }
65 
66 void CCustomKernel::cleanup_custom()
67 {
68  SG_DEBUG("cleanup up custom kernel\n");
70  kmatrix.matrix=NULL;
71  upper_diagonal=false;
72  kmatrix.num_cols=0;
73  kmatrix.num_rows=0;
74 }
75 
77 {
78  cleanup_custom();
80 }
81 

SHOGUN Machine Learning Toolbox - Documentation