to assign the print_function.
This function frees the memory used by a parameter set.
-- Variable: extern void (*liblinear_print_string) (const char *);
+- Function: void set_print_string_function(void (*print_func)(const char *));
- Users can specify their output format by
- liblinear_print_string = &your_print_function;
+ Users can specify their output format by a function. Use
+ svm_set_print_string_function(NULL);
+ for default printing to stdout.
Building Windows Binaries
=========================
fflush(stdout);
}
-void (*liblinear_print_string) (const char *) = &print_string_stdout;
+static void (*liblinear_print_string) (const char *) = &print_string_stdout;
#if 1
static void info(const char *fmt,...)
label[i] = model_->label[i];
}
+void set_print_string_function(void (*print_func) (const char*))
+{
+ if (print_func == NULL)
+ liblinear_print_string = &print_string_stdout;
+ else
+ liblinear_print_string = print_func;
+}
+
void destroy_model(struct model *model_);
void destroy_param(struct parameter *param);
const char *check_parameter(const struct problem *prob, const struct parameter *param);
-extern void (*liblinear_print_string) (const char *);
+void set_print_string_function(void (*print_func) (const char*));
#ifdef __cplusplus
}
#define Malloc(type,n) (type *)malloc((n)*sizeof(type))
#define INF HUGE_VAL
-void print_null(const char *s){}
-
-void (*liblinear_default_print_string) (const char *);
+void print_null(const char *s) {}
void exit_with_help()
{
int i, argc = 1;
char cmd[CMD_LEN];
char *argv[CMD_LEN/2];
+ void (*print_func)(const char*) = NULL;
// default values
param.solver_type = L2R_L2LOSS_SVC_DUAL;
col_format_flag = 0;
bias = -1;
- // train loaded only once under matlab
- if(liblinear_default_print_string == NULL)
- liblinear_default_print_string = liblinear_print_string;
- else
- liblinear_print_string = liblinear_default_print_string;
if(nrhs <= 1)
return 1;
param.weight[param.nr_weight-1] = atof(argv[i]);
break;
case 'q':
- liblinear_print_string = &print_null;
+ print_func = &print_null;
i--;
break;
default:
}
}
+ set_print_string_function(print_func);
+
if(param.eps == INF)
{
if(param.solver_type == L2R_LR || param.solver_type == L2R_L2LOSS_SVC)
void parse_command_line(int argc, char **argv, char *input_file_name, char *model_file_name)
{
int i;
+ void (*print_func)(const char*) = NULL;
// default values
param.solver_type = L2R_L2LOSS_SVC_DUAL;
break;
case 'q':
- liblinear_print_string = &print_null;
+ print_func = &print_null;
i--;
break;
}
}
+ set_print_string_function(print_func);
+
// determine filenames
if(i>=argc)
exit_with_help();