📄 mksinc.c
字号:
/* Copyright (c) Colorado School of Mines, 2006.*//* All rights reserved. *//*********************** self documentation **********************//*****************************************************************************MKSINC - Compute least-squares optimal sinc interpolation coefficients.mksinc Compute least-squares optimal sinc interpolation coefficients.******************************************************************************Function Prototype:void mksinc (float d, int lsinc, float sinc[]);******************************************************************************Input:d fractional distance to interpolation point; 0.0<=d<=1.0lsinc length of sinc approximation; lsinc%2==0 and lsinc<=20Output:sinc array[lsinc] containing interpolation coefficients******************************************************************************Notes:The coefficients are a least-squares-best approximation to the idealsinc function for frequencies from zero up to a computed maximumfrequency. For a given interpolator length, lsinc, mksinc computesthe maximum frequency, fmax (expressed as a fraction of the nyquistfrequency), using the following empirically derived relation (froma Western Geophysical Technical Memorandum by Ken Larner): fmax = min(0.066+0.265*log(lsinc),1.0)Note that fmax increases as lsinc increases, up to a maximum of 1.0.Use the coefficients to interpolate a uniformly-sampled function y(i) as follows: lsinc-1 y(i+d) = sum sinc[j]*y(i+j+1-lsinc/2) j=0Interpolation error is greatest for d=0.5, but for frequencies lessthan fmax, the error should be less than 1.0 percent.******************************************************************************Author: Dave Hale, Colorado School of Mines, 06/02/89*****************************************************************************//**************** end self doc ********************************/#include "cwp.h"void mksinc (float d, int lsinc, float sinc[])/*****************************************************************************Compute least-squares optimal sinc interpolation coefficients.******************************************************************************Input:d fractional distance to interpolation point; 0.0<=d<=1.0lsinc length of sinc approximation; lsinc%2==0 and lsinc<=20Output:sinc array[lsinc] containing interpolation coefficients******************************************************************************Notes:The coefficients are a least-squares-best approximation to the idealsinc function for frequencies from zero up to a computed maximumfrequency. For a given interpolator length, lsinc, mksinc computesthe maximum frequency, fmax (expressed as a fraction of the nyquistfrequency), using the following empirically derived relation (froma Western Geophysical Technical Memorandum by Ken Larner): fmax = min(0.066+0.265*log(lsinc),1.0)Note that fmax increases as lsinc increases, up to a maximum of 1.0.Use the coefficients to interpolate a uniformly-sampled function y(i) as follows: lsinc-1 y(i+d) = sum sinc[j]*y(i+j+1-lsinc/2) j=0Interpolation error is greatest for d=0.5, but for frequencies lessthan fmax, the error should be less than 1.0 percent.******************************************************************************Author: Dave Hale, Colorado School of Mines, 06/02/89*****************************************************************************/{ int j; double s[20],a[20],c[20],work[20],fmax; /* compute auto-correlation and cross-correlation arrays */ fmax = 0.066+0.265*log((double)lsinc); fmax = (fmax<1.0)?fmax:1.0; for (j=0; j<lsinc; j++) { a[j] = dsinc(fmax*j); c[j] = dsinc(fmax*(lsinc/2-j-1+d)); } /* solve symmetric Toeplitz system for the sinc approximation */ stoepd(lsinc,a,c,s,work); for (j=0; j<lsinc; j++) sinc[j] = s[j];}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -