| pktools 2.6.7 Processing Kernel for geospatial data

Public Member Functions | Static Public Member Functions | Protected Attributes | List of all members
Kernel Class Referenceabstract
Inheritance diagram for Kernel:
[legend]
Collaboration diagram for Kernel:
[legend]

## Public Member Functions
| Kernel (int l, svm_node *const *x, const svm_parameter &param)
virtual Qfloat * | get_Q (int column, int len) const =0
virtual double * | get_QD () const =0
virtual void | swap_index (int i, int j) const
virtual Qfloat * | get_Q (int column, int len) const =0
virtual double * | get_QD () const =0
virtual void | swap_index (int i, int j) const =0

## Static Public Member Functions
static double | k_function (const svm_node *x, const svm_node *y, const svm_parameter &param)

## Protected Attributes
double(Kernel::* | kernel_function )(int i, int j) const

## Detailed Description

Definition at line 204 of file svm.cpp.

## Constructor & Destructor Documentation

## ◆ Kernel()

Kernel::Kernel | ( | int | l,
|  | svm_node *const * | x,
|  | const svm_parameter & | param
| ) |  |

Definition at line 255 of file svm.cpp.

256:kernel_type(param.kernel_type), degree(param.degree),
257 gamma(param.gamma), coef0(param.coef0)
258{
259 switch(kernel_type)
260 {
261 case LINEAR:
262 kernel_function = &Kernel::kernel_linear;
263 break;
264 case POLY:
265 kernel_function = &Kernel::kernel_poly;
266 break;
267 case RBF:
268 kernel_function = &Kernel::kernel_rbf;
269 break;
270 case SIGMOID:
271 kernel_function = &Kernel::kernel_sigmoid;
272 break;
273 case PRECOMPUTED:
274 kernel_function = &Kernel::kernel_precomputed;
275 break;
276 }
277
278 clone(x,x_,l);
279
280 if(kernel_type == RBF)
281 {
282 x_square = new double[l];
283 for(int i=0;i<l;i++)
284 x_square[i] = dot(x[i],x[i]);
285 }
286 else
287 x_square = 0;
288}

## ◆ ~Kernel()

Kernel::~Kernel | ( |  | ) |
| virtual

Definition at line 290 of file svm.cpp.

291{
292 delete[] x;
293 delete[] x_square;
294}

## Member Function Documentation

## ◆ get_Q()

virtual Qfloat * Kernel::get_Q | ( | int | column,
|  | int | len
| ) |  | const
| pure virtual

Implements QMatrix.

## ◆ get_QD()

virtual double * Kernel::get_QD | ( |  | ) | const
| pure virtual

Implements QMatrix.

## ◆ k_function()

double Kernel::k_function | ( | const svm_node * | x,
|  | const svm_node * | y,
|  | const svm_parameter & | param
| ) |  |
| static

Definition at line 318 of file svm.cpp.

320{
321 switch(param.kernel_type)
322 {
323 case LINEAR:
324 return dot(x,y);
325 case POLY:
326 return powi(param.gamma*dot(x,y)+param.coef0,param.degree);
327 case RBF:
328 {
329 double sum = 0;
330 while(x->index != -1 && y->index !=-1)
331 {
332 if(x->index == y->index)
333 {
334 double d = x->value - y->value;
335 sum += d*d;
336 ++x;
337 ++y;
338 }
339 else
340 {
341 if(x->index > y->index)
342 {
343 sum += y->value * y->value;
344 ++y;
345 }
346 else
347 {
348 sum += x->value * x->value;
349 ++x;
350 }
351 }
352 }
353
354 while(x->index != -1)
355 {
356 sum += x->value * x->value;
357 ++x;
358 }
359
360 while(y->index != -1)
361 {
362 sum += y->value * y->value;
363 ++y;
364 }
365
366 return exp(-param.gamma*sum);
367 }
368 case SIGMOID:
369 return tanh(param.gamma*dot(x,y)+param.coef0);
370 case PRECOMPUTED: //x: test (validation), y: SV
371 return x[(int)(y->value)].value;
372 default:
373 return 0; // Unreachable
374 }
375}

## ◆ swap_index()

virtual void Kernel::swap_index | ( | int | i,
|  | int | j
| ) |  | const
| inline virtual

Implements QMatrix.

Definition at line 213 of file svm.cpp.

214 {
215 swap(x[i],x[j]);
216 if(x_square) swap(x_square[i],x_square[j]);
217 }

## Member Data Documentation

## ◆ kernel_function

double(Kernel::* Kernel::kernel_function) (int i, int j) const
| protected

Definition at line 220 of file svm.cpp.

The documentation for this class was generated from the following file:

- /tmp/slackdce/slackrepo.NvCr9x/build_pktools/PKTOOLS-2.6.7.6/src/algorithms/svm.cpp