SHOGUN  v3.0.1
 全部  命名空间 文件 函数 变量 类型定义 枚举 枚举值 友元 宏定义  
SparseSpatialSampleStringKernel.h
浏览该文件的文档.
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___ */
EKernelType
Definition: Kernel.h:51
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:203
double float64_t
Definition: common.h:48
Sparse Spatial Sample String Kernel by Pavel Kuksa pkuksa@cs.rutgers.edu and Vladimir Pavlovic vladim...
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:62
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:24

SHOGUN Machine Learning Toolbox - Documentation