17 using namespace shogun;
26 int32_t size, int32_t l, int32_t
id, int32_t od)
38 int32_t len, int32_t
id, int32_t od)
62 const int32_t PYRAL = 2 *
length - 1;
63 const int32_t pyra_len = num_features-PYRAL+1;
64 const int32_t pyra_len2 = (int32_t) pyra_len/2;
71 SG_INFO(
"initializing pyramid weights: size=%ld length=%i\n",
82 PYRAL_pot = DEGREE1_1 ? 1.0 : PYRAL_;
99 for (j = 0; j < pyra_len; j++)
101 for (j = 0; j < pyra_len; j++)
117 float64_t CSimpleLocalityImprovedStringKernel::dot_pyr (
const char*
const x1,
118 const char*
const x2,
const int32_t NOF_NTS,
const int32_t NTWIDTH,
119 const int32_t DEGREE1,
const int32_t DEGREE2,
float64_t *pyra)
121 const int32_t PYRAL = 2*NTWIDTH-1;
122 int32_t pyra_len, pyra_len2;
125 int32_t DEGREE1_1 = (DEGREE1 & 0x1)==0;
126 int32_t DEGREE1_1n = (DEGREE1 & ~0x1)!=0;
127 int32_t DEGREE1_2 = (DEGREE1 & 0x2)!=0;
128 int32_t DEGREE1_3 = (DEGREE1 & ~0x3)!=0;
129 int32_t DEGREE1_4 = (DEGREE1 & 0x4)!=0;
132 PYRAL_pot = DEGREE1_1 ? 1.0 : PYRAL_;
136 if (DEGREE1_2) PYRAL_pot *= PYRAL_;
140 if (DEGREE1_4) PYRAL_pot *= PYRAL_;
145 ASSERT((DEGREE1 & ~0x7) == 0);
146 ASSERT((DEGREE2 & ~0x7) == 0);
148 pyra_len = NOF_NTS-PYRAL+1;
149 pyra_len2 = (int32_t) pyra_len/2;
152 for (j = 0; j < pyra_len; j++)
154 for (j = 0; j < pyra_len; j++)
155 pyra[j] /= PYRAL_pot;
158 register int32_t conv;
164 for (j = 0; j < PYRAL; j++)
165 conv += (x1[j] == x2[j]) ? 1 : 0;
167 for (i = 0; i < NOF_NTS-PYRAL+1; i++)
171 conv += ((x1[i+PYRAL-1] == x2[i+PYRAL-1]) ? 1 : 0 ) -
172 ((x1[i-1] == x2[i-1]) ? 1 : 0);
175 pot2 = (DEGREE1_1) ? 1.0 : conv2;
181 if (DEGREE1_3 && DEGREE1_4)
188 pot = ((DEGREE2 & 0x1) == 0) ? 1.0 : sum;
189 if ((DEGREE2 & ~0x1) != 0)
192 if ((DEGREE2 & 0x2) != 0)
194 if ((DEGREE2 & ~0x3) != 0)
197 if ((DEGREE2 & 0x4) != 0)
205 int32_t idx_a, int32_t idx_b)
208 bool free_avec, free_bvec;
226 void CSimpleLocalityImprovedStringKernel::init()
239 "pyramid_weights",
"Pyramid weights.");