@@ -115,9 +115,9 @@ static void sparse_svm(double *w, int *iter, double *lambda, int *saturated, dou
115115 int dfmax = dfmax_ [0 ]; int max_iter = max_iter_ [0 ]; int user = user_ [0 ]; int message = message_ [0 ];
116116 int i , j , k , l , lstart , lp , jn , num_pos , mismatch , nnzero = 0 , violations = 0 , nv = 0 ;
117117 double gi = 1.0 /gamma , cmax , cmin , csum , pct , lstep , ldiff , lmax , l1 , l2 , v1 , v2 , v3 , tmp , change , max_update , update , scrfactor = 1.0 ;
118- double * x2 = Calloc (n * p , double ); // x^2
119- double * yx = Calloc (n * p , double ); // elementwise products: y[i] * x[i][j]
120- double * syx = Calloc (p , double ); // column sum of yx
118+ double * x2 = R_Calloc (n * p , double ); // x^2
119+ double * yx = R_Calloc (n * p , double ); // elementwise products: y[i] * x[i][j]
120+ double * syx = R_Calloc (p , double ); // column sum of yx
121121 csum = 0.0 ; num_pos = 0 ;
122122 // intercept column
123123 for (i = 0 ; i < n ; i ++ ) {
@@ -128,17 +128,17 @@ static void sparse_svm(double *w, int *iter, double *lambda, int *saturated, dou
128128 }
129129 syx [0 ] = csum ;
130130
131- double * shift = Calloc (p , double );
132- double * scale = Calloc (p , double );
133- double * w_old = Calloc (p , double );
134- double * r = Calloc (n , double ); // residual: 1-y(xw+b)
135- double * s = Calloc (p , double );
136- double * d1 = Calloc (n , double );
137- double * d2 = Calloc (n , double );
138- double * z = Calloc (p , double ); // partial derivative used for screening: X^t*d1/n
131+ double * shift = R_Calloc (p , double );
132+ double * scale = R_Calloc (p , double );
133+ double * w_old = R_Calloc (p , double );
134+ double * r = R_Calloc (n , double ); // residual: 1-y(xw+b)
135+ double * s = R_Calloc (p , double );
136+ double * d1 = R_Calloc (n , double );
137+ double * d2 = R_Calloc (n , double );
138+ double * z = R_Calloc (p , double ); // partial derivative used for screening: X^t*d1/n
139139 double cutoff ;
140- int * include = Calloc (p , int );
141- int * nonconst = Calloc (p , int );
140+ int * include = R_Calloc (p , int );
141+ int * nonconst = R_Calloc (p , int );
142142
143143 // Preprocessing
144144 if (ppflag == 1 ) {
@@ -327,19 +327,19 @@ static void sparse_svm(double *w, int *iter, double *lambda, int *saturated, dou
327327 // Postprocessing
328328 if (ppflag ) postprocess (w , shift , scale , nonconst , nlam , p );
329329
330- Free (x2 );
331- Free (yx );
332- Free (syx );
333- Free (shift );
334- Free (scale );
335- Free (w_old );
336- Free (r );
337- Free (s );
338- Free (d1 );
339- Free (d2 );
340- Free (z );
341- Free (include );
342- Free (nonconst );
330+ R_Free (x2 );
331+ R_Free (yx );
332+ R_Free (syx );
333+ R_Free (shift );
334+ R_Free (scale );
335+ R_Free (w_old );
336+ R_Free (r );
337+ R_Free (s );
338+ R_Free (d1 );
339+ R_Free (d2 );
340+ R_Free (z );
341+ R_Free (include );
342+ R_Free (nonconst );
343343}
344344
345345static const R_CMethodDef cMethods [] = {
0 commit comments