17 using namespace shogun;
27 int32_t size, int32_t l, int32_t
id, int32_t od)
40 int32_t len, int32_t
id, int32_t od)
65 const int32_t PYRAL = 2 *
length - 1;
66 const int32_t pyra_len = num_features-PYRAL+1;
67 const int32_t pyra_len2 = (int32_t) pyra_len/2;
74 SG_INFO(
"initializing pyramid weights: size=%ld length=%i\n",
85 PYRAL_pot = DEGREE1_1 ? 1.0 : PYRAL_;
102 for (j = 0; j < pyra_len; j++)
104 for (j = 0; j < pyra_len; j++)
120 float64_t CSimpleLocalityImprovedStringKernel::dot_pyr (
const char*
const x1,
121 const char*
const x2,
const int32_t NOF_NTS,
const int32_t NTWIDTH,
122 const int32_t DEGREE1,
const int32_t DEGREE2,
float64_t *pyra)
124 const int32_t PYRAL = 2*NTWIDTH-1;
125 int32_t pyra_len, pyra_len2;
128 int32_t DEGREE1_1 = (DEGREE1 & 0x1)==0;
129 int32_t DEGREE1_1n = (DEGREE1 & ~0x1)!=0;
130 int32_t DEGREE1_2 = (DEGREE1 & 0x2)!=0;
131 int32_t DEGREE1_3 = (DEGREE1 & ~0x3)!=0;
132 int32_t DEGREE1_4 = (DEGREE1 & 0x4)!=0;
135 PYRAL_pot = DEGREE1_1 ? 1.0 : PYRAL_;
139 if (DEGREE1_2) PYRAL_pot *= PYRAL_;
143 if (DEGREE1_4) PYRAL_pot *= PYRAL_;
148 ASSERT((DEGREE1 & ~0x7) == 0);
149 ASSERT((DEGREE2 & ~0x7) == 0);
151 pyra_len = NOF_NTS-PYRAL+1;
152 pyra_len2 = (int32_t) pyra_len/2;
155 for (j = 0; j < pyra_len; j++)
157 for (j = 0; j < pyra_len; j++)
158 pyra[j] /= PYRAL_pot;
161 register int32_t conv;
167 for (j = 0; j < PYRAL; j++)
168 conv += (x1[j] == x2[j]) ? 1 : 0;
170 for (i = 0; i < NOF_NTS-PYRAL+1; i++)
174 conv += ((x1[i+PYRAL-1] == x2[i+PYRAL-1]) ? 1 : 0 ) -
175 ((x1[i-1] == x2[i-1]) ? 1 : 0);
178 pot2 = (DEGREE1_1) ? 1.0 : conv2;
184 if (DEGREE1_3 && DEGREE1_4)
191 pot = ((DEGREE2 & 0x1) == 0) ? 1.0 : sum;
192 if ((DEGREE2 & ~0x1) != 0)
195 if ((DEGREE2 & 0x2) != 0)
197 if ((DEGREE2 & ~0x3) != 0)
200 if ((DEGREE2 & 0x4) != 0)
208 int32_t idx_a, int32_t idx_b)
211 bool free_avec, free_bvec;
229 void CSimpleLocalityImprovedStringKernel::init()
242 "pyramid_weights",
"Pyramid weights.");