int main (int argc, char *argv[]) { enum {ArraySize = 10}; static LALStatus status; static REAL4Vector *x; static REAL4Vector *y; static REAL8Vector *xx; static REAL8Vector *yy; SInterpolateOut sintout; SInterpolatePar sintpar; DInterpolateOut dintout; DInterpolatePar dintpar; int i; ParseOptions (argc, argv); LALSCreateVector (&status, &x, ArraySize); TestStatus (&status, CODES(0), 1); LALSCreateVector (&status, &y, ArraySize); TestStatus (&status, CODES(0), 1); LALDCreateVector (&status, &xx, ArraySize); TestStatus (&status, CODES(0), 1); LALDCreateVector (&status, &yy, ArraySize); TestStatus (&status, CODES(0), 1); if ( verbose ) printf ("Initial data:\n"); if ( verbose ) printf ("y = P(x) = 7 - 8x + 2x^2 + 2x^3 - x^4\n"); if ( verbose ) printf ("-----------------\n"); if ( verbose ) printf ("x\ty\n"); if ( verbose ) printf ("=================\n"); for (i = 0; i < ArraySize; ++i) { REAL4 xi = x->data[i] = xx->data[i] = i*i; y->data[i] = yy->data[i] = 7 + xi*(-8 + xi*(2 + xi*(2 - xi))); if ( verbose ) printf ("%.0f\t%.0f\n", x->data[i], y->data[i]); } if ( verbose ) printf ("-----------------\n"); if ( verbose ) printf ("\nInterpolate to x = 0.3:\n"); if ( verbose ) printf ("---------------------------------\n"); if ( verbose ) printf ("order\ty\t\tdy\n"); if ( verbose ) printf ("=================================\n"); sintpar.x = x->data; sintpar.y = y->data; dintpar.x = xx->data; dintpar.y = yy->data; for (i = 2; i < ArraySize; ++i) { sintpar.n = i; dintpar.n = i; LALSPolynomialInterpolation (&status, &sintout, 0.3, &sintpar); TestStatus (&status, CODES(0), 1); LALDPolynomialInterpolation (&status, &dintout, 0.3, &dintpar); TestStatus (&status, CODES(0), 1); if ( verbose ) printf ("%d\t%f\t%f\t%f\t%f\n", i - 1, sintout.y, sintout.dy, dintout.y, dintout.dy); } if ( verbose ) printf ("---------------------------------\n"); if ( verbose ) printf ("\nExtrapolate to x = -0.3:\n"); if ( verbose ) printf ("---------------------------------\n"); if ( verbose ) printf ("order\ty\t\tdy\n"); if ( verbose ) printf ("=================================\n"); sintpar.x = x->data; sintpar.y = y->data; dintpar.x = xx->data; dintpar.y = yy->data; for (i = 2; i < ArraySize; ++i) { sintpar.n = i; dintpar.n = i; LALSPolynomialInterpolation (&status, &sintout, -0.3, &sintpar); TestStatus (&status, CODES(0), 1); LALDPolynomialInterpolation (&status, &dintout, -0.3, &dintpar); TestStatus (&status, CODES(0), 1); if ( verbose ) printf ("%d\t%f\t%f\t%f\t%f\n", i - 1, sintout.y, sintout.dy, dintout.y, dintout.dy); } if ( verbose ) printf ("---------------------------------\n"); LALSDestroyVector (&status, &x); TestStatus (&status, CODES(0), 1); LALSDestroyVector (&status, &y); TestStatus (&status, CODES(0), 1); LALDDestroyVector (&status, &xx); TestStatus (&status, CODES(0), 1); LALDDestroyVector (&status, &yy); TestStatus (&status, CODES(0), 1); LALCheckMemoryLeaks (); LALSCreateVector (&status, &x, ArraySize); TestStatus (&status, CODES(0), 1); LALSCreateVector (&status, &y, ArraySize); TestStatus (&status, CODES(0), 1); LALDCreateVector (&status, &xx, ArraySize); TestStatus (&status, CODES(0), 1); LALDCreateVector (&status, &yy, ArraySize); TestStatus (&status, CODES(0), 1); #ifndef LAL_NDEBUG if ( ! lalNoDebug ) { if ( verbose ) printf ("\nCheck error conditions:\n"); if ( verbose ) printf ("\nNull pointer:\r"); LALSPolynomialInterpolation (&status, NULL, -0.3, &sintpar); TestStatus (&status, CODES(INTERPOLATEH_ENULL), 1); LALDPolynomialInterpolation (&status, NULL, -0.3, &dintpar); TestStatus (&status, CODES(INTERPOLATEH_ENULL), 1); if ( verbose ) printf ("Null pointer check passed.\n"); if ( verbose ) printf ("\nNull pointer:\r"); LALSPolynomialInterpolation (&status, &sintout, -0.3, NULL); TestStatus (&status, CODES(INTERPOLATEH_ENULL), 1); LALDPolynomialInterpolation (&status, &dintout, -0.3, NULL); TestStatus (&status, CODES(INTERPOLATEH_ENULL), 1); if ( verbose ) printf ("Null pointer check passed.\n"); sintpar.x = NULL; dintpar.x = NULL; if ( verbose ) printf ("\nNull pointer:\r"); LALSPolynomialInterpolation (&status, &sintout, -0.3, &sintpar); TestStatus (&status, CODES(INTERPOLATEH_ENULL), 1); LALDPolynomialInterpolation (&status, &dintout, -0.3, &dintpar); TestStatus (&status, CODES(INTERPOLATEH_ENULL), 1); if ( verbose ) printf ("Null pointer check passed.\n"); sintpar.x = x->data; sintpar.y = NULL; dintpar.x = xx->data; dintpar.y = NULL; if ( verbose ) printf ("\nNull pointer:\r"); LALSPolynomialInterpolation (&status, &sintout, -0.3, &sintpar); TestStatus (&status, CODES(INTERPOLATEH_ENULL), 1); LALDPolynomialInterpolation (&status, &dintout, -0.3, &dintpar); TestStatus (&status, CODES(INTERPOLATEH_ENULL), 1); if ( verbose ) printf ("Null pointer check passed.\n"); sintpar.y = y->data; sintpar.n = 1; dintpar.y = yy->data; dintpar.n = 1; if ( verbose ) printf ("\nInvalid size:\r"); LALSPolynomialInterpolation (&status, &sintout, -0.3, &sintpar); TestStatus (&status, CODES(INTERPOLATEH_ESIZE), 1); dintout.dy = XLALREAL8PolynomialInterpolation (&(dintout.y), -0.3, dintpar.y, dintpar.x, dintpar.n); if (xlalErrno == XLAL_ESIZE) xlalErrno = 0; else abort(); if ( verbose ) printf ("Invalid size check passed.\n"); x->data[1] = x->data[0] = 2; xx->data[1] = xx->data[0] = 2; sintpar.n = 3; dintpar.n = 3; if ( verbose ) printf ("\nZero divide:\r"); LALSPolynomialInterpolation (&status, &sintout, -0.3, &sintpar); TestStatus (&status, CODES(INTERPOLATEH_EZERO), 1); dintout.dy = XLALREAL8PolynomialInterpolation (&(dintout.y), -0.3, dintpar.y, dintpar.x, dintpar.n); if (xlalErrno == XLAL_EFPDIV0) xlalErrno = 0; else abort(); if ( verbose ) printf ("Zero divide check passed.\n"); } #endif LALSDestroyVector (&status, &x); TestStatus (&status, CODES(0), 1); LALSDestroyVector (&status, &y); TestStatus (&status, CODES(0), 1); LALDDestroyVector (&status, &xx); TestStatus (&status, CODES(0), 1); LALDDestroyVector (&status, &yy); TestStatus (&status, CODES(0), 1); return 0; }
int main ( int argc, char *argv[] ) { const int size = 8; COMPLEX8Vector *z1 = NULL; COMPLEX8Vector *z2 = NULL; COMPLEX8Vector *z3 = NULL; REAL4Vector *x1 = NULL; REAL4Vector *x2 = NULL; REAL4Vector *x3 = NULL; REAL4Vector *y_1 = NULL; REAL4Vector *y2 = NULL; REAL4Vector *y3 = NULL; static LALStatus status; INT4 i; ParseOptions( argc, argv ); LALCCreateVector(&status, &z1, size); TestStatus( &status, CODES(0), 1 ); LALCCreateVector(&status, &z2, size); TestStatus( &status, CODES(0), 1 ); LALCCreateVector(&status, &z3, size); TestStatus( &status, CODES(0), 1 ); LALSCreateVector(&status, &x1, size); TestStatus( &status, CODES(0), 1 ); LALSCreateVector(&status, &x2, size); TestStatus( &status, CODES(0), 1 ); LALSCreateVector(&status, &x3, size); TestStatus( &status, CODES(0), 1 ); LALSCreateVector(&status, &y_1, size/2); TestStatus( &status, CODES(0), 1 ); y2 = (REAL4Vector *)LALMalloc(sizeof(REAL4Vector)); y2->data = NULL; y2->length = size; y3 = (REAL4Vector *)LALMalloc(sizeof(REAL4Vector)); y3->data = (REAL4 *)LALMalloc(size*sizeof(REAL4)); y3->length = 0; for (i = 0; i < size; ++i) { z1->data[i] = 1 + i; z1->data[i] += I * (2 + i*i); z2->data[i] = 3 + i + i*i*i; z2->data[i] += I * (4 + i*i + i*i*i); x1->data[i] = 5 + i + i*i; x2->data[i] = 6 + i + i*i + i*i*i; } if (verbose) printf("\n"); LALCCVectorMultiply(&status, z3, z1, z2); TestStatus( &status, CODES(0), 1 ); for (i = 0; i < size; ++i) if (verbose) printf("(% 6.0f,% 6.0f) x (% 6.0f,% 6.0f) = (% 6.0f,% 6.0f)\n", crealf(z1->data[i]), cimagf(z1->data[i]), crealf(z2->data[i]), cimagf(z2->data[i]), crealf(z3->data[i]), cimagf(z3->data[i])); if (verbose) printf("\n"); LALCCVectorMultiplyConjugate(&status, z3, z1, z2); TestStatus( &status, CODES(0), 1 ); for (i = 0; i < size; ++i) if (verbose) printf("(% 6.0f,% 6.0f) x (% 6.0f,% 6.0f)* = (% 6.0f,% 6.0f)\n", crealf(z1->data[i]), cimagf(z1->data[i]), crealf(z2->data[i]), cimagf(z2->data[i]), crealf(z3->data[i]), cimagf(z3->data[i])); if (verbose) printf("\n"); LALCCVectorDivide(&status, z3, z1, z2); TestStatus( &status, CODES(0), 1 ); for (i = 0; i < size; ++i) if (verbose) printf("(% 6.0f,% 6.0f) / (% 6.0f,% 6.0f) = (% 9.6f,% 9.6f)\n", crealf(z1->data[i]), cimagf(z1->data[i]), crealf(z2->data[i]), cimagf(z2->data[i]), crealf(z3->data[i]), cimagf(z3->data[i])); if (verbose) printf("\n"); LALSCVectorMultiply(&status, z3, x1, z1); TestStatus( &status, CODES(0), 1 ); for (i = 0; i < size; ++i) if (verbose) printf("% 6.0f x (% 6.0f,% 6.0f) = (% 6.0f,% 6.0f)\n", crealf(x1->data[i]), crealf(z1->data[i]), cimagf(z1->data[i]), crealf(z3->data[i]), cimagf(z3->data[i])); if (verbose) printf("\n"); LALSSVectorMultiply(&status, x3, x1, x2); TestStatus( &status, CODES(0), 1 ); for (i = 0; i < size; ++i) if (verbose) printf("% 6.0f x % 6.0f = % 6.0f\n", x1->data[i], x2->data[i], x3->data[i]); if (verbose) printf("\n"); #ifndef LAL_NDEBUG if ( ! lalNoDebug ) { LALSSVectorMultiply(&status, x3, x1, NULL); TestStatus( &status, CODES(VECTOROPSH_ENULL), 1 ); LALSSVectorMultiply(&status, x3, y2, x2); TestStatus( &status, CODES(VECTOROPSH_ENULL), 1 ); LALSSVectorMultiply(&status, y3, x1, x2); TestStatus( &status, CODES(VECTOROPSH_ESIZE), 1 ); LALSSVectorMultiply(&status, x3, x1, y_1); TestStatus( &status, CODES(VECTOROPSH_ESZMM), 1 ); } #endif LALCDestroyVector(&status, &z1); TestStatus( &status, CODES(0), 1 ); LALCDestroyVector(&status, &z2); TestStatus( &status, CODES(0), 1 ); LALCDestroyVector(&status, &z3); TestStatus( &status, CODES(0), 1 ); LALSDestroyVector(&status, &x1); TestStatus( &status, CODES(0), 1 ); LALSDestroyVector(&status, &x2); TestStatus( &status, CODES(0), 1 ); LALSDestroyVector(&status, &x3); TestStatus( &status, CODES(0), 1 ); LALSDestroyVector(&status, &y_1); TestStatus( &status, CODES(0), 1 ); LALFree(y2); LALFree(y3->data); LALFree(y3); x1 = x2 = x3 = y_1 = y2 = y3 = NULL; z1 = z2 = z3 = NULL; LALCCreateVector(&status, &z1, size); TestStatus( &status, CODES(0), 1 ); LALSCreateVector(&status, &x1, size); TestStatus( &status, CODES(0), 1 ); LALSCreateVector(&status, &x2, size); TestStatus( &status, CODES(0), 1 ); LALSCreateVector(&status, &x3, size); TestStatus( &status, CODES(0), 1 ); for (i = 0; i < size; ++i) { z1->data[i] = (12.0 + i) *cos(LAL_PI/3.0*i); z1->data[i] += I * (12.0 + i )*sin(LAL_PI/3.0*i); } if (verbose) printf("\n"); LALCVectorAbs(&status, x1, z1); TestStatus( &status, CODES(0), 1 ); for (i = 0; i < size; ++i) if (verbose) printf(" Abs(% f,%f) = %f \n", crealf(z1->data[i]), cimagf(z1->data[i]), x1->data[i]); LALCVectorAngle(&status, x2, z1); TestStatus( &status, CODES(0), 1 ); for (i = 0; i < size; ++i) if (verbose) printf(" Angle(%f,%f) = %f \n", crealf(z1->data[i]), cimagf(z1->data[i]), x2->data[i]); LALUnwrapREAL4Angle(&status, x3, x2); TestStatus( &status, CODES(0), 1 ); for (i = 0; i < size; ++i) if (verbose) printf(" Unwrap Phase Angle ( %f ) = %f \n", x2->data[i], x3->data[i]); LALSCreateVector(&status, &y_1, size/2); TestStatus( &status, CODES(0), 1 ); y2 = (REAL4Vector *)LALMalloc(sizeof(REAL4Vector)); y2->data = NULL; y2->length = size; y3 = (REAL4Vector *)LALMalloc(sizeof(REAL4Vector)); y3->data = (REAL4 *)LALMalloc(size*sizeof(REAL4)); y3->length = 0; if (verbose) printf("\n"); #ifndef LAL_NDEBUG if ( ! lalNoDebug ) { LALCVectorAbs(&status, x1, NULL); TestStatus( &status, CODES(VECTOROPSH_ENULL), 1 ); LALCVectorAbs(&status, NULL, z1); TestStatus( &status, CODES(VECTOROPSH_ENULL), 1 ); LALCVectorAbs(&status, y_1, z1); TestStatus( &status, CODES(VECTOROPSH_ESZMM), 1 ); LALCVectorAbs(&status, y2, z1); TestStatus( &status, CODES(VECTOROPSH_ENULL), 1 ); LALCVectorAbs(&status, y3, z1); TestStatus( &status, CODES(VECTOROPSH_ESIZE), 1 ); LALCVectorAngle(&status, x2, NULL); TestStatus( &status, CODES(VECTOROPSH_ENULL), 1 ); LALCVectorAngle(&status, NULL, z1); TestStatus( &status, CODES(VECTOROPSH_ENULL), 1 ); LALCVectorAngle(&status, y_1, z1); TestStatus( &status, CODES(VECTOROPSH_ESZMM), 1 ); LALCVectorAngle(&status, y2, z1); TestStatus( &status, CODES(VECTOROPSH_ENULL), 1 ); LALCVectorAngle(&status, y3, z1); TestStatus( &status, CODES(VECTOROPSH_ESIZE), 1 ); LALUnwrapREAL4Angle(&status, x3, NULL); TestStatus( &status, CODES(VECTOROPSH_ENULL), 1 ); LALUnwrapREAL4Angle(&status, NULL, x2); TestStatus( &status, CODES(VECTOROPSH_ENULL), 1 ); LALUnwrapREAL4Angle(&status, y_1, x2); TestStatus( &status, CODES(VECTOROPSH_ESZMM), 1 ); LALUnwrapREAL4Angle(&status, y2, x2); TestStatus( &status, CODES(VECTOROPSH_ENULL), 1 ); LALUnwrapREAL4Angle(&status, y3, x2); TestStatus( &status, CODES(VECTOROPSH_ESIZE), 1 ); LALUnwrapREAL4Angle(&status, x2, x2); TestStatus( &status, CODES(VECTOROPSH_ESAME), 1 ); } #endif LALCDestroyVector(&status, &z1); TestStatus( &status, CODES(0), 1 ); LALSDestroyVector(&status, &x1); TestStatus( &status, CODES(0), 1 ); LALSDestroyVector(&status, &x2); TestStatus( &status, CODES(0), 1 ); LALSDestroyVector(&status, &x3); TestStatus( &status, CODES(0), 1 ); LALSDestroyVector(&status, &y_1); TestStatus( &status, CODES(0), 1 ); LALFree(y2); LALFree(y3->data); LALFree(y3); LALCheckMemoryLeaks(); return 0; }
static int CheckDetector(LALStatus *status, LALDetector *cachedDetector) { LALDetector constructedDetector; LALDetectorType type = cachedDetector->type; LALFrDetector frDetector = cachedDetector->frDetector; INT2 i, j; printf(" Name is \"%s\",\n", frDetector.name); frDetector.name[1] = '?'; printf(" Changing to \"%s\",\n", frDetector.name); LALCreateDetector( status, &constructedDetector, &frDetector, type ); TestStatus( status, CODES(0), DETECTORSITETESTC_EFLS ); printf(" Enum'ed type is %d (LALDETECTORTYPE_IFODIFF=%d)\n", constructedDetector.type, LALDETECTORTYPE_IFODIFF); for (i=0; i<3; ++i) { printf(" x[%d]:\n cached: %.15g calc: %.15g diff: %g\n", i+1, cachedDetector->location[i], constructedDetector.location[i], cachedDetector->location[i] - constructedDetector.location[i]); if ( cachedDetector->location[i] - constructedDetector.location[i] >= DETECTORSITETESTC_LOCTOL ) { return DETECTORSITETESTC_EFLS; } } for (i=0; i<3; ++i) { for (j=0; j<3; ++j) { printf(" d[%d,%d]:\n cached: %g calc: %g diff: %g\n", i+1, j+1, cachedDetector->response[i][j], constructedDetector.response[i][j], cachedDetector->response[i][j] - constructedDetector.response[i][j]); if ( cachedDetector->response[i][j] - constructedDetector.response[i][j] >= DETECTORSITETESTC_RESTOL ) { return DETECTORSITETESTC_EFLS; } } } printf(" Latitude:\n cached: %g calc: %g diff: %g\n", cachedDetector->frDetector.vertexLatitudeRadians, constructedDetector.frDetector.vertexLatitudeRadians, cachedDetector->frDetector.vertexLatitudeRadians - constructedDetector.frDetector.vertexLatitudeRadians); if ( cachedDetector->frDetector.vertexLatitudeRadians != constructedDetector.frDetector.vertexLatitudeRadians) { return DETECTORSITETESTC_EFLS; } printf(" Longitude:\n cached: %g calc: %g diff: %g\n", cachedDetector->frDetector.vertexLongitudeRadians, constructedDetector.frDetector.vertexLongitudeRadians, cachedDetector->frDetector.vertexLongitudeRadians - constructedDetector.frDetector.vertexLongitudeRadians); if ( cachedDetector->frDetector.vertexLongitudeRadians != constructedDetector.frDetector.vertexLongitudeRadians) { return DETECTORSITETESTC_EFLS; } printf(" X Arm altitide:\n cached: %g calc: %g diff: %g\n", cachedDetector->frDetector.xArmAltitudeRadians, constructedDetector.frDetector.xArmAltitudeRadians, cachedDetector->frDetector.xArmAltitudeRadians - constructedDetector.frDetector.xArmAltitudeRadians); if ( cachedDetector->frDetector.xArmAltitudeRadians != constructedDetector.frDetector.xArmAltitudeRadians) { return DETECTORSITETESTC_EFLS; } printf(" X Arm azimuth:\n cached: %g calc: %g diff: %g\n", cachedDetector->frDetector.xArmAzimuthRadians, constructedDetector.frDetector.xArmAzimuthRadians, cachedDetector->frDetector.xArmAzimuthRadians - constructedDetector.frDetector.xArmAzimuthRadians); if ( cachedDetector->frDetector.xArmAzimuthRadians != constructedDetector.frDetector.xArmAzimuthRadians) { return DETECTORSITETESTC_EFLS; } printf(" Y Arm altitide:\n cached: %g calc: %g diff: %g\n", cachedDetector->frDetector.yArmAltitudeRadians, constructedDetector.frDetector.yArmAltitudeRadians, cachedDetector->frDetector.yArmAltitudeRadians - constructedDetector.frDetector.yArmAltitudeRadians); if ( cachedDetector->frDetector.yArmAltitudeRadians != constructedDetector.frDetector.yArmAltitudeRadians) { return DETECTORSITETESTC_EFLS; } printf(" Y Arm azimuth:\n cached: %g calc: %g diff: %g\n", cachedDetector->frDetector.yArmAzimuthRadians, constructedDetector.frDetector.yArmAzimuthRadians, cachedDetector->frDetector.yArmAzimuthRadians - constructedDetector.frDetector.yArmAzimuthRadians); if ( cachedDetector->frDetector.yArmAzimuthRadians != constructedDetector.frDetector.yArmAzimuthRadians) { return DETECTORSITETESTC_EFLS; } return DETECTORSITETESTC_ENOM; }
static void FUNC ( void ) { CreateArraySequenceIn input; UINT4Vector dimLength; UINT4 data[] = { 2, 3, 2 }; UINT4 dataBad[] = { 2, 3, 0 }; static LALStatus status; static VTYPE *sequence; static VTYPE sstore; /* * * Test ordinary behavior. * */ dimLength.length = 3; dimLength.data = data; input.length = 2; input.dimLength = &dimLength; CFUNC ( &status, &sequence, &input ); TestStatus( &status, CODES( 0 ), 1 ); memset( sequence->data, 0, sequence->length*sequence->arrayDim*sizeof( TYPE ) ); DFUNC ( &status, &sequence ); TestStatus( &status, CODES( 0 ), 1 ); LALCheckMemoryLeaks(); /* * * Test error codes. * */ #ifndef LAL_NDEBUG if ( ! lalNoDebug ) { input.length = 0; CFUNC ( &status, &sequence, &input ); TestStatus( &status, CODES( SEQFACTORIESH_ESLENGTH ), 1 ); input.length = 2; input.dimLength->data = dataBad; CFUNC ( &status, &sequence, &input ); TestStatus( &status, CODES( SEQFACTORIESH_EALENGTH ), 1 ); CFUNC ( &status, &sequence, NULL ); TestStatus( &status, CODES( SEQFACTORIESH_EINPTR ), 1 ); DFUNC ( &status, NULL ); TestStatus( &status, CODES( SEQFACTORIESH_EVPTR ), 1 ); input.dimLength->data = data; CFUNC ( &status, NULL, &input ); TestStatus( &status, CODES( SEQFACTORIESH_EVPTR ), 1 ); DFUNC ( &status, &sequence ); TestStatus( &status, CODES( SEQFACTORIESH_EUPTR ), 1 ); sequence = &sstore; CFUNC ( &status, &sequence, &input ); TestStatus( &status, CODES( SEQFACTORIESH_EUPTR ), 1 ); DFUNC ( &status, &sequence ); TestStatus( &status, CODES( SEQFACTORIESH_EDPTR ), 1 ); } #else (void)sstore; (void)dataBad; #endif LALCheckMemoryLeaks(); printf( "PASS: tests of %s and %s\n", STRING(CFUNC), STRING(DFUNC)); return; }
int main( int argc, char *argv[] ) { const UINT4 n = 65536; const REAL4 dt = 1.0 / 16384.0; static LALStatus status; static REAL4TimeSeries x; static COMPLEX8FrequencySeries X; static REAL4TimeSeries y; static REAL4FrequencySeries Y; static COMPLEX8TimeSeries z; static COMPLEX8FrequencySeries Z; RealFFTPlan *fwdRealPlan = NULL; RealFFTPlan *revRealPlan = NULL; ComplexFFTPlan *fwdComplexPlan = NULL; ComplexFFTPlan *revComplexPlan = NULL; RandomParams *randpar = NULL; AverageSpectrumParams avgSpecParams; UINT4 srate[] = { 4096, 9000 }; UINT4 npts[] = { 262144, 1048576 }; REAL4 var[] = { 5, 16 }; UINT4 j, sr, np, vr; /*CHAR fname[2048];*/ ParseOptions( argc, argv ); LALSCreateVector( &status, &x.data, n ); TestStatus( &status, CODES( 0 ), 1 ); LALCCreateVector( &status, &X.data, n / 2 + 1 ); TestStatus( &status, CODES( 0 ), 1 ); LALCCreateVector( &status, &z.data, n ); TestStatus( &status, CODES( 0 ), 1 ); LALCCreateVector( &status, &Z.data, n ); TestStatus( &status, CODES( 0 ), 1 ); LALCreateForwardRealFFTPlan( &status, &fwdRealPlan, n, 0 ); TestStatus( &status, CODES( 0 ), 1 ); LALCreateReverseRealFFTPlan( &status, &revRealPlan, n, 0 ); TestStatus( &status, CODES( 0 ), 1 ); LALCreateForwardComplexFFTPlan( &status, &fwdComplexPlan, n, 0 ); TestStatus( &status, CODES( 0 ), 1 ); LALCreateReverseComplexFFTPlan( &status, &revComplexPlan, n, 0 ); TestStatus( &status, CODES( 0 ), 1 ); randpar = XLALCreateRandomParams( 100 ); /* * * Try the real transform. * */ x.f0 = 0; x.deltaT = dt; x.sampleUnits = lalMeterUnit; snprintf( x.name, sizeof( x.name ), "x" ); XLALNormalDeviates( x.data, randpar ); for ( j = 0; j < n; ++j ) /* add a 60 Hz line */ { REAL4 t = j * dt; x.data->data[j] += 0.1 * cos( LAL_TWOPI * 60.0 * t ); } LALSPrintTimeSeries( &x, "x.out" ); snprintf( X.name, sizeof( X.name ), "X" ); LALTimeFreqRealFFT( &status, &X, &x, fwdRealPlan ); TestStatus( &status, CODES( 0 ), 1 ); LALCPrintFrequencySeries( &X, "X.out" ); LALFreqTimeRealFFT( &status, &x, &X, revRealPlan ); TestStatus( &status, CODES( 0 ), 1 ); LALSPrintTimeSeries( &x, "xx.out" ); /* * * Try the average power spectum. * */ avgSpecParams.method = useMean; for ( np = 0; np < XLAL_NUM_ELEM(npts) ; ++np ) { /* length of time series for 7 segments, overlapped by 1/2 segment */ UINT4 tsLength = npts[np] * 7 - 6 * npts[np] / 2; LALCreateVector( &status, &y.data, tsLength ); TestStatus( &status, CODES( 0 ), 1 ); LALCreateVector( &status, &Y.data, npts[np] / 2 + 1 ); TestStatus( &status, CODES( 0 ), 1 ); avgSpecParams.overlap = npts[np] / 2; /* create the window */ avgSpecParams.window = XLALCreateHannREAL4Window(npts[np]); avgSpecParams.plan = NULL; LALCreateForwardRealFFTPlan( &status, &avgSpecParams.plan, npts[np], 0 ); TestStatus( &status, CODES( 0 ), 1 ); for ( sr = 0; sr < XLAL_NUM_ELEM(srate) ; ++sr ) { /* set the sample rate of the time series */ y.deltaT = 1.0 / (REAL8) srate[sr]; for ( vr = 0; vr < XLAL_NUM_ELEM(var) ; ++vr ) { REAL4 eps = 1e-6; /* very conservative fp precision */ REAL4 Sfk = 2.0 * var[vr] * var[vr] * y.deltaT; REAL4 sfk = 0; REAL4 lbn; REAL4 sig; REAL4 ssq; REAL4 tol; /* create the data */ XLALNormalDeviates( y.data, randpar ); ssq = 0; for ( j = 0; j < y.data->length; ++j ) { y.data->data[j] *= var[vr]; ssq += y.data->data[j] * y.data->data[j]; } /* compute tolerance for comparison */ lbn = log( y.data->length ) / log( 2 ); sig = sqrt( 2.5 * lbn * eps * eps * ssq / y.data->length ); tol = 5 * sig; /* compute the psd and find the average */ LALREAL4AverageSpectrum( &status, &Y, &y, &avgSpecParams ); TestStatus( &status, CODES( 0 ), 1 ); LALSMoment( &status, &sfk, Y.data, 1 ); TestStatus( &status, CODES( 0 ), 1 ); /* check the result */ if ( fabs(Sfk-sfk) > tol ) { fprintf( stderr, "FAIL: PSD estimate appears incorrect\n"); fprintf( stderr, "expected %e, got %e ", Sfk, sfk ); fprintf( stderr, "(difference = %e, tolerance = %e)\n", fabs(Sfk-sfk), tol ); exit(2); } } } /* destroy structures that need to be resized */ LALDestroyRealFFTPlan( &status, &avgSpecParams.plan ); TestStatus( &status, CODES( 0 ), 1 ); XLALDestroyREAL4Window( avgSpecParams.window ); LALDestroyVector( &status, &y.data ); TestStatus( &status, CODES( 0 ), 1 ); LALDestroyVector( &status, &Y.data ); TestStatus( &status, CODES( 0 ), 1 ); } /* * * Try the complex transform. * */ z.f0 = 0; z.deltaT = dt; z.sampleUnits = lalVoltUnit; snprintf( z.name, sizeof( z.name ), "z" ); { /* dirty hack */ REAL4Vector tmp; tmp.length = 2 * z.data->length; tmp.data = (REAL4 *)z.data->data; XLALNormalDeviates( &tmp, randpar ); } for ( j = 0; j < n; ++j ) /* add a 50 Hz line and a 500 Hz ringdown */ { REAL4 t = j * dt; z.data->data[j] += 0.2 * cos( LAL_TWOPI * 50.0 * t ); z.data->data[j] += I * exp( -t ) * sin( LAL_TWOPI * 500.0 * t ); } LALCPrintTimeSeries( &z, "z.out" ); TestStatus( &status, CODES( 0 ), 1 ); snprintf( Z.name, sizeof( Z.name ), "Z" ); LALTimeFreqComplexFFT( &status, &Z, &z, fwdComplexPlan ); TestStatus( &status, CODES( 0 ), 1 ); LALCPrintFrequencySeries( &Z, "Z.out" ); LALFreqTimeComplexFFT( &status, &z, &Z, revComplexPlan ); TestStatus( &status, CODES( 0 ), 1 ); LALCPrintTimeSeries( &z, "zz.out" ); XLALDestroyRandomParams( randpar ); LALDestroyRealFFTPlan( &status, &fwdRealPlan ); TestStatus( &status, CODES( 0 ), 1 ); LALDestroyRealFFTPlan( &status, &revRealPlan ); TestStatus( &status, CODES( 0 ), 1 ); LALDestroyComplexFFTPlan( &status, &fwdComplexPlan ); TestStatus( &status, CODES( 0 ), 1 ); LALDestroyComplexFFTPlan( &status, &revComplexPlan ); TestStatus( &status, CODES( 0 ), 1 ); LALCDestroyVector( &status, &Z.data ); TestStatus( &status, CODES( 0 ), 1 ); LALCDestroyVector( &status, &z.data ); TestStatus( &status, CODES( 0 ), 1 ); LALCDestroyVector( &status, &X.data ); TestStatus( &status, CODES( 0 ), 1 ); LALSDestroyVector( &status, &x.data ); TestStatus( &status, CODES( 0 ), 1 ); LALCheckMemoryLeaks(); return 0; }
static void FUNC ( void ) { static UINT4 dims[3] = { 1, 2, 4 }; UINT4Vector dimLength = { 3, dims }; #ifndef LAL_NDEBUG static UINT4 dbad[3] = { 1, 0, 4 }; UINT4Vector badLength1 = { 3, NULL }; UINT4Vector badLength2 = { 0, dims }; UINT4Vector badLength3 = { 3, dbad }; #endif static LALStatus status; static VTYPE *array; static VTYPE astore; static TYPE datum; /* * * Test ordinary behavior. * */ CFUNC ( &status, &array, &dimLength ); TestStatus( &status, CODES( 0 ), 1 ); memset( array->data, 0, dims[0]*dims[1]*dims[2]*sizeof( TYPE ) ); /* resize up */ /* * dimLength.data[0] *= 2; * dimLength.data[1] *= 3; * dimLength.data[2] *= 4; */ dims[0] *= 2; dims[1] *= 3; dims[2] *= 4; RFUNC ( &status, &array, &dimLength ); TestStatus( &status, CODES( 0 ), 1 ); memset( array->data, 0, dims[0]*dims[1]*dims[2]*sizeof( TYPE ) ); /* resize down */ dims[0] /= 2; dims[1] /= 3; dims[2] /= 2; RFUNC ( &status, &array, &dimLength ); TestStatus( &status, CODES( 0 ), 1 ); memset( array->data, 0, dims[0]*dims[1]*dims[2]*sizeof( TYPE ) ); /* resize down again */ dims[2] /= 2; RFUNC ( &status, &array, &dimLength ); TestStatus( &status, CODES( 0 ), 1 ); memset( array->data, 0, dims[0]*dims[1]*dims[2]*sizeof( TYPE ) ); DFUNC ( &status, &array ); TestStatus( &status, CODES( 0 ), 1 ); LALCheckMemoryLeaks(); /* * * Test error codes. * */ #ifndef LAL_NDEBUG if ( ! lalNoDebug ) { CFUNC ( &status, &array, &badLength1 ); TestStatus( &status, CODES( AVFACTORIESH_EVPTR ), 1 ); RFUNC ( &status, &array, &badLength1 ); TestStatus( &status, CODES( AVFACTORIESH_EVPTR ), 1 ); CFUNC ( &status, &array, &badLength2 ); TestStatus( &status, CODES( AVFACTORIESH_ELENGTH ), 1 ); RFUNC ( &status, &array, &badLength2 ); TestStatus( &status, CODES( AVFACTORIESH_ELENGTH ), 1 ); CFUNC ( &status, &array, &badLength3 ); TestStatus( &status, CODES( AVFACTORIESH_ELENGTH ), 1 ); RFUNC ( &status, &array, &badLength3 ); TestStatus( &status, CODES( AVFACTORIESH_ELENGTH ), 1 ); LALCheckMemoryLeaks(); DFUNC ( &status, NULL ); TestStatus( &status, CODES( AVFACTORIESH_EVPTR ), 1 ); CFUNC ( &status, NULL, &dimLength ); TestStatus( &status, CODES( AVFACTORIESH_EVPTR ), 1 ); RFUNC ( &status, NULL, &badLength1 ); TestStatus( &status, CODES( AVFACTORIESH_EVPTR ), 1 ); DFUNC ( &status, &array ); TestStatus( &status, CODES( AVFACTORIESH_EUPTR ), 1 ); array = &astore; CFUNC ( &status, &array, &dimLength ); TestStatus( &status, CODES( AVFACTORIESH_EUPTR ), 1 ); RFUNC ( &status, &array, &badLength1 ); TestStatus( &status, CODES( AVFACTORIESH_EVPTR ), 1); RFUNC ( &status, &array, &badLength2 ); TestStatus( &status, CODES( AVFACTORIESH_ELENGTH ), 1); RFUNC ( &status, &array, &badLength3 ); TestStatus( &status, CODES( AVFACTORIESH_ELENGTH ), 1); DFUNC ( &status, &array ); TestStatus( &status, CODES( AVFACTORIESH_EDPTR ), 1 ); array->data = &datum; DFUNC ( &status, &array ); TestStatus( &status, CODES( AVFACTORIESH_EDPTR ), 1 ); ClearStatus( &status ); } #else array = &astore; array->data = &datum; #endif LALCheckMemoryLeaks(); printf( "PASS: tests of %s, %s, and %s\n", STRING(CFUNC), STRING(RFUNC), STRING(DFUNC)); return; }
int main (int argc, char *argv[]) { static LALStatus status; SFindRootIn sinput; DFindRootIn dinput; REAL4 y_0; REAL4 sroot; REAL8 yy0; REAL8 droot; /* * * Parse the command line options * */ ParseOptions (argc, argv); /* * * Set up input structure and function parameter y_0. * */ y_0 = -1; sinput.function = F; sinput.xmin = 1e-3; sinput.xmax = 2e-3; sinput.xacc = 1e-6; yy0 = -1; dinput.function = FF; dinput.xmin = 1e-3; dinput.xmax = 2e-3; dinput.xacc = 1e-15; /* * * Check to see if bracketing and root finding work. * */ if (verbose) { printf ("\n===== Check Root Finding =====\n\n"); } if (verbose) { printf ("Initial domain: [%e,%e]\n", dinput.xmin, dinput.xmax); } LALSBracketRoot (&status, &sinput, &y_0); TestStatus (&status, CODES(0), 1); if (verbose) { printf ("Bracket domain: [%e,%e]\n", sinput.xmin, sinput.xmax); } if (sinput.xmin > 1 || sinput.xmax < 1) { fprintf (stderr, "Root not bracketed correctly\n"); return 1; } LALDBracketRoot (&status, &dinput, &yy0); TestStatus (&status, CODES(0), 1); if (verbose) { printf ("Bracket domain: [%e,%e]\n", dinput.xmin, dinput.xmax); } if (dinput.xmin > 1 || dinput.xmax < 1) { fprintf (stderr, "Root not bracketed correctly\n"); return 1; } LALSBisectionFindRoot (&status, &sroot, &sinput, &y_0); TestStatus (&status, CODES(0), 1); if (verbose) { printf ("Root = %e (acc = %e)\n", sroot, sinput.xacc); } if (fabs(sroot - 1) > sinput.xacc) { fprintf (stderr, "Root not found to correct accuracy\n"); return 1; } LALDBisectionFindRoot (&status, &droot, &dinput, &yy0); TestStatus (&status, CODES(0), 1); if (verbose) { printf ("Root = %.15e (acc = %e)\n", droot, dinput.xacc); } if (fabs(droot - 1) > dinput.xacc) { fprintf (stderr, "Root not found to correct accuracy\n"); return 1; } /* * * Check to make sure that correct error codes are generated. * */ #ifndef LAL_NDEBUG if ( ! lalNoDebug ) { if (verbose || lalDebugLevel) { printf ("\n===== Check Errors =====\n"); } /* recursive error from an error occurring in the function */ if (verbose) { printf ("\n----- Recursive Error: Code -1 (2 times)\n"); } LALSBracketRoot (&status, &sinput, NULL); TestStatus (&status, CODES(-1), 1); ClearStatus (&status); LALDBracketRoot (&status, &dinput, NULL); TestStatus (&status, CODES(-1), 1); ClearStatus (&status); /* one of the arguments is a null pointer */ if (verbose) { printf ("\n----- Null Pointer Error: Code 1 (10 times)\n"); } LALSBracketRoot (&status, NULL, &y_0); TestStatus (&status, CODES(FINDROOTH_ENULL), 1); LALDBracketRoot (&status, NULL, &yy0); TestStatus (&status, CODES(FINDROOTH_ENULL), 1); LALSBisectionFindRoot (&status, NULL, &sinput, &y_0); TestStatus (&status, CODES(FINDROOTH_ENULL), 1); LALDBisectionFindRoot (&status, NULL, &dinput, &yy0); TestStatus (&status, CODES(FINDROOTH_ENULL), 1); LALSBisectionFindRoot (&status, &sroot, NULL, &y_0); TestStatus (&status, CODES(FINDROOTH_ENULL), 1); LALDBisectionFindRoot (&status, &droot, NULL, &yy0); TestStatus (&status, CODES(FINDROOTH_ENULL), 1); sinput.function = NULL; dinput.function = NULL; LALSBracketRoot (&status, &sinput, &y_0); TestStatus (&status, CODES(FINDROOTH_ENULL), 1); LALDBracketRoot (&status, &dinput, &yy0); TestStatus (&status, CODES(FINDROOTH_ENULL), 1); LALSBisectionFindRoot (&status, &sroot, &sinput, &y_0); TestStatus (&status, CODES(FINDROOTH_ENULL), 1); LALDBisectionFindRoot (&status, &droot, &dinput, &yy0); TestStatus (&status, CODES(FINDROOTH_ENULL), 1); /* invalid initial domain error for BracketRoot() */ if (verbose) { printf ("\n----- Invalid Initial Domain: Code 2 (2 times)\n"); } sinput.function = F; sinput.xmin = 5; sinput.xmax = 5; dinput.function = FF; dinput.xmin = 5; dinput.xmax = 5; LALSBracketRoot (&status, &sinput, &y_0); TestStatus (&status, CODES(FINDROOTH_EIDOM), 1); LALDBracketRoot (&status, &dinput, &yy0); TestStatus (&status, CODES(FINDROOTH_EIDOM), 1); /* maximum iterations exceeded error */ if (verbose) { printf ("\n----- Maximum Iteration Exceeded: Code 4 (4 times)\n"); } y_0 = 1; /* there is no root when y_0 > 0 */ sinput.xmin = -1e-18; sinput.xmax = 1e-18; yy0 = 1; /* there is no root when y_0 > 0 */ dinput.xmin = -1e-18; dinput.xmax = 1e-18; LALSBracketRoot (&status, &sinput, &y_0); TestStatus (&status, CODES(FINDROOTH_EMXIT), 1); LALDBracketRoot (&status, &dinput, &yy0); TestStatus (&status, CODES(FINDROOTH_EMXIT), 1); y_0 = -1; sinput.xmin = 0; sinput.xmax = 1e19; sinput.xacc = 2e-38; yy0 = -1; dinput.xmin = 0; dinput.xmax = 1e19; dinput.xacc = 2e-38; LALSBisectionFindRoot (&status, &sroot, &sinput, &y_0); TestStatus (&status, CODES(FINDROOTH_EMXIT), 1); LALDBisectionFindRoot (&status, &droot, &dinput, &yy0); TestStatus (&status, CODES(FINDROOTH_EMXIT), 1); /* root not bracketed error in BisectionFindRoot() */ if (verbose) { printf ("\n----- Root Not Bracketed: Code 8 (2 times)\n"); } sinput.xmin = -5; sinput.xmax = -3; sinput.xacc = 1e-6; dinput.xmin = -5; dinput.xmax = -3; dinput.xacc = 1e-6; LALSBisectionFindRoot (&status, &sroot, &sinput, &y_0); TestStatus (&status, CODES(FINDROOTH_EBRKT), 1); LALDBisectionFindRoot (&status, &droot, &dinput, &yy0); TestStatus (&status, CODES(FINDROOTH_EBRKT), 1); } #endif return 0; }
int main( int argc, char *argv[] ) { static LALStatus status; RealFFTPlan *fwd = NULL; RealFFTPlan *rev = NULL; REAL4Vector *dat = NULL; REAL4Vector *rfft = NULL; REAL4Vector *ans = NULL; COMPLEX8Vector *dft = NULL; COMPLEX8Vector *fft = NULL; #if LAL_CUDA_ENABLED /* The test itself should pass at 1e-4, but it might fail at * some rare cases where accuracy is bad for some numbers. */ REAL8 eps = 3e-4; #else /* very conservative floating point precision */ REAL8 eps = 1e-6; #endif REAL8 lbn; REAL8 ssq; REAL8 var; REAL8 tol; UINT4 nmax; UINT4 m; UINT4 n; UINT4 i; UINT4 j; UINT4 k; UINT4 s = 0; FILE *fp; ParseOptions( argc, argv ); m = m_; n = n_; fp = verbose ? stdout : NULL ; if ( n == 0 ) { nmax = 65536; } else { nmax = n--; } while ( n < nmax ) { if ( n < 128 ) { ++n; } else { n *= 2; } LALSCreateVector( &status, &dat, n ); TestStatus( &status, CODES( 0 ), 1 ); LALSCreateVector( &status, &rfft, n ); TestStatus( &status, CODES( 0 ), 1 ); LALSCreateVector( &status, &ans, n ); TestStatus( &status, CODES( 0 ), 1 ); LALCCreateVector( &status, &dft, n / 2 + 1 ); TestStatus( &status, CODES( 0 ), 1 ); LALCCreateVector( &status, &fft, n / 2 + 1 ); TestStatus( &status, CODES( 0 ), 1 ); LALCreateForwardRealFFTPlan( &status, &fwd, n, 0 ); TestStatus( &status, CODES( 0 ), 1 ); LALCreateReverseRealFFTPlan( &status, &rev, n, 0 ); TestStatus( &status, CODES( 0 ), 1 ); /* * * Do m trials of random data. * */ for ( i = 0; i < m; ++i ) { srand( s++ ); /* seed the random number generator */ /* * * Create data and compute error tolerance. * * Reference: Kaneko and Liu, * "Accumulation of round-off error in fast fourier tranforms" * J. Asssoc. Comp. Mach, Vol 17 (No 4) 637-654, October 1970. * */ srand( i ); /* seed the random number generator */ ssq = 0; for ( j = 0; j < n; ++j ) { dat->data[j] = 20.0 * rand() / (REAL4)( RAND_MAX + 1.0 ) - 10.0; ssq += dat->data[j] * dat->data[j]; fp ? fprintf( fp, "%e\n", dat->data[j] ) : 0; } lbn = log( n ) / log( 2 ); var = 2.5 * lbn * eps * eps * ssq / n; tol = 5 * sqrt( var ); /* up to 5 sigma excursions */ fp ? fprintf( fp, "\neps = %e \ntol = %e\n", eps, tol ) : 0; /* * * Perform forward FFT and DFT (only if n < 100). * */ LALForwardRealFFT( &status, fft, dat, fwd ); TestStatus( &status, CODES( 0 ), 1 ); LALREAL4VectorFFT( &status, rfft, dat, fwd ); TestStatus( &status, CODES( 0 ), 1 ); LALREAL4VectorFFT( &status, ans, rfft, rev ); TestStatus( &status, CODES( 0 ), 1 ); fp ? fprintf( fp, "rfft()\t\trfft(rfft())\trfft(rfft())\n\n" ) : 0; for ( j = 0; j < n; ++j ) { fp ? fprintf( fp, "%e\t%e\t%e\n", rfft->data[j], ans->data[j], ans->data[j] / n ) : 0; } if ( n < 128 ) { LALForwardRealDFT( &status, dft, dat ); TestStatus( &status, CODES( 0 ), 1 ); /* * * Check accuracy of FFT vs DFT. * */ fp ? fprintf( fp, "\nfftre\t\tfftim\t\t" ) : 0; fp ? fprintf( fp, "dtfre\t\tdftim\n" ) : 0; for ( k = 0; k <= n / 2; ++k ) { REAL8 fftre = creal(fft->data[k]); REAL8 fftim = cimag(fft->data[k]); REAL8 dftre = creal(dft->data[k]); REAL8 dftim = cimag(dft->data[k]); REAL8 errre = fabs( dftre - fftre ); REAL8 errim = fabs( dftim - fftim ); REAL8 avere = fabs( dftre + fftre ) / 2 + eps; REAL8 aveim = fabs( dftim + fftim ) / 2 + eps; REAL8 ferre = errre / avere; REAL8 ferim = errim / aveim; fp ? fprintf( fp, "%e\t%e\t", fftre, fftim ) : 0; fp ? fprintf( fp, "%e\t%e\n", dftre, dftim ) : 0; /* fp ? fprintf( fp, "%e\t%e\t", errre, errim ) : 0; */ /* fp ? fprintf( fp, "%e\t%e\n", ferre, ferim ) : 0; */ if ( ferre > eps && errre > tol ) { fputs( "FAIL: Incorrect result from forward transform\n", stderr ); fprintf( stderr, "\tdifference = %e\n", errre ); fprintf( stderr, "\ttolerance = %e\n", tol ); fprintf( stderr, "\tfrac error = %e\n", ferre ); fprintf( stderr, "\tprecision = %e\n", eps ); return 1; } if ( ferim > eps && errim > tol ) { fputs( "FAIL: Incorrect result from forward transform\n", stderr ); fprintf( stderr, "\tdifference = %e\n", errim ); fprintf( stderr, "\ttolerance = %e\n", tol ); fprintf( stderr, "\tfrac error = %e\n", ferim ); fprintf( stderr, "\tprecision = %e\n", eps ); return 1; } } } /* * * Perform reverse FFT and check accuracy vs original data. * */ LALReverseRealFFT( &status, ans, fft, rev ); TestStatus( &status, CODES( 0 ), 1 ); fp ? fprintf( fp, "\ndat->data[j]\tans->data[j] / n\n" ) : 0; for ( j = 0; j < n; ++j ) { REAL8 err = fabs( dat->data[j] - ans->data[j] / n ); REAL8 ave = fabs( dat->data[j] + ans->data[j] / n ) / 2 + eps; REAL8 fer = err / ave; fp ? fprintf( fp, "%e\t%e\n", dat->data[j], ans->data[j] / n ) : 0; /* fp ? fprintf( fp, "%e\t%e\n", err, fer ) : 0; */ if ( fer > eps && err > tol ) { fputs( "FAIL: Incorrect result after reverse transform\n", stderr ); fprintf( stderr, "\tdifference = %e\n", err ); fprintf( stderr, "\ttolerance = %e\n", tol ); fprintf( stderr, "\tfrac error = %e\n", fer ); fprintf( stderr, "\tprecision = %e\n", eps ); return 1; } } } LALSDestroyVector( &status, &dat ); TestStatus( &status, CODES( 0 ), 1 ); LALSDestroyVector( &status, &rfft ); TestStatus( &status, CODES( 0 ), 1 ); LALSDestroyVector( &status, &ans ); TestStatus( &status, CODES( 0 ), 1 ); LALCDestroyVector( &status, &dft ); TestStatus( &status, CODES( 0 ), 1 ); LALCDestroyVector( &status, &fft ); TestStatus( &status, CODES( 0 ), 1 ); LALDestroyRealFFTPlan( &status, &fwd ); TestStatus( &status, CODES( 0 ), 1 ); LALDestroyRealFFTPlan( &status, &rev ); TestStatus( &status, CODES( 0 ), 1 ); } LALCheckMemoryLeaks(); return 0; }