File: update-libsvm3.patch

package info (click to toggle)
libalgorithm-svm-perl 0.13-5
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 436 kB
  • sloc: cpp: 3,051; perl: 364; makefile: 5
file content (62 lines) | stat: -rw-r--r-- 1,885 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
Description: Update bindings for libsvm3.
 Upstream makes use of bundled libsvm2 which has been removed on a
 separate patch.  This patch updates the bindings for libsvm3 which
 is packaged in Debian.
 .
 The libsvm README file states the following:
 - Function: void svm_free_and_destroy_model(struct svm_model **model_ptr_ptr);
 .
    This function frees the memory used by a model and destroys the model
    structure. It is equivalent to svm_destroy_model, which
    is deprecated after version 3.0.
Origin: vendor
Forwarded: https://rt.cpan.org/Public/Bug/Display.html?id=79106
Author: Mathieu Bridon <bochecha@fedoraproject.org>
Last-Update: 2012-08-21

--- a/bindings.cpp
+++ b/bindings.cpp
@@ -166,7 +166,7 @@
 
   // Free any old model we have.
   if(model != NULL) {
-    svm_destroy_model(model);
+    svm_free_and_destroy_model(&model);
     model = NULL;
   }
 
@@ -282,7 +282,7 @@
   }
 
   if(model != NULL) {
-    svm_destroy_model(model);
+    svm_free_and_destroy_model(&model);
     model = NULL;
   }
 
@@ -357,7 +357,7 @@
 	sumyy += y*y;
 	sumvy += v*y;
       }
-      svm_destroy_model(submodel);
+      svm_free_and_destroy_model(&submodel);
       // cout << "Mean squared error = %g\n", error/(end-begin));
       total_error += error;			
     } else {
@@ -368,7 +368,7 @@
 	double v = svm_predict(submodel,prob->x[j]);
 	if(v == prob->y[j]) ++correct;
       }
-      svm_destroy_model(submodel);
+      svm_free_and_destroy_model(&submodel);
       //cout << "Accuracy = " << 100.0*correct/(end-begin) << " (" <<
       //correct << "/" << (end-begin) << endl;
       total_correct += correct;
@@ -423,6 +423,6 @@
 
 SVM::~SVM() {
 	if(x_space!=NULL) { free_x_space(); }
-  if(model != NULL) { svm_destroy_model(model); model=NULL; }
+  if(model != NULL) { svm_free_and_destroy_model(&model); model=NULL; }
   if(prob != NULL) { free(prob); prob=NULL; }
 }