Menu

Bug (+ fix) in the DST class

There's a sign error in the DST class in GeographicLib 2.1. This affects the DST::refine member function which isn't used elsewhere in GeographicLib. Here's the fix

diff --git a/src/DST.cpp b/src/DST.cpp
index 6fc3ee90..1e70bfd1 100644
--- a/src/DST.cpp
+++ b/src/DST.cpp
@@ -67,7 +67,7 @@ namespace GeographicLib {
     fft_transform(data, F+_N, true);
     for (int i = 0; i < _N; ++i) data[i] = F[i+_N];
     for (int i = _N; i < 2*_N; ++i)
-      F[i] = (-data[2*_N-1-i] + F[2*_N-1-i])/2;
+      F[i] = (data[2*_N-1-i] - F[2*_N-1-i])/2;
     for (int i = 0; i < _N; ++i)
       F[i] = (data[i] + F[i])/2;
   }
Posted by Charles Karney 2022-06-13

Log in to post a comment.