SHOGUN  v2.0.0
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
SparseSpatialSampleStringKernel.h
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) 2010 Soeren Sonnenburg
8  * Copyright (C) 2010 Berlin Institute of Technology
9  */
10 
11 #ifndef _SPARSESPATIALSAMPLESTRINGKERNEL_H___
12 #define _SPARSESPATIALSAMPLESTRINGKERNEL_H___
13 
14 #include <shogun/lib/common.h>
16 
17 namespace shogun
18 {
20  struct SSKFeatures
21  {
23  int *features;
25  int *group;
27  int n;
28  };
29 
35 {
36  public:
40 
47 
49 
56  virtual bool init(CFeatures* l, CFeatures* r);
57 
59  virtual void cleanup();
60 
66  {
67  return K_SPARSESPATIALSAMPLE;
68  }
69 
73  void set_d(int32_t max_distance)
74  {
75  ASSERT(d>0);
76  d=max_distance;
77  }
78 
80  int32_t get_d()
81  {
82  return d;
83  }
84 
88  void set_t(int32_t sequence_length)
89  {
90  ASSERT(t==2 || t==3);
91  t=sequence_length;
92  }
93 
95  int32_t get_t()
96  {
97  return t;
98  }
99 
104  virtual const char* get_name() const { return "SparseSpatialSampleStringKernel"; }
105 
106  protected:
115  virtual float64_t compute(int32_t idx_a, int32_t idx_b);
116 
124  SSKFeatures *extractTriple(int **S, int *len, int nStr, int d1, int d2);
131  SSKFeatures *extractDouble(int **S, int *len, int nStr, int d1);
136  void compute_double(int32_t idx_a, int32_t idx_b);
141  void compute_triple(int32_t idx_a, int32_t idx_b);
148  int* cntsrtna(int *sx, int k, int r, int na);
157  void countAndUpdate(int *outK, int *sx, int *g, int k, int r, int nStr);
158 
159  protected:
162  int32_t t;
163 
166  int32_t d;
167 
169  bool isVerbose;
170 };
171 }
172 #endif /* _SPARSESPATIALSAMPLESTRINGKERNEL_H___ */

SHOGUN Machine Learning Toolbox - Documentation