LinearByteKernel.h

Go to the documentation of this file.
00001 /*
00002  * This program is free software; you can redistribute it and/or modify
00003  * it under the terms of the GNU General Public License as published by
00004  * the Free Software Foundation; either version 3 of the License, or
00005  * (at your option) any later version.
00006  *
00007  * Written (W) 1999-2008 Soeren Sonnenburg
00008  * Copyright (C) 1999-2008 Fraunhofer Institute FIRST and Max-Planck-Society
00009  */
00010 
00011 #ifndef _LINEARBYTEKERNEL_H___
00012 #define _LINEARBYTEKERNEL_H___
00013 
00014 #include "lib/common.h"
00015 #include "kernel/SimpleKernel.h"
00016 #include "features/ByteFeatures.h"
00017 
00019 class CLinearByteKernel: public CSimpleKernel<BYTE>
00020 {
00021     public:
00028         CLinearByteKernel(INT size, bool do_rescale=true, DREAL scale=1.0);
00029 
00037         CLinearByteKernel(CByteFeatures* l, CByteFeatures *r, bool do_rescale=true, DREAL scale=1.0);
00038 
00039         virtual ~CLinearByteKernel();
00040 
00047         virtual bool init(CFeatures* l, CFeatures* r);
00048 
00050         virtual void cleanup();
00051 
00057         virtual bool load_init(FILE* src);
00058 
00064         virtual bool save_init(FILE* dest);
00065 
00070         virtual EKernelType get_kernel_type() { return K_LINEAR; }
00071 
00076         virtual const CHAR* get_name() { return "Linear"; }
00077 
00086         virtual bool init_optimization(INT num_suppvec, INT* sv_idx, DREAL* alphas);
00087 
00092         virtual bool delete_optimization();
00093 
00099         virtual DREAL compute_optimized(INT idx);
00100 
00102         virtual void clear_normal();
00103 
00109         virtual void add_to_normal(INT idx, DREAL weight);
00110 
00111     protected:
00120         virtual DREAL compute(INT idx_a, INT idx_b);
00121 
00123         virtual void init_rescale();
00124 
00125     protected:
00127         double scale;
00129         bool do_rescale;
00131         bool initialized;
00133         double* normal;
00134 };
00135 
00136 #endif /* _LINEARBYTEKERNEL_H__ */

SHOGUN Machine Learning Toolbox - Documentation