NFFT Logo 3.2.3
sinc.c
1 /*
2  * Copyright (c) 2002, 2012 Jens Keiner, Stefan Kunis, Daniel Potts
3  *
4  * This program is free software; you can redistribute it and/or modify it under
5  * the terms of the GNU General Public License as published by the Free Software
6  * Foundation; either version 2 of the License, or (at your option) any later
7  * version.
8  *
9  * This program is distributed in the hope that it will be useful, but WITHOUT
10  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
11  * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
12  * details.
13  *
14  * You should have received a copy of the GNU General Public License along with
15  * this program; if not, write to the Free Software Foundation, Inc., 51
16  * Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
17  */
18 
19 /* $Id: util.c 3483 2010-04-23 19:02:34Z keiner $ */
20 
21 #include "infft.h"
22 
23 R X(sinc)(const R x)
24 {
25  /* Based on sinc function from Boost C++ library. */
26  const R b = EPSILON;
27  const R bs = SQRT(b);
28  const R bs2 = SQRT(bs);
29 
30  if (FABS(x) >= bs2)
31  return SIN(x)/x;
32  else
33  {
34  R r = K(1.0);
35 
36  if (FABS(x) >= b)
37  {
38  const R x2 = x * x;
39  r -= x2 / K(6.0);
40 
41  if (FABS(x) >= bs)
42  r += (x2 * x2) / K(120.0);
43  }
44 
45  return r;
46  }
47 }

Generated on Tue Apr 30 2013 by Doxygen 1.8.1