changeset 8:7ec763dc767c perf

Indent
author Chris Cannam
date Tue, 02 Oct 2018 13:15:33 +0100
parents 3b2fed77a6cf
children 54dd64b6cfc0
files FChTransformUtils.cpp
diffstat 1 files changed, 32 insertions(+), 34 deletions(-) [+]
line wrap: on
line diff
--- a/FChTransformUtils.cpp	Tue Oct 02 13:14:21 2018 +0100
+++ b/FChTransformUtils.cpp	Tue Oct 02 13:15:33 2018 +0100
@@ -13,7 +13,7 @@
 
   You should have received a copy of the GNU General Public License
   along with this program.  If not, see <http://www.gnu.org/licenses/>.
- */
+*/
 
 
 #include "FChTransformUtils.h"
@@ -22,60 +22,58 @@
 void cumtrapz(const double *x, const double *y, size_t N, double *accum)
 /*Trapezoidal Integrator: 1/2(b-a)(F(a)+F(b))*/
 {
-
-accum[0]=0.0;
-for (size_t i = 1; i < N; i++) {
-    accum[i]=accum[i-1]+0.5*(x[i]-x[i-1])*(y[i]+y[i-1]);
-}
-
+    accum[0]=0.0;
+    for (size_t i = 1; i < N; i++) {
+        accum[i]=accum[i-1]+0.5*(x[i]-x[i-1])*(y[i]+y[i-1]);
+    }
 }
 
 
 void interp1(const double *x1, const double *y1, size_t N1, const double *x2, double *y2, size_t N2){
 /*1-D linear interpolation*/
 
-	for (size_t i = 0; i < N2; i++) {
-		/*Smaller or equal than the smallest, or larger or equal than the largest.*/
-		if ( x2[i] <= x1[0] ) {
-			y2[i] = y1[0];
-		} else if ( x2[i] >= x1[N1-1] ) {
-			y2[i] = y1[N1-1];
-		} else {
-			/*Search every value of x2 in x1*/
-			size_t j = 1;
-			size_t salir = 0;
-			while ((j<N1)&&(!salir)) {			
-				if ( x2[i] <= x1[j] ) {
-					//y2[i] = ( x2[i]*( y1[j] - y1[j-1] ) + x1[j]*y1[j-1] - x1[j-1]*y1[j] ) / ( x1[j] - x1[j-1] );
-					y2[i] = y1[j-1] + ( ( y1[j] - y1[j-1] )*(x2[i] - x1[j-1] ) )/ ( x1[j] - x1[j-1] );
-					salir = 1;
-				} // if
-				j++;
-			} // for
-		} // else
-	} // for
+    for (size_t i = 0; i < N2; i++) {
+        /*Smaller or equal than the smallest, or larger or equal than the largest.*/
+        if ( x2[i] <= x1[0] ) {
+            y2[i] = y1[0];
+        } else if ( x2[i] >= x1[N1-1] ) {
+            y2[i] = y1[N1-1];
+        } else {
+            /*Search every value of x2 in x1*/
+            size_t j = 1;
+            size_t salir = 0;
+            while ((j<N1)&&(!salir)) {			
+                if ( x2[i] <= x1[j] ) {
+                    //y2[i] = ( x2[i]*( y1[j] - y1[j-1] ) + x1[j]*y1[j-1] - x1[j-1]*y1[j] ) / ( x1[j] - x1[j-1] );
+                    y2[i] = y1[j-1] + ( ( y1[j] - y1[j-1] )*(x2[i] - x1[j-1] ) )/ ( x1[j] - x1[j-1] );
+                    salir = 1;
+                } // if
+                j++;
+            } // for
+        } // else
+    } // for
 
 }
 
 void interp1q(const double *y1, const size_t *x2_int, const double *x2_frac, double *y2, size_t N2){
 
-	for(size_t i=0;i<N2;i++){
-		y2[i] = y1[x2_int[i]]*(1.0-x2_frac[i])+y1[x2_int[i]+1]*x2_frac[i];
-	} // for
+    for(size_t i=0;i<N2;i++){
+        y2[i] = y1[x2_int[i]]*(1.0-x2_frac[i])+y1[x2_int[i]+1]*x2_frac[i];
+    } // for
 
 }
 
 void hanning_window(double *p_window, size_t n, bool normalize) {
 
-	double accum=0;
+    double accum=0;
     for (size_t i = 0; i < n; i++) {
         p_window[i] = 0.5*(1.0-cos(2*M_PI*(double)(i+1)/((double)n+1.0)));
         accum += p_window[i];
     }
-	if (normalize) {
+    if (normalize) {
     	for (size_t i = 0; i < n; i++) { //window normalization
-    		p_window[i] = p_window[i]/accum;
+            p_window[i] = p_window[i]/accum;
     	}
-	}
+    }
 
 }