SHOGUN  4.2.0
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules 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/config.h>
15 
16 #include <shogun/lib/common.h>
18 
19 namespace shogun
20 {
22  struct SSKFeatures
23  {
25  int *features;
27  int *group;
29  int n;
30  };
31 
37 {
38  public:
42 
49 
51 
58  virtual bool init(CFeatures* l, CFeatures* r);
59 
61  virtual void cleanup();
62 
68  {
69  return K_SPARSESPATIALSAMPLE;
70  }
71 
75  void set_d(int32_t max_distance)
76  {
77  ASSERT(d>0)
78  d=max_distance;
79  }
80 
82  int32_t get_d()
83  {
84  return d;
85  }
86 
90  void set_t(int32_t sequence_length)
91  {
92  ASSERT(t==2 || t==3)
93  t=sequence_length;
94  }
95 
97  int32_t get_t()
98  {
99  return t;
100  }
101 
106  virtual const char* get_name() const { return "SparseSpatialSampleStringKernel"; }
107 
108  protected:
117  virtual float64_t compute(int32_t idx_a, int32_t idx_b);
118 
126  SSKFeatures *extractTriple(int **S, int *len, int nStr, int d1, int d2);
133  SSKFeatures *extractDouble(int **S, int *len, int nStr, int d1);
138  void compute_double(int32_t idx_a, int32_t idx_b);
143  void compute_triple(int32_t idx_a, int32_t idx_b);
150  int* cntsrtna(int *sx, int k, int r, int na);
159  void countAndUpdate(int *outK, int *sx, int *g, int k, int r, int nStr);
160 
161  protected:
164  int32_t t;
165 
168  int32_t d;
169 
171  bool isVerbose;
172 };
173 }
174 #endif /* _SPARSESPATIALSAMPLESTRINGKERNEL_H___ */
EKernelType
Definition: Kernel.h:57
SSKFeatures * extractTriple(int **S, int *len, int nStr, int d1, int d2)
virtual bool init(CFeatures *l, CFeatures *r)
#define ASSERT(x)
Definition: SGIO.h:201
double float64_t
Definition: common.h:50
Sparse Spatial Sample String Kernel by Pavel Kuksa pkuksa@cs.rutgers.edu and Vladimir Pavlovic vladim...
all of classes and functions are contained in the shogun namespace
Definition: class_list.h:18
virtual float64_t compute(int32_t idx_a, int32_t idx_b)
The class Features is the base class of all feature objects.
Definition: Features.h:68
SSKFeatures * extractDouble(int **S, int *len, int nStr, int d1)
void countAndUpdate(int *outK, int *sx, int *g, int k, int r, int nStr)
Template class StringKernel, is the base class of all String Kernels.
Definition: StringKernel.h:26

SHOGUN Machine Learning Toolbox - Documentation