From 4cbfbad8b55f47627fe687ac238f6a75305c73bc Mon Sep 17 00:00:00 2001 From: h_vogt Date: Sun, 21 Aug 2011 10:43:07 +0000 Subject: [PATCH] type long --> int --- ChangeLog | 5 + src/include/ngspice/fftext.h | 18 +- src/maths/fft/fftext.c | 31 ++-- src/maths/fft/fftlib.c | 252 +++++++++++++-------------- src/maths/fft/fftlib.h | 16 +- src/spicelib/devices/isrc/isrcacct.c | 5 +- src/spicelib/devices/vsrc/vsrcacct.c | 5 +- 7 files changed, 172 insertions(+), 160 deletions(-) diff --git a/ChangeLog b/ChangeLog index 1e702768e..b4aa6b8c2 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +2011-08-21 Holger Vogt + * fftext.h, fftext.c, fftlib.c, fftlib.h: type long to int + (patch by Robert) + isracct.c, vsrcacct.c: suppress info on freeing fft tables + 2011-08-21 Robert Larice * src/main.c , * src/frontend/runcoms.c , diff --git a/src/include/ngspice/fftext.h b/src/include/ngspice/fftext.h index b17f60969..69b53d3ca 100644 --- a/src/include/ngspice/fftext.h +++ b/src/include/ngspice/fftext.h @@ -9,7 +9,7 @@ #define FFT(a,n) if(!fftInit(roundtol(LOG2(n)))) ffts(a,roundtol(LOG2(n)),1);else printf("fft error\n"); *******************************************************************/ -int fftInit(long M); +int fftInit(int M); // malloc and init cosine and bit reversed tables for a given size fft, ifft, rfft, rifft /* INPUTS */ /* M = log2 of fft size (ex M=10 for 1024 point fft) */ @@ -19,7 +19,7 @@ int fftInit(long M); void fftFree(void); // release storage for all private cosine and bit reversed tables -void ffts(double *data, long M, long Rows); +void ffts(double *data, int M, int Rows); /* Compute in-place complex fft on the rows of the input array */ /* INPUTS */ /* *ioptr = input data array */ @@ -28,7 +28,7 @@ void ffts(double *data, long M, long Rows); /* OUTPUTS */ /* *ioptr = output data array */ -void iffts(double *data, long M, long Rows); +void iffts(double *data, int M, int Rows); /* Compute in-place inverse complex fft on the rows of the input array */ /* INPUTS */ /* *ioptr = input data array */ @@ -37,7 +37,7 @@ void iffts(double *data, long M, long Rows); /* OUTPUTS */ /* *ioptr = output data array */ -void rffts(double *data, long M, long Rows); +void rffts(double *data, int M, int Rows); /* Compute in-place real fft on the rows of the input array */ /* The result is the complex spectra of the positive frequencies */ /* except the location for the first complex number contains the real */ @@ -51,7 +51,7 @@ void rffts(double *data, long M, long Rows); /* *ioptr = output data array in the following order */ /* Re(x[0]), Re(x[N/2]), Re(x[1]), Im(x[1]), Re(x[2]), Im(x[2]), ... Re(x[N/2-1]), Im(x[N/2-1]). */ -void riffts(double *data, long M, long Rows); +void riffts(double *data, int M, int Rows); /* Compute in-place real ifft on the rows of the input array */ /* data order as from rffts */ /* INPUTS */ @@ -62,7 +62,7 @@ void riffts(double *data, long M, long Rows); /* OUTPUTS */ /* *ioptr = real output data array */ -void rspectprod(double *data1, double *data2, double *outdata, long N); +void rspectprod(double *data1, double *data2, double *outdata, int N); // When multiplying a pair of spectra from rfft care must be taken to multiply the // two real values seperately from the complex ones. This routine does it correctly. // the result can be stored in-place over one of the inputs @@ -81,9 +81,9 @@ void rspectprod(double *data1, double *data2, double *outdata, long N); //This is how I like to define a real matrix: //struct matrix { // real matrix // double *d; // pointer to data -// long Nrows; // number of rows in the matrix -// long Ncols; // number of columns in the matrix (can be less than Rsiz) -// long Rsiz; // number of doubles from one row to the next +// int Nrows; // number of rows in the matrix +// int Ncols; // number of columns in the matrix (can be less than Rsiz) +// int Rsiz; // number of doubles from one row to the next //}; //typedef struct matrix matrix; diff --git a/src/maths/fft/fftext.c b/src/maths/fft/fftext.c index 28a69b6ba..6df797ca7 100644 --- a/src/maths/fft/fftext.c +++ b/src/maths/fft/fftext.c @@ -12,14 +12,15 @@ #include "fftlib.h" #include "matlib.h" #include +#include // pointers to storage of Utbl's and BRLow's -static double *UtblArray[8*sizeof(long)] = +static double *UtblArray[8*sizeof(int)] = {0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0}; -static short *BRLowArray[8*sizeof(long)/2] = {0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0}; +static short *BRLowArray[8*sizeof(int)/2] = {0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0}; -int fftInit(long M) +int fftInit(int M) { // malloc and init cosine and bit reversed tables for a given size fft, ifft, rfft, rifft /* INPUTS */ @@ -29,11 +30,11 @@ int fftInit(long M) int theError = 1; /*** I did NOT test cases with M>27 ***/ - if ((M >= 0) && (M < 8*sizeof(long))) { + if ((M >= 0) && ((size_t) M < 8*sizeof(int))) { theError = 0; if (UtblArray[M] == 0) { // have we not inited this size fft yet? // init cos table - UtblArray[M] = (double *) malloc( (POW2(M)/4+1)*sizeof(double) ); + UtblArray[M] = TMALLOC(double, POW2(M)/4+1); if (UtblArray[M] == 0) theError = 2; else { @@ -41,7 +42,7 @@ int fftInit(long M) } if (M > 1) { if (BRLowArray[M/2] == 0) { // init bit reversed table for cmplx fft - BRLowArray[M/2] = (short *) malloc( POW2(M/2-1)*sizeof(short) ); + BRLowArray[M/2] = TMALLOC(short, POW2(M/2-1)); if (BRLowArray[M/2] == 0) theError = 2; else { @@ -51,7 +52,7 @@ int fftInit(long M) } if (M > 2) { if (BRLowArray[(M-1)/2] == 0) { // init bit reversed table for real fft - BRLowArray[(M-1)/2] = (short *) malloc( POW2((M-1)/2-1)*sizeof(short) ); + BRLowArray[(M-1)/2] = TMALLOC(short, POW2((M-1)/2-1)); if (BRLowArray[(M-1)/2] == 0) theError = 2; else { @@ -67,14 +68,14 @@ int fftInit(long M) void fftFree(void) { // release storage for all private cosine and bit reversed tables - long i1; - for (i1=8*sizeof(long)/2-1; i1>=0; i1--) { + int i1; + for (i1=8*sizeof(int)/2-1; i1>=0; i1--) { if (BRLowArray[i1] != 0) { free(BRLowArray[i1]); BRLowArray[i1] = 0; }; }; - for (i1=8*sizeof(long)-1; i1>=0; i1--) { + for (i1=8*sizeof(int)-1; i1>=0; i1--) { if (UtblArray[i1] != 0) { free(UtblArray[i1]); UtblArray[i1] = 0; @@ -87,7 +88,7 @@ void fftFree(void) Just make sure fftlib has been called for each M first. **************************************************/ -void ffts(double *data, long M, long Rows) +void ffts(double *data, int M, int Rows) { /* Compute in-place complex fft on the rows of the input array */ /* INPUTS */ @@ -99,7 +100,7 @@ void ffts(double *data, long M, long Rows) ffts1(data, M, Rows, UtblArray[M], BRLowArray[M/2]); } -void iffts(double *data, long M, long Rows) +void iffts(double *data, int M, int Rows) { /* Compute in-place inverse complex fft on the rows of the input array */ /* INPUTS */ @@ -111,7 +112,7 @@ void iffts(double *data, long M, long Rows) iffts1(data, M, Rows, UtblArray[M], BRLowArray[M/2]); } -void rffts(double *data, long M, long Rows) +void rffts(double *data, int M, int Rows) { /* Compute in-place real fft on the rows of the input array */ /* The result is the complex spectra of the positive frequencies */ @@ -128,7 +129,7 @@ void rffts(double *data, long M, long Rows) rffts1(data, M, Rows, UtblArray[M], BRLowArray[(M-1)/2]); } -void riffts(double *data, long M, long Rows) +void riffts(double *data, int M, int Rows) { /* Compute in-place real ifft on the rows of the input array */ /* data order as from rffts */ @@ -142,7 +143,7 @@ void riffts(double *data, long M, long Rows) riffts1(data, M, Rows, UtblArray[M], BRLowArray[(M-1)/2]); } -void rspectprod(double *data1, double *data2, double *outdata, long N) +void rspectprod(double *data1, double *data2, double *outdata, int N) { // When multiplying a pair of spectra from rfft care must be taken to multiply the // two real values seperately from the complex ones. This routine does it correctly. diff --git a/src/maths/fft/fftlib.c b/src/maths/fft/fftlib.c index e71549466..b69ec5be0 100644 --- a/src/maths/fft/fftlib.c +++ b/src/maths/fft/fftlib.c @@ -3,7 +3,7 @@ lower level fft stuff including routines called in fftext.c and fft2d.c *******************************************************************/ #include "fftlib.h" #include -#define MCACHE (11-(sizeof(double)/8)) // fft's with M bigger than this bust primary cache +#define MCACHE (11-(int)(sizeof(double)/8)) // fft's with M bigger than this bust primary cache // some math constants to 40 decimal places #define MYPI 3.141592653589793238462643383279502884197 // pi @@ -20,7 +20,7 @@ lower level fft stuff including routines called in fftext.c and fft2d.c routines to initialize tables used by fft routines **************************************************/ -void fftCosInit(long M, double *Utbl) +void fftCosInit(int M, double *Utbl) { /* Compute Utbl, the cosine table for ffts */ /* of size (pow(2,M)/4 +1) */ @@ -28,15 +28,15 @@ void fftCosInit(long M, double *Utbl) /* M = log2 of fft size */ /* OUTPUTS */ /* *Utbl = cosine table */ - unsigned long fftN = POW2(M); - unsigned long i1; + int fftN = POW2(M); + int i1; Utbl[0] = 1.0; for (i1 = 1; i1 < fftN/4; i1++) Utbl[i1] = cos( (2.0 * MYPI * i1) / fftN ); Utbl[fftN/4] = 0.0; } -void fftBRInit(long M, short *BRLow) +void fftBRInit(int M, short *BRLow) { /* Compute BRLow, the bit reversed table for ffts */ /* of size pow(2,M/2 -1) */ @@ -44,19 +44,19 @@ void fftBRInit(long M, short *BRLow) /* M = log2 of fft size */ /* OUTPUTS */ /* *BRLow = bit reversed counter table */ - long Mroot_1 = M / 2 - 1; - long Nroot_1 = POW2(Mroot_1); - long i1; - long bitsum; - long bitmask; - long bit; + int Mroot_1 = M / 2 - 1; + int Nroot_1 = POW2(Mroot_1); + int i1; + int bitsum; + int bitmask; + int bit; for (i1 = 0; i1 < Nroot_1; i1++) { bitsum = 0; bitmask = 1; for (bit=1; bit <= Mroot_1; bitmask<<=1, bit++) if (i1 & bitmask) bitsum = bitsum + (Nroot_1 >> bit); - BRLow[i1] = bitsum; + BRLow[i1] = (short) bitsum; }; } @@ -64,8 +64,8 @@ void fftBRInit(long M, short *BRLow) parts of ffts1 *************************************************/ -static inline void bitrevR2(double *ioptr, long M, short *BRLow); -static inline void bitrevR2(double *ioptr, long M, short *BRLow) +static inline void bitrevR2(double *ioptr, int M, short *BRLow); +static inline void bitrevR2(double *ioptr, int M, short *BRLow) { /*** bit reverse and first radix 2 stage of forward or inverse fft ***/ double f0r; @@ -92,17 +92,17 @@ static inline void bitrevR2(double *ioptr, long M, short *BRLow) double *p1r; double *IOP; double *iolimit; - long Colstart; - long iCol; - unsigned long posA; - unsigned long posAi; - unsigned long posB; - unsigned long posBi; - - const unsigned long Nrems2 = POW2((M+3)/2); - const unsigned long Nroot_1_ColInc = POW2(M)-Nrems2; - const unsigned long Nroot_1 = POW2(M/2-1)-1; - const unsigned long ColstartShift = (M+1)/2 +1; + int Colstart; + int iCol; + int posA; + int posAi; + int posB; + int posBi; + + const int Nrems2 = POW2((M+3)/2); + const int Nroot_1_ColInc = POW2(M)-Nrems2; + const int Nroot_1 = POW2(M/2-1)-1; + const int ColstartShift = (M+1)/2 +1; posA = POW2(M); // 1/2 of POW2(M) complexes posAi = posA + 1; posB = posA + 2; @@ -410,16 +410,16 @@ static inline void fft8pt(double *ioptr) ioptr[15] = f6i; } -static inline void bfR2(double *ioptr, long M, long NDiffU); -static inline void bfR2(double *ioptr, long M, long NDiffU) +static inline void bfR2(double *ioptr, int M, int NDiffU); +static inline void bfR2(double *ioptr, int M, int NDiffU) { /*** 2nd radix 2 stage ***/ - unsigned long pos; - unsigned long posi; - unsigned long pinc; - unsigned long pnext; - unsigned long NSameU; - unsigned long SameUCnt; + int pos; + int posi; + int pinc; + int pnext; + int NSameU; + int SameUCnt; double *pstrt; double *p0r, *p1r, *p2r, *p3r; @@ -520,17 +520,17 @@ static inline void bfR2(double *ioptr, long M, long NDiffU) } } -static inline void bfR4(double *ioptr, long M, long NDiffU); -static inline void bfR4(double *ioptr, long M, long NDiffU) +static inline void bfR4(double *ioptr, int M, int NDiffU); +static inline void bfR4(double *ioptr, int M, int NDiffU) { /*** 1 radix 4 stage ***/ - unsigned long pos; - unsigned long posi; - unsigned long pinc; - unsigned long pnext; - unsigned long pnexti; - unsigned long NSameU; - unsigned long SameUCnt; + int pos; + int posi; + int pinc; + int pnext; + int pnexti; + int NSameU; + int SameUCnt; double *pstrt; double *p0r, *p1r, *p2r, *p3r; @@ -730,21 +730,21 @@ static inline void bfR4(double *ioptr, long M, long NDiffU) } -static inline void bfstages(double *ioptr, long M, double *Utbl, long Ustride, long NDiffU, long StageCnt); -static inline void bfstages(double *ioptr, long M, double *Utbl, long Ustride, long NDiffU, long StageCnt) +static inline void bfstages(double *ioptr, int M, double *Utbl, int Ustride, int NDiffU, int StageCnt); +static inline void bfstages(double *ioptr, int M, double *Utbl, int Ustride, int NDiffU, int StageCnt) { /*** RADIX 8 Stages ***/ - unsigned long pos; - unsigned long posi; - unsigned long pinc; - unsigned long pnext; - unsigned long NSameU; - unsigned long Uinc; - unsigned long Uinc2; - unsigned long Uinc4; - unsigned long DiffUCnt; - unsigned long SameUCnt; - unsigned long U2toU3; + int pos; + int posi; + int pinc; + int pnext; + int NSameU; + int Uinc; + int Uinc2; + int Uinc4; + int DiffUCnt; + int SameUCnt; + int U2toU3; double *pstrt; double *p0r, *p1r, *p2r, *p3r; @@ -1052,11 +1052,11 @@ static inline void bfstages(double *ioptr, long M, double *Utbl, long Ustride, l } } -void fftrecurs(double *ioptr, long M, double *Utbl, long Ustride, long NDiffU, long StageCnt); -void fftrecurs(double *ioptr, long M, double *Utbl, long Ustride, long NDiffU, long StageCnt) +void fftrecurs(double *ioptr, int M, double *Utbl, int Ustride, int NDiffU, int StageCnt); +void fftrecurs(double *ioptr, int M, double *Utbl, int Ustride, int NDiffU, int StageCnt) { /* recursive bfstages calls to maximize on chip cache efficiency */ - long i1; + int i1; if (M <= MCACHE) // fits on chip ? bfstages(ioptr, M, Utbl, Ustride, NDiffU, StageCnt); /* RADIX 8 Stages */ else { @@ -1067,7 +1067,7 @@ void fftrecurs(double *ioptr, long M, double *Utbl, long Ustride, long NDiffU, l } } -void ffts1(double *ioptr, long M, long Rows, double *Utbl, short *BRLow) +void ffts1(double *ioptr, int M, int Rows, double *Utbl, short *BRLow) { /* Compute in-place complex fft on the rows of the input array */ /* INPUTS */ @@ -1079,8 +1079,8 @@ void ffts1(double *ioptr, long M, long Rows, double *Utbl, short *BRLow) /* OUTPUTS */ /* *ioptr = output data array */ - long StageCnt; - long NDiffU; + int StageCnt; + int NDiffU; switch (M) { case 0: @@ -1137,8 +1137,8 @@ void ffts1(double *ioptr, long M, long Rows, double *Utbl, short *BRLow) parts of iffts1 *************************************************/ -static inline void scbitrevR2(double *ioptr, long M, short *BRLow, double scale); -static inline void scbitrevR2(double *ioptr, long M, short *BRLow, double scale) +static inline void scbitrevR2(double *ioptr, int M, short *BRLow, double scale); +static inline void scbitrevR2(double *ioptr, int M, short *BRLow, double scale) { /*** scaled bit reverse and first radix 2 stage forward or inverse fft ***/ double f0r; @@ -1165,17 +1165,17 @@ static inline void scbitrevR2(double *ioptr, long M, short *BRLow, double scale) double *p1r; double *IOP; double *iolimit; - long Colstart; - long iCol; - unsigned long posA; - unsigned long posAi; - unsigned long posB; - unsigned long posBi; - - const unsigned long Nrems2 = POW2((M+3)/2); - const unsigned long Nroot_1_ColInc = POW2(M)-Nrems2; - const unsigned long Nroot_1 = POW2(M/2-1)-1; - const unsigned long ColstartShift = (M+1)/2 +1; + int Colstart; + int iCol; + int posA; + int posAi; + int posB; + int posBi; + + const int Nrems2 = POW2((M+3)/2); + const int Nroot_1_ColInc = POW2(M)-Nrems2; + const int Nroot_1 = POW2(M/2-1)-1; + const int ColstartShift = (M+1)/2 +1; posA = POW2(M); // 1/2 of POW2(M) complexes posAi = posA + 1; posB = posA + 2; @@ -1483,16 +1483,16 @@ static inline void ifft8pt(double *ioptr, double scale) ioptr[15] = scale*f6i; } -static inline void ibfR2(double *ioptr, long M, long NDiffU); -static inline void ibfR2(double *ioptr, long M, long NDiffU) +static inline void ibfR2(double *ioptr, int M, int NDiffU); +static inline void ibfR2(double *ioptr, int M, int NDiffU) { /*** 2nd radix 2 stage ***/ - unsigned long pos; - unsigned long posi; - unsigned long pinc; - unsigned long pnext; - unsigned long NSameU; - unsigned long SameUCnt; + int pos; + int posi; + int pinc; + int pnext; + int NSameU; + int SameUCnt; double *pstrt; double *p0r, *p1r, *p2r, *p3r; @@ -1593,17 +1593,17 @@ static inline void ibfR2(double *ioptr, long M, long NDiffU) } } -static inline void ibfR4(double *ioptr, long M, long NDiffU); -static inline void ibfR4(double *ioptr, long M, long NDiffU) +static inline void ibfR4(double *ioptr, int M, int NDiffU); +static inline void ibfR4(double *ioptr, int M, int NDiffU) { /*** 1 radix 4 stage ***/ - unsigned long pos; - unsigned long posi; - unsigned long pinc; - unsigned long pnext; - unsigned long pnexti; - unsigned long NSameU; - unsigned long SameUCnt; + int pos; + int posi; + int pinc; + int pnext; + int pnexti; + int NSameU; + int SameUCnt; double *pstrt; double *p0r, *p1r, *p2r, *p3r; @@ -1803,21 +1803,21 @@ static inline void ibfR4(double *ioptr, long M, long NDiffU) } -static inline void ibfstages(double *ioptr, long M, double *Utbl, long Ustride, long NDiffU, long StageCnt); -static inline void ibfstages(double *ioptr, long M, double *Utbl, long Ustride, long NDiffU, long StageCnt) +static inline void ibfstages(double *ioptr, int M, double *Utbl, int Ustride, int NDiffU, int StageCnt); +static inline void ibfstages(double *ioptr, int M, double *Utbl, int Ustride, int NDiffU, int StageCnt) { /*** RADIX 8 Stages ***/ - unsigned long pos; - unsigned long posi; - unsigned long pinc; - unsigned long pnext; - unsigned long NSameU; - unsigned long Uinc; - unsigned long Uinc2; - unsigned long Uinc4; - unsigned long DiffUCnt; - unsigned long SameUCnt; - unsigned long U2toU3; + int pos; + int posi; + int pinc; + int pnext; + int NSameU; + int Uinc; + int Uinc2; + int Uinc4; + int DiffUCnt; + int SameUCnt; + int U2toU3; double *pstrt; double *p0r, *p1r, *p2r, *p3r; @@ -2128,11 +2128,11 @@ static inline void ibfstages(double *ioptr, long M, double *Utbl, long Ustride, } } -void ifftrecurs(double *ioptr, long M, double *Utbl, long Ustride, long NDiffU, long StageCnt); -void ifftrecurs(double *ioptr, long M, double *Utbl, long Ustride, long NDiffU, long StageCnt) +void ifftrecurs(double *ioptr, int M, double *Utbl, int Ustride, int NDiffU, int StageCnt); +void ifftrecurs(double *ioptr, int M, double *Utbl, int Ustride, int NDiffU, int StageCnt) { /* recursive bfstages calls to maximize on chip cache efficiency */ - long i1; + int i1; if (M <= MCACHE) ibfstages(ioptr, M, Utbl, Ustride, NDiffU, StageCnt); /* RADIX 8 Stages */ else { @@ -2143,7 +2143,7 @@ void ifftrecurs(double *ioptr, long M, double *Utbl, long Ustride, long NDiffU, } } -void iffts1(double *ioptr, long M, long Rows, double *Utbl, short *BRLow) +void iffts1(double *ioptr, int M, int Rows, double *Utbl, short *BRLow) { /* Compute in-place inverse complex fft on the rows of the input array */ /* INPUTS */ @@ -2155,8 +2155,8 @@ void iffts1(double *ioptr, long M, long Rows, double *Utbl, short *BRLow) /* OUTPUTS */ /* *ioptr = output data array */ - long StageCnt; - long NDiffU; + int StageCnt; + int NDiffU; const double scale = 1.0/POW2(M); switch (M) { @@ -2502,14 +2502,14 @@ static inline void rfft8pt(double *ioptr) ioptr[15] = scale*f6i; } -static inline void frstage(double *ioptr, long M, double *Utbl); -static inline void frstage(double *ioptr, long M, double *Utbl) +static inline void frstage(double *ioptr, int M, double *Utbl); +static inline void frstage(double *ioptr, int M, double *Utbl) { /* Finish RFFT */ - unsigned long pos; - unsigned long posi; - unsigned long diffUcnt; + int pos; + int posi; + int diffUcnt; double *p0r, *p1r; double *u0r, *u0i; @@ -2629,7 +2629,7 @@ static inline void frstage(double *ioptr, long M, double *Utbl) }; } -void rffts1(double *ioptr, long M, long Rows, double *Utbl, short *BRLow) +void rffts1(double *ioptr, int M, int Rows, double *Utbl, short *BRLow) { /* Compute in-place real fft on the rows of the input array */ /* The result is the complex spectra of the positive frequencies */ @@ -2646,8 +2646,8 @@ void rffts1(double *ioptr, long M, long Rows, double *Utbl, short *BRLow) /* Re(x[0]), Re(x[N/2]), Re(x[1]), Im(x[1]), Re(x[2]), Im(x[2]), ... Re(x[N/2-1]), Im(x[N/2-1]). */ double scale; - long StageCnt; - long NDiffU; + int StageCnt; + int NDiffU; M=M-1; switch (M) { @@ -2999,14 +2999,14 @@ static inline void rifft8pt(double *ioptr, double scale) ioptr[15] = scale*f6i; } -static inline void ifrstage(double *ioptr, long M, double *Utbl); -static inline void ifrstage(double *ioptr, long M, double *Utbl) +static inline void ifrstage(double *ioptr, int M, double *Utbl); +static inline void ifrstage(double *ioptr, int M, double *Utbl) { /* Start RIFFT */ - unsigned long pos; - unsigned long posi; - unsigned long diffUcnt; + int pos; + int posi; + int diffUcnt; double *p0r, *p1r; double *u0r, *u0i; @@ -3126,7 +3126,7 @@ static inline void ifrstage(double *ioptr, long M, double *Utbl) }; } -void riffts1(double *ioptr, long M, long Rows, double *Utbl, short *BRLow) +void riffts1(double *ioptr, int M, int Rows, double *Utbl, short *BRLow) { /* Compute in-place real ifft on the rows of the input array */ /* data order as from rffts1 */ @@ -3141,8 +3141,8 @@ void riffts1(double *ioptr, long M, long Rows, double *Utbl, short *BRLow) /* *ioptr = real output data array */ double scale; - long StageCnt; - long NDiffU; + int StageCnt; + int NDiffU; scale = 1.0/POW2(M); M=M-1; diff --git a/src/maths/fft/fftlib.h b/src/maths/fft/fftlib.h index 7a87c7bc4..e49220642 100644 --- a/src/maths/fft/fftlib.h +++ b/src/maths/fft/fftlib.h @@ -1,14 +1,14 @@ #define MYRECIPLN2 1.442695040888963407359924681001892137426 // 1.0/log(2) /* some useful conversions between a number and its power of 2 */ -#define LOG2(a) (MYRECIPLN2*log(a)) // doubleing point logarithm base 2 -#define POW2(m) ((unsigned long) 1 << (m)) // integer power of 2 for m<32 +#define LOG2(a) (MYRECIPLN2*log(a)) // floating point logarithm base 2 +#define POW2(m) (1 << (m)) // integer power of 2 for m<32 /******************************************************************* lower level fft stuff called by routines in fftext.c and fft2d.c *******************************************************************/ -void fftCosInit(long M, double *Utbl); +void fftCosInit(int M, double *Utbl); /* Compute Utbl, the cosine table for ffts */ /* of size (pow(2,M)/4 +1) */ /* INPUTS */ @@ -16,7 +16,7 @@ void fftCosInit(long M, double *Utbl); /* OUTPUTS */ /* *Utbl = cosine table */ -void fftBRInit(long M, short *BRLow); +void fftBRInit(int M, short *BRLow); /* Compute BRLow, the bit reversed table for ffts */ /* of size pow(2,M/2 -1) */ /* INPUTS */ @@ -24,7 +24,7 @@ void fftBRInit(long M, short *BRLow); /* OUTPUTS */ /* *BRLow = bit reversed counter table */ -void ffts1(double *ioptr, long M, long Rows, double *Utbl, short *BRLow); +void ffts1(double *ioptr, int M, int Rows, double *Utbl, short *BRLow); /* Compute in-place complex fft on the rows of the input array */ /* INPUTS */ /* *ioptr = input data array */ @@ -35,7 +35,7 @@ void ffts1(double *ioptr, long M, long Rows, double *Utbl, short *BRLow); /* OUTPUTS */ /* *ioptr = output data array */ -void iffts1(double *ioptr, long M, long Rows, double *Utbl, short *BRLow); +void iffts1(double *ioptr, int M, int Rows, double *Utbl, short *BRLow); /* Compute in-place inverse complex fft on the rows of the input array */ /* INPUTS */ /* *ioptr = input data array */ @@ -46,7 +46,7 @@ void iffts1(double *ioptr, long M, long Rows, double *Utbl, short *BRLow); /* OUTPUTS */ /* *ioptr = output data array */ -void rffts1(double *ioptr, long M, long Rows, double *Utbl, short *BRLow); +void rffts1(double *ioptr, int M, int Rows, double *Utbl, short *BRLow); /* Compute in-place real fft on the rows of the input array */ /* The result is the complex spectra of the positive frequencies */ /* except the location for the first complex number contains the real */ @@ -62,7 +62,7 @@ void rffts1(double *ioptr, long M, long Rows, double *Utbl, short *BRLow); /* Re(x[0]), Re(x[N/2]), Re(x[1]), Im(x[1]), Re(x[2]), Im(x[2]), ... Re(x[N/2-1]), Im(x[N/2-1]). */ -void riffts1(double *ioptr, long M, long Rows, double *Utbl, short *BRLow); +void riffts1(double *ioptr, int M, int Rows, double *Utbl, short *BRLow); /* Compute in-place real ifft on the rows of the input array */ /* data order as from rffts1 */ /* INPUTS */ diff --git a/src/spicelib/devices/isrc/isrcacct.c b/src/spicelib/devices/isrc/isrcacct.c index a39e26971..1aab8ab98 100644 --- a/src/spicelib/devices/isrc/isrcacct.c +++ b/src/spicelib/devices/isrc/isrcacct.c @@ -16,6 +16,8 @@ extern int fftInit(long M); extern void fftFree(void); extern void rffts(float *data, long M, long Rows); +extern bool ft_ngdebug; /* some additional debug info printed */ + #define SAMETIME(a,b) (fabs((a)-(b))<= TIMETOL * PW) #define TIMETOL 1e-7 @@ -197,7 +199,8 @@ ISRCaccept(CKTcircuit *ckt, GENmodel *inModel) /* FIXME, dont' want this here, over to aof_get or somesuch */ if (ckt->CKTtime == 0.0) { - printf("VSRC: free fft tables\n"); + if (ft_ngdebug) + printf("VSRC: free fft tables\n"); fftFree(); } diff --git a/src/spicelib/devices/vsrc/vsrcacct.c b/src/spicelib/devices/vsrc/vsrcacct.c index 928beac7e..96899a6b5 100644 --- a/src/spicelib/devices/vsrc/vsrcacct.c +++ b/src/spicelib/devices/vsrc/vsrcacct.c @@ -16,6 +16,8 @@ extern int fftInit(long M); extern void fftFree(void); extern void rffts(float *data, long M, long Rows); +extern bool ft_ngdebug; /* some additional debug info printed */ + #define SAMETIME(a,b) (fabs((a)-(b))<= TIMETOL * PW) #define TIMETOL 1e-7 @@ -197,7 +199,8 @@ VSRCaccept(CKTcircuit *ckt, GENmodel *inModel) /* FIXME, dont' want this here, over to aof_get or somesuch */ if (ckt->CKTtime == 0.0) { - printf("VSRC: free fft tables\n"); + if(ft_ngdebug) + printf("VSRC: free fft tables\n"); fftFree(); }