{"id":19795602,"url":"https://github.com/dkogan/pdl-fftw3","last_synced_at":"2025-08-12T06:47:32.113Z","repository":{"id":8104165,"uuid":"9519251","full_name":"dkogan/PDL-FFTW3","owner":"dkogan","description":null,"archived":false,"fork":false,"pushed_at":"2015-06-16T02:02:44.000Z","size":340,"stargazers_count":1,"open_issues_count":1,"forks_count":1,"subscribers_count":5,"default_branch":"master","last_synced_at":"2025-02-28T16:09:19.413Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Perl","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"other","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/dkogan.png","metadata":{"files":{"readme":"README.pod","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2013-04-18T10:38:24.000Z","updated_at":"2014-09-09T10:04:29.000Z","dependencies_parsed_at":"2022-09-02T18:25:19.664Z","dependency_job_id":null,"html_url":"https://github.com/dkogan/PDL-FFTW3","commit_stats":null,"previous_names":[],"tags_count":4,"template":false,"template_full_name":null,"purl":"pkg:github/dkogan/PDL-FFTW3","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dkogan%2FPDL-FFTW3","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dkogan%2FPDL-FFTW3/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dkogan%2FPDL-FFTW3/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dkogan%2FPDL-FFTW3/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/dkogan","download_url":"https://codeload.github.com/dkogan/PDL-FFTW3/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dkogan%2FPDL-FFTW3/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":270016678,"owners_count":24512964,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-08-12T02:00:09.011Z","response_time":80,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-11-12T07:16:48.474Z","updated_at":"2025-08-12T06:47:32.081Z","avatar_url":"https://github.com/dkogan.png","language":"Perl","funding_links":[],"categories":[],"sub_categories":[],"readme":"=head1 NOTICE\n\nPDL::FFTW3 is no longer maintained in this repository, and I\u003cthis\u003e repository\nremains here for reference only. Development continues at\nL\u003chttps://github.com/PDLPorters/pdl-fftw3\u003e.\n\n=head1 NAME\n\nPDL::FFTW3 - PDL interface to the Fastest Fourier Transform in the West v3\n\n=head1 DESCRIPTION\n\nThis is a PDL binding to version 3 of the FFTW library. Supported are complex\n\u003c-\u003e complex and real \u003c-\u003e complex FFTs.\n\n=head1 SYNOPSIS\n\n use PDL;\n use PDL::FFTW3;\n use PDL::Graphics::Gnuplot;\n use PDL::Complex;\n\n # Basic functionality\n my $x = sin( sequence(100) * 2.0 ) + 2.0 * cos( sequence(100) / 3.0 );\n my $F = rfft1( $x );\n gplot( with =\u003e 'lines', inner($F,$F));\n\n =====\u003e\n\n  8000 ++------------+-------------+------------+-------------+------------++\n       +             +             +            +             +             +\n       |                                                                    |\n       |      *                                                             |\n  7000 ++     *                                                            ++\n       |      *                                                             |\n       |      *                                                             |\n       |      *                                                             |\n       |      *                                                             |\n  6000 ++     *                                                            ++\n       |      *                                                             |\n       |      *                                                             |\n       |      *                                                             |\n  5000 ++     *                                                            ++\n       |      *                                                             |\n       |      *                                                             |\n       |      **                                                            |\n  4000 ++     **                                                           ++\n       |      **                                                            |\n       |     * *                                                            |\n       |     * *                                                            |\n       |     * *                                                            |\n  3000 ++    * *                                                           ++\n       |     * *                                                            |\n       |     * *                                                            |\n       |     * *                                   *                        |\n  2000 ++    * *                                   *                       ++\n       |     * *                                   *                        |\n       |     * *                                   **                       |\n       |     * *                                   **                       |\n       |     * *                                   **                       |\n  1000 ++    *  *                                 * *                      ++\n       |     *  *                                 * *                       |\n       |    **   *                                *  *                      |\n       +   *     *   +             +            + *  *        +             +\n     0 ****-------*********************************--************************\n       0             10            20           30            40            50\n\n\n\n # Correlation of two real signals\n\n # two signals offset by 30 units\n my $x    = sequence(100);\n my $y1   = exp( 0.2*($x - 20.5) ** (-2.0) );\n my $y2   = exp( 0.2*($x - 50.5) ** (-2.0) );\n\n # compute the correlation\n my $F12  = rfft1( cat($y1,$y2) );\n my $corr = irfft1( Cmul(      $F12(:,:,(1)),\n                            Cconj $F12(:,:,(0)) ) );\n # and find the peak\n say maximum_ind($corr);\n\n =====\u003e 30\n\n=head1 DESCRIPTION\n\n=head2 Supported operations\n\nThis module computes the Discrete Fourier Transform. In its most basic form,\nthis transform converts a vector of complex numbers in the time domain into\nanother vector of complex numbers in the frequency domain. These complex \u003c-\u003e\ncomplex transforms are supported with C\u003cfftN\u003e functions for a rank-C\u003cN\u003e\ntransform. The opposite effect (transform data in the frequency domain back to\nthe time domain) can be achieved with the C\u003cifftN\u003e functions.\n\nA common use case is to transform purely-real data. This data has 0 for its\ncomplex component, and FFTW can take advantage of this to compute the FFT faster\nand using less memory. Since a Fourier Transform of a real signal has an even\nreal part and an odd imaginary part, only 1/2 of the spectrum is needed. These\nforward real -\u003e complex transforms are supported with the C\u003crfftN\u003e functions.\nThe backward version of this transform is complex -\u003e real and is supported with\nthe C\u003cirfftN\u003e functions.\n\n=head2 Basic usage details\n\nArbitrary C\u003cN\u003e-dimensional transforms are supported. All functions exported by\nthis module have the C\u003cN\u003e in their name, so for instance a complex \u003c-\u003e complex\n3D forward transform is computed with the C\u003cfft3\u003e function. The rank I\u003cmust\nalways\u003e be specified in this way; there is no function called simply C\u003cfft\u003e.\n\nIn-place operation is supported for complex \u003c-\u003e complex functions, but not the\nreal ones (real function don't have mathing dimensionality of the input and\noutput). An in-place transform of C\u003c$x\u003e can be computed with\n\n fft1( $x-\u003einplace );\n\nAll the functions in this module support PDL threading. For instance, if we have\n4 different image piddles C\u003c$a\u003e, C\u003c$b\u003e, C\u003c$c\u003e, C\u003c$d\u003e and we want to compute\ntheir 2D FFTs at the same time, we can say\n\n my $ABCD_transformed = rfft2( PDL::cat( $a, $b, $c, $d) );\n\nThis takes advantage of PDL's automatic parallelization, if appropriate (See\nL\u003cPDL::ParallelCPU\u003e).\n\n=head2 Data formats\n\nFFTW supports single and double-precision floating point numbers directly. If\npossible, the PDL input will be used as-is. If not, a type conversion will be\nmade to use the lowest-common type. So as an example, the following will perform\na single-precision floating point transform (and return data of that type).\n\n fft1( $x-\u003ebyte )\n\nThis module expects complex numbers to be stored as a (real,imag) pair in the\nfirst dimension of a piddle. Thus in a complex piddle C\u003c$x\u003e, it is expected that\nC\u003c$x-E\u003cgt\u003edim(0) == 2\u003e (this module verifies this before proceeding).\n\nGenerally, the sizes of the input and the output must match. This is completely\ntrue for the complex \u003c-\u003e complex transforms: the output will have the same size\nand the input, and an error will result if this isn't possible for some reason.\n\nThis is a little bit more involved for the real \u003c-\u003e complex transforms. If I'm\ntransforming a real 3D vector of dimensions C\u003cK,L,M\u003e, I will get an output of\ndimensions C\u003c2,int(K/2)+1,L,M\u003e. The leading 2 is there because the output is\ncomplex; the C\u003cK/2\u003e is there because the input was real. The first dimension is\nalways the one that gets the C\u003cK/2\u003e. This is described in detail in section 2.4\nof the FFTW manual.\n\nNote that given a real input, the dimensionality of the complex transformed\noutput is unambiguous. However, this is I\u003cnot\u003e true for the backward transform.\nFor instance, a 1D inverse transform of a vector of 10 complex numbers can\nproduce real output of either 18 or 19 elements (because C\u003cint(18/2)+1 == 10\u003e\nand C\u003cint(19/2)+1 == 10\u003e).\n\nI\u003cWithout any extra information this module assumes the even-sized input\u003e.\n\nThus C\u003cirfft1( sequence(2,10) )-E\u003cgt\u003edim(0) == 18\u003e is true. If we want the odd-sized output, we have to explicitly pass this into the function like this:\n\n irfft1( sequence(2,10), zeros(19) )\n\nHere I create a new output piddle with the C\u003czeros\u003e function; C\u003cirfft1\u003e then\nfills in this piddle with the result of the computation. This module validates\nall of its input, so only 18 and 19 are valid here. An error will be thrown if\nyou try to pass in C\u003czeros(20)\u003e.\n\nThis all means that the following will produce surprising results if\nC\u003c$x-E\u003cgt\u003edim(0)\u003e isn't even\n\n irfft1( rfft1( $x ) )\n\n=head2 FFT normalization\n\nFollowing the widest-used convention for discrete Fourier transforms,\nthis module normalizes the inverse transform (but not the forward\ntransform) by dividing by the number of elements in the data set, so\nthat\n\n ifft1( fft1( $x ) )\n\nis a slow approximate no-op, if C\u003c$x\u003e is well-behaved.\n\nThis is different from the behavior of the underlying FFTW3 library itself,\nbut more consistent with other FFT packages for popular analysis languages\nincluding PDL.\n\n\n=head1 FUNCTIONS\n\n=head2 fftN (fft1, fft2, fft3, ..., fftn)\n\nThe basic complex \u003c-\u003e complex FFT. You can pass in the rank as a\nparameter with the C\u003cfftn\u003e form, or append the rank to the function\nname for ranks up to 9. These functions all take one input piddle and\none output piddle.  The dimensions of the input and the output are\nidentical. The output parameter is optional and, if present, must be\nthe last argument. If the output piddle is passed in, the user I\u003cmust\u003e\nmake sure the dimensions match.\n\nThe 0 dim of the input PDL must have size 2 and run over (real,imaginary)\ncomponents. The transform is carried out over dims 1 through N.\n\nThe fftn form takes a minimum of two arguments: the PDL to transform,\nand the number of dimensions to transform as a separate argument.\n\nThe following are equivalent:\n\n $X = fftn( $x, 1 );\n $X = fft1( $x );\n fft1( $x, my $X = $x-\u003ezeros );\n\n\n=head2 ifftN (ifft1, ifft2, ifft3, ..., fftn)\n\nThe basic, properly normalized, complex \u003c-\u003e complex backward\nFFT. Everything is exactly like in the C\u003cfftN\u003e functions, except the\ninverse transform is computed and normalized, so that (for example)\n\n ifft1( fft1 ( $x ) )\n\nis a good approximation of C\u003c$x\u003e itself.\n\n=head2 rfftN (rfft1, rfft2, rfft3, ..., rfftn)\n\nThe real -\u003e complex FFT. You can pass in the rank with the C\u003crfftn\u003e\nform, or append the rank to the function name for ranks up to 9.\nThese functions all take one input piddle and one output piddle. The\ndimensions of the input and the output are not identical, but are\nrelated as described in L\u003cData formats\u003e. The output can be passed in\nas the last argument, if desired. If the output piddle is passed in,\nthe user I\u003cmust\u003e make sure the dimensions match.\n\nIn the C\u003crfftn\u003e form, the rank is the second argument.\n\nThe following are equivalent:\n\n $X = rfftn( $x, 1 );\n $X = rfft1( $x );\n rfft1( $x, my $X = $x-\u003ezeroes );\n\n=head2 irfftN (irfft1, irfft2, irfft3, ..., irfftn)\n\nThe complex -\u003e real inverse FFT. You can pass in the rank with the\nC\u003cirfftn\u003e form, or append the rank to the function name for ranks up\nto 9. Argument passing and interpretation is as described in\nC\u003crfftN\u003e above. Please read L\u003cData formats\u003e for details about dimension\ninterpretation. There's an ambiguity about the output dimensionality,\nwhich is described in that section.\n\n=head1 AUTHOR\n\nDima Kogan, C\u003c\u003c \u003cdima@secretsauce.net\u003e \u003e\u003e; contributions from Craig\nDeForest, C\u003c\u003c \u003ccraig@deforest.org\u003e \u003e\u003e.\n\n=head1 HISTORY\n\n=head2 VERSION 0.02\n\n=over\n\n=item Use Alien::FFTW3 for build (if present)\n\n=item add parametric rank functions\n\n=item normalize inverses\n\n=item shorter abbreviation for realfft functions\n\n=back\n\n=head2 VERSION 0.01\n\nEarly working version in github\n\n=head1 LICENSE AND COPYRIGHT\n\nCopyright 2013 Dima Kogan and Craig DeForest.\n\nThis program is free software; you can redistribute it and/or modify it\nunder the terms of the GNU General Public License.\n\n=cut\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdkogan%2Fpdl-fftw3","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdkogan%2Fpdl-fftw3","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdkogan%2Fpdl-fftw3/lists"}