SparseLinearKernel.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 _SPARSELINEARKERNEL_H___
00012 #define _SPARSELINEARKERNEL_H___
00013 
00014 #include "lib/common.h"
00015 #include "kernel/SparseKernel.h"
00016 #include "features/SparseFeatures.h"
00017 
00024 class CSparseLinearKernel: public CSparseKernel<float64_t>
00025 {
00026     public:
00029         CSparseLinearKernel();
00030 
00036         CSparseLinearKernel(
00037             CSparseFeatures<float64_t>* l, CSparseFeatures<float64_t>* r);
00038 
00039         virtual ~CSparseLinearKernel();
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_SPARSELINEAR; }
00071 
00076         virtual const char* get_name() { return "SparseLinear" ; }
00077 
00086         virtual bool init_optimization(int32_t num_suppvec, int32_t* sv_idx,
00087             float64_t* alphas);
00088 
00093         virtual bool delete_optimization();
00094 
00100         virtual float64_t compute_optimized(int32_t idx);
00101 
00103         virtual void clear_normal();
00104 
00110         virtual void add_to_normal(int32_t idx, float64_t weight);
00111 
00117         inline const float64_t* get_normal(int32_t& len)
00118         {
00119             len=normal_length;
00120             return normal;
00121         }
00122 
00123     protected:
00132         virtual float64_t compute(int32_t idx_a, int32_t idx_b);
00133 
00134     protected:
00136         float64_t* normal;
00138         int32_t normal_length;
00139 };
00140 
00141 #endif /* _SPARSELINEARKERNEL_H__ */

SHOGUN Machine Learning Toolbox - Documentation