@@ -90,34 +90,32 @@ int update_ever_active(int coord,
90
90
return (0 );
91
91
}
92
92
93
- int check_KKT (double * theta , /* current theta */
93
+ int check_KKT (double * theta , /* current theta */
94
94
double * gradient_ptr , /* Sigma times theta */
95
- int nrow , /* how many rows in Sigma */
96
- double bound ) /* Lagrange multipler for \ell_1 */
95
+ int nrow , /* how many rows in Sigma */
96
+ double bound ) /* Lagrange multipler for \ell_1 */
97
97
{
98
98
// First check inactive
99
99
100
100
int irow ;
101
101
int fail = 0 ;
102
- double tol = 1.e-4 ;
103
- double * theta_ptr = theta ;
104
- double * gradient_ptr_tmp = gradient_ptr ;
102
+ double tol = 1.e-6 ;
103
+ double * theta_ptr , * gradient_ptr_tmp ;
105
104
double gradient ;
106
105
107
106
for (irow = 0 ; irow < nrow ; irow ++ ) {
108
-
109
- gradient = * gradient_ptr_tmp ;
107
+ theta_ptr = (( double * ) theta + irow );
108
+ gradient_ptr_tmp = (( double * ) gradient_ptr + irow ) ;
110
109
111
110
// Compute this coordinate of the gradient
112
111
113
- if (fabs (* theta_ptr ) > tol ) { // these coordinates of gradients should be equal to \pm bound
114
- if (fabs (fabs (gradient ) - bound ) > tol * bound ) {
115
- return (0 );
116
- }
117
- else if ((* theta_ptr > 0 ) && (gradient > 0 )) {
112
+ gradient = * gradient_ptr_tmp ;
113
+
114
+ if (* theta_ptr != 0 ) { // these coordinates of gradients should be equal to -bound
115
+ if ((* theta_ptr > 0 ) && (fabs (gradient + bound ) > tol * bound )) {
118
116
return (0 );
119
117
}
120
- else if ((* theta_ptr < 0 ) && (gradient < 0 )) {
118
+ else if ((* theta_ptr < 0 ) && (fabs ( gradient - bound ) > tol * bound )) {
121
119
return (0 );
122
120
}
123
121
}
@@ -126,12 +124,9 @@ int check_KKT(double *theta, /* current theta */
126
124
return (0 );
127
125
}
128
126
}
129
- theta_ptr ++ ;
130
- gradient_ptr_tmp ++ ;
131
127
}
132
128
133
- return (fail == 0 );
134
-
129
+ return (1 );
135
130
}
136
131
137
132
double update_one_coord (double * Sigma_ptr , /* A covariance matrix: X^TX/n */
@@ -232,13 +227,13 @@ int find_one_row_(double *Sigma_ptr, /* A covariance matrix: X^TX/n */
232
227
int iactive = 0 ;
233
228
int * active_ptr ;
234
229
235
- double old_value = objective (Sigma_ptr ,
236
- linear_func_ptr ,
237
- ever_active_ptr ,
238
- nactive_ptr ,
239
- nrow ,
240
- bound ,
241
- theta );
230
+ /* double old_value = objective(Sigma_ptr, */
231
+ /* linear_func_ptr, */
232
+ /* ever_active_ptr, */
233
+ /* nactive_ptr, */
234
+ /* nrow, */
235
+ /* bound, */
236
+ /* theta); */
242
237
double new_value ;
243
238
double tol = 1.e-8 ;
244
239
@@ -298,19 +293,19 @@ int find_one_row_(double *Sigma_ptr, /* A covariance matrix: X^TX/n */
298
293
break ;
299
294
}
300
295
301
- new_value = objective (Sigma_ptr ,
302
- linear_func_ptr ,
303
- ever_active_ptr ,
304
- nactive_ptr ,
305
- nrow ,
306
- bound ,
307
- theta );
308
-
309
- if (((old_value - new_value ) < tol * fabs (new_value )) && (iter > 0 )) {
310
- break ;
311
- }
312
-
313
- old_value = new_value ;
296
+ /* new_value = objective(Sigma_ptr, */
297
+ /* linear_func_ptr, */
298
+ /* ever_active_ptr, */
299
+ /* nactive_ptr, */
300
+ /* nrow, */
301
+ /* bound, */
302
+ /* theta); */
303
+
304
+ /* if (((old_value - new_value) < tol * fabs(new_value)) && (iter > 0)) { */
305
+ /* break; */
306
+ /* } */
307
+
308
+ // old_value = new_value;
314
309
}
315
310
return (iter );
316
311
}
0 commit comments