Mercurial > hg > sv-dependency-builds
view src/fftw-3.3.5/doc/html/Complex-numbers.html @ 127:7867fa7e1b6b
Current fftw source
author | Chris Cannam <cannam@all-day-breakfast.com> |
---|---|
date | Tue, 18 Oct 2016 13:40:26 +0100 |
parents | |
children |
line wrap: on
line source
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <html> <!-- This manual is for FFTW (version 3.3.5, 30 July 2016). Copyright (C) 2003 Matteo Frigo. Copyright (C) 2003 Massachusetts Institute of Technology. Permission is granted to make and distribute verbatim copies of this manual provided the copyright notice and this permission notice are preserved on all copies. Permission is granted to copy and distribute modified versions of this manual under the conditions for verbatim copying, provided that the entire resulting derived work is distributed under the terms of a permission notice identical to this one. Permission is granted to copy and distribute translations of this manual into another language, under the above conditions for modified versions, except that this permission notice may be stated in a translation approved by the Free Software Foundation. --> <!-- Created by GNU Texinfo 5.2, http://www.gnu.org/software/texinfo/ --> <head> <title>FFTW 3.3.5: Complex numbers</title> <meta name="description" content="FFTW 3.3.5: Complex numbers"> <meta name="keywords" content="FFTW 3.3.5: Complex numbers"> <meta name="resource-type" content="document"> <meta name="distribution" content="global"> <meta name="Generator" content="makeinfo"> <meta http-equiv="Content-Type" content="text/html; charset=utf-8"> <link href="index.html#Top" rel="start" title="Top"> <link href="Concept-Index.html#Concept-Index" rel="index" title="Concept Index"> <link href="index.html#SEC_Contents" rel="contents" title="Table of Contents"> <link href="Data-Types-and-Files.html#Data-Types-and-Files" rel="up" title="Data Types and Files"> <link href="Precision.html#Precision" rel="next" title="Precision"> <link href="Data-Types-and-Files.html#Data-Types-and-Files" rel="prev" title="Data Types and Files"> <style type="text/css"> <!-- a.summary-letter {text-decoration: none} blockquote.smallquotation {font-size: smaller} div.display {margin-left: 3.2em} div.example {margin-left: 3.2em} div.indentedblock {margin-left: 3.2em} div.lisp {margin-left: 3.2em} div.smalldisplay {margin-left: 3.2em} div.smallexample {margin-left: 3.2em} div.smallindentedblock {margin-left: 3.2em; font-size: smaller} div.smalllisp {margin-left: 3.2em} kbd {font-style:oblique} pre.display {font-family: inherit} pre.format {font-family: inherit} pre.menu-comment {font-family: serif} pre.menu-preformatted {font-family: serif} pre.smalldisplay {font-family: inherit; font-size: smaller} pre.smallexample {font-size: smaller} pre.smallformat {font-family: inherit; font-size: smaller} pre.smalllisp {font-size: smaller} span.nocodebreak {white-space:nowrap} span.nolinebreak {white-space:nowrap} span.roman {font-family:serif; font-weight:normal} span.sansserif {font-family:sans-serif; font-weight:normal} ul.no-bullet {list-style: none} --> </style> </head> <body lang="en" bgcolor="#FFFFFF" text="#000000" link="#0000FF" vlink="#800080" alink="#FF0000"> <a name="Complex-numbers"></a> <div class="header"> <p> Next: <a href="Precision.html#Precision" accesskey="n" rel="next">Precision</a>, Previous: <a href="Data-Types-and-Files.html#Data-Types-and-Files" accesskey="p" rel="prev">Data Types and Files</a>, Up: <a href="Data-Types-and-Files.html#Data-Types-and-Files" accesskey="u" rel="up">Data Types and Files</a> [<a href="index.html#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="Concept-Index.html#Concept-Index" title="Index" rel="index">Index</a>]</p> </div> <hr> <a name="Complex-numbers-1"></a> <h4 class="subsection">4.1.1 Complex numbers</h4> <p>The default FFTW interface uses <code>double</code> precision for all floating-point numbers, and defines a <code>fftw_complex</code> type to hold complex numbers as: </p> <div class="example"> <pre class="example">typedef double fftw_complex[2]; </pre></div> <a name="index-fftw_005fcomplex-1"></a> <p>Here, the <code>[0]</code> element holds the real part and the <code>[1]</code> element holds the imaginary part. </p> <p>Alternatively, if you have a C compiler (such as <code>gcc</code>) that supports the C99 revision of the ANSI C standard, you can use C’s new native complex type (which is binary-compatible with the typedef above). In particular, if you <code>#include <complex.h></code> <em>before</em> <code><fftw3.h></code>, then <code>fftw_complex</code> is defined to be the native complex type and you can manipulate it with ordinary arithmetic (e.g. <code>x = y * (3+4*I)</code>, where <code>x</code> and <code>y</code> are <code>fftw_complex</code> and <code>I</code> is the standard symbol for the imaginary unit); <a name="index-C99-1"></a> </p> <p>C++ has its own <code>complex<T></code> template class, defined in the standard <code><complex></code> header file. Reportedly, the C++ standards committee has recently agreed to mandate that the storage format used for this type be binary-compatible with the C99 type, i.e. an array <code>T[2]</code> with consecutive real <code>[0]</code> and imaginary <code>[1]</code> parts. (See report <a href="http://www.open-std.org/jtc1/sc22/WG21/docs/papers/2002/n1388.pdf WG21/N1388">http://www.open-std.org/jtc1/sc22/WG21/docs/papers/2002/n1388.pdf WG21/N1388</a>.) Although not part of the official standard as of this writing, the proposal stated that: “This solution has been tested with all current major implementations of the standard library and shown to be working.” To the extent that this is true, if you have a variable <code>complex<double> *x</code>, you can pass it directly to FFTW via <code>reinterpret_cast<fftw_complex*>(x)</code>. <a name="index-C_002b_002b-3"></a> <a name="index-portability-2"></a> </p> </body> </html>