17 using namespace shogun;
20 :
CStringKernel<char>(0), width(0.0), degree(0), shift(0), window(0),
21 motif_positions_lhs(NULL), motif_positions_rhs(NULL),
22 position_weights(NULL), weights(NULL)
28 int32_t size,
float64_t w, int32_t d, int32_t s, int32_t wl)
29 :
CStringKernel<char>(size), width(w), degree(d), shift(s), window(wl),
30 motif_positions_lhs(NULL), motif_positions_rhs(NULL), position_weights(NULL), weights(NULL)
37 float64_t w, int32_t d, int32_t s, int32_t wl, int32_t size)
38 :
CStringKernel<char>(size), width(w), degree(d), shift(s), window(wl),
39 motif_positions_lhs(NULL), motif_positions_rhs(NULL), position_weights(NULL), weights(NULL)
58 SG_ERROR(
"Number of vectors does not agree (LHS: %d, Motif LHS: %d).\n",
61 SG_ERROR(
"Number of vectors does not agree (RHS: %d, Motif RHS: %d).\n",
77 SG_ERROR(
"Number of dimensions does not agree.\n");
90 bool free_avec, free_bvec;
94 int32_t alen_pos, blen_pos;
95 bool afree_pos, bfree_pos;
98 ASSERT(alen_pos==blen_pos);
99 int32_t num_pos=alen_pos;
105 for (int32_t p=0; p<num_pos; p++)
107 result_rbf+=
CMath::sq(positions_a[p]-positions_b[p]);
109 for (int32_t p2=0; p2<num_pos; p2++)
110 result_rbf+=
CMath::sq( (positions_a[p]-positions_a[p2]) - (positions_b[p]-positions_b[p2]) );
114 limit =
alen - positions_a[p];
119 result_wds+=
compute_wds(&avec[positions_a[p]], &bvec[positions_b[p]],
134 char* avec,
char* bvec, int32_t len)
138 for (int32_t i=0; i<
shift; i++)
142 for (int32_t i=0; i<len; i++)
148 for (int32_t j=0; (j<
degree) && (i+j<len); j++)
150 if (avec[i+j]!=bvec[i+j])
160 for (int32_t i=0; i<len; i++)
162 for (int32_t k=1; (k<=
shift) && (i+k<len); k++)
169 for (int32_t j=0; (j<
degree) && (i+j+k<len); j++)
171 if (avec[i+j+k]!=bvec[i+j])
177 for (int32_t j=0; (j<
degree) && (i+j+k<len); j++)
179 if (avec[i+j]!=bvec[i+j+k])
186 max_shift_vec[k-1] += sumi1 + sumi2 ;
191 for (int32_t i=0; i<
shift; i++)
192 result += max_shift_vec[i]/(2*(i+1)) ;