home *** CD-ROM | disk | FTP | other *** search
- #include <stdlib.h>
- #include <stdio.h>
- #include <sys/time.h>
- #include <math.h>
- #include "conv.h"
-
- /* --------- The following definitions change
- according to precision required -------- */
-
-
- #ifdef SINGLE /* complex single precision */
-
- typedef float this_variable;
-
- #define OPS_PER_ITER 2
-
- void sfir1d_();
- #define MY_CONV sfir1d_
- #define MY_RECU siir1d_
- #define MY_CORR scor1d_
- #define MY_INIT sinit_
- #define TOLERANCE 1.e-5
-
- #endif
- #ifdef DOUBLE /* real double precision */
-
- typedef double this_variable;
-
- #define OPS_PER_ITER 2
-
- void dfir1d_(), ornl_dfir1d_(), simple_dfir1d_();
- #define MY_CONV dfir1d_
- #define MY_RECU diir1d_
- #define MY_CORR dcor1d_
- #define MY_INIT dinit_
- #define TOLERANCE 1.e-10
-
- #endif
-
- /* ---------- The rest is the same ---------------- */
-
- #define MAX_SIZE 55
- #define DEFAULT_TRIALS 999
- #define MAX_INC 5
- #define MAX_TIMES 3
-
- #define ABS(a) ( ((a)>0) ? (a) : -(a))
- #define MAX(a,b) ( ((a) > (b)) ? (a) : (b))
- #define MIN(a,b) ( ((a) < (b)) ? (a) : (b))
-
- int nf, ng, nh;
- int incf, nf1, nf2, incg, ng1, ng2, inch, nh1, nh2;
- this_variable *vx, *vy, *vz, *vt, *vr;
- this_variable alpha, beta;
-
- double t, x, y, z, u;
-
- main(argc,argv)
- int argc;
- char *argv[];
- {
- int i, j, k;
-
- /* ******************************************************* */
-
-
- get_values();
-
- fprintf(stderr,"(%3d,%3d,%3d | %2d,%3d,%3d | %2d,%3d,%3d | %5.2f | %2d,%3d,%3d | %5.2f): ",
- nf,ng,nh, incf,nf1,nf2, incg,ng1,ng2, alpha, inch,nh1,nh2, beta);
-
- vx = (this_variable *)my_malloc(((nf+1)) * sizeof( this_variable));
- vy = (this_variable *)my_malloc(((ng+1)) * sizeof( this_variable));
- vz = (this_variable *)my_malloc(((nh+1)) * sizeof( this_variable));
- vt = (this_variable *)my_malloc(((nh+1)) * sizeof( this_variable));
- vr = (this_variable *)my_malloc(((nh+1)) * sizeof( this_variable));
-
- if( (vx == (this_variable *)0) ||
- (vy == (this_variable *)0) ||
- (vt == (this_variable *)0) ||
- (vr == (this_variable *)0) ||
- (vz == (this_variable *)0)) {
- fprintf( stderr, "Malloc problem ... Exiting");
- exit( -2);
- }
- i = MY_INIT( &nf, vx);
- j = MY_INIT( &ng, vy);
- /*
- *vy = 1.2;
- */
- k = nh+1;
- MY_INIT( &k, vz);
-
- do_it();
-
- print_it();
-
- my_free ( vx);
- my_free ( vy);
- my_free ( vz);
- my_free ( vt);
- my_free ( vr);
- }
-
-
- do_it()
- {
- int i, j, k;
-
- i = nf2-nf1+1;
- j = ng2-ng1+1;
- k = nh2-nh1+1;
- MY_CONV( vx,&incf,&nf1,&i,vy,&incg,&ng1,&j,
- vz,&inch,&nh1,&k, &alpha, &beta);
-
-
- MY_RECU( vx,&incf,&nf1,&i,vy,&incg,&ng1,&j,
- vr,&inch,&nh1,&k);
-
-
- MY_CORR( vx,&incf,&nf1,&i,vy,&incg,&ng1,&j,
- vt,&inch,&nh1,&k);
- }
-
- print_it()
- {
- int min, max, i;
- min = MIN( MIN(nf1,ng1), nh1);
- max = MAX( MAX(nf2,ng2), nh2);
- for( i = min; i <= max ; i++) {
- printf( "%d ", i);
- printf( " %f", ( (i<nf1) || (i>nf2) ) ? (0.0) : (double)vx[(i-nf1)*incf]);
- printf( " %f", ( (i<ng1) || (i>ng2) ) ? (0.0) : (double)vy[(i-ng1)*incg]);
- printf( " %f", ( (i<nh1) || (i>nh2) ) ? (0.0) : (double)vz[(i-nh1)*inch]);
- printf( " %f", ( (i<nh1) || (i>nh2) ) ? (0.0) : (double)vt[(i-nh1)*inch]);
- printf( " %f", ( (i<nh1) || (i>nh2) ) ? (0.0) : (double)vr[(i-nh1)*inch]);
- printf( "\n");
- }
- }
-
- get_values(){
- fprintf(stderr, "Enter nf1 : ");
- scanf( "%d", &nf1);
- fprintf(stderr, "Enter nf2 : ");
- scanf( "%d", &nf2);
- fprintf(stderr, "Enter incf : ");
- scanf( "%d", &incf);
-
- fprintf(stderr, "Enter ng1 : ");
- scanf( "%d", &ng1);
- fprintf(stderr, "Enter ng2 : ");
- scanf( "%d", &ng2);
- fprintf(stderr, "Enter incg : ");
- scanf( "%d", &incg);
-
- fprintf(stderr, "Enter nh1 : ");
- scanf( "%d", &nh1);
- fprintf(stderr, "Enter nh2 : ");
- scanf( "%d", &nh2);
- fprintf(stderr, "Enter inch : ");
- scanf( "%d", &inch);
-
- alpha = 1.;
- beta = 0.;
-
- nf = nf2-nf1+1;
- ng = ng2-ng1+1;
- nh = nh2-nh1+1;
- inirand_();
- }
-
-