nco: using float precision PI literal in nco utilities
/*
- * Copyright (c) 2007 - 2015 Joseph Gaeddert
+ * Copyright (c) 2007 - 2021 Joseph Gaeddert
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
#include <stdlib.h>
#include <stdio.h>
+// NOTE: this is defined in multiple places, but should be included here
+// until an appropriate place for literals can be found
+#define LIQUID_PI (3.14159265358979323846264338327950288f)
+
// unwrap phase of array (basic)
void liquid_unwrap_phase(float * _theta,
unsigned int _n)
{
unsigned int i;
for (i=1; i<_n; i++) {
- while ( (_theta[i] - _theta[i-1]) > M_PI ) _theta[i] -= 2*M_PI;
- while ( (_theta[i] - _theta[i-1]) < -M_PI ) _theta[i] += 2*M_PI;
+ while ( (_theta[i] - _theta[i-1]) > LIQUID_PI ) _theta[i] -= 2*LIQUID_PI;
+ while ( (_theta[i] - _theta[i-1]) < -LIQUID_PI ) _theta[i] += 2*LIQUID_PI;
}
}
@@ -57,8 +61,8 @@ void liquid_unwrap_phase2(float * _theta,
dphi /= (float)(_n-1);
for (i=1; i<_n; i++) {
- while ( (_theta[i] - _theta[i-1]) > M_PI+dphi ) _theta[i] -= 2*M_PI;
- while ( (_theta[i] - _theta[i-1]) < -M_PI+dphi ) _theta[i] += 2*M_PI;
+ while ( (_theta[i] - _theta[i-1]) > LIQUID_PI+dphi ) _theta[i] -= 2*LIQUID_PI;
+ while ( (_theta[i] - _theta[i-1]) < -LIQUID_PI+dphi ) _theta[i] += 2*LIQUID_PI;
}
}
