Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.
double timeTestFunction_clock(TestFunction_t func, double[] data, int i1, int i2)
{
clock_t start;
clock_t end;
start = clock();
func(data, i1, i2);
end = clock();
return ((double) (end-start))/CLOCKS_PER_SEC;
}
The signature of the function four1 is:
d = timeTestFunction_clock(four1, complexData-1, SIZE, 1);
void four1(double data[], int nn, int isign)
{
unsigned long n, mmax, m, j, istep, i;
double wtemp, wr, wpr, wpi, wi, theta;
double tempr, tempi;
n = nn << 1;
j = 1;
for (i = 1; i < n; i += 2) {
if (j > i) {
SWAP(data[j], data[i]);
SWAP(data[j+1], data[i+1]);
}
m = nn;
while (m >= 2 && j > m) {
j -= m;
m >>= 1;
}
j += m;
}
mmax = 2;
while (n > mmax) {
istep = mmax << 1;
theta = isign * (6.28318530717959 / mmax);
wtemp = sin(0.5 * theta);
wpr = -2.0 * wtemp * wtemp;
wpi = sin(theta);
wr = 1.0;
wi = 0.0;
for (m = 1; m < mmax; m += 2) {
for (i = m; i <= n; i += istep) {
j = i + mmax;
tempr = wr * data[j] - wi * data[j+1];
tempi = wr * data[j+1] + wi * data[j];
data[j] = data[i] - tempr;
data[j+1] = data[i+1] - tempi;
data[i] += tempr;
data[i+1] += tempi;
}
wr = (wtemp = wr) * wpr - wi * wpi + wr;
wi = wi * wpr + wtemp * wpi + wi;
}
mmax = istep;
}
}
*******************************************************************
int main()
{
int i;
double d;
createComplexSawtooth(complexData, SIZE);
displayComplex(complexData, SIZE);
d = timeTestFunction_clock(four1, complexData-1, SIZE, 1);
//four1(complexData-1, SIZE, 1); <-- this works
postProcessComplex(complexData, SIZE);
return 0;
)
void four1(double data[], int nn, int isign)
{
}
typedef void (* TestFunction_t)(double [], int, int);
double timeTestFunction_clock(TestFunction_t func, double data[], int i1, int i2)
{
func(data, i1, i2);
return 0.0;
}
int main()
{
double d = timeTestFunction_clock(four1, 0, 0, 1);
return 0;
}
Why do you substract 1?
Could you send complexData declaration and use?