52 -1, 0, 0, 2, -5, 3, 7,
53 0, -3, -1, -2, -4, -3, -3, 8,
54 -2, 0, 1, -2, -4, 1, 0, -3, 11,
55 -2, -5, -5, -5, -2, -4, -5, -6, -5, 6,
56 -2, -3, -5, -5, -2, -3, -4, -5, -4, 2, 6,
57 -1, 3, 0, -1, -5, 2, 1, -2, -1, -4, -4, 7,
58 -1, -2, -3, -5, -2, -1, -3, -4, -2, 2, 3, -2, 8,
59 -3, -4, -5, -5, -4, -5, -5, -5, -2, 0, 1, -5, 0, 9,
60 -1, -3, -3, -2, -4, -2, -2, -3, -3, -4, -4, -2, -4, -5, 11,
61 2, -1, 1, 0, -1, 0, 0, 0, -1, -4, -4, 0, -2, -4, -1, 6,
62 0, -2, 0, -2, -1, -1, -1, -2, -3, -1, -2, -1, -1, -3, -2, 2, 7,
63 -4, -4, -6, -6, -3, -3, -4, -4, -4, -4, -2, -4, -2, 1, -6, -4, -4, 16,
64 -3, -3, -3, -5, -4, -2, -3, -5, 3, -2, -2, -3, -1, 4, -4, -3, -2, 3, 10,
65 0, -4, -4, -5, -1, -3, -4, -5, -5, 4, 1, -3, 1, -1, -4, -2, 0, -4, -2, 6};
68 static int32_t
BINDEX(int32_t i, int32_t j)
70 return (((i)>(j))?(j)+(((i)*(i+1))/2):(i)+(((j)*(j+1))/2));
85 #define LOGP(x,y) LogSum(x,y)
102 init_static_variables();
113 init_static_variables();
145 void CLocalAlignmentStringKernel::init_logsum(){
152 int32_t CLocalAlignmentStringKernel::LogSum(int32_t p1, int32_t p2)
155 static int32_t firsttime=1;
164 if (diff>=LOGSUM_TBL)
166 else if (diff<=-LOGSUM_TBL)
171 return p2+logsum_lookup[-diff];
178 return (p1-p2>50.) ? p1 : p1+log(1.+exp(p2-p1));
180 return (p2-p1>50.) ? p2 : p2+log(1.+exp(p1-p2));
184 void CLocalAlignmentStringKernel::init_static_variables()
195 isAA = SG_CALLOC(int32_t, 256);
200 for (i=0 ; i<NAA*(NAA+1)/2; i++)
214 float64_t CLocalAlignmentStringKernel::LAkernelcompute(
215 int32_t* aaX, int32_t* aaY,
216 int32_t nX, int32_t nY )
245 logM=SG_CALLOC(int32_t, 2*cl);
246 logX=SG_CALLOC(int32_t, 2*cl);
247 logY=SG_CALLOC(int32_t, 2*cl);
248 logX2=SG_CALLOC(int32_t, 2*cl);
249 logY2=SG_CALLOC(int32_t, 2*cl);
256 for (j=0; j<cl; j++) {
274 for (i=1; i<=nX; i++) {
285 for (j=1; j<=nY; j++) {
299 logX2[curpos]=
LOGP(logM[frompos], logX2[frompos]);
311 aux=
LOGP(logM[frompos], logY2[frompos]);
312 logY2[curpos]=
LOGP(aux, logX2[frompos]);
319 aux=
LOGP(logX[frompos], logY[frompos]);
320 aux2=
LOGP(0, logM[frompos]);
341 aux=
LOGP(logX2[curpos], logY2[curpos]);
342 aux2=
LOGP(0, logM[curpos]);
374 if ( (lx<1) || (ly<1) )
379 aax = SG_CALLOC(int32_t, lx);
380 aay = SG_CALLOC(int32_t, ly);
386 if (
isAA[toupper(x[i])])
387 aax[j++]=
aaIndex[toupper(x[i])-
'A'];
391 if (
isAA[toupper(y[i])])
392 aay[j++]=
aaIndex[toupper(y[i])-
'A'];
397 float64_t result=LAkernelcompute(aax, aay, lx, ly);
409 void CLocalAlignmentStringKernel::init()
static int32_t BINDEX(int32_t i, int32_t j)
virtual bool set_normalizer(CKernelNormalizer *normalizer)
static const char * aaList
static int32_t logsum_lookup[LOGSUM_TBL]
static const int32_t blosum[]
virtual bool init_normalizer()
CFeatures * rhs
feature vectors to occur on right hand side
virtual float64_t compute(int32_t idx_a, int32_t idx_b)
all of classes and functions are contained in the shogun namespace
virtual ~CLocalAlignmentStringKernel()
virtual bool init(CFeatures *l, CFeatures *r)
CFeatures * lhs
feature vectors to occur on left hand side
The class Features is the base class of all feature objects.
friend class CSqrtDiagKernelNormalizer
CLocalAlignmentStringKernel(int32_t size=0)
Template class StringKernel, is the base class of all String Kernels.