Public Member Functions | |
CCustomKernel () | |
CCustomKernel (CKernel *k) | |
virtual | ~CCustomKernel () |
virtual float32_t * | get_kernel_matrix_shortreal (int32_t &m, int32_t &n, float32_t *target=NULL) |
virtual bool | dummy_init (int32_t rows, int32_t cols) |
virtual bool | init (CFeatures *l, CFeatures *r) |
virtual void | cleanup () |
virtual bool | load_init (FILE *src) |
virtual bool | save_init (FILE *dest) |
virtual EKernelType | get_kernel_type () |
virtual EFeatureType | get_feature_type () |
virtual EFeatureClass | get_feature_class () |
virtual const char * | get_name () |
bool | set_triangle_kernel_matrix_from_triangle (const float64_t *km, int32_t len) |
bool | set_triangle_kernel_matrix_from_full (const float64_t *km, int32_t rows, int32_t cols) |
bool | set_full_kernel_matrix_from_full (const float64_t *km, int32_t rows, int32_t cols) |
Protected Member Functions | |
virtual float64_t | compute (int32_t row, int32_t col) |
Protected Attributes | |
float32_t * | kmatrix |
int32_t | num_rows |
int32_t | num_cols |
bool | upper_diagonal |
This kernel allows for custom user provided kernel matrices. For squared training matrices it allows to store only the upper triangle of the kernel to save memory: Full symmetric kernel matrices can be stored as is or can be internally converted into (or directly given in) upper triangle representation. Also note that values are stored as 32bit floats.
Definition at line 28 of file CustomKernel.h.
CCustomKernel::CCustomKernel | ( | ) |
default constructor
Definition at line 17 of file CustomKernel.cpp.
CCustomKernel::CCustomKernel | ( | CKernel * | k | ) |
constructor
compute custom kernel from given kernel matrix
k | kernel matrix |
Definition at line 22 of file CustomKernel.cpp.
CCustomKernel::~CCustomKernel | ( | ) | [virtual] |
Definition at line 65 of file CustomKernel.cpp.
void CCustomKernel::cleanup | ( | ) | [virtual] |
virtual float64_t CCustomKernel::compute | ( | int32_t | row, | |
int32_t | col | |||
) | [protected, virtual] |
compute kernel function
row | row | |
col | col |
Implements CKernel.
Definition at line 153 of file CustomKernel.h.
bool CCustomKernel::dummy_init | ( | int32_t | rows, | |
int32_t | cols | |||
) | [virtual] |
initialize kernel with dummy features
Kernels always need feature objects assigned. As the custom kernel does not really require this it creates some magic dummy features that only know about the number of vectors
rows | features of left-hand side | |
cols | features of right-hand side |
Definition at line 83 of file CustomKernel.cpp.
virtual EFeatureClass CCustomKernel::get_feature_class | ( | ) | [virtual] |
return feature class the kernel can deal with
Implements CKernel.
Definition at line 106 of file CustomKernel.h.
virtual EFeatureType CCustomKernel::get_feature_type | ( | ) | [virtual] |
return feature type the kernel can deal with
Implements CKernel.
Definition at line 100 of file CustomKernel.h.
float32_t * CCustomKernel::get_kernel_matrix_shortreal | ( | int32_t & | m, | |
int32_t & | n, | |||
float32_t * | target = NULL | |||
) | [virtual] |
get kernel matrix shortreal
m | dimension m of matrix | |
n | dimension n of matrix | |
target | target for kernel matrix |
Reimplemented from CKernel.
Definition at line 70 of file CustomKernel.cpp.
virtual EKernelType CCustomKernel::get_kernel_type | ( | ) | [virtual] |
return what type of kernel we are
Implements CKernel.
Definition at line 94 of file CustomKernel.h.
virtual const char* CCustomKernel::get_name | ( | ) | [virtual] |
return the kernel's name
Implements CKernel.
Definition at line 112 of file CustomKernel.h.
initialize kernel
l | features of left-hand side | |
r | features of right-hand side |
Reimplemented from CKernel.
Definition at line 88 of file CustomKernel.cpp.
bool CCustomKernel::load_init | ( | FILE * | src | ) | [virtual] |
load kernel init_data
src | file to load from |
Implements CKernel.
Definition at line 114 of file CustomKernel.cpp.
bool CCustomKernel::save_init | ( | FILE * | dest | ) | [virtual] |
save kernel init_data
dest | file to save to |
Implements CKernel.
Definition at line 119 of file CustomKernel.cpp.
bool CCustomKernel::set_full_kernel_matrix_from_full | ( | const float64_t * | km, | |
int32_t | rows, | |||
int32_t | cols | |||
) |
set full kernel matrix from full kernel matrix
km | kernel matrix | |
rows | number of rows in matrix | |
cols | number of cols in matrix |
Definition at line 177 of file CustomKernel.cpp.
bool CCustomKernel::set_triangle_kernel_matrix_from_full | ( | const float64_t * | km, | |
int32_t | rows, | |||
int32_t | cols | |||
) |
set kernel matrix (only elements from upper triangle) from squared matrix
km | kernel matrix | |
rows | number of rows in matrix | |
cols | number of cols in matrix |
Definition at line 154 of file CustomKernel.cpp.
bool CCustomKernel::set_triangle_kernel_matrix_from_triangle | ( | const float64_t * | km, | |
int32_t | len | |||
) |
set kernel matrix (only elements from upper triangle) from elements of upper triangle (concat'd), including the main diagonal
km | kernel matrix | |
len | denotes the size of the array and should match len=cols*(cols+1)/2 |
Definition at line 124 of file CustomKernel.cpp.
float32_t* CCustomKernel::kmatrix [protected] |
kernel matrix
Definition at line 176 of file CustomKernel.h.
int32_t CCustomKernel::num_cols [protected] |
number of columns
Definition at line 180 of file CustomKernel.h.
int32_t CCustomKernel::num_rows [protected] |
number of rows
Definition at line 178 of file CustomKernel.h.
bool CCustomKernel::upper_diagonal [protected] |
upper diagonal
Definition at line 182 of file CustomKernel.h.