intsinc8.c
来自「该程序是用vc开发的对动态数组进行管理的DLL」· C语言 代码 · 共 162 行
C
162 行
/* Copyright (c) Colorado School of Mines, 2003.*//* All rights reserved. *//*********************** self documentation **********************//*****************************************************************************INTSINC8 - Functions to interpolate uniformly-sampled data via 8-coeff. sinc approximations:ints8c interpolation of a uniformly-sampled fcomplex function y(x) via an 8-coefficient sinc approximation.ints8r Interpolation of a uniformly-sampled real function y(x) via a table of 8-coefficient sinc approximations******************************************************************************Function Prototypes:void ints8c (int nxin, float dxin, float fxin, fcomplex yin[], fcomplex yinl, fcomplex yinr, int nxout, float xout[], fcomplex yout[]);void ints8r (int nxin, float dxin, float fxin, float yin[], float yinl, float yinr, int nxout, float xout[], float yout[]);******************************************************************************Input:nxin number of x values at which y(x) is inputdxin x sampling interval for input y(x)fxin x value of first sample inputyin array[nxin] of input y(x) values: yin[0] = y(fxin), etc.yinl value used to extrapolate yin values to left of yin[0]yinr value used to extrapolate yin values to right of yin[nxin-1]nxout number of x values a which y(x) is outputxout array[nxout] of x values at which y(x) is outputOutput:yout array[nxout] of output y(x): yout[0] = y(xout[0]), etc.******************************************************************************Notes:Because extrapolation of the input function y(x) is defined by theleft and right values yinl and yinr, the xout values are not restrictedto lie within the range of sample locations defined by nxin, dxin, andfxin.The maximum error for frequiencies less than 0.6 nyquist is less thanone percent.******************************************************************************Author: Dave Hale, Colorado School of Mines, 06/02/89*****************************************************************************//**************** end self doc ********************************/#include "cwp.h"/* these are used by both ints8c and ints8r */#define LTABLE 8#define NTABLE 513void ints8c (int nxin, float dxin, float fxin, fcomplex yin[], fcomplex yinl, fcomplex yinr, int nxout, float xout[], fcomplex yout[])/*****************************************************************************Interpolation of a uniformly-sampled fcomplex function y(x) via atable of 8-coefficient sinc approximations; maximum error for frequienciesless than 0.6 nyquist is less than one percent.******************************************************************************Input:nxin number of x values at which y(x) is inputdxin x sampling interval for input y(x)fxin x value of first sample inputyin array[nxin] of input y(x) values: yin[0] = y(fxin), etc.yinl value used to extrapolate yin values to left of yin[0]yinr value used to extrapolate yin values to right of yin[nxin-1]nxout number of x values a which y(x) is outputxout array[nxout] of x values at which y(x) is outputOutput:yout array[nxout] of output y(x): yout[0] = y(xout[0]), etc.******************************************************************************Notes:Because extrapolation of the input function y(x) is defined by theleft and right values yinl and yinr, the xout values are not restrictedto lie within the range of sample locations defined by nxin, dxin, andfxin.******************************************************************************Author: Dave Hale, Colorado School of Mines, 06/02/89*****************************************************************************/{ static float table[NTABLE][LTABLE]; static int tabled=0; int jtable; float frac; /* tabulate sinc interpolation coefficients if not already tabulated */ if (!tabled) { for (jtable=1; jtable<NTABLE-1; jtable++) { frac = (float)jtable/(float)(NTABLE-1); mksinc(frac,LTABLE,&table[jtable][0]); } for (jtable=0; jtable<LTABLE; jtable++) { table[0][jtable] = 0.0; table[NTABLE-1][jtable] = 0.0; } table[0][LTABLE/2-1] = 1.0; table[NTABLE-1][LTABLE/2] = 1.0; tabled = 1; } /* interpolate using tabulated coefficients */ intt8c(NTABLE,table,nxin,dxin,fxin,yin,yinl,yinr,nxout,xout,yout);}void ints8r (int nxin, float dxin, float fxin, float yin[], float yinl, float yinr, int nxout, float xout[], float yout[])/*****************************************************************************Interpolation of a uniformly-sampled real function y(x) via atable of 8-coefficient sinc approximations; maximum error for frequienciesless than 0.6 nyquist is less than one percent.******************************************************************************Input:nxin number of x values at which y(x) is inputdxin x sampling interval for input y(x)fxin x value of first sample inputyin array[nxin] of input y(x) values: yin[0] = y(fxin), etc.yinl value used to extrapolate yin values to left of yin[0]yinr value used to extrapolate yin values to right of yin[nxin-1]nxout number of x values a which y(x) is outputxout array[nxout] of x values at which y(x) is outputOutput:yout array[nxout] of output y(x): yout[0] = y(xout[0]), etc.******************************************************************************Notes:Because extrapolation of the input function y(x) is defined by theleft and right values yinl and yinr, the xout values are not restrictedto lie within the range of sample locations defined by nxin, dxin, andfxin.******************************************************************************Author: Dave Hale, Colorado School of Mines, 06/02/89*****************************************************************************/{ static float table[NTABLE][LTABLE]; static int tabled=0; int jtable; float frac; /* tabulate sinc interpolation coefficients if not already tabulated */ if (!tabled) { for (jtable=1; jtable<NTABLE-1; jtable++) { frac = (float)jtable/(float)(NTABLE-1); mksinc(frac,LTABLE,&table[jtable][0]); } for (jtable=0; jtable<LTABLE; jtable++) { table[0][jtable] = 0.0; table[NTABLE-1][jtable] = 0.0; } table[0][LTABLE/2-1] = 1.0; table[NTABLE-1][LTABLE/2] = 1.0; tabled = 1; } /* interpolate using tabulated coefficients */ intt8r(NTABLE,table,nxin,dxin,fxin,yin,yinl,yinr,nxout,xout,yout);}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?