aboutsummaryrefslogtreecommitdiff
path: root/include
diff options
context:
space:
mode:
authorGertjan van den Burg <burg@ese.eur.nl>2013-08-05 17:21:36 +0200
committerGertjan van den Burg <burg@ese.eur.nl>2013-08-05 17:21:36 +0200
commit203ee5997bf80d4386b7b9fcd17365763c36e0ad (patch)
treeedc19cae4563f5265460569a8796d6ba8c3533cb /include
downloadgensvm-203ee5997bf80d4386b7b9fcd17365763c36e0ad.tar.gz
gensvm-203ee5997bf80d4386b7b9fcd17365763c36e0ad.zip
initial commit
Diffstat (limited to 'include')
-rw-r--r--include/MSVMMaj.h40
-rw-r--r--include/libMSVMMaj.h26
-rw-r--r--include/util.h36
3 files changed, 102 insertions, 0 deletions
diff --git a/include/MSVMMaj.h b/include/MSVMMaj.h
new file mode 100644
index 0000000..fbcea8c
--- /dev/null
+++ b/include/MSVMMaj.h
@@ -0,0 +1,40 @@
+
+#define MAX_ITER 10000000
+#define MAX_LINE_LENGTH 1024
+
+/*
+ Model structure
+*/
+struct Model {
+ int weight_idx;
+ long K;
+ long n;
+ long m;
+ double epsilon;
+ double p;
+ double kappa;
+ double lambda;
+ double *W;
+ double *t;
+ double *V;
+ double *Vbar;
+ double *U;
+ double *UU;
+ double *Q;
+ double *H;
+ double *R;
+ double *rho;
+ double training_error;
+ char *data_file;
+};
+
+/*
+ Data structure
+*/
+struct Data {
+ long K;
+ long n;
+ long m;
+ long *y;
+ double *Z;
+};
diff --git a/include/libMSVMMaj.h b/include/libMSVMMaj.h
new file mode 100644
index 0000000..c886ded
--- /dev/null
+++ b/include/libMSVMMaj.h
@@ -0,0 +1,26 @@
+#include <stdio.h>
+#include <stdlib.h>
+#include <math.h>
+#include <time.h>
+#include <cblas.h>
+#include <string.h>
+#include "util.h"
+
+void simplex_gen(long K, double *U);
+void category_matrix(struct Model *model, struct Data *data);
+void simplex_diff(struct Model *model, struct Data *dataset);
+
+void calculate_errors(struct Model *model, struct Data *data, double *ZV);
+void calculate_huber(struct Model *model);
+
+double get_msvmmaj_loss(struct Model *model, struct Data *data, double *ZV);
+void msvmmaj_update(struct Model *model, struct Data *data,
+ int *ClassIdx, double *A, double *B, double *Omega,
+ double *ZAZ, double *ZAZV, double *ZAZVT);
+void step_doubling(struct Model *model);
+
+void main_loop(struct Model *model, struct Data *data);
+
+int dposv(char UPLO, int N, int NRHS, double *A, int LDA, double *B, int LDB);
+
+void initialize_weights(struct Data *data, struct Model *model);
diff --git a/include/util.h b/include/util.h
new file mode 100644
index 0000000..0b5009e
--- /dev/null
+++ b/include/util.h
@@ -0,0 +1,36 @@
+#include <stdarg.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <math.h>
+#include <string.h>
+#include "MSVMMaj.h"
+
+#define Calloc(type, n) (type *)calloc((n), sizeof(type))
+#define Malloc(type, n) (type *)malloc((n)*sizeof(type))
+#define Memset(var, type, n) memset(var, 0, (n)*sizeof(type))
+#define maximum(a, b) a > b ? a : b
+#define minimum(a, b) a < b ? a : b
+
+void read_data(struct Data *dataset, struct Model *model, char *data_file);
+
+int check_argv(int argc, char **argv, char *str);
+int check_argv_eq(int argc, char **argv, char *str);
+
+void set_print_string_function(void (*print_func)(const char *));
+void info(const char *fmt,...);
+
+double rnd();
+
+void matrix_set(double *M, long cols, long i, long j, double val);
+void matrix_add(double *M, long cols, long i, long j, double val);
+void matrix_mult(double *M, long cols, long i, long j, double val);
+double matrix_get(double *M, long cols, long i, long j);
+
+void matrix3_set(double *M, long N2, long N3, long i, long j, long k, double val);
+double matrix3_get(double *M, long N2, long N3, long i, long j, long k);
+
+void allocate_model(struct Model *model);
+void free_model(struct Model *model);
+void free_data(struct Data *data);
+
+void print_matrix(double *M, long rows, long cols);