SHOGUN
v3.2.0
|
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 Gunnar Raetsch 00008 * Copyright (C) 1999-2009 Fraunhofer Institute FIRST and Max-Planck-Society 00009 */ 00010 00011 #ifndef __PLIFARRAY_H__ 00012 #define __PLIFARRAY_H__ 00013 00014 #include <shogun/lib/common.h> 00015 #include <shogun/mathematics/Math.h> 00016 #include <shogun/base/DynArray.h> 00017 #include <shogun/structure/PlifBase.h> 00018 00019 namespace shogun 00020 { 00021 00023 class CPlifArray: public CPlifBase 00024 { 00025 public: 00027 CPlifArray(); 00028 virtual ~CPlifArray(); 00029 00034 void add_plif(CPlifBase* new_plif); 00035 00037 void clear(); 00038 00043 int32_t get_num_plifs() 00044 { 00045 return m_array.get_num_elements(); 00046 } 00047 00053 virtual float64_t lookup_penalty( 00054 float64_t p_value, float64_t* svm_values) const; 00055 00061 virtual float64_t lookup_penalty( 00062 int32_t p_value, float64_t* svm_values) const; 00063 00065 virtual void penalty_clear_derivative(); 00066 00073 virtual void penalty_add_derivative( 00074 float64_t p_value, float64_t* svm_values, float64_t factor); 00075 00080 virtual float64_t get_max_value() const 00081 { 00082 return max_value; 00083 } 00084 00089 virtual float64_t get_min_value() const 00090 { 00091 return min_value; 00092 } 00093 00098 virtual bool uses_svm_values() const; 00099 00104 virtual int32_t get_max_id() const; 00105 00106 void get_used_svms(int32_t* num_svms, int32_t* svm_ids); 00107 00112 virtual void list_plif() const 00113 { 00114 SG_PRINT("CPlifArray(num_elements=%i, min_value=%1.2f, max_value=%1.2f)\n", m_array.get_num_elements(), min_value, max_value) 00115 for (int32_t i=0; i<m_array.get_num_elements(); i++) 00116 { 00117 SG_PRINT("%i. ", i) 00118 m_array[i]->list_plif() ; 00119 } 00120 } 00121 00123 virtual const char* get_name() const { return "PlifArray"; } 00124 00125 protected: 00127 DynArray<CPlifBase*> m_array; 00129 float64_t max_value; 00131 float64_t min_value; 00132 }; 00133 } 00134 #endif