61 mu_assert(value == 1.0,
"Incorrect value at 0, 0");
63 mu_assert(value == 1.0,
"Incorrect value at 0, 1");
67 mu_assert(value >= -1.0 && value <= 0.25,
"Incorrect value at 1, 0");
69 mu_assert(value >= -1.0 && value <= 0.25,
"Incorrect value at 1, 1");
73 mu_assert(value >= -0.25 && value <= 1.0,
"Incorrect value at 2, 0");
75 mu_assert(value >= -0.25 && value <= 1.0,
"Incorrect value at 2, 1");
105 for (i=0; i<
n; i++) {
121 mu_assert(value == 1.0,
"Incorrect value at 0, 0");
123 mu_assert(value == 1.0,
"Incorrect value at 0, 1");
127 mu_assert(value >= -1.0 && value <= 0.25,
"Incorrect value at 1, 0");
129 mu_assert(value >= -1.0 && value <= 0.25,
"Incorrect value at 1, 1");
133 mu_assert(value >= -0.25 && value <= 1.0,
"Incorrect value at 2, 0");
135 mu_assert(value >= -0.25 && value <= 1.0,
"Incorrect value at 2, 1");
176 "Incorrect V value at 0, 0");
178 "Incorrect V value at 0, 1");
180 "Incorrect V value at 1, 0");
182 "Incorrect V value at 1, 1");
184 "Incorrect V value at 2, 0");
186 "Incorrect V value at 2, 1");
188 "Incorrect V value at 3, 0");
190 "Incorrect V value at 3, 1");
192 "Incorrect V value at 4, 0");
194 "Incorrect V value at 4, 1");
196 "Incorrect V value at 5, 0");
198 "Incorrect V value at 5, 1");
221 for (i=0; i<model->
n; i++) {
222 mu_assert(model->
rho[i] == 1.0,
"incorrect weight in rho");
256 for (i=0; i<4; i++) {
258 "Incorrect weight for class 1");
260 for (i=0; i<3; i++) {
262 "Incorrect weight for class 2");
265 "Incorrect weight for class 3");
Minimal unit testing framework for C.
#define Calloc(type, size)
char * test_init_weights_2()
#define mu_assert(test, message)
#define matrix_get(M, cols, i, j)
char * test_init_weights_wrong()
char * test_init_null_sparse()
void gensvm_free_model(struct GenModel *model)
Free allocated GenModel struct.
int weight_idx
which weights to use (1 = unit, 2 = group)
double * V
augmented weight matrix
#define mu_run_test(test)
long * y
array of class labels, 1..K
struct GenModel * gensvm_init_model(void)
Initialize a GenModel structure.
A structure to represent the data.
void gensvm_initialize_weights(struct GenData *data, struct GenModel *model)
Initialize instance weights.
A structure to represent a single GenSVM model.
#define mu_test_missing()
long n
number of instances in the dataset
void gensvm_free_data(struct GenData *data)
Free allocated GenData struct.
double * rho
vector of instance weights
void gensvm_allocate_model(struct GenModel *model)
Allocate memory for a GenModel.
void gensvm_init_V(struct GenModel *from_model, struct GenModel *to_model, struct GenData *data)
Seed the matrix V from an existing model or using rand.
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.
char * test_init_null_dense()
#define matrix_set(M, cols, i, j, val)
char * test_init_weights_1()
Header file for gensvm_init.c.
long n
number of instances
struct GenData * gensvm_init_data(void)
Initialize a GenData structure.
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