GenSVM
|
Header file for gensvm_base.c. More...
#include "gensvm_sparse.h"
Go to the source code of this file.
Classes | |
struct | GenData |
A structure to represent the data. More... | |
struct | GenModel |
A structure to represent a single GenSVM model. More... | |
struct | GenWork |
A structure to hold the GenSVM workspace. More... | |
Functions | |
struct GenModel * | gensvm_init_model (void) |
Initialize a GenModel structure. More... | |
void | gensvm_allocate_model (struct GenModel *model) |
Allocate memory for a GenModel. More... | |
void | gensvm_reallocate_model (struct GenModel *model, long n, long m) |
Reallocate memory for GenModel. More... | |
void | gensvm_free_model (struct GenModel *model) |
Free allocated GenModel struct. More... | |
struct GenData * | gensvm_init_data (void) |
Initialize a GenData structure. More... | |
void | gensvm_free_data (struct GenData *data) |
Free allocated GenData struct. More... | |
struct GenWork * | gensvm_init_work (struct GenModel *model) |
Initialize the workspace structure. More... | |
void | gensvm_free_work (struct GenWork *work) |
Free an allocated GenWork instance. More... | |
void | gensvm_reset_work (struct GenWork *work) |
Reset all matrices of a GenWork instance. More... | |
Header file for gensvm_base.c.
Contains documentation and declarations of GenModel and GenData, and function declarations for the functions in gensvm_base.c.
This file is part of GenSVM.
GenSVM is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
GenSVM is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License along with GenSVM. If not, see http://www.gnu.org/licenses/.
Definition in file gensvm_base.h.
void gensvm_allocate_model | ( | struct GenModel * | model | ) |
Allocate memory for a GenModel.
This function can be used to allocate the memory needed for a GenModel. All arrays in the model are specified and initialized to 0.
[in] | model | GenModel to allocate |
Definition at line 144 of file gensvm_base.c.
void gensvm_free_data | ( | struct GenData * | data | ) |
Free allocated GenData struct.
Simply free a previously allocated GenData struct by freeing all its components. Note that the data struct itself is also freed here.
[in] | data | GenData struct to free |
Definition at line 73 of file gensvm_base.c.
void gensvm_free_model | ( | struct GenModel * | model | ) |
Free allocated GenModel struct.
Simply free a previously allocated GenModel by freeing all its component arrays. Note that the model struct itself is also freed here.
[in] | model | GenModel to free |
Definition at line 211 of file gensvm_base.c.
void gensvm_free_work | ( | struct GenWork * | work | ) |
Free an allocated GenWork instance.
This function simply frees every matrix allocated for in the GenWork workspace.
[in] | work | a pointer to an allocated GenWork instance |
Definition at line 277 of file gensvm_base.c.
struct GenData* gensvm_init_data | ( | void | ) |
Initialize a GenData structure.
A GenData structure is initialized and default values are set. A pointer to the initialized data is returned.
Definition at line 45 of file gensvm_base.c.
struct GenModel* gensvm_init_model | ( | void | ) |
Initialize a GenModel structure.
A GenModel structure is initialized and the default value for the parameters are set. A pointer to the initialized model is returned.
Definition at line 102 of file gensvm_base.c.
Initialize the workspace structure.
During the computations in gensvm_get_update(), a number of matrices need to be allocated which are used to store intermediate results. To avoid reallocating these matrices at every call to gensvm_get_update(), we create here a workspace with these matrices. This workspace is created once by gensvm_optimize(), and is passed to gensvm_get_update() and gensvm_get_loss(). See the documentation of the GenWork structure for information on each allocated field.
[in] | model | a GenModel with the dimensionality of the problem |
Definition at line 245 of file gensvm_base.c.
void gensvm_reallocate_model | ( | struct GenModel * | model, |
long | n, | ||
long | m | ||
) |
Reallocate memory for GenModel.
This function can be used to reallocate existing memory for a GenModel, upon a change in the model dimensions. This is used in combination with kernels.
[in] | model | GenModel to reallocate |
[in] | n | new value of GenModel->n |
[in] | m | new value of GenModel->m |
Definition at line 172 of file gensvm_base.c.
void gensvm_reset_work | ( | struct GenWork * | work | ) |
Reset all matrices of a GenWork instance.
In the gensvm_get_update() function, it is expected for some matrices that all their entries are initialized to 0. This function sets the memory for each of the matrices in the GenWork workspace to 0 to facilitate this.
[in,out] | work | an initialized GenWork instance. On exit, the matrices of the GenWork instance are all initialized to 0. |
Definition at line 302 of file gensvm_base.c.