Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix relaxation bug with incorrect lengths #200

Merged
merged 1 commit into from
Jan 11, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
7 changes: 4 additions & 3 deletions src/aa.c
Original file line number Diff line number Diff line change
Expand Up @@ -284,17 +284,18 @@ static void update_accel_params(const aa_float *x, const aa_float *f, AaWork *a,
/* f = (1-relaxation) * \sum_i a_i x_i + relaxation * \sum_i a_i f_i */
static void relax(aa_float *f, AaWork *a, aa_int len) {
TIME_TIC
/* x_work = x - S * work */
/* x_work = x initially */
blas_int bdim = (blas_int)(a->dim), one = 1, blen = (blas_int)len;
aa_float onef = 1.0, neg_onef = -1.0;
aa_float one_m_relaxation = 1. - a->relaxation;
/* x_work = x - S * work */
BLAS(gemv)
("NoTrans", &bdim, &blen, &neg_onef, a->S, &bdim, a->work, &one, &onef,
a->x_work, &one);
/* f = relaxation * f */
BLAS(scal)(&blen, &a->relaxation, f, &one);
BLAS(scal)(&bdim, &a->relaxation, f, &one);
/* f += (1 - relaxation) * x_work */
BLAS(axpy)(&blen, &one_m_relaxation, a->x_work, &one, f, &one);
BLAS(axpy)(&bdim, &one_m_relaxation, a->x_work, &one, f, &one);
TIME_TOC
}

Expand Down