GenSVM
Classes | Functions
gensvm_base.h File Reference

Header file for gensvm_base.c. More...

#include "gensvm_sparse.h"
Include dependency graph for gensvm_base.h:
This graph shows which files directly or indirectly include this file:

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 GenModelgensvm_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 GenDatagensvm_init_data (void)
 Initialize a GenData structure. More...
 
void gensvm_free_data (struct GenData *data)
 Free allocated GenData struct. More...
 
struct GenWorkgensvm_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...
 

Detailed Description

Header file for gensvm_base.c.

Author
G.J.J. van den Burg
Date
2016-05-01

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.

Function Documentation

◆ gensvm_allocate_model()

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.

Parameters
[in]modelGenModel to allocate

Definition at line 144 of file gensvm_base.c.

◆ gensvm_free_data()

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.

Parameters
[in]dataGenData struct to free

Definition at line 73 of file gensvm_base.c.

Here is the call graph for this function:

◆ gensvm_free_model()

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.

Parameters
[in]modelGenModel to free

Definition at line 211 of file gensvm_base.c.

◆ gensvm_free_work()

void gensvm_free_work ( struct GenWork work)

Free an allocated GenWork instance.

This function simply frees every matrix allocated for in the GenWork workspace.

Parameters
[in]worka pointer to an allocated GenWork instance

Definition at line 277 of file gensvm_base.c.

◆ gensvm_init_data()

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.

Returns
initialized GenData

Definition at line 45 of file gensvm_base.c.

◆ gensvm_init_model()

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.

Returns
initialized GenModel

Definition at line 102 of file gensvm_base.c.

◆ gensvm_init_work()

struct GenWork* gensvm_init_work ( struct GenModel model)

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.

Parameters
[in]modela GenModel with the dimensionality of the problem
Returns
an allocated GenWork instance

Definition at line 245 of file gensvm_base.c.

◆ gensvm_reallocate_model()

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.

Parameters
[in]modelGenModel to reallocate
[in]nnew value of GenModel->n
[in]mnew value of GenModel->m

Definition at line 172 of file gensvm_base.c.

◆ gensvm_reset_work()

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.

Parameters
[in,out]workan 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.