Skip to content

Commit

Permalink
Bump libsvm 3.35
Browse files Browse the repository at this point in the history
  • Loading branch information
jschueller committed Nov 25, 2024
1 parent accfadd commit a720218
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 12 deletions.
2 changes: 1 addition & 1 deletion lib/src/LibSVM/otsvm/svm.h
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#ifndef _LIBSVM_H
#define _LIBSVM_H

#define LIBSVM_VERSION 332
#define LIBSVM_VERSION 335

#ifdef __cplusplus
extern "C" {
Expand Down
22 changes: 11 additions & 11 deletions lib/src/LibSVM/svm.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ static void info(const char *fmt,...)
char buf[BUFSIZ];
va_list ap;
va_start(ap,fmt);
vsprintf(buf,fmt,ap);
vsnprintf(buf,BUFSIZ,fmt,ap);
va_end(ap);
(*svm_print_string)(buf);
}
Expand All @@ -71,7 +71,7 @@ static void info(const char *fmt,...) {}
class Cache
{
public:
Cache(int l,long int size);
Cache(int l,size_t size);
~Cache();

// request data [0,len)
Expand All @@ -81,7 +81,7 @@ class Cache
void swap_index(int i, int j);
private:
int l;
long int size;
size_t size;
struct head_t
{
head_t *prev, *next; // a circular list
Expand All @@ -95,12 +95,12 @@ class Cache
void lru_insert(head_t *h);
};

Cache::Cache(int l_,long int size_):l(l_),size(size_)
Cache::Cache(int l_,size_t size_):l(l_),size(size_)
{
head = (head_t *)calloc(l,sizeof(head_t)); // initialized to 0
size /= sizeof(Qfloat);
size -= l * sizeof(head_t) / sizeof(Qfloat);
size = max(size, 2 * (long int) l); // cache must be large enough for two columns
size_t header_size = l * sizeof(head_t) / sizeof(Qfloat);
size = max(size, 2 * (size_t) l + header_size) - header_size; // cache must be large enough for two columns
lru_head.next = lru_head.prev = &lru_head;
}

Expand Down Expand Up @@ -136,7 +136,7 @@ int Cache::get_data(const int index, Qfloat **data, int len)
if(more > 0)
{
// free old space
while(size < more)
while(size < (size_t)more)
{
head_t *old = lru_head.next;
lru_delete(old);
Expand All @@ -148,7 +148,7 @@ int Cache::get_data(const int index, Qfloat **data, int len)

// allocate new space
h->data = (Qfloat *)realloc(h->data,sizeof(Qfloat)*len);
size -= more;
size -= more; // previous while loop guarantees size >= more and subtraction of size_t variable will not underflow
swap(h->len,len);
}

Expand Down Expand Up @@ -1274,7 +1274,7 @@ class SVC_Q: public Kernel
:Kernel(prob.l, prob.x, param)
{
clone(y,y_,prob.l);
cache = new Cache(prob.l,(long int)(param.cache_size*(1<<20)));
cache = new Cache(prob.l,(size_t)(param.cache_size*(1<<20)));
QD = new double[prob.l];
for(int i=0;i<prob.l;i++)
QD[i] = (this->*kernel_function)(i,i);
Expand Down Expand Up @@ -1326,7 +1326,7 @@ class ONE_CLASS_Q: public Kernel
ONE_CLASS_Q(const svm_problem& prob, const svm_parameter& param)
:Kernel(prob.l, prob.x, param)
{
cache = new Cache(prob.l,(long int)(param.cache_size*(1<<20)));
cache = new Cache(prob.l,(size_t)(param.cache_size*(1<<20)));
QD = new double[prob.l];
for(int i=0;i<prob.l;i++)
QD[i] = (this->*kernel_function)(i,i);
Expand Down Expand Up @@ -1373,7 +1373,7 @@ class SVR_Q: public Kernel
:Kernel(prob.l, prob.x, param)
{
l = prob.l;
cache = new Cache(l,(long int)(param.cache_size*(1<<20)));
cache = new Cache(l,(size_t)(param.cache_size*(1<<20)));
QD = new double[2*l];
sign = new schar[2*l];
index = new int[2*l];
Expand Down

0 comments on commit a720218

Please sign in to comment.