Update clang-tidy to clang version 8
[alexxy/gromacs.git] / src / gromacs / fft / fft_fftpack.cpp
index 33655730bd837e8dfc284669f6935cd628901caf..f87426fa675b988878bb5cb374efd420111c88f4 100644 (file)
@@ -2,7 +2,7 @@
  * This file is part of the GROMACS molecular simulation package.
  *
  * Copyright (c) 1991-2003 David van der Spoel, Erik Lindahl, University of Groningen.
- * Copyright (c) 2013,2014,2015,2016,2017, by the GROMACS development team, led by
+ * Copyright (c) 2013,2014,2015,2016,2017,2019, by the GROMACS development team, led by
  * Mark Abraham, David van der Spoel, Berk Hess, and Erik Lindahl,
  * and including many others, as listed in the AUTHORS file in the
  * top-level source directory and at http://www.gromacs.org.
@@ -86,7 +86,7 @@ gmx_fft_init_1d(gmx_fft_t *        pfft,
     }
     *pfft = nullptr;
 
-    if ( (fft = (struct gmx_fft *)malloc(sizeof(struct gmx_fft))) == nullptr)
+    if ( (fft = static_cast<struct gmx_fft *>(malloc(sizeof(struct gmx_fft)))) == nullptr)
     {
         return ENOMEM;
     }
