Fix bug in FourierBasis

release/4.3a0
Varun Agrawal 2021-08-29 04:21:57 -04:00
parent 066bd0f05b
commit 65837c1030
1 changed files with 7 additions and 3 deletions

View File

@ -40,9 +40,13 @@ class GTSAM_EXPORT FourierBasis : public Basis<FourierBasis> {
static Weights CalculateWeights(size_t N, double x) {
Weights b(N);
b[0] = 1;
for (size_t i = 1, n = 1; i < N; i += 2, n++) {
b[i] = cos(n * x);
b[i + 1] = sin(n * x);
for (size_t i = 1, n = 1; i < N; i++) {
if (i % 2 == 1) {
b[i] = cos(n * x);
} else {
b[i] = sin(n * x);
n++;
}
}
return b;
}