LCOV - code coverage report
Current view: top level - src - gensvm_grid.c (source / functions) Hit Total Coverage
Test: coverage.all Lines: 40 40 100.0 %
Date: 2017-02-21 18:44:20 Functions: 2 2 100.0 %

          Line data    Source code
       1             : /**
       2             :  * @file gensvm_grid.c
       3             :  * @author G.J.J. van den Burg
       4             :  * @date 2016-05-01
       5             :  * @brief Functions for initializing GenGrid structures
       6             :  *
       7             :  * @details
       8             :  * This file contains functions for initializing and freeing a GenGrid 
       9             :  * instance.  In addition, default values for this structure are defined here 
      10             :  * (and only here).
      11             :  *
      12             :  * @copyright
      13             :  Copyright 2016, G.J.J. van den Burg.
      14             : 
      15             :  This file is part of GenSVM.
      16             : 
      17             :  GenSVM is free software: you can redistribute it and/or modify
      18             :  it under the terms of the GNU General Public License as published by
      19             :  the Free Software Foundation, either version 3 of the License, or
      20             :  (at your option) any later version.
      21             : 
      22             :  GenSVM is distributed in the hope that it will be useful,
      23             :  but WITHOUT ANY WARRANTY; without even the implied warranty of
      24             :  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
      25             :  GNU General Public License for more details.
      26             : 
      27             :  You should have received a copy of the GNU General Public License
      28             :  along with GenSVM. If not, see <http://www.gnu.org/licenses/>.
      29             : 
      30             :  */
      31             : 
      32             : #include "gensvm_grid.h"
      33             : 
      34             : /**
      35             :  * @brief Initialize a GenGrid structure
      36             :  *
      37             :  * @brief
      38             :  * This function is used to initialize a GenGrid struct, and set its default 
      39             :  * parameters. A pointer to the generated struct is returned.
      40             :  *
      41             :  * @return      initialized GenGrid struct
      42             :  *
      43             :  */
      44           3 : struct GenGrid *gensvm_init_grid(void)
      45             : {
      46           3 :         struct GenGrid *grid = Malloc(struct GenGrid, 1);
      47             : 
      48             :         // initialize to defaults
      49           3 :         grid->traintype = CV;
      50           3 :         grid->kerneltype = K_LINEAR;
      51           3 :         grid->folds = 10;
      52           3 :         grid->repeats = 0;
      53           3 :         grid->percentile = 95.0;
      54           3 :         grid->Np = 0;
      55           3 :         grid->Nl = 0;
      56           3 :         grid->Nk = 0;
      57           3 :         grid->Ne = 0;
      58           3 :         grid->Nw = 0;
      59           3 :         grid->Ng = 0;
      60           3 :         grid->Nc = 0;
      61           3 :         grid->Nd = 0;
      62             : 
      63             :         // set arrays to NULL
      64           3 :         grid->weight_idxs = NULL;
      65           3 :         grid->ps = NULL;
      66           3 :         grid->lambdas = NULL;
      67           3 :         grid->kappas = NULL;
      68           3 :         grid->epsilons = NULL;
      69           3 :         grid->gammas = NULL;
      70           3 :         grid->coefs = NULL;
      71           3 :         grid->degrees = NULL;
      72           3 :         grid->train_data_file = NULL;
      73           3 :         grid->test_data_file = NULL;
      74             : 
      75           3 :         return grid;
      76             : }
      77             : 
      78             : /**
      79             :  * @brief Free a GenGrid structure
      80             :  *
      81             :  * @details
      82             :  * This function frees all elements of a GenGrid structure, including the 
      83             :  * GenGrid structure itself. The provided argument is set to NULL on exit.
      84             :  *
      85             :  * @param[in]   grid    a GenGrid struct to free
      86             :  *
      87             :  */
      88           3 : void gensvm_free_grid(struct GenGrid *grid)
      89             : {
      90           3 :         free(grid->weight_idxs);
      91           3 :         free(grid->ps);
      92           3 :         free(grid->lambdas);
      93           3 :         free(grid->kappas);
      94           3 :         free(grid->epsilons);
      95           3 :         free(grid->gammas);
      96           3 :         free(grid->coefs);
      97           3 :         free(grid->degrees);
      98           3 :         free(grid->train_data_file);
      99           3 :         free(grid->test_data_file);
     100           3 :         free(grid);
     101           3 :         grid = NULL;
     102           3 : }

Generated by: LCOV version 1.12