16 using namespace shogun;
19 :
CStringKernel<char>(0), width(0.0), degree(0), shift(0), window(0),
20 motif_positions_lhs(NULL), motif_positions_rhs(NULL),
21 position_weights(NULL), weights(NULL)
27 int32_t size,
float64_t w, int32_t d, int32_t s, int32_t wl)
28 :
CStringKernel<char>(size), width(w), degree(d), shift(s), window(wl),
29 motif_positions_lhs(NULL), motif_positions_rhs(NULL), position_weights(NULL), weights(NULL)
36 float64_t w, int32_t d, int32_t s, int32_t wl, int32_t size)
37 :
CStringKernel<char>(size), width(w), degree(d), shift(s), window(wl),
38 motif_positions_lhs(NULL), motif_positions_rhs(NULL), position_weights(NULL), weights(NULL)
57 SG_ERROR(
"Number of vectors does not agree (LHS: %d, Motif LHS: %d).\n",
60 SG_ERROR(
"Number of vectors does not agree (RHS: %d, Motif RHS: %d).\n",
76 SG_ERROR(
"Number of dimensions does not agree.\n");
89 bool free_avec, free_bvec;
93 int32_t alen_pos, blen_pos;
94 bool afree_pos, bfree_pos;
97 ASSERT(alen_pos==blen_pos);
98 int32_t num_pos=alen_pos;
104 for (int32_t p=0; p<num_pos; p++)
106 result_rbf+=
CMath::sq(positions_a[p]-positions_b[p]);
108 for (int32_t p2=0; p2<num_pos; p2++)
109 result_rbf+=
CMath::sq( (positions_a[p]-positions_a[p2]) - (positions_b[p]-positions_b[p2]) );
113 limit =
alen - positions_a[p];
118 result_wds+=
compute_wds(&avec[positions_a[p]], &bvec[positions_b[p]],
133 char* avec,
char* bvec, int32_t len)
137 for (int32_t i=0; i<
shift; i++)
141 for (int32_t i=0; i<len; i++)
147 for (int32_t j=0; (j<
degree) && (i+j<len); j++)
149 if (avec[i+j]!=bvec[i+j])
159 for (int32_t i=0; i<len; i++)
161 for (int32_t k=1; (k<=
shift) && (i+k<len); k++)
168 for (int32_t j=0; (j<
degree) && (i+j+k<len); j++)
170 if (avec[i+j+k]!=bvec[i+j])
176 for (int32_t j=0; (j<
degree) && (i+j+k<len); j++)
178 if (avec[i+j]!=bvec[i+j+k])
185 max_shift_vec[k-1] += sumi1 + sumi2 ;
190 for (int32_t i=0; i<
shift; i++)
191 result += max_shift_vec[i]/(2*(i+1)) ;
219 SG_ADD(&
degree,
"degree",
"the degree of weighted degree kernel part",
222 "the shift of weighted degree with shifts kernel part",
MS_AVAILABLE);