Skip to content

Commit 524cd2e

Browse files
authored
Merge pull request #418 from gruenich/feature/c-23
Make compatible with C23
2 parents a256976 + 5c409e3 commit 524cd2e

File tree

7 files changed

+45
-82
lines changed

7 files changed

+45
-82
lines changed

src/GFIR/corrections.c

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,7 @@
2626
/* ************************************************************ */
2727
/* Inverse sinc function to correct DAC sinc envelope */
2828
/* ************************************************************ */
29-
double InvSinc(x)
30-
double x;
29+
double InvSinc(double x)
3130
{
3231
if(fpclassify(x) == FP_ZERO) return(1.0);
3332
return(fabs((M_PI*x)/(sin(M_PI*x) + DELTA)));
@@ -36,8 +35,7 @@ double x;
3635
/* ************************************************************ */
3736
/* Invsinc function shifted into lower frequency stage. */
3837
/* ************************************************************ */
39-
double InvSincS(x, k, x0)
40-
double x, k, x0;
38+
double InvSincS(double x, double k, double x0)
4139
{
4240
double xin;
4341

@@ -49,8 +47,7 @@ double x, k, x0;
4947
/* ************************************************************ */
5048
/* Unity function, no correction is envolved. */
5149
/* ************************************************************ */
52-
double One(x)
53-
double x;
50+
double One(double x)
5451
{
5552
return(1.0);
56-
}
53+
}

src/GFIR/dfilter.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,4 +21,4 @@ struct dfilter {
2121
double phase[POINTS];
2222
double logamp[POINTS]; /* Amplitude in log scale */
2323
double max; /* Maximum of amplitude */
24-
};
24+
};

src/GFIR/gfir_lms.c

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -21,13 +21,12 @@
2121
#define CSDPREC 16 /* CSD Coefficients precision */
2222

