fix bug with lookback = 0
@@ -56,6 +56,7 @@ void update_accel_params(Work * w, scs_int idx){
}
blasint initAccelWrk(Accel * a){
+ DEBUG_FUNC
blasint info;
scs_float twork;
scs_int l = a->l;
@@ -72,6 +73,7 @@ blasint initAccelWrk(Accel * a){
}
Accel* initAccel(Work * w) {
+ DEBUG_FUNC
Accel * a = scs_malloc(sizeof(Accel));
if (!a) {
RETURN SCS_NULL;
@@ -83,6 +85,10 @@ Accel* initAccel(Work * w) {
of anderson acceleration, and so there is one fewer var in lin sys. */
/* Use MIN to prevent not full rank matrices */
a->k = MIN(2 * l, w->stgs->acceleration_lookback - 1);
+ if (a->k <= 0) {
+ a->dF = a->dG = a->f = a->g = a->theta = a->tmp = a->dFQR = a->wrk = SCS_NULL;
+ RETURN a;
+ }
a->dF = scs_malloc(sizeof(scs_float) * 2 * l * a->k);
a->dG = scs_malloc(sizeof(scs_float) * 2 * l * a->k);
a->f = scs_malloc(sizeof(scs_float) * 2 * l);
@@ -127,7 +133,7 @@ scs_int accelerate(Work *w, scs_int iter) {
scs_int info;
timer accelTimer;
tic(&accelTimer);
- if (k == 0) {
+ if (k <= 0) {
RETURN 0;
}
if (iter < k) {
@@ -152,6 +158,7 @@ scs_int accelerate(Work *w, scs_int iter) {
}
void freeAccel(Accel * a) {
+ DEBUG_FUNC
if(a) {
if (a->dF)
scs_free(a->dF);
@@ -171,6 +178,7 @@ void freeAccel(Accel * a) {
scs_free(a->wrk);
scs_free(a);
}
+ RETURN;
}
#else
@@ -192,9 +200,10 @@ scs_int accelerate(Work *w, scs_int iter) {
#endif
char *getAccelSummary(const Info *info, Accel *a) {
+ DEBUG_FUNC
char *str = scs_malloc(sizeof(char) * 64);
sprintf(str, "\tAcceleration: avg solve time: %1.2es\n",
a->totalAccelTime / (info->iter + 1) / 1e3);
a->totalAccelTime = 0.0;
- return str;
+ RETURN str;
}