@@ -95,7 +95,7 @@ gmx_fft_init_1d(gmx_fft_t *        pfft,
     fft->n    = nx;
 
     /* Need 4*n storage for 1D complex FFT */
-    if ( (fft->work = (real *)malloc(sizeof(real)*(4*nx))) == nullptr)
+    if ( (fft->work = static_cast<real *>(malloc(sizeof(real)*(4*nx)))) == nullptr)
     {
         free(fft);
         return ENOMEM;
@@ -126,7 +126,7 @@ gmx_fft_init_1d_real(gmx_fft_t *        pfft,
     }
     *pfft = nullptr;
 
-    if ( (fft = (struct gmx_fft *)malloc(sizeof(struct gmx_fft))) == nullptr)
+    if ( (fft = static_cast<struct gmx_fft *>(malloc(sizeof(struct gmx_fft)))) == nullptr)
     {
         return ENOMEM;
     }
@@ -135,7 +135,7 @@ gmx_fft_init_1d_real(gmx_fft_t *        pfft,
     fft->n    = nx;
 
     /* Need 2*n storage for 1D real FFT */
-    if ((fft->work = (real *)malloc(sizeof(real)*(2*nx))) == nullptr)
+    if ((fft->work = static_cast<real *>(malloc(sizeof(real)*(2*nx)))) == nullptr)
     {
         free(fft);
         return ENOMEM;
@@ -168,7 +168,7 @@ gmx_fft_init_2d_real(gmx_fft_t *        pfft,
     *pfft = nullptr;
 
     /* Create the X transform */
-    if ( (fft = (struct gmx_fft *)malloc(sizeof(struct gmx_fft))) == nullptr)
+    if ( (fft = static_cast<struct gmx_fft *>(malloc(sizeof(struct gmx_fft)))) == nullptr)
     {
         return ENOMEM;
     }
@@ -178,7 +178,7 @@ gmx_fft_init_2d_real(gmx_fft_t *        pfft,
     /* Need 4*nx storage for 1D complex FFT, and another
      * 2*nx*nyc elements for complex-to-real storage in our high-level routine.
      */
-    if ( (fft->work = (real *)malloc(sizeof(real)*(4*nx+2*nx*nyc))) == nullptr)
+    if ( (fft->work = static_cast<real *>(malloc(sizeof(real)*(4*nx+2*nx*nyc)))) == nullptr)
     {
         free(fft);
         return ENOMEM;
@@ -211,8 +211,8 @@ gmx_fft_1d               (gmx_fft_t                  fft,
 
     if (n == 1)
     {
-        p1    = (real *)in_data;
-        p2    = (real *)out_data;
+        p1    = static_cast<real *>(in_data);
+        p2    = static_cast<real *>(out_data);
         p2[0] = p1[0];
         p2[1] = p1[1];
     }
@@ -222,8 +222,8 @@ gmx_fft_1d               (gmx_fft_t                  fft,
      */
     if (in_data != out_data)
     {
-        p1 = (real *)in_data;
-        p2 = (real *)out_data;
+        p1 = static_cast<real *>(in_data);
+        p2 = static_cast<real *>(out_data);
 
         /* n complex = 2*n real elements */
         for (i = 0; i < 2*n; i++)
@@ -238,11 +238,11 @@ gmx_fft_1d               (gmx_fft_t                  fft,
 
     if (dir == GMX_FFT_FORWARD)
     {
-        fftpack_cfftf1(n, (real *)out_data, fft->work+2*n, fft->work, fft->ifac, -1);
+        fftpack_cfftf1(n, static_cast<real *>(out_data), fft->work+2*n, fft->work, fft->ifac, -1);
     }
     else if (dir == GMX_FFT_BACKWARD)
     {
-        fftpack_cfftf1(n, (real *)out_data, fft->work+2*n, fft->work, fft->ifac, 1);
+        fftpack_cfftf1(n, static_cast<real *>(out_data), fft->work+2*n, fft->work, fft->ifac, 1);
     }
     else
     {
@@ -269,8 +269,8 @@ gmx_fft_1d_real          (gmx_fft_t                  fft,
 
     if (n == 1)
     {
-        p1    = (real *)in_data;
-        p2    = (real *)out_data;
+        p1    = static_cast<real *>(in_data);
+        p2    = static_cast<real *>(out_data);
         p2[0] = p1[0];
         if (dir == GMX_FFT_REAL_TO_COMPLEX)
         {
@@ -286,8 +286,8 @@ gmx_fft_1d_real          (gmx_fft_t                  fft,
          */
         if (in_data != out_data)
         {
-            p1 = (real *)in_data;
-            p2 = (real *)out_data;
+            p1 = static_cast<real *>(in_data);
+            p2 = static_cast<real *>(out_data);
 
             for (i = 0; i < 2*(n/2+1); i++)
             {
@@ -298,14 +298,14 @@ gmx_fft_1d_real          (gmx_fft_t                  fft,
         /* Elements 0 ..   n-1 in work are used for ffac values,
          * Elements n .. 2*n-1 are internal FFTPACK work space.
          */
-        fftpack_rfftf1(n, (real *)out_data, fft->work+n, fft->work, fft->ifac);
+        fftpack_rfftf1(n, static_cast<real *>(out_data), fft->work+n, fft->work, fft->ifac);
 
         /*
          * FFTPACK has a slightly more compact storage than we, time to
          * convert it: ove most of the array one step up to make room for
          * zero imaginary parts.
          */
-        p2 = (real *)out_data;
+        p2 = static_cast<real *>(out_data);
         for (i = n-1; i > 0; i--)
         {
             p2[i+1] = p2[i];
@@ -328,15 +328,15 @@ gmx_fft_1d_real          (gmx_fft_t                  fft,
          * is more compact than ours (2 reals) it will fit, so compact it
          * and copy on-the-fly to the output array.
          */
-        p1 = (real *) in_data;
-        p2 = (real *)out_data;
+        p1 = static_cast<real *>(in_data);
+        p2 = static_cast<real *>(out_data);
 
         p2[0] = p1[0];
         for (i = 1; i < n; i++)
         {
             p2[i] = p1[i+1];
         }
-        fftpack_rfftb1(n, (real *)out_data, fft->work+n, fft->work, fft->ifac);
+        fftpack_rfftb1(n, static_cast<real *>(out_data), fft->work+n, fft->work, fft->ifac);
     }
     else
     {
@@ -378,8 +378,8 @@ gmx_fft_2d_real          (gmx_fft_t                  fft,
          */
         if (in_data != out_data)
         {
-            p1 = (real *)in_data;
-            p2 = (real *)out_data;
+            p1 = static_cast<real *>(in_data);
+            p2 = static_cast<real *>(out_data);
 
             for (i = 0; i < nx; i++)
             {
@@ -454,8 +454,8 @@ gmx_fft_2d_real          (gmx_fft_t                  fft,
             /* Output (pointed to by data) is now in padded format.
              * Pack it into out_data if we were doing an out-of-place transform.
              */
-            p1 = (real *)data;
-            p2 = (real *)out_data;
+            p1 = reinterpret_cast<real *>(data);
+            p2 = static_cast<real *>(out_data);
 
             for (i = 0; i < nx; i++)
             {