41 matrix_set(model->
V, model->
K-1, 0, 0, 0.9025324416711976);
42 matrix_set(model->
V, model->
K-1, 0, 1, 0.9776784486541952);
43 matrix_set(model->
V, model->
K-1, 1, 0, 0.8336347240271171);
44 matrix_set(model->
V, model->
K-1, 1, 1, 0.1213543508830703);
45 matrix_set(model->
V, model->
K-1, 2, 0, 0.9401310852208050);
46 matrix_set(model->
V, model->
K-1, 2, 1, 0.7407478086613410);
47 matrix_set(model->
V, model->
K-1, 3, 0, 0.9053353815353901);
48 matrix_set(model->
V, model->
K-1, 3, 1, 0.8056059951641629);
55 matrix_set(data->
Z, data->
m+1, 0, 0, 1.0000000000000000);
56 matrix_set(data->
Z, data->
m+1, 0, 1, 0.4787662921736276);
57 matrix_set(data->
Z, data->
m+1, 0, 2, 0.7983044792882817);
58 matrix_set(data->
Z, data->
m+1, 0, 3, 0.4273006962165122);
59 matrix_set(data->
Z, data->
m+1, 1, 0, 1.0000000000000000);
60 matrix_set(data->
Z, data->
m+1, 1, 1, 0.7160319769123790);
61 matrix_set(data->
Z, data->
m+1, 1, 2, 0.5233066338418962);
62 matrix_set(data->
Z, data->
m+1, 1, 3, 0.4063256860579537);
63 matrix_set(data->
Z, data->
m+1, 2, 0, 1.0000000000000000);
64 matrix_set(data->
Z, data->
m+1, 2, 1, 0.3735389652435536);
65 matrix_set(data->
Z, data->
m+1, 2, 2, 0.8156214578257802);
66 matrix_set(data->
Z, data->
m+1, 2, 3, 0.6928367712901857);
67 matrix_set(data->
Z, data->
m+1, 3, 0, 1.0000000000000000);
68 matrix_set(data->
Z, data->
m+1, 3, 1, 0.3694690105850765);
69 matrix_set(data->
Z, data->
m+1, 3, 2, 0.8539671806454873);
70 matrix_set(data->
Z, data->
m+1, 3, 3, 0.5455108033084728);
71 matrix_set(data->
Z, data->
m+1, 4, 0, 1.0000000000000000);
72 matrix_set(data->
Z, data->
m+1, 4, 1, 0.8802158533820680);
73 matrix_set(data->
Z, data->
m+1, 4, 2, 0.0690778177684403);
74 matrix_set(data->
Z, data->
m+1, 4, 3, 0.4513353324958240);
75 matrix_set(data->
Z, data->
m+1, 5, 0, 1.0000000000000000);
76 matrix_set(data->
Z, data->
m+1, 5, 1, 0.7752402729955837);
77 matrix_set(data->
Z, data->
m+1, 5, 2, 0.3941285577056867);
78 matrix_set(data->
Z, data->
m+1, 5, 3, 0.2921042477960945);
79 matrix_set(data->
Z, data->
m+1, 6, 0, 1.0000000000000000);
80 matrix_set(data->
Z, data->
m+1, 6, 1, 0.6139038657913901);
81 matrix_set(data->
Z, data->
m+1, 6, 2, 0.4529743309354828);
82 matrix_set(data->
Z, data->
m+1, 6, 3, 0.7295983135133345);
83 matrix_set(data->
Z, data->
m+1, 7, 0, 1.0000000000000000);
84 matrix_set(data->
Z, data->
m+1, 7, 1, 0.7663625136928905);
85 matrix_set(data->
Z, data->
m+1, 7, 2, 0.3845759571625976);
86 matrix_set(data->
Z, data->
m+1, 7, 3, 0.2291505633226144);
89 double *ZV =
Calloc(
double, n*(
K-1));
94 "Incorrect ZV at 0, 0");
96 "Incorrect ZV at 0, 1");
98 "Incorrect ZV at 1, 0");
100 "Incorrect ZV at 1, 1");
102 "Incorrect ZV at 2, 0");
104 "Incorrect ZV at 2, 1");
106 "Incorrect ZV at 3, 0");
108 "Incorrect ZV at 3, 1");
110 "Incorrect ZV at 4, 0");
112 "Incorrect ZV at 4, 1");
114 "Incorrect ZV at 5, 0");
116 "Incorrect ZV at 5, 1");
118 "Incorrect ZV at 6, 0");
120 "Incorrect ZV at 6, 1");
122 "Incorrect ZV at 7, 0");
124 "Incorrect ZV at 7, 1");
145 matrix_set(model->
V, model->
K-1, 0, 0, 0.9025324416711976);
146 matrix_set(model->
V, model->
K-1, 0, 1, 0.9776784486541952);
147 matrix_set(model->
V, model->
K-1, 1, 0, 0.8336347240271171);
148 matrix_set(model->
V, model->
K-1, 1, 1, 0.1213543508830703);
149 matrix_set(model->
V, model->
K-1, 2, 0, 0.9401310852208050);
150 matrix_set(model->
V, model->
K-1, 2, 1, 0.7407478086613410);
151 matrix_set(model->
V, model->
K-1, 3, 0, 0.9053353815353901);
152 matrix_set(model->
V, model->
K-1, 3, 1, 0.8056059951641629);
158 data->
Z =
Calloc(
double, data->
n*(data->
m+1));
159 matrix_set(data->
Z, data->
m+1, 0, 0, 1.0000000000000000);
160 matrix_set(data->
Z, data->
m+1, 0, 1, 0.4787662921736276);
161 matrix_set(data->
Z, data->
m+1, 0, 2, 0.7983044792882817);
162 matrix_set(data->
Z, data->
m+1, 0, 3, 0.4273006962165122);
163 matrix_set(data->
Z, data->
m+1, 1, 0, 1.0000000000000000);
164 matrix_set(data->
Z, data->
m+1, 1, 1, 0.7160319769123790);
165 matrix_set(data->
Z, data->
m+1, 1, 2, 0.5233066338418962);
166 matrix_set(data->
Z, data->
m+1, 1, 3, 0.4063256860579537);
167 matrix_set(data->
Z, data->
m+1, 2, 0, 1.0000000000000000);
168 matrix_set(data->
Z, data->
m+1, 2, 1, 0.3735389652435536);
169 matrix_set(data->
Z, data->
m+1, 2, 2, 0.8156214578257802);
170 matrix_set(data->
Z, data->
m+1, 2, 3, 0.6928367712901857);
173 double *ZV =
Calloc(
double, data->
n*(
K-1));
178 "Incorrect ZV at 0, 0");
180 "Incorrect ZV at 0, 1");
182 "Incorrect ZV at 1, 0");
184 "Incorrect ZV at 1, 1");
186 "Incorrect ZV at 2, 0");
188 "Incorrect ZV at 2, 1");
209 matrix_set(model->
V, model->
K-1, 0, 0, 0.9025324416711976);
210 matrix_set(model->
V, model->
K-1, 0, 1, 0.9776784486541952);
211 matrix_set(model->
V, model->
K-1, 1, 0, 0.8336347240271171);
212 matrix_set(model->
V, model->
K-1, 1, 1, 0.1213543508830703);
213 matrix_set(model->
V, model->
K-1, 2, 0, 0.9401310852208050);
214 matrix_set(model->
V, model->
K-1, 2, 1, 0.7407478086613410);
215 matrix_set(model->
V, model->
K-1, 3, 0, 0.9053353815353901);
216 matrix_set(model->
V, model->
K-1, 3, 1, 0.8056059951641629);
223 matrix_set(data->
Z, data->
m+1, 0, 0, 1.0000000000000000);
224 matrix_set(data->
Z, data->
m+1, 0, 1, 0.4787662921736276);
225 matrix_set(data->
Z, data->
m+1, 0, 2, 0.7983044792882817);
226 matrix_set(data->
Z, data->
m+1, 0, 3, 0.4273006962165122);
227 matrix_set(data->
Z, data->
m+1, 1, 0, 1.0000000000000000);
228 matrix_set(data->
Z, data->
m+1, 1, 1, 0.7160319769123790);
229 matrix_set(data->
Z, data->
m+1, 1, 2, 0.5233066338418962);
230 matrix_set(data->
Z, data->
m+1, 1, 3, 0.4063256860579537);
231 matrix_set(data->
Z, data->
m+1, 2, 0, 1.0000000000000000);
232 matrix_set(data->
Z, data->
m+1, 2, 1, 0.3735389652435536);
233 matrix_set(data->
Z, data->
m+1, 2, 2, 0.8156214578257802);
234 matrix_set(data->
Z, data->
m+1, 2, 3, 0.6928367712901857);
235 matrix_set(data->
Z, data->
m+1, 3, 0, 1.0000000000000000);
236 matrix_set(data->
Z, data->
m+1, 3, 1, 0.3694690105850765);
237 matrix_set(data->
Z, data->
m+1, 3, 2, 0.8539671806454873);
238 matrix_set(data->
Z, data->
m+1, 3, 3, 0.5455108033084728);
239 matrix_set(data->
Z, data->
m+1, 4, 0, 1.0000000000000000);
240 matrix_set(data->
Z, data->
m+1, 4, 1, 0.8802158533820680);
241 matrix_set(data->
Z, data->
m+1, 4, 2, 0.0690778177684403);
242 matrix_set(data->
Z, data->
m+1, 4, 3, 0.4513353324958240);
243 matrix_set(data->
Z, data->
m+1, 5, 0, 1.0000000000000000);
244 matrix_set(data->
Z, data->
m+1, 5, 1, 0.7752402729955837);
245 matrix_set(data->
Z, data->
m+1, 5, 2, 0.3941285577056867);
246 matrix_set(data->
Z, data->
m+1, 5, 3, 0.2921042477960945);
247 matrix_set(data->
Z, data->
m+1, 6, 0, 1.0000000000000000);
248 matrix_set(data->
Z, data->
m+1, 6, 1, 0.6139038657913901);
249 matrix_set(data->
Z, data->
m+1, 6, 2, 0.4529743309354828);
250 matrix_set(data->
Z, data->
m+1, 6, 3, 0.7295983135133345);
251 matrix_set(data->
Z, data->
m+1, 7, 0, 1.0000000000000000);
252 matrix_set(data->
Z, data->
m+1, 7, 1, 0.7663625136928905);
253 matrix_set(data->
Z, data->
m+1, 7, 2, 0.3845759571625976);
254 matrix_set(data->
Z, data->
m+1, 7, 3, 0.2291505633226144);
263 double *ZV =
Calloc(
double, n*(
K-1));
268 "Incorrect ZV at 0, 0");
270 "Incorrect ZV at 0, 1");
272 "Incorrect ZV at 1, 0");
274 "Incorrect ZV at 1, 1");
276 "Incorrect ZV at 2, 0");
278 "Incorrect ZV at 2, 1");
280 "Incorrect ZV at 3, 0");
282 "Incorrect ZV at 3, 1");
284 "Incorrect ZV at 4, 0");
286 "Incorrect ZV at 4, 1");
288 "Incorrect ZV at 5, 0");
290 "Incorrect ZV at 5, 1");
292 "Incorrect ZV at 6, 0");
294 "Incorrect ZV at 6, 1");
296 "Incorrect ZV at 7, 0");
298 "Incorrect ZV at 7, 1");
319 matrix_set(model->
V, model->
K-1, 0, 0, 0.9025324416711976);
320 matrix_set(model->
V, model->
K-1, 0, 1, 0.9776784486541952);
321 matrix_set(model->
V, model->
K-1, 1, 0, 0.8336347240271171);
322 matrix_set(model->
V, model->
K-1, 1, 1, 0.1213543508830703);
323 matrix_set(model->
V, model->
K-1, 2, 0, 0.9401310852208050);
324 matrix_set(model->
V, model->
K-1, 2, 1, 0.7407478086613410);
325 matrix_set(model->
V, model->
K-1, 3, 0, 0.9053353815353901);
326 matrix_set(model->
V, model->
K-1, 3, 1, 0.8056059951641629);
332 data->
Z =
Calloc(
double, data->
n*(data->
m+1));
333 matrix_set(data->
Z, data->
m+1, 0, 0, 1.0000000000000000);
334 matrix_set(data->
Z, data->
m+1, 0, 1, 0.4787662921736276);
335 matrix_set(data->
Z, data->
m+1, 0, 2, 0.7983044792882817);
336 matrix_set(data->
Z, data->
m+1, 0, 3, 0.4273006962165122);
337 matrix_set(data->
Z, data->
m+1, 1, 0, 1.0000000000000000);
338 matrix_set(data->
Z, data->
m+1, 1, 1, 0.7160319769123790);
339 matrix_set(data->
Z, data->
m+1, 1, 2, 0.5233066338418962);
340 matrix_set(data->
Z, data->
m+1, 1, 3, 0.4063256860579537);
341 matrix_set(data->
Z, data->
m+1, 2, 0, 1.0000000000000000);
342 matrix_set(data->
Z, data->
m+1, 2, 1, 0.3735389652435536);
343 matrix_set(data->
Z, data->
m+1, 2, 2, 0.8156214578257802);
344 matrix_set(data->
Z, data->
m+1, 2, 3, 0.6928367712901857);
353 double *ZV =
Calloc(
double, data->
n*(data->
K-1));
358 "Incorrect ZV at 0, 0");
360 "Incorrect ZV at 0, 1");
362 "Incorrect ZV at 1, 0");
364 "Incorrect ZV at 1, 1");
366 "Incorrect ZV at 2, 0");
368 "Incorrect ZV at 2, 1");
Minimal unit testing framework for C.
#define Calloc(type, size)
long K
number of classes for the workspace
long m
number of features for the workspace
#define mu_assert(test, message)
#define matrix_get(M, cols, i, j)
char * test_zv_sparse_2()
void gensvm_free_model(struct GenModel *model)
Free allocated GenModel struct.
double * V
augmented weight matrix
#define mu_run_test(test)
struct GenModel * gensvm_init_model(void)
Initialize a GenModel structure.
A structure to represent the data.
A structure to represent a single GenSVM model.
void gensvm_calculate_ZV(struct GenModel *model, struct GenData *data, double *ZV)
Wrapper around sparse/dense versions of this function.
long n
number of instances in the dataset
char * test_zv_sparse_1()
void gensvm_free_data(struct GenData *data)
Free allocated GenData struct.
Header file for gensvm_zv.c.
long K
number of classes in the dataset
long m
number of predictors (width of RAW)
struct GenSparse * gensvm_dense_to_sparse(double *A, long rows, long cols)
Convert a dense matrix to a GenSparse structure if advantageous.
#define matrix_set(M, cols, i, j, val)
long n
number of instances
struct GenData * gensvm_init_data(void)
Initialize a GenData structure.
long n
number of instances for the workspace
long m
number of predictor variables in the dataset
double * RAW
augmented raw data matrix
struct GenSparse * spZ
sparse representation of the augmented data matrix