diff options
| author | Gertjan van den Burg <gertjanvandenburg@gmail.com> | 2017-02-17 19:02:52 -0500 |
|---|---|---|
| committer | Gertjan van den Burg <gertjanvandenburg@gmail.com> | 2017-02-17 19:02:52 -0500 |
| commit | 3a30e992cf022f4ec3c76506c070e59d093951d4 (patch) | |
| tree | fe14713d50876c1d37f1acec40b9a77875d2bba3 /tests/src/test_gensvm_copy.c | |
| parent | minor code clarification (diff) | |
| download | gensvm-3a30e992cf022f4ec3c76506c070e59d093951d4.tar.gz gensvm-3a30e992cf022f4ec3c76506c070e59d093951d4.zip | |
Remove kernelparam array in favour of explicit kernel parameters
This simplifies a lot of the code and will make it easier to link
to other languages.
Diffstat (limited to 'tests/src/test_gensvm_copy.c')
| -rw-r--r-- | tests/src/test_gensvm_copy.c | 69 |
1 files changed, 24 insertions, 45 deletions
diff --git a/tests/src/test_gensvm_copy.c b/tests/src/test_gensvm_copy.c index 0064eb9..ff5b86d 100644 --- a/tests/src/test_gensvm_copy.c +++ b/tests/src/test_gensvm_copy.c @@ -66,10 +66,9 @@ char *test_copy_model_poly_1() from_model->kappa = 1.0; from_model->weight_idx = 2; from_model->kerneltype = K_POLY; - from_model->kernelparam = Calloc(double, 3); - from_model->kernelparam[0] = 1.0; - from_model->kernelparam[1] = 2.0; - from_model->kernelparam[2] = 3.0; + from_model->gamma = 1.0; + from_model->coef = 2.0; + from_model->degree = 3.0; gensvm_copy_model(from_model, to_model); @@ -79,12 +78,9 @@ char *test_copy_model_poly_1() mu_assert(to_model->kappa == 1.0, "to->kappa incorrect."); mu_assert(to_model->weight_idx == 2, "to->weight_idx incorrect."); mu_assert(to_model->kerneltype == K_POLY, "to->kerneltype incorrect"); - mu_assert(to_model->kernelparam[0] == 1.0, - "to->kernelparam[0] is incorrect."); - mu_assert(to_model->kernelparam[1] == 2.0, - "to->kernelparam[1] is incorrect."); - mu_assert(to_model->kernelparam[2] == 3.0, - "to->kernelparam[2] is incorrect."); + mu_assert(to_model->gamma == 1.0, "to->gamma is incorrect."); + mu_assert(to_model->coef == 2.0, "to->coef is incorrect."); + mu_assert(to_model->degree == 3.0, "to->degree is incorrect."); gensvm_free_model(from_model); gensvm_free_model(to_model); @@ -103,11 +99,9 @@ char *test_copy_model_poly_2() from_model->kappa = 1.0; from_model->weight_idx = 2; from_model->kerneltype = K_POLY; - from_model->kernelparam = Calloc(double, 3); - from_model->kernelparam[0] = 1.0; - from_model->kernelparam[1] = 2.0; - from_model->kernelparam[2] = 3.0; - to_model->kernelparam = Calloc(double, 3); + from_model->gamma = 1.0; + from_model->coef = 2.0; + from_model->degree = 3.0; gensvm_copy_model(from_model, to_model); @@ -118,12 +112,9 @@ char *test_copy_model_poly_2() mu_assert(to_model->weight_idx == 2, "to_model->weight_idx incorrect."); mu_assert(to_model->kerneltype == K_POLY, "to->kerneltype incorrect"); - mu_assert(to_model->kernelparam[0] == 1.0, - "to->kernelparam[0] is incorrect."); - mu_assert(to_model->kernelparam[1] == 2.0, - "to->kernelparam[1] is incorrect."); - mu_assert(to_model->kernelparam[2] == 3.0, - "to->kernelparam[2] is incorrect."); + mu_assert(to_model->gamma == 1.0, "to->gamma is incorrect."); + mu_assert(to_model->coef == 2.0, "to->coef is incorrect."); + mu_assert(to_model->degree == 3.0, "to->degree is incorrect."); gensvm_free_model(from_model); gensvm_free_model(to_model); @@ -142,8 +133,7 @@ char *test_copy_model_rbf_1() from_model->kappa = 1.0; from_model->weight_idx = 2; from_model->kerneltype = K_RBF; - from_model->kernelparam = Calloc(double, 1); - from_model->kernelparam[0] = 5.0; + from_model->gamma = 5.0; gensvm_copy_model(from_model, to_model); @@ -154,8 +144,7 @@ char *test_copy_model_rbf_1() mu_assert(to_model->weight_idx == 2, "to_model->weight_idx incorrect."); mu_assert(to_model->kerneltype == K_RBF, "to->kerneltype incorrect"); - mu_assert(to_model->kernelparam[0] == 5.0, - "to->kernelparam[0] is incorrect."); + mu_assert(to_model->gamma == 5.0, "to->gamma is incorrect."); gensvm_free_model(from_model); gensvm_free_model(to_model); @@ -174,9 +163,7 @@ char *test_copy_model_rbf_2() from_model->kappa = 1.0; from_model->weight_idx = 2; from_model->kerneltype = K_RBF; - from_model->kernelparam = Calloc(double, 1); - from_model->kernelparam[0] = 5.0; - to_model->kernelparam = Calloc(double, 1); + from_model->gamma = 5.0; gensvm_copy_model(from_model, to_model); @@ -187,8 +174,7 @@ char *test_copy_model_rbf_2() mu_assert(to_model->weight_idx == 2, "to_model->weight_idx incorrect."); mu_assert(to_model->kerneltype == K_RBF, "to->kerneltype incorrect"); - mu_assert(to_model->kernelparam[0] == 5.0, - "to->kernelparam[0] is incorrect."); + mu_assert(to_model->gamma == 5.0, "to->gamma is incorrect."); gensvm_free_model(from_model); gensvm_free_model(to_model); @@ -207,9 +193,8 @@ char *test_copy_model_sigmoid_1() from_model->kappa = 1.0; from_model->weight_idx = 2; from_model->kerneltype = K_SIGMOID; - from_model->kernelparam = Calloc(double, 2); - from_model->kernelparam[0] = 5.0; - from_model->kernelparam[1] = 10.0; + from_model->gamma = 5.0; + from_model->coef = 10.0; gensvm_copy_model(from_model, to_model); @@ -221,10 +206,8 @@ char *test_copy_model_sigmoid_1() "to_model->weight_idx incorrect."); mu_assert(to_model->kerneltype == K_SIGMOID, "to->kerneltype incorrect"); - mu_assert(to_model->kernelparam[0] == 5.0, - "to->kernelparam[0] is incorrect."); - mu_assert(to_model->kernelparam[1] == 10.0, - "to->kernelparam[1] is incorrect."); + mu_assert(to_model->gamma == 5.0, "to->gamma is incorrect."); + mu_assert(to_model->coef == 10.0, "to->coef is incorrect."); gensvm_free_model(from_model); gensvm_free_model(to_model); @@ -243,10 +226,8 @@ char *test_copy_model_sigmoid_2() from_model->kappa = 1.0; from_model->weight_idx = 2; from_model->kerneltype = K_SIGMOID; - from_model->kernelparam = Calloc(double, 2); - from_model->kernelparam[0] = 5.0; - from_model->kernelparam[1] = 10.0; - to_model->kernelparam = Calloc(double, 2); + from_model->gamma = 5.0; + from_model->coef = 10.0; gensvm_copy_model(from_model, to_model); @@ -258,10 +239,8 @@ char *test_copy_model_sigmoid_2() "to_model->weight_idx incorrect."); mu_assert(to_model->kerneltype == K_SIGMOID, "to->kerneltype incorrect"); - mu_assert(to_model->kernelparam[0] == 5.0, - "to->kernelparam[0] is incorrect."); - mu_assert(to_model->kernelparam[1] == 10.0, - "to->kernelparam[1] is incorrect."); + mu_assert(to_model->gamma == 5.0, "to->gamma is incorrect."); + mu_assert(to_model->coef == 10.0, "to->coef is incorrect."); gensvm_free_model(from_model); gensvm_free_model(to_model); |
