61 #include <gsl/gsl_math.h>
107 float *told, oldres, newres;
110 int ncon, i, j, ichan, istart, istop;
112 float conres, a2, rta2, conlim, conend,
113 freqend, bord, conbord, cchan, chstep, chpos, xarg, xnorm,
114 freqlc, chlim, xdist, arg, rinfinity = GSL_POSINF;
117 if(newres < oldres ||
min(newres, oldres) < 0.0)
119 st_fail(
"CHNGRES: newres %f must be > oldres %f", newres, oldres);
126 st_fail(
"CHNGRES: nchan %d must be even", nchan);
130 if(nchan < 1 || nchan > 8196)
132 st_fail(
"CHNGRES: nchan %d out of range", nchan);
136 cchan = (float)nchan / 2.0 + 0.5;
147 xarg = rta2 * oldres / conres;
157 freqend = (nchan - cchan) * oldres;
158 conbord = conend * 0.4248 * conres;
159 ncon = freqend / newres;
160 freqlc = ncon * newres;
161 bord = freqend - freqlc;
179 chstep = newres / oldres;
180 chlim = conlim * 0.4248 * chstep;
181 chpos = cchan + 0.5 * chstep;
184 bzero((
char *)&tnew,
sizeof(tnew));
196 istart = chpos - chlim + 0.5;
197 istop = chpos + chlim + 0.5;
211 for(j=istart;j<istop;j++)
214 arg = -xarg * xdist * xarg * xdist;
216 if(gsl_finite(told[j]))
218 tnew[ichan] = told[j] * exp(arg) + tnew[ichan];
225 tnew[ichan] /= xnorm;
229 tnew[ichan] = rinfinity;
240 chpos = cchan - 0.5 * chstep;
246 istart = chpos - chlim + 0.5;
247 istop = chpos + chlim + 0.5;
261 for(j=istart;j<istop;j++)
264 arg = -xarg * xdist * xarg * xdist;
266 if(gsl_finite(told[j]))
268 tnew[ichan] = told[j] * exp(arg) + tnew[ichan];
269 xnorm = xnorm + exp(arg);
275 tnew[ichan] /= xnorm;
279 tnew[ichan] = rinfinity;
282 chpos = chpos - chstep;
291 if(i < cchan-ncon || i > cchan+ncon)
int chgres(float *told, int nchan, float oldres, float newres)