SLIM
1.0
Sparse Linear Methods (SLIM) for top-n recommender systems
|
This file contains all the utility routines. More...
#include <slim.h>
Go to the source code of this file.
Functions | |
ctrl_t * | create_ctrl () |
Create a ctrl structure wich contains all the default parameters for SLIM. | |
void | free_ctrl (ctrl_t *ctrl) |
Free a ctrl structure. | |
void | start_timer (ctimer_t *ctimer) |
Start a timer to record current time. | |
void | end_timer (ctimer_t *ctimer) |
End a timer to record a length of a duration. | |
void | display_timer (ctimer_t *ctimer, char *msg) |
Display a user-defined message and a duration length recorded by a timer. | |
int | count_nnz (double *array, int narray) |
Count the number of non-zero values in an array. | |
void | find_topk (double *w, int n, int topk, double *map, int *topk2) |
Find the top-k values from an array. | |
void | get_column (gk_csr_t *constraint, int i, double *w) |
Get a column from a csr matrix. | |
This file contains all the utility routines.
Definition in file util.c.
int count_nnz | ( | double * | array, |
int | narray | ||
) |
Count the number of non-zero values in an array.
[in] | array | An array whose non-zero values will be counted |
[in] | narray | The length of the array |
Definition at line 134 of file util.c.
References EPSILON2.
Referenced by slim_fs_learn().
ctrl_t* create_ctrl | ( | ) |
Create a ctrl structure wich contains all the default parameters for SLIM.
Definition at line 21 of file util.c.
References ctrl_t::beta, ctrl_t::bl, ctrl_t::bsize, ctrl_t::bu, ctrl_t::dbglvl, ctrl_t::endi, ctrl_t::fs, ctrl_t::fs_file, ctrl_t::k, ctrl_t::lambda, ctrl_t::max_bcls_niters, ctrl_t::model_file, ctrl_t::nratings, ctrl_t::optTol, ctrl_t::pred_file, ctrl_t::starti, ctrl_t::test_file, ctrl_t::topn, ctrl_t::train_file, and ctrl_t::transpose.
Referenced by main(), and parse_cmdline().
void display_timer | ( | ctimer_t * | ctimer, |
char * | msg | ||
) |
Display a user-defined message and a duration length recorded by a timer.
[in] | ctimer | A timer with a length of a duration recorded |
[in] | msg | A user-defined message to display |
Definition at line 116 of file util.c.
References ctimer_t::end, and ctimer_t::start.
Referenced by slim_learn(), and slim_test().
void end_timer | ( | ctimer_t * | ctimer | ) |
End a timer to record a length of a duration.
[in] | ctimer | A timer to end |
Definition at line 101 of file util.c.
References ctimer_t::end.
Referenced by slim_learn(), and slim_test().
void find_topk | ( | double * | w, |
int | n, | ||
int | topk, | ||
double * | map, | ||
int * | topk2 | ||
) |
Find the top-k values from an array.
[in] | w | The array whose top-k values will be found |
[in] | n | The length of the array w |
[in] | topk | The number of top values to be found |
[out] | map | The array of indices that correspond to the top-k values in the input array |
[out] | topk2 | The actual number of top values that are found |
Definition at line 159 of file util.c.
Referenced by slim_fs_learn().
void free_ctrl | ( | ctrl_t * | ctrl | ) |
Free a ctrl structure.
[in] | ctrl | A pointer to a ctrl structure to be freed |
Definition at line 68 of file util.c.
References ctrl_t::fs_file, ctrl_t::model_file, ctrl_t::pred_file, ctrl_t::test_file, and ctrl_t::train_file.
Referenced by main().
void get_column | ( | gk_csr_t * | constraint, |
int | i, | ||
double * | w | ||
) |
Get a column from a csr matrix.
[in] | constraint | A matrix from which one column is to be retrievd |
[in] | i | The index of the column to be retrieved |
[out] | w | The output vector which saves the retrieved column |
Definition at line 194 of file util.c.
Referenced by slim_learn().
void start_timer | ( | ctimer_t * | ctimer | ) |
Start a timer to record current time.
[in] | ctimer | A timer to start |
Definition at line 88 of file util.c.
References ctimer_t::start.
Referenced by slim_learn(), and slim_test().