2323
/* *********************************************************************** */
24-
int gfir_lms(hr, hi, hcsd, n, w1, w2, a1, a2, cprec, csdprec, correction)
25-
struct dfilter *hr, *hi, *hcsd;
26-
int n;
27-
double w1, w2, a1, a2;
28-
int cprec;
29-
int csdprec;
30-
double (*correction)();
24+
int gfir_lms(struct dfilter *hr, struct dfilter *hi, struct dfilter *hcsd,
25+
int n,
26+
double w1, double w2, double a1, double a2,
27+
int cprec,
28+
int csdprec,
29+
double (*correction)(double x))
3130
{
3231
double *weights, *desired, *w;
3332
int i, points;

src/GFIR/lms.c

Lines changed: 8 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -24,9 +24,9 @@
2424
#define ODD 1
2525

2626
/* Declare functions from Numerical Recipes that are used here */
27-
double *vector();
28-
int *ivector();
29-
double **matrix();
27+
double *vector(int nl, int nh);
28+
int *ivector(int nl, int nh);
29+
double **matrix(int nrl, int nrh, int ncl, int nch);
3030

3131
/* ************************************************************************
3232
* Trigonometric functions for CASE1, CASE2, CASE3 and CASE4 filters
@@ -78,18 +78,10 @@ double Case4F(double w, int i)
7878
* 0 - if everything is OK
7979
* -1 - otherwise
8080
* ************************************************************************ */
81-
int lms(hr, hi, hcsd, n, w, des, weight, p, cprec, csdprec, symmetry,
82-
bincode, csdcode, csdcoder)
83-
double *hr, *hi, *hcsd;
84-
int n;
85-
double *w;
86-
double *des;
87-
double *weight;
88-
int p;
89-
int cprec;
90-
int csdprec;
91-
int symmetry;
92-
int **bincode, **csdcode, **csdcoder;
81+
int lms(double *hr, double *hi, double *hcsd,
82+
int n, double *w, double *des, double *weight,
83+
int p, int cprec, int csdprec, int symmetry,
84+
int **bincode, int **csdcode, int **csdcoder)
9385
{
9486

9587
/* All this is for solving a linear system */
@@ -100,7 +92,7 @@ int **bincode, **csdcode, **csdcoder;
10092
/* Parameters of real function Hr(w) */
10193
double *a; /* Coefficients */
10294
int L; /* Number of terms in Hr(w) sum */
103-
double (*f)(); /* Trigonometric function in Hr(w) */
95+
double (*f)(double w, int i); /* Trigonometric function in Hr(w) */
10496

10597
int parity; /* Parity of the filter (ODD or EVEN) */
10698
int i, j, k; /* Loop counters */

src/GFIR/lms.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,9 +21,9 @@
2121
#define LMS_POINTS 4000
2222

2323
/* Amplitude correction functions */
24-
double InvSinc();
25-
double InvSincS();
26-
double One();
24+
double InvSinc(double x);
25+
double InvSincS(double x);
26+
double One(double x);
2727

2828
/* Amplitude correction functions we can support */
2929
#define NONE One /* Constant */

src/GFIR/recipes.c

Lines changed: 10 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -57,8 +57,7 @@ void nrerror(char * error_text);
5757
/*****************************************************/
5858
/*** Allocates a double vector with range [nl..nh]. ***/
5959
/*****************************************************/
60-
double *vector(nl,nh)
61-
int nl,nh;
60+
double *vector(int nl, int nh)
6261
{
6362
double *v;
6463

@@ -70,8 +69,7 @@ int nl,nh;
7069
/*****************************************************/
7170
/*** Allocates an int vector with range [nl..nh]. ***/
7271
/*****************************************************/
73-
int *ivector(nl,nh)
74-
int nl,nh;
72+
int *ivector(int nl, int nh)
7573
{
7674
int *v;
7775

@@ -83,19 +81,15 @@ int nl,nh;
8381
/****************************************************/
8482
/*** Frees a double vector allocated by vector(). ***/
8583
/****************************************************/
86-
void free_vector(v,nl,nh)
87-
double *v;
88-
int nl,nh;
84+
void free_vector(double *v, int nl, int nh)
8985
{
9086
free((char*) (v+nl));
9187
}
9288

9389
/****************************************************/
9490
/*** Frees an int vector allocated by ivector(). ***/
9591
/****************************************************/
96-
void free_ivector(v,nl,nh)
97-
int *v;
98-
int nl,nh;
92+
void free_ivector(int *v, int nl, int nh)
9993
{
10094
free((char*) (v+nl));
10195
}
@@ -104,8 +98,7 @@ int nl,nh;
10498
/**** Allocates a double matrix with ****/
10599
/**** range [nrl..nrh] [ncl..nch]. ****/
106100
/*******************************************/
107-
double **matrix(nrl,nrh,ncl,nch)
108-
int nrl,nrh,ncl,nch;
101+
double **matrix(int nrl, int nrh, int ncl, int nch)
109102
{
110103
int i;
111104
double **m;
@@ -129,9 +122,7 @@ int nrl,nrh,ncl,nch;
129122
/**** Frees a matrix allocated by ... ***/
130123
/**** matrix(). ***/
131124
/******************************************/
132-
void free_matrix(m,nrl,nrh,ncl,nch)
133-
double **m;
134-
int nrl,nrh,ncl,nch;
125+
void free_matrix(double **m, int nrl, int nrh, int ncl, int nch)
135126
{
136127
int i;
137128

@@ -142,11 +133,8 @@ int nrl,nrh,ncl,nch;
142133
/*************************************************/
143134
/*** Numerical Recipes standard error handler. ***/
144135
/*************************************************/
145-
void nrerror(error_text)
146-
char error_text[];
136+
void nrerror(char error_text[])
147137
{
148-
void exit();
149-
150138
fprintf(stderr,"Numerical Recipes run-time error...\n");
151139
fprintf(stderr,"%s\n",error_text);
152140
fprintf(stderr,"Forced to exit.\n");
@@ -160,14 +148,11 @@ char error_text[];
160148
/* indx[1:n] temporary storage, */
161149
/* d temporary storage. */
162150
/* ******************************************************************** */
163-
int ludcmp(a,n,indx,d)
164-
int n, *indx;
165-
double **a,*d;
151+
int ludcmp(double **a, int n, int *indx, double *d)
166152
{
167153
int i,imax,j,k;
168154
double big,dum,sum,temp;
169-
double *vv,*vector();
170-
void free_vector();
155+
double *vv;
171156

172157
imax = 0;
173158

@@ -223,9 +208,7 @@ double **a,*d;
223208
/* ******************************************************************** */
224209
/* Solve system of equation */
225210
/* ******************************************************************** */
226-
void lubksb(a,n,indx,b)
227-
double **a,b[];
228-
int n,indx[];
211+
void lubksb(double **a, int n, int indx[], double b[])
229212
{
230213
int i,ii=0,ip,j;
231214
double sum;

src/GFIR/rounding.c

Lines changed: 13 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,7 @@ int csd2int(int cprec, int *code);
1717

1818
/* ************************************************************************
1919
************************************************************************ */
20-
void round2int(a, b, n, cprec)
21-
double *a, *b;
22-
int n, cprec;
20+
void round2int(double *a, double *b, int n, int cprec)
2321
{
2422
int i,k;
2523

@@ -32,10 +30,8 @@ int n, cprec;
3230

3331
/* ************************************************************************
3432
************************************************************************ */
35-
void round2csd(a, b, n, cprec, csdprec, bincode, csdcode, csdcoder)
36-
double *a, *b;
37-
int n, cprec, csdprec;
38-
int **bincode, **csdcode, **csdcoder;
33+
void round2csd(double *a, double *b, int n, int cprec, int csdprec,
34+
int **bincode, int **csdcode, int **csdcoder)
3935
{
4036
int i,k, ia;
4137

@@ -118,8 +114,7 @@ void printcode(int ** code, int n, int cprec)
118114
/* ************************************************************************
119115
Print CSD code in the form of two common sub-expressions sharing
120116
************************************************************************ */
121-
void print_cses_code(xpx, xmx, x, n, cprec)
122-
int **xpx, **xmx, **x, n, cprec;
117+
void print_cses_code(int **xpx, int **xmx, int **x, int n, int cprec)
123118
{
124119
int i, j;
125120
int symmetry;
@@ -193,14 +188,14 @@ int **xpx, **xmx, **x, n, cprec;
193188
}
194189

195190
/* ************************************************************************
191+
* int a Input integer to be converted into CSD code
192+
* int cprec Integer precision
193+
* int csdprec CSD precistion
194+
* int *bincode Binary code
195+
* int *csdcode CSD code
196+
* int *csdcoder CSD code rounded to 'csdprec' nonzero bits
196197
************************************************************************ */
197-
void int2csd(a, cprec, csdprec, bincode, csdcode, csdcoder)
198-
int a; /* Input integer to be converted into CSD code */
199-
int cprec; /* Integer precision */
200-
int csdprec; /* CSD precistion */
201-
int *bincode; /* Binary code */
202-
int *csdcode; /* CSD code */
203-
int *csdcoder; /* CSD code rounded to 'csdprec' nonzero bits */
198+
void int2csd(int a, int cprec, int csdprec, int *bincode, int *csdcode, int *csdcoder)
204199
{
205200
int i, sign, ci, ci1, nzeroes;
206201

@@ -243,8 +238,7 @@ int *csdcoder; /* CSD code rounded to 'csdprec' nonzero bits */
243238

244239
/* ************************************************************************
245240
************************************************************************ */
246-
int csd2int(cprec, code)
247-
int cprec, *code;
241+
int csd2int(int cprec, int *code)
248242
{
249243
int i, a;
250244

@@ -257,9 +251,7 @@ int cprec, *code;
257251
/* ************************************************************************
258252
Extract x+x>>2 and x-x>>2 subexpressions from the CSD code
259253
************************************************************************ */
260-
void csesh(code, n, cprec, xpx, xmx, x )
261-
int n, cprec;
262-
int **code, **xpx, **xmx, **x;
254+
void csesh(int **code, int n, int cprec, int **xpx, int **xmx, int **x)
263255
{
264256
int i, k;
265257

0 commit comments

Comments
 (0